/* ==========================================================================
   Intro sequence — film leader before the spec sheet.

   Stages, in order:
     1. wordmark types out in ASCII on black
     2. an arming prompt (a real user gesture, which is the only way a
        browser will let the clip play with sound)
     3. the Apollo clip, captioned
     4. fade to the white sheet

   Stage 2 is not decoration. Chrome, Safari and Firefox all block audible
   autoplay on load; without a click or keypress the clip would either be
   silenced or refuse to start. Arming it turns that constraint into part
   of the sequence.
   ========================================================================== */

#intro-overlay {
    position: fixed;
    inset: 0;
    background-color: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    transition: opacity 900ms ease-out;
    overflow: hidden;
}

#intro-overlay[hidden] {
    display: none;
}

/* ---- Stage 1: the wordmark ---- */

#intro-text {
    /* This is a <pre>, so it arrives carrying the spec-sheet code-block
       styling from style.css. Strip it back to bare glyphs on black. */
    background: none;
    border: 0;
    padding: 0;
    overflow: visible;

    font-family: var(--font-mono);
    color: #fff;
    /* The art is 91 columns wide. The vw term guarantees it fits any
       viewport instead of overflowing on a phone. */
    font-size: clamp(0.26rem, 1.55vw, 0.72rem);
    font-weight: 700;
    line-height: 1.1;
    white-space: pre;
    margin: 0;
    text-align: center;
}

.cursor::after {
    content: "█";
    animation: blink 0.75s step-end infinite;
}

@keyframes blink {
    from, to { opacity: 1; }
    50%      { opacity: 0; }
}

/* ---- Stage 2: arming prompt ---- */

#intro-arm {
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 0.5rem + 0.55vw, 0.78rem);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #fff;
    background: none;
    border: 1px solid #fff;
    border-radius: 0;
    padding: 0.7rem 1.4rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 500ms ease-in, background-color 120ms, color 120ms;
    animation: pulse 2.2s ease-in-out infinite;
    text-align: center;
    max-width: 100%;
}

#intro-arm.visible {
    opacity: 1;
}

#intro-arm:hover,
#intro-arm:focus-visible {
    background: var(--accent, #fc3d21);
    border-color: var(--accent, #fc3d21);
    color: #fff;
    outline: none;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

/* ---- Stage 3: the clip ---- */

#intro-clip-stage {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    width: 100%;
    max-width: 760px;
}

#intro-clip-stage.playing {
    display: flex;
}

#intro-clip {
    width: 100%;
    height: auto;
    max-height: 62vh;
    max-height: 62dvh;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: #000;
    object-fit: contain;
}

/* The quote as a caption: carries the moment even when the clip is muted,
   the audio is blocked, or the visitor simply has sound off. */
#intro-caption {
    font-family: var(--font-mono);
    font-size: clamp(0.66rem, 0.55rem + 0.6vw, 0.9rem);
    line-height: 1.6;
    letter-spacing: 0.05em;
    color: #fff;
    text-align: center;
    margin: 0;
    max-width: 46ch;
    opacity: 0;
    transition: opacity 700ms ease-in;
    text-wrap: balance;
}

#intro-caption.visible {
    opacity: 1;
}

#intro-caption .attribution {
    display: block;
    margin-top: 0.6rem;
    font-size: 0.72em;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent, #fc3d21);
}

/* ---- Skip ---- */

#intro-skip {
    position: absolute;
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    right: max(1.25rem, env(safe-area-inset-right));
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
}

#intro-skip:hover,
#intro-skip:focus-visible {
    color: #fff;
    border-color: #fff;
    outline: none;
}

/* ---- Reduced motion: no typing, no pulse, no film leader ----
   The script also skips the clip entirely under this setting. */

@media (prefers-reduced-motion: reduce) {
    #intro-overlay {
        transition: none;
    }

    #intro-arm {
        animation: none;
    }

    .cursor::after {
        animation: none;
    }

    #intro-caption {
        transition: none;
    }
}
