/* ==================================================================
   Externo — launch sequence
   White stage, #FFC13D as the only gold. Quiet background: one soft
   glow and two hairline rings, nothing else. Edge to edge, one screen.
   ================================================================== */

:root {
    --paper: #FFFFFF;
    --ink: #14100A;
    --ink-45: #7A7466;

    /* Brand gold — #FFC13D is the only gold on this page. Lighter touches
       are this exact colour at reduced alpha, never a duller mix. */
    --gold: #FFC13D;

    --pad: clamp(14px, 2.6vw, 40px);

    /* Fluid sizes clamped against BOTH axes so nothing overflows a
       short landscape phone. */
    --mark-w: max(190px, min(46vw, 34vh, 520px));
    --num: max(1.85rem, min(7.4vw, 10.4vh, 5.25rem));
    --stamp: max(0.82rem, min(2.5vw, 3.1vh, 1.6rem));
    --micro: max(0.5rem, min(1.05vw, 1.5vh, 0.6875rem));
}

html,
body {
    height: 100%;
}

body {
    position: relative;
    background: var(--paper);
    color: var(--ink);
    overflow-x: hidden;
}

/* ------------------------------------------------------------------
   Preloader
   Hidden unless JS is actually running, so a script failure can never
   leave a blank white page behind an overlay.
   ------------------------------------------------------------------ */

.preloader {
    display: none;
}

.is-loading .preloader {
    --hole: 0px;

    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent var(--hole), #000 calc(var(--hole) + 1px));
    mask-image: radial-gradient(circle at 50% 50%, transparent var(--hole), #000 calc(var(--hole) + 1px));
}

/* Content stays put while the overlay is up */
.is-loading body {
    overflow: hidden;
}

.preloader__icon {
    display: block;
    width: max(58px, min(11vw, 13vh, 104px));
    height: auto;
    overflow: visible;
}

.preloader__e {
    fill: var(--ink);
}

.preloader__ring {
    fill: var(--gold);
}

/* ------------------------------------------------------------------
   Stage
   ------------------------------------------------------------------ */

.stage {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.layer {
    position: absolute;
    inset: -8%;
    will-change: transform;
}

/* A trace of warmth behind the wordmark — barely there by design */
.layer--bloom {
    background: radial-gradient(ellipse 30% 17% at 50% 42%, rgba(255, 193, 61, 0.09) 0%, rgba(255, 193, 61, 0) 72%);
}

/* Two hairlines, nothing more.
   Centred with inset+margin, NOT `translate`: GSAP folds any individual
   transform property into `transform` and blanks it, so a `translate` here
   would be discarded the first time the parallax moves this layer. */
.layer--rings {
    inset: 0;
    margin: auto;
    width: min(96vh, 92vw, 820px);
    height: min(96vh, 92vw, 820px);
}

.ring {
    fill: none;
    stroke: var(--gold);
    stroke-width: 1;
    opacity: 0.4;
    transform-origin: 300px 300px;
}

.ring--b {
    opacity: 0.22;
}

/* ------------------------------------------------------------------
   HUD
   ------------------------------------------------------------------ */

.hud {
    position: fixed;
    inset: 0;
    z-index: 2;
    padding: var(--pad);
    pointer-events: none;
}

.hud__bar {
    position: absolute;
    left: var(--pad);
    right: var(--pad);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--ink-45);
    font-size: var(--micro);
    font-weight: 500;
    letter-spacing: 0.22em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.hud__bar--top { top: calc(var(--pad) + 2px); }
.hud__bar--bottom { bottom: calc(var(--pad) + 2px); }

.hud__item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hud__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
}

/* ------------------------------------------------------------------
   Core
   ------------------------------------------------------------------ */

.core {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100svh;
    padding:
        calc(var(--pad) + clamp(28px, 5vh, 56px))
        clamp(20px, 5vw, 64px);
    text-align: center;
}

/* --- Wordmark --------------------------------------------------- */

.brand {
    perspective: 900px;
    will-change: transform;
}

.brand__tilt {
    transform-style: preserve-3d;
    cursor: pointer;
    will-change: transform;
}

.brand__mark {
    display: block;
    width: var(--mark-w);
    height: auto;
    overflow: visible;
}

.brand__letters path {
    fill: var(--ink);
}

.brand__halo {
    fill: var(--gold);
    transform-origin: 52px 11px;
    /* Declared up front so GSAP has a matching shape to interpolate from */
    filter: drop-shadow(0px 0px 0px rgba(255, 193, 61, 0));
    will-change: transform, filter;
}

/* --- Launch window ---------------------------------------------- */

.window {
    position: relative;
    margin-top: clamp(20px, 3.4vh, 44px);
    padding: clamp(10px, 1.6vh, 18px) clamp(22px, 4vw, 52px);
}

.window__bracket {
    position: absolute;
    top: 0;
    bottom: 0;
    width: clamp(10px, 1.4vw, 16px);
    border: 1px solid var(--gold);
}

.window__bracket--l { left: 0; border-right: 0; }
.window__bracket--r { right: 0; border-left: 0; }

/* Gold is structure and light here, never small text: #FFC13D on white is
   1.7:1, so labels stay ink and the gold does the framing.
   Block-level flex, not inline-flex: as an inline box this sat in a line box
   built from the section's inherited 25.6px line-height, which padded ~9px
   above the label that the bottom of the module had no counterpart for. */
.window__label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--ink-45);
    font-size: var(--micro);
    font-weight: 600;
    letter-spacing: 0.24em;
    line-height: 1;
    text-transform: uppercase;
}

.window__icon {
    width: 1.1em;
    height: 1.1em;
    color: var(--gold);
    stroke-width: 2;
}

.window__value {
    margin-top: clamp(6px, 1vh, 12px);
    color: var(--ink-45);
    font-size: var(--stamp);
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.06em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.window__digits .d,
.window__digits .s {
    display: inline-block;
}

/* The run of eights is struck in full ink against held-back digits —
   two differentiators, weight and tone, so the pattern reads instantly */
.window__digits .is8 {
    color: var(--ink);
    font-weight: 700;
}

/* Held back from the eights by weight, not by fading below AA: these were
   2.28:1 and 2.68:1 on white. --ink-45 is 4.65:1. */
.window__digits .dim {
    color: var(--ink-45);
}

.window__digits .s {
    padding: 0 0.06em;
    color: var(--ink-45);
}

.window__gap {
    display: inline-block;
    width: clamp(10px, 1.6vw, 22px);
}

/* --- Countdown --------------------------------------------------- */

.readout {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(8px, 1.4vw, 20px);
    width: 100%;
    max-width: 1000px;
    margin-top: clamp(22px, 4vh, 52px);
}

.cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 2.4vh, 30px) clamp(4px, 1vw, 16px);
    border: 1px solid rgba(20, 16, 10, 0.07);
    background: rgba(255, 255, 255, 0.35);
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* Corner ticks */
.cell::before,
.cell::after {
    content: "";
    position: absolute;
    width: clamp(10px, 1.4vw, 18px);
    height: clamp(10px, 1.4vw, 18px);
    border: 0 solid var(--gold);
    opacity: 0.72;
    transition: opacity 0.25s ease, width 0.3s ease, height 0.3s ease;
}

.cell::before {
    top: -1px;
    left: -1px;
    border-top-width: 2px;
    border-left-width: 2px;
}

.cell::after {
    right: -1px;
    bottom: -1px;
    border-right-width: 2px;
    border-bottom-width: 2px;
}

/* The once-a-second pulse only changes opacity — animating width here
   would lay out the cell every single second for the life of the page. */
.cell--pulse::before,
.cell--pulse::after {
    opacity: 1;
}

@media (hover: hover) {
    .cell:hover {
        border-color: rgba(255, 193, 61, 0.55);
        background: rgba(255, 193, 61, 0.09);
    }

    .cell:hover::before,
    .cell:hover::after {
        width: clamp(16px, 2.2vw, 26px);
        height: clamp(16px, 2.2vw, 26px);
        opacity: 1;
    }
}

.cell__num {
    display: flex;
    justify-content: center;
    font-size: var(--num);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

/* Each character is a window one glyph tall; changing it scrolls the
   old character up and out and the new one in behind it. */
.digit {
    display: block;
    height: 1.06em;
    overflow: hidden;
}

.digit__roll {
    display: block;
}

.digit__char {
    display: block;
    height: 1.06em;
    line-height: 1.06;
}

.cell__label {
    display: block;
    margin-top: clamp(8px, 1.4vh, 16px);
    color: var(--ink-45);
    font-size: var(--micro);
    font-weight: 500;
    letter-spacing: 0.22em;
    line-height: 1;
    text-transform: uppercase;
}

/* --- Live state -------------------------------------------------- */

.live {
    display: none;
    margin-top: clamp(22px, 4vh, 52px);
    padding: clamp(18px, 3vh, 36px) clamp(24px, 5vw, 64px);
    background: var(--gold);
    color: var(--ink);
    font-size: var(--stamp);
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
}

.is-live .readout {
    display: none;
}

.is-live .live {
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

/* Phones: two by two, and the window stacks date over time */
@media (max-width: 719px) {
    .readout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: clamp(8px, 2vw, 14px);
        max-width: 460px;
    }

    .window__value {
        white-space: normal;
    }

    .window__gap {
        display: block;
        width: 100%;
        height: clamp(4px, 0.8vh, 8px);
    }

    .hud__bar {
        letter-spacing: 0.14em;
    }
}

/* Short viewports — landscape phones, small laptops */
@media (max-height: 560px) {
    .window {
        margin-top: clamp(10px, 2vh, 18px);
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .readout {
        margin-top: clamp(12px, 2.4vh, 22px);
    }

    .layer--rings {
        opacity: 0.6;
    }
}

/* Landscape phones: four across fits better than 2x2 */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
    .readout {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        max-width: 780px;
    }

    .window__gap {
        display: inline-block;
        width: 14px;
        height: auto;
    }

    .window__value {
        white-space: nowrap;
    }
}

@media (max-width: 420px) {
    .hud__bar--bottom {
        display: none;
    }
}

/* ------------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    .cell,
    .cell::before,
    .cell::after {
        transition: none;
    }
}
