/* ============================================================
   STILL LOADING… — Design System & Screen Styles
   ============================================================ */

:root {
    --off-white: #F5F5F3;
    --near-black: #0D0D0D;
    --text-primary: #1A1A1A;
    --text-secondary: #888888;
    --text-muted: #BBBBBB;
    --light-on-dark: #E8E8E6;
    --transition: 800ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 1400ms cubic-bezier(0.4, 0, 0.2, 1);
    --max-width: 680px;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    background: var(--off-white);
    font-family: var(--font-body);
    color: var(--text-primary);
    overflow: hidden; /* screens are full-viewport; nothing should page-scroll */
}

/* ---------- Screens ---------- */

.screen {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 24px;
    padding: 60px 40px;
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition);
    background: var(--off-white);
    text-align: center;
}
.screen.active { opacity: 1; pointer-events: all; }
.screen.dark { background: var(--near-black); color: var(--light-on-dark); }

.screen p {
    max-width: var(--max-width);
    font-size: 18px;
    line-height: 1.6;
    margin: 0;
}

/* ---------- Video / audio ---------- */

.screen video {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
}
.screen audio { display: none; } /* no native player UI — controlled entirely by JS */

/* Text/UI sitting on top of a full-bleed video needs to stay above it */
.screen.dark .lower-third,
.screen.dark p,
.screen.dark .loading-bar-wrap {
    position: relative;
    z-index: 1;
}

/* ---------- Persistent UI ---------- */

#persistent-ui {
    position: fixed; bottom: 24px; right: 28px; z-index: 999;
    font-family: var(--font-mono); font-size: 12px;
    color: var(--text-muted); letter-spacing: 0.08em;
    pointer-events: none; /* never blocks screen clicks */
}
.screen.dark ~ #persistent-ui, body.dark-mode #persistent-ui {
    color: rgba(232, 232, 230, 0.4);
}

/* ---------- Loading bar ---------- */

.loading-bar-wrap {
    width: 100%; max-width: 520px; height: 3px;
    background: rgba(26, 26, 26, 0.12); border-radius: 2px; overflow: hidden;
}
.screen.dark .loading-bar-wrap { background: rgba(232, 232, 230, 0.15); }

.loading-bar-fill {
    height: 100%; background: #1A1A1A; border-radius: 2px; width: 0%;
}
.screen.dark .loading-bar-fill { background: #E8E8E6; }

/* ---------- Fade-in text on screen entry ---------- */

.fade-in {
    opacity: 0; transform: translateY(6px);
    transition: opacity 900ms ease, transform 900ms ease;
}
.screen.active .fade-in { opacity: 1; transform: translateY(0); }
.screen.active .fade-in:nth-child(2) { transition-delay: 200ms; }
.screen.active .fade-in:nth-child(3) { transition-delay: 400ms; }
.screen.active .fade-in:nth-child(4) { transition-delay: 600ms; }
.screen.active .fade-in:nth-child(5) { transition-delay: 800ms; }

/* ---------- Lower-third captions (interview screens) ---------- */

.lower-third {
    position: absolute; left: 40px; bottom: 48px;
    display: flex; flex-direction: column; gap: 2px;
    font-family: var(--font-mono);
    opacity: 0; animation: ltShow 6s ease forwards;
}
.lt-name { font-size: 15px; color: var(--light-on-dark); }
.lt-role { font-size: 12px; color: rgba(232, 232, 230, 0.55); }

@keyframes ltShow {
    0% { opacity: 0; transform: translateY(6px); }
    10% { opacity: 1; transform: translateY(0); }
    83% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---------- Waveform (screens 14 & 15) ---------- */

.waveform {
    display: flex; align-items: center; gap: 3px; height: 40px;
}
.waveform-bar {
    width: 2px; background: rgba(232, 232, 230, 0.25);
    border-radius: 2px; animation: wave 1.4s ease-in-out infinite;
}
@keyframes wave {
    0%, 100% { transform: scaleY(1); opacity: 0.3; }
    50% { transform: scaleY(1.5); opacity: 0.7; }
}
/* Organic variation per bar — heights 8–38px, staggered delays 0–0.6s */
.waveform-bar:nth-child(1)  { height: 12px; animation-delay: 0.0s; }
.waveform-bar:nth-child(2)  { height: 22px; animation-delay: 0.04s; }
.waveform-bar:nth-child(3)  { height: 34px; animation-delay: 0.08s; }
.waveform-bar:nth-child(4)  { height: 18px; animation-delay: 0.12s; }
.waveform-bar:nth-child(5)  { height: 38px; animation-delay: 0.16s; }
.waveform-bar:nth-child(6)  { height: 14px; animation-delay: 0.20s; }
.waveform-bar:nth-child(7)  { height: 28px; animation-delay: 0.24s; }
.waveform-bar:nth-child(8)  { height: 8px;  animation-delay: 0.28s; }
.waveform-bar:nth-child(9)  { height: 30px; animation-delay: 0.32s; }
.waveform-bar:nth-child(10) { height: 20px; animation-delay: 0.36s; }
.waveform-bar:nth-child(11) { height: 36px; animation-delay: 0.40s; }
.waveform-bar:nth-child(12) { height: 16px; animation-delay: 0.44s; }
.waveform-bar:nth-child(13) { height: 26px; animation-delay: 0.48s; }
.waveform-bar:nth-child(14) { height: 10px; animation-delay: 0.52s; }
.waveform-bar:nth-child(15) { height: 32px; animation-delay: 0.56s; }

/* ---------- Archive (screen 10) ---------- */

#archive-list {
    width: 100%; max-width: var(--max-width);
    max-height: 60vh;
    overflow-y: auto; scroll-behavior: smooth; scrollbar-width: none;
    display: flex; flex-direction: column; gap: 16px;
}
#archive-list::-webkit-scrollbar { display: none; }

.archive-item {
    font-size: 15px; line-height: 1.6; color: var(--text-secondary);
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(26, 26, 26, 0.08);
}
.archive-item-own {
    color: var(--text-primary);
    font-weight: 500;
}
.archive-item-own::before {
    content: 'You wrote:';
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* ---------- Interruptions (screen 06) ---------- */

.interruption {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 20px;
    opacity: 0; /* JS sets to 1 when its timer fires */
    pointer-events: none; /* JS sets to 'all' when its timer fires */
    cursor: pointer;
    transition: opacity 400ms ease;
    background: var(--near-black);
    color: var(--light-on-dark);
    padding: 10px 16px;
    border-radius: 6px;
}
/* Rough scattered positions — adjust once real content/sizing is in place */
#int-1 { top: 20%; left: 15%; }
#int-2 { top: 60%; right: 12%; }
#int-3 { bottom: 15%; left: 30%; }

/* ---------- Text inputs (screens 09, 16) ---------- */

input[type="text"] {
    width: 100%; max-width: 420px;
    padding: 14px 16px;
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(26, 26, 26, 0.25);
    outline: none;
    text-align: center;
}
input[type="text"]::placeholder { color: var(--text-muted); }
input[type="text"]:focus { border-bottom-color: var(--text-primary); }
.screen.dark input[type="text"] {
    color: var(--light-on-dark);
    border-bottom-color: rgba(232, 232, 230, 0.3);
}
.screen.dark input[type="text"]::placeholder { color: rgba(232, 232, 230, 0.4); }

/* ---------- Buttons (screen 16, tap-to-play) ---------- */

button {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid rgba(26, 26, 26, 0.3);
    border-radius: 4px;
    padding: 10px 22px;
    cursor: pointer;
    transition: background 300ms ease, color 300ms ease;
}
button:hover { background: var(--text-primary); color: var(--off-white); }

.screen-16-buttons {
    display: flex; gap: 12px;
    margin-top: 8px;
}

/* tap-to-play — should feel like part of the piece, not an error state */
.tap-to-play {
    position: absolute;
    bottom: 60px; left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    color: rgba(232, 232, 230, 0.6);
    background: transparent;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    z-index: 2;
}
.tap-to-play:hover { background: transparent; color: var(--light-on-dark); }

/* ---------- Mono/meta text (timers, mirror messages) ---------- */

#wait-timer, #do-nothing-timer, #int-count {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
}
.screen.dark #wait-timer,
.screen.dark #do-nothing-timer,
.screen.dark #int-count {
    color: rgba(232, 232, 230, 0.55);
}

#mirror-message, #int-message {
    font-size: 18px;
    line-height: 1.6;
    max-width: var(--max-width);
}

/* ---------- Exit button ---------- */

#exit-button {
    position: fixed; top: 24px; right: 28px; z-index: 999;
    font-family: var(--font-mono); font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: transparent; border: none;
    padding: 4px 8px;
    cursor: pointer;
    text-transform: uppercase;
}
#exit-button:hover { background: transparent; color: var(--text-secondary); }
.screen.dark ~ #exit-button {
    color: rgba(232, 232, 230, 0.4);
}

/* Waiting Room's timer is intentionally never shown to the visitor —
   it exists only so JS has something to update internally */
#wait-timer { display: none; }

/* Silence bar sits at 30% opacity per spec, independent of its width */
#bar-14 { opacity: 0.3; }

/* Screen 18's title: small, bottom-centre, not the usual large fade-in text */
.screen-18-title {
    position: absolute;
    bottom: 32px; left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    max-width: none;
}

/* "Or skip." styled as plain text, not a boxed button */
.link-button {
    border: none;
    background: transparent;
    text-decoration: underline;
    color: var(--text-secondary);
    padding: 10px 4px;
}
.link-button:hover { background: transparent; color: var(--text-primary); }

/* Screen 6's reading passage */
.reading-passage {
    max-width: var(--max-width);
    text-align: left;
    display: flex; flex-direction: column; gap: 18px;
}
.reading-passage p { font-size: 17px; line-height: 1.7; margin: 0; }

/* ============================================================
   Responsive — narrow / mobile screens
   ============================================================ */

@media (max-width: 600px) {
    .screen {
        padding: 32px 20px;
        gap: 16px;
    }
    .screen p {
        font-size: 16px;
    }

    .lower-third {
        left: 20px; bottom: 28px;
    }
    .lt-name { font-size: 13px; }
    .lt-role { font-size: 11px; }

    .loading-bar-wrap { max-width: 90%; }

    .waveform { height: 30px; gap: 2px; }

    input[type="text"] { font-size: 15px; max-width: 100%; }

    .screen-16-buttons {
        flex-direction: column;
        width: 100%;
        max-width: 280px;
    }
    .screen-16-buttons button { width: 100%; }

    /* Interruptions: keep them on-screen and legible at small widths
       rather than relying on the desktop scatter positions */
    .interruption {
        font-size: 16px;
        padding: 8px 12px;
    }
    #int-1 { top: 18%; left: 10%; }
    #int-2 { top: 55%; right: 8%; }
    #int-3 { bottom: 12%; left: 15%; }

    #persistent-ui {
        bottom: 16px; right: 16px;
        font-size: 11px;
    }
}

/* iOS notch/home-indicator safe areas — keeps the counter and
   bottom-anchored elements from sitting under the home bar */
@supports (padding: max(0px)) {
    #persistent-ui {
        bottom: max(24px, env(safe-area-inset-bottom));
        right: max(28px, env(safe-area-inset-right));
    }
    .screen {
        padding-bottom: max(60px, env(safe-area-inset-bottom));
    }
}

/* ---------- Rotate-to-landscape prompt ---------- */

#rotate-prompt {
    display: none;
    position: fixed; inset: 0; z-index: 10000;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 16px;
    background: var(--near-black);
    color: var(--light-on-dark);
    text-align: center;
    padding: 40px;
    font-family: var(--font-mono);
    font-size: 15px;
    letter-spacing: 0.05em;
}
#rotate-prompt::before {
    content: '⟲';
    font-size: 32px;
    display: block;
}

/* Touch devices only, so a narrowed desktop browser window
   doesn't accidentally trigger this */
@media (orientation: portrait) and (pointer: coarse) {
    #rotate-prompt { display: flex; }
}