/* ================================================================
   POWER — Shutdown / Restart / Sleep overlays + dialog
   --------------------------------------------------------------
   Layers (z-index):
     Lock-Screen      6000
     Power-Overlay    9500   (over Boot 9000)
     Power-Dialog     9600
   ================================================================ */

/* Original windows hidden during shutdown-cascade.
   No transition — genie-ghost provides visual continuity. */
.window--power-hide { opacity: 0 !important; visibility: hidden !important; }

/* ============================================================
   POWER OVERLAY (shutdown / restart screen)
   ============================================================ */
.power-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: var(--byte-ink-950);
    color: var(--byte-text);
    font-family: var(--byte-font-mono);
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.power-overlay.is-visible { opacity: 1; pointer-events: all; }
.power-overlay.is-fading-out { opacity: 0; pointer-events: none; }

.power-overlay__fortune {
    position: absolute;
    top: 14vh;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: var(--byte-text-subtle);
    letter-spacing: 0.04em;
    opacity: 0;
    transition: opacity 200ms ease-out;
    text-align: center;
    max-width: 90vw;
    line-height: 1.4;
}
.power-overlay__fortune.is-visible { opacity: 1; }

/* CRT-Off line + dot — single element, two transition phases via classes */
.power-overlay__crt {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100vw;
    height: 1px;
    background: #fff;
    box-shadow: 0 0 8px rgba(255,255,255,0.9), 0 0 22px rgba(255,255,255,0.7);
    transform: translate(-50%, -50%) scaleX(0);
    transform-origin: center;
    opacity: 0;
    pointer-events: none;
}
.power-overlay__crt.crt-line {
    /* Phase 1: fade in horizontal line */
    opacity: 1;
    transform: translate(-50%, -50%) scaleX(1);
    transition: opacity 80ms ease-out, transform 80ms ease-out;
}
.power-overlay__crt.crt-collapse {
    /* Phase 2: collapse line to dot, glow expands vertically */
    transform: translate(-50%, -50%) scaleX(0.005) scaleY(8);
    transition: transform 200ms cubic-bezier(0.45, 0, 0.55, 1);
}
.power-overlay__crt.crt-fade {
    /* Phase 3: dot fades + bloom out */
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(0.005) scaleY(20);
    transition: opacity 250ms ease-out, transform 250ms ease-out;
}

.power-overlay__restart-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transition: opacity 200ms ease-out;
}
.power-overlay__restart-prompt.is-visible { opacity: 1; }

.power-overlay__wordmark {
    font-size: 32px;
    margin-bottom: 24px;
    justify-content: center;
}
.power-overlay__wordmark::before { width: 28px; height: 28px; }

.power-overlay__restart-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%);
    border: 1px solid var(--byte-border-strong);
    color: var(--byte-text);
    padding: 12px 26px;
    font-family: var(--byte-font-mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 999px;
    transition: background 200ms ease-out, border-color 200ms ease-out, box-shadow 200ms ease-out, transform 200ms ease-out;
    box-shadow: 0 0 0 0 rgba(253, 125, 0, 0);
}
.power-overlay__restart-btn i {
    font-size: 16px;
    color: var(--byte-primary);
    filter: drop-shadow(0 0 6px var(--byte-primary-glow));
}
.power-overlay__restart-btn:hover,
.power-overlay__restart-btn:focus-visible {
    background: linear-gradient(180deg, rgba(253, 125, 0, 0.12) 0%, rgba(253, 125, 0, 0.04) 100%);
    border-color: var(--byte-primary);
    box-shadow: 0 0 24px -4px rgba(253, 125, 0, 0.6);
    outline: none;
    transform: translateY(-1px);
}
.power-overlay__restart-btn:active { transform: translateY(0); }

/* ============================================================
   POWER DIALOG (confirm modal)
   ============================================================ */
.power-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9600;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    opacity: 0;
    transition: opacity 300ms ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}
.power-dialog-backdrop.is-visible { opacity: 1; }

.power-dialog {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 60%),
        var(--byte-surface);
    border: 1px solid var(--byte-border-strong);
    border-radius: 14px;
    box-shadow:
        0 30px 80px rgba(0,0,0,0.7),
        0 0 0 1px rgba(255,255,255,0.03) inset,
        0 1px 0 rgba(255,255,255,0.05) inset;
    padding: 0;
    min-width: 440px;
    max-width: 92vw;
    max-height: 92vh;
    transform: scale(0.96) translateY(8px);
    transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
/* Top accent line — mirrors the menubar gradient */
.power-dialog::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--byte-primary) 30%, var(--byte-accent) 70%, transparent);
    opacity: 0.55;
    pointer-events: none;
}
.power-dialog-backdrop.is-visible .power-dialog { transform: scale(1) translateY(0); }

.power-dialog__header {
    padding: 28px 32px 20px;
    text-align: center;
    border-bottom: 1px solid var(--byte-border);
}
.power-dialog__brand {
    font-size: 18px;
    margin-bottom: 18px;
    justify-content: center;
}
.power-dialog__brand::before { width: 20px; height: 20px; }
.power-dialog__title {
    font-family: var(--byte-font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--byte-text-muted);
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.power-dialog__hint {
    font-size: 14px;
    color: var(--byte-text);
    margin: 0;
    line-height: 1.5;
}

.power-dialog__buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    padding: 20px 24px 16px;
    min-height: 0;
    overflow-y: auto;
}
.power-dialog__btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 100%), var(--byte-surface-2);
    border: 1px solid var(--byte-border-strong);
    color: var(--byte-text);
    padding: 18px 12px;
    font-family: var(--byte-font-mono);
    font-size: 13px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 140ms ease-out;
}
.power-dialog__btn i {
    font-size: 24px;
    color: var(--byte-text-muted);
    transition: color 180ms ease-out, filter 180ms ease-out;
}
.power-dialog__btn:hover,
.power-dialog__btn:focus-visible {
    background: linear-gradient(180deg, rgba(253, 125, 0, 0.10) 0%, rgba(253, 125, 0, 0.02) 100%), var(--byte-surface-3);
    border-color: var(--byte-primary);
    box-shadow: 0 8px 24px -8px rgba(253, 125, 0, 0.5), 0 0 0 1px rgba(253, 125, 0, 0.1) inset;
    outline: none;
    transform: translateY(-1px);
}
.power-dialog__btn:hover i,
.power-dialog__btn:focus-visible i {
    color: var(--byte-primary);
    filter: drop-shadow(0 0 8px var(--byte-primary-glow));
}
.power-dialog__btn:active { transform: translateY(0); }

.power-dialog__btn--shutdown:hover,
.power-dialog__btn--shutdown:focus-visible {
    background: linear-gradient(180deg, rgba(220, 53, 69, 0.16) 0%, rgba(220, 53, 69, 0.04) 100%), var(--byte-surface-3);
    border-color: rgba(220, 53, 69, 0.6);
    box-shadow: 0 8px 24px -8px rgba(220, 53, 69, 0.5), 0 0 0 1px rgba(220, 53, 69, 0.15) inset;
}
.power-dialog__btn--shutdown:hover i,
.power-dialog__btn--shutdown:focus-visible i {
    color: #ff6b78;
    filter: drop-shadow(0 0 8px rgba(255, 107, 120, 0.5));
}

.power-dialog__footer {
    padding: 0 24px 20px;
    display: flex;
    justify-content: center;
}
.power-dialog__btn--cancel {
    flex-direction: row;
    background: transparent;
    border: 1px solid var(--byte-border);
    padding: 8px 20px;
    font-size: 12px;
    color: var(--byte-text-muted);
    border-radius: 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    min-width: 0;
}
.power-dialog__btn--cancel:hover,
.power-dialog__btn--cancel:focus-visible {
    background: var(--byte-surface-2);
    border-color: var(--byte-border-strong);
    box-shadow: none;
    color: var(--byte-text);
    transform: none;
}

/* ============================================================
   LOCK SCREEN (sleep)
   ============================================================ */
.lock-screen {
    position: fixed;
    inset: 0;
    z-index: 6000;
    background:
        radial-gradient(ellipse 60% 50% at 50% 35%, rgba(253, 125, 0, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse at center, var(--byte-ink-900) 0%, var(--byte-ink-950) 70%);
    color: var(--byte-text);
    font-family: var(--byte-font-mono);
    opacity: 0;
    transition: opacity 400ms ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}
/* Subtle vignette + scanline texture */
.lock-screen::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.5) 100%);
    pointer-events: none;
}
.lock-screen.is-visible { opacity: 1; }
.lock-screen.is-fading-out { opacity: 0; transition: opacity 300ms ease-out; }

.lock-screen__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.lock-screen__clock-wrap {
    margin-bottom: 48px;
}
.lock-screen__date {
    font-family: var(--byte-font-ui);
    font-size: 15px;
    font-weight: 500;
    color: var(--byte-text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.lock-screen__time {
    font-size: 132px;
    font-weight: 200;
    line-height: 0.95;
    letter-spacing: -0.04em;
    color: var(--byte-text);
    text-shadow:
        0 0 40px rgba(253, 125, 0, 0.25),
        0 0 100px rgba(253, 125, 0, 0.10);
    font-variant-numeric: tabular-nums;
    background: linear-gradient(180deg, var(--byte-text) 0%, var(--byte-text-muted) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lock-screen__wordmark {
    font-size: 16px;
    margin-bottom: 22px;
    justify-content: center;
}
.lock-screen__wordmark::before { width: 18px; height: 18px; }

.lock-screen__hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--byte-text-subtle);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 8px 14px;
    border: 1px solid var(--byte-border);
    border-radius: 999px;
    background: rgba(255,255,255,0.02);
}
.lock-screen__hint i { font-size: 14px; color: var(--byte-text-muted); }
@media (prefers-reduced-motion: no-preference) {
    .lock-screen__hint {
        animation: lock-hint-pulse 3s ease-in-out infinite;
    }
}
@keyframes lock-hint-pulse {
    0%, 100% { opacity: 0.7; transform: translateY(0); }
    50%      { opacity: 1;   transform: translateY(-2px); }
}

/* ============================================================
   sudo rm -rf / — destruction overlay
   ============================================================ */
.rmrf-overlay {
    position: fixed; inset: 0;
    /* z=9300 sits between Boot-Overlay (9000) and Power-Overlay (9500) so a
       concurrent shutdown after `rm -rf /` stacks correctly on top of the
       prank overlay. Previously both were 9500 and DOM-order decided. */
    z-index: 9300;
    background: #000;
    opacity: 0;
    transition: opacity 300ms ease;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    pointer-events: all;
}
.rmrf-overlay.is-visible { opacity: 1; }
.rmrf-overlay__text {
    font: 16px/1.6 'JetBrains Mono', monospace;
    color: var(--byte-fog-300, #9aa8ae);
    opacity: 0;
    transition: opacity 600ms ease;
}
.rmrf-overlay__text.is-visible { opacity: 1; }
.rmrf-overlay__panic {
    font: 13px/1.7 'JetBrains Mono', monospace;
    color: #ccc;
    white-space: pre;
    text-align: left;
    max-width: 90vw;
    opacity: 0;
    transition: opacity 400ms ease;
}
.rmrf-overlay__panic.is-visible { opacity: 1; }
.rmrf-overlay__panic b { color: #fff; font-weight: normal; }
.rmrf-overlay__cursor {
    display: inline-block;
    width: 8px; height: 15px;
    background: #ccc;
    vertical-align: text-bottom;
    animation: rmrf-blink 1s steps(1) infinite;
}
@keyframes rmrf-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
.rmrf-hide {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
.rmrf-shake { animation: rmrf-shake 60ms linear 5; }
@keyframes rmrf-shake {
    0%, 100% { transform: translate(0); }
    25%  { transform: translate(-4px, 2px); }
    50%  { transform: translate(3px, -3px); }
    75%  { transform: translate(-2px, -2px); }
}
.rmrf-flicker { animation: rmrf-flicker 400ms steps(1) 1; }
@keyframes rmrf-flicker {
    0%   { opacity: 1; }
    8%   { opacity: 0.1; }
    12%  { opacity: 1; }
    28%  { opacity: 0.05; }
    33%  { opacity: 1; }
    55%  { opacity: 0.15; }
    60%  { opacity: 1; }
    78%  { opacity: 0.08; }
    82%  { opacity: 1; }
    100% { opacity: 1; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .power-overlay,
    .power-overlay__fortune,
    .power-overlay__restart-prompt,
    .power-dialog-backdrop,
    .power-dialog,
    .lock-screen { transition: opacity 50ms linear !important; }
    .power-overlay__crt { display: none !important; }
    .rmrf-overlay,
    .rmrf-overlay__text,
    .rmrf-overlay__panic { transition: opacity 50ms linear !important; }
    .rmrf-shake { animation: none !important; }
    .rmrf-flicker { animation: none !important; }
    .rmrf-overlay__cursor { animation: none !important; }
}

/* ============================================================
   MOBILE  (≤767px)
   ============================================================ */
@media (max-width: 767px) {
    .power-dialog {
        min-width: 0;
        width: calc(100vw - 32px);
    }
    .power-dialog__header { padding: 22px 20px 16px; }
    .power-dialog__buttons {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 16px 16px 12px;
    }
    .power-dialog__btn {
        flex-direction: row;
        justify-content: center;
        min-height: 48px;
        padding: 12px 16px;
    }
    .power-dialog__btn i { font-size: 18px; }
    .power-dialog__footer { padding: 0 16px 16px; }
    .power-overlay__crt { display: none !important; }
    .lock-screen__time { font-size: 84px; }
    .lock-screen__date { font-size: 13px; letter-spacing: 0.12em; }
    .lock-screen__clock-wrap { margin-bottom: 36px; }
}
