/* =========================================================================
   Scroll-driven layer.
   Everything here is an ENHANCEMENT: gated behind @supports (animation-timeline)
   and prefers-reduced-motion. Browsers without it keep the IntersectionObserver
   fallback in site.js, and the page is fully readable with neither.
   Scroll-driven animations run off the main thread, so this costs no TBT.
   ========================================================================= */

/* ---------- scroll progress rail ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--paper-100);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 150;
  pointer-events: none;
}

/* ---------- horizontal proof strip (the games) ---------- */
.strip {
  margin-top: var(--s-7);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-500) transparent;
  padding-bottom: var(--s-5);
}
/* the strip rail is a hairline, not a slab */
.strip::-webkit-scrollbar { height: 3px; }
.strip::-webkit-scrollbar-track {
  background: var(--ink-300);
  border: 0;
}
.strip::-webkit-scrollbar-thumb {
  background: var(--paper-400);
  border: 0;
  border-radius: 0;
}
.strip::-webkit-scrollbar-thumb:hover { background: var(--paper-100); }
.strip-track {
  display: flex;
  gap: var(--s-4);
  width: max-content;
  padding-inline: 2px;
}
.tile {
  scroll-snap-align: start;
  width: 8.5rem;
  flex: none;
  text-decoration: none;
  display: grid;
  gap: var(--s-3);
}
.tile img {
  width: 8.5rem;
  height: 8.5rem;
  border: 1px solid var(--line-soft);
  background: var(--ink-100);
  /* monochrome by default; the colour arrives when you reach for it */
  filter: grayscale(1) contrast(1.08) brightness(0.92);
  transition: border-color var(--dur) var(--ease-out),
              transform var(--dur) var(--ease-out),
              filter var(--dur) var(--ease-out);
}
.tile:hover img, .tile:focus-visible img {
  border-color: var(--paper-100);
  transform: translateY(-4px);
  filter: grayscale(0) contrast(1) brightness(1);
}
.tile-name {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--text-dim);
  line-height: 1.35;
}
.strip-block { margin-top: var(--s-8); }
.strip-hint {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: var(--s-3);
}

/* ---------- sticky through-line ---------- */
.pin-wrap { display: grid; gap: var(--s-6); }
@media (min-width: 62rem) {
  .pin-wrap { grid-template-columns: 1fr 1.15fr; gap: var(--s-8); align-items: start; }
  .pin-side { position: sticky; top: 7rem; }
}
.pin-list { display: grid; gap: var(--s-5); }

/* ---------- experience rail that draws as you scroll ---------- */
.timeline { position: relative; }
@media (min-width: 56rem) {
  .timeline::before {
    content: "";
    position: absolute;
    left: 12.25rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--line-soft);
  }
  .timeline::after {
    content: "";
    position: absolute;
    left: 12.25rem;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--paper-100);
    transform-origin: 50% 0;
    transform: scaleY(0);
  }
  .role { position: relative; }
  .role::before {
    content: "";
    position: absolute;
    left: -0.28rem;
    top: 2.15rem;
    width: 0.5rem;
    height: 0.5rem;
    background: var(--ink-500);
    rotate: 45deg;
    z-index: 1;
  }
}

/* =========================================================================
   ENHANCEMENT ONLY below this line
   ========================================================================= */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {

    /* progress rail tracks document scroll */
    .progress {
      animation: rail linear both;
      animation-timeline: scroll(root block);
    }
    @keyframes rail { to { transform: scaleX(1); } }

    /* hero: grid drifts, content settles away as you leave */
    .hero-deco {
      animation: drift linear both;
      animation-timeline: scroll(root block);
      animation-range: 0 90vh;
    }
    @keyframes drift {
      to { transform: translate3d(0, 9%, 0) scale(1.06); opacity: 0.25; }
    }
    .hero-inner {
      animation: settle linear both;
      animation-timeline: scroll(root block);
      animation-range: 20vh 92vh;
    }
    @keyframes settle {
      to { opacity: 0; transform: translate3d(0, -2.5rem, 0); }
    }

    /* section content rises as it enters the viewport, off the main thread */
    .rise {
      animation: enter linear both;
      animation-timeline: view();
      animation-range: entry 4% cover 22%;
      opacity: 1;           /* the JS fallback no longer owns this */
      transform: none;
      transition: none;
    }
    @keyframes enter {
      from { transform: translateY(2.25rem); }
      to   { transform: none; }
    }

    /* cards get a slight scale so a row does not move as one slab */
    .card.rise {
      animation: enter-card linear both;
      animation-timeline: view();
      animation-range: entry 2% cover 26%;
    }
    @keyframes enter-card {
      from { transform: translateY(2.5rem) scale(0.975); }
      to   { transform: none; }
    }

    /* the experience rail draws itself */
    @media (min-width: 56rem) {
      .timeline::after {
        animation: draw linear both;
        animation-timeline: view(block);
        animation-range: entry 55% exit 45%;
      }
      @keyframes draw { to { transform: scaleY(1); } }
    }

    /* game tiles arrive in sequence as the strip enters */
    .tile {
      animation: tile-in linear both;
      animation-timeline: view(inline);
      animation-range: entry 0% entry 85%;
    }
    @keyframes tile-in {
      from { transform: translateY(1.25rem) scale(0.94); }
      to   { transform: none; }
    }

    /* the readout cells stagger in */
    .readout-cell {
      animation: enter linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 18%;
    }
  }
}

/* Reduced motion: no scroll coupling at all, everything simply present. */
@media (prefers-reduced-motion: reduce) {
  .progress { display: none; }
  .rise, .card.rise, .tile, .readout-cell, .hero-inner, .hero-deco {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .timeline::after { display: none; }
  .strip { scroll-snap-type: none; }
}
