/* ============================================================
   MOTION

   Two reveal styles: a translate+fade for general content, and a
   line mask for display type where the text slides up from behind
   an invisible edge. The mask reads as deliberate rather than as
   a page that hasn't finished loading.

   Every reveal is scoped to .js, which the head script adds. With
   JavaScript off nothing is hidden in the first place.

   Everything is opt-in via data attributes and everything is
   disabled under prefers-reduced-motion, in one block at the
   bottom of this file.
   ============================================================ */

@keyframes pulse-ring {
    0%   { transform: scale(.8); opacity: .9; }
    70%  { transform: scale(1.9); opacity: 0; }
    100% { transform: scale(1.9); opacity: 0; }
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------
   REVEAL PRIMITIVES
   JS adds .is-visible when the element enters the viewport.
   ------------------------------------------------------------ */

/* Only hide reveals when JavaScript is available to bring them back. */
.js [data-reveal] {
    opacity: 0;
    transition: opacity var(--dur-reveal) var(--ease-out-expo),
                transform var(--dur-reveal) var(--ease-out-expo);
    transition-delay: var(--reveal-delay, 0ms);
    will-change: opacity, transform;
}

.js [data-reveal="up"]    { transform: translateY(24px); }
.js [data-reveal="down"]  { transform: translateY(-18px); }
.js [data-reveal="left"]  { transform: translateX(28px); }
.js [data-reveal="right"] { transform: translateX(-28px); }
.js [data-reveal="scale"] { transform: scale(.97); }
.js [data-reveal="fade"]  { transform: none; }

.js [data-reveal].is-visible {
    opacity: 1;
    transform: none;
}

/* ------------------------------------------------------------
   MASKED LINE REVEAL — the signature move for display type.

   The text slides up from behind an invisible edge. It is done
   with overflow on the container and a transform on an inner
   wrapper (injected by reveal.js), NOT with clip-path on the
   element itself: Chrome factors an element's own clip-path into
   the IntersectionObserver rect, so a fully-clipped element never
   reports as intersecting and the reveal never fires.

   The padding/margin pair stops descenders being shaved off.
   ------------------------------------------------------------ */
.js [data-reveal="mask"] {
    opacity: 1;
    overflow: hidden;
    padding-bottom: .14em;
    margin-bottom: -.14em;
}
.js [data-reveal="mask"] > .reveal-inner {
    display: block;
    transform: translateY(110%);
    transition: transform var(--dur-reveal) var(--ease-out-expo);
    transition-delay: var(--reveal-delay, 0ms);
    will-change: transform;
}
.js [data-reveal="mask"].is-visible > .reveal-inner { transform: none; }

/* Stagger children: JS sets --reveal-delay per item. */
.js [data-reveal-group] > * { transition-delay: var(--reveal-delay, 0ms); }

/* ------------------------------------------------------------
   HERO SEQUENCE
   ------------------------------------------------------------ */
.hero-sequence {
    position: relative;
    /* The pinned scroll track. Frame index maps to progress through it. */
    height: 260svh;
    /* Must paint its own surface: .section does this, but the hero is not a
       .section, and without it the veil gradient composites over the page
       background instead of over the hero. */
    background: var(--bg);
    color: var(--fg);
}
.hero-sticky {
    position: sticky;
    top: 0;
    height: 100svh;
    overflow: hidden;
    display: grid;
    place-items: center;
}
.hero-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Reserve the box so there is no layout shift while frames load. */
    background: var(--ink);
}
.hero-veil {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(120% 80% at 50% 15%, transparent 30%, rgb(8 8 10 / .55) 100%),
        linear-gradient(to bottom, rgb(8 8 10 / .35) 0%, transparent 28%, transparent 62%, rgb(8 8 10 / .92) 100%);
    pointer-events: none;
}
.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding-inline: var(--gutter);
    width: 100%;
    max-width: var(--container);
}
.hero-scroll-cue {
    position: absolute;
    bottom: var(--s-8);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    letter-spacing: var(--tracking-label);
    color: rgb(250 250 249 / .5);
}
.hero-scroll-cue .bar {
    width: 1px; height: 2.5rem;
    background: linear-gradient(to bottom, rgb(250 250 249 / .5), transparent);
    animation: cue-slide 2.2s var(--ease-in-out) infinite;
}
@keyframes cue-slide {
    0%, 100% { transform: scaleY(.4); transform-origin: top; opacity: .3; }
    50%      { transform: scaleY(1);  transform-origin: top; opacity: 1; }
}

/* Loading shimmer for the first frame. */
.hero-canvas[data-loading="1"] {
    background-image: linear-gradient(100deg, #0c0c10 20%, #16161c 42%, #0c0c10 64%);
    background-size: 200% 100%;
    animation: shimmer 1.6s linear infinite;
}

/* ------------------------------------------------------------
   MAGNETIC BUTTON
   ------------------------------------------------------------ */
.magnetic { transition: transform var(--dur) var(--ease-out-expo); will-change: transform; }

/* ------------------------------------------------------------
   TILT — much subtler than v2's ±12°, which read as a gimmick.
   ------------------------------------------------------------ */
[data-tilt] { transform-style: preserve-3d; will-change: transform; }

/* ------------------------------------------------------------
   VIEW TRANSITIONS
   ------------------------------------------------------------ */
@view-transition { navigation: auto; }

::view-transition-old(root) {
    animation: vt-out 180ms var(--ease-out-quart) both;
}
::view-transition-new(root) {
    animation: vt-in 380ms var(--ease-out-expo) both;
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in  { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------
   REDUCED MOTION
   One authoritative block. Everything above degrades to
   "already in its final state" rather than simply snapping.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    [data-reveal] {
        opacity: 1 !important;
        transform: none !important;
        overflow: visible !important;
    }
    .js [data-reveal="mask"] > .reveal-inner { transform: none !important; }

    .hero-sequence { height: auto; }
    .hero-sticky { position: relative; height: 100svh; }
    .hero-scroll-cue .bar { animation: none; }
    .pulse-dot::after { animation: none; opacity: .3; }
    .hero-canvas[data-loading="1"] { animation: none; }

    ::view-transition-old(root),
    ::view-transition-new(root) { animation: none !important; }
}
