/* Robots’ Last Exam — homepage intro.
   A welcome film fills the screen, then the camera pulls back: the film becomes one tile of a
   tilted wall of footage (a floor seen from above, facing up and out of the screen) and the
   title rises over it. Built and driven by home-intro.js from home-intro-wall.js. Desktop-first. */

/* The intro is pinned inside a taller track; the extra height is the scroll that pushes the
   camera into a scene (act two) and then holds on it. */
.intro-track { position: relative; height: 330vh; }
/* Where the scene fills the screen: the middle of the hold (PUSH_END and HOLD_END in home-intro.js). */
.intro-anchor { position: absolute; left: 0; top: calc((100% - 100vh) * 0.54); width: 1px; height: 1px; }
#scene-showcase { top: calc((100% - 100vh) * .96); }

.intro {
  --gap: 14px;
  --radius: 10px;
  position: sticky; top: 0; z-index: 0;   /* the film below slides up over it */
  height: 100vh; min-height: 560px; overflow: hidden;
  background: #000000; color: var(--cream);
}
.act, .film, .participate, .site-footer { position: relative; z-index: 1; }

/* Paint the matching still before deferred scripts attach the opening player. */
.intro[data-welcome-poster]:not([data-phase]) {
  background: #000;
}
.intro[data-welcome-poster]:not([data-phase])::before {
  content: ""; position: absolute; inset: 0; transform: scale(1.1);
  background: url("/assets/home-video/welcome-blackboard.jpg") center / cover no-repeat;
}
/* ---------- the wall ---------- */
/* home-intro.js sizes the wall from the camera (how far it can see up and down the tilted surface)
   and writes its transform every frame; the values here are only the no-script resting state. */
.intro-scene { position: absolute; inset: 0; z-index: 1; perspective: var(--depth, 1500px); perspective-origin: 50% 34%; }
.intro-wall {
  position: absolute; left: 50%; top: 50%;
  display: flex; gap: var(--gap);
  width: var(--wall-w, 210vw); height: var(--wall-h, 250vh);
  margin: calc(var(--wall-above, 185vh) * -1) 0 0 calc(var(--wall-w, 210vw) / -2);
  transform-origin: 50% var(--wall-above, 185vh);   /* the pivot sits at the middle of the screen */
  transform: rotateX(62deg);
  will-change: transform;
}
.intro-col {
  position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap);
  animation: intro-drift var(--dur, 150s) linear infinite; animation-delay: var(--delay, 0s);
}
/* Each column holds its tiles twice; travelling one set is a seamless loop toward the viewer.
   home-intro.js holds the columns in place during camera transitions. */
@keyframes intro-drift {
  from { transform: translate3d(0, calc(-50% - var(--gap) / 2), 0); }
  to   { transform: translate3d(0, 0, 0); }
}

.intro-tile {
  position: relative; flex: none; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0;
  border-radius: var(--radius); overflow: hidden; background: #161617; color: var(--cream); cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,255,255,.07);   /* a hairline of light on each card's edge */
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .45s ease, box-shadow .45s ease;
}
.intro-tile[data-id] {
  background-image: var(--wall-posters); background-size: var(--poster-grid); background-repeat: no-repeat;
}
.intro-tile img, .intro-tile video, .intro-handoff-frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.intro-tile video { opacity: 0; transition: opacity .6s ease; }
.intro-tile video.is-playing { opacity: 1; }
.intro-cap {
  position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: 6px; padding: 38px 14px 12px; text-align: left;
  background: linear-gradient(to top, rgba(0,0,0,.88), rgba(0,0,0,0));
  opacity: 0; transform: translateY(8px); transition: opacity .3s ease, transform .4s cubic-bezier(.2, .8, .2, 1);
}
.intro-cap b { font: 500 9px/1 var(--mono); letter-spacing: .19em; text-transform: uppercase; opacity: .78; }
.intro-cap span { font: 600 15px/1.15 var(--display); letter-spacing: -.012em; }

/* Tiles react only once the camera has settled. */
.intro:not([data-phase="ready"]) .intro-wall { pointer-events: none; }
.intro[data-phase="ready"] .intro-tile:hover, .intro[data-phase="ready"] .intro-tile:focus-visible {
  transform: scale(1.05); z-index: 2; box-shadow: 0 0 0 1px rgba(255,255,255,.55), 0 30px 70px rgba(0,0,0,.65);
}
.intro[data-phase="ready"] .intro-tile:hover .intro-cap, .intro[data-phase="ready"] .intro-tile:focus-visible .intro-cap { opacity: 1; transform: none; }

/* The welcome film on its own plane (see home-intro.js): screen-sized, mapped onto the film tile. */
.intro-film { position: absolute; left: 50%; top: 50%; overflow: hidden; background: #161617; pointer-events: none; transform-origin: 50% 50%; will-change: transform; }
.intro-film img, .intro-film video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.intro-film video { opacity: 0; transition: opacity .6s ease; }
.intro-film video.is-playing { opacity: 1; }

.intro-film:not(.intro-film--scene) { z-index: 1; }

/* ---------- atmosphere and title ---------- */
/* Distance haze at the far end, a floor falling into shadow at the near end, and a soft pool of
   shade under the title so it reads without flattening the wall. */
.intro-veil {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity 1.6s ease .7s;
  background:
    radial-gradient(52% 34% at 50% 45%, rgba(0,0,0,.7) 0%, rgba(0,0,0,.38) 52%, rgba(0,0,0,0) 100%),
    linear-gradient(to bottom, #000000 0%, rgba(0,0,0,.78) 12%, rgba(0,0,0,.28) 30%, rgba(0,0,0,0) 46%),
    linear-gradient(to top, #000000 0%, rgba(0,0,0,0) 18%);
}
/* --leave runs 0 → 1 as the page starts to scroll into the scene. */
.intro-copy { position: absolute; left: 0; right: 0; top: 45%; z-index: 3; transform: translateY(calc(-50% - var(--leave, 0) * 70px)); opacity: calc(1 - var(--leave, 0)); padding: 0 6vw; text-align: center; pointer-events: none; }
/* Apple-style headline: semibold, tight, generous size; a regular-weight line beneath it. */
.intro-copy .display { font: 600 clamp(54px, 7.3vw, 144px)/1.05 var(--display); letter-spacing: -.022em; text-shadow: 0 2px 50px rgba(0,0,0,.45); }
.intro-copy .lede { margin-top: clamp(12px, 1.3vw, 24px); font: 400 clamp(19px, 1.95vw, 32px)/1.16 var(--display); letter-spacing: .004em; color: rgba(245,245,247,.92); text-shadow: 0 1px 24px rgba(0,0,0,.6); }

/* Each line rises from behind its own edge. */
.intro-line { display: block; overflow: hidden; padding: .06em .06em .16em; margin: -.06em -.06em -.16em; }
.intro-line > span { display: block; transform: translate3d(0, 112%, 0); transition: transform 1.25s cubic-bezier(.16, 1, .3, 1); }
.intro[data-phase="wall"] .intro-line > span, .intro[data-phase="ready"] .intro-line > span { transform: none; }
.intro[data-phase="wall"] .display .intro-line > span { transition-delay: 1.45s; }
.intro[data-phase="wall"] .lede .intro-line:nth-child(1) > span { transition-delay: 1.62s; }
.intro[data-phase="wall"] .lede .intro-line:nth-child(2) > span { transition-delay: 1.72s; }

.intro-hint { position: absolute; left: 0; right: 0; bottom: 22px; z-index: 3; text-align: center; font: 500 10px/1 var(--mono); letter-spacing: .19em; text-transform: uppercase; opacity: 0; transition: opacity .8s ease 2.8s; pointer-events: none; }
.intro[data-phase="wall"] .intro-veil, .intro[data-phase="ready"] .intro-veil { opacity: 1; }
.intro[data-phase="wall"] .intro-hint, .intro[data-phase="ready"] .intro-hint { opacity: .8; }

/* ---------- act two: one scene, full screen ---------- */
.intro-film--scene { z-index: 1; }
/* The scene plane's footage lies in layers; a scene taking its turn fades in over the one that is leaving,
   and the words that differ from scene to scene (name, kind, figures) leave and come back quickly. */
.intro-film-layer { position: absolute; inset: 0; opacity: 0; transition: opacity .75s ease; }
.intro-film-layer.is-on { opacity: 1; }
.intro.is-quick.is-scene #scene-act-title, .intro.is-quick.is-scene .scene-act-foot { transition: opacity .42s ease; }
.intro.is-turning.is-scene #scene-act-title, .intro.is-turning.is-scene .scene-act-foot { opacity: 0; transition: opacity .22s ease; }
/* Once the scene fills the screen the wall behind it rests, and the row of scenes underneath can take the pointer. */
.intro.is-covered .intro-wall { visibility: hidden; }
.intro.is-covered .intro-scene { pointer-events: none; }
.intro.is-strip .intro-film--scene { transition: opacity .25s ease; }
.intro.is-pushed .intro-veil { opacity: 0; transition: opacity .7s ease; }
.intro.is-pushed .intro-hint { opacity: 0; transition: opacity .3s ease; }
.intro.is-pushed .intro-wall { pointer-events: none; }
.scene-act { position: absolute; inset: 0; z-index: 3; visibility: hidden; opacity: 0; pointer-events: none; transition: opacity .5s ease, visibility 0s linear .5s; }
.intro.is-scene .scene-act { visibility: visible; opacity: 1; pointer-events: auto; transition: opacity .8s ease, visibility 0s; }
.scene-act-shade { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,.5) 0, rgba(0,0,0,0) 160px),
    linear-gradient(90deg, rgba(0,0,0,.6) 0, rgba(0,0,0,.3) 36%, rgba(0,0,0,0) 68%),
    linear-gradient(0deg, rgba(0,0,0,.7) 0, rgba(0,0,0,.24) 34%, rgba(0,0,0,0) 58%); }
/* Same footing as the stage further down: headline on the base line, facts beneath it. */
.scene-act-head { position: absolute; left: calc(var(--rail) + var(--pad)); right: calc(var(--right) + var(--pad)); bottom: calc(100% - var(--base) + 30px); }
.scene-act-head .eyebrow { margin-bottom: 20px; }
.scene-act-head .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 40px; }
.scene-act-foot { position: absolute; left: calc(var(--rail) + var(--pad) + 6px); right: calc(var(--right) + var(--pad)); top: calc(var(--base) + 36px); display: grid; grid-template-columns: 195px minmax(0, 1fr); align-items: start; }
.scene-act-head > *, .scene-act-foot { opacity: 0; transform: translateY(22px); transition: opacity .4s ease, transform .4s ease; }
.intro.is-scene .scene-act-head > *, .intro.is-scene .scene-act-foot { opacity: 1; transform: none; transition: opacity .9s cubic-bezier(.2, .7, .2, 1) calc(.1s + var(--i, 0) * .09s), transform 1.1s cubic-bezier(.2, .7, .2, 1) calc(.1s + var(--i, 0) * .09s); }
.scene-act-head > :nth-child(2) { --i: 1; }
.scene-act-head > :nth-child(3) { --i: 2; }
.scene-act-foot { --i: 3; }

/* The fixed top band stays out of the way while the welcome film plays. */
.band, .mark, .topbar { transition-property: opacity, background, border-color, color; transition-duration: .9s; }
html[data-intro="welcome"] .band, html[data-intro="welcome"] .mark, html[data-intro="welcome"] .topbar { opacity: 0; pointer-events: none; }
html[data-intro="wall"] .band, html[data-intro="wall"] .mark, html[data-intro="wall"] .topbar { transition-delay: 1.3s; }

@media (prefers-reduced-motion: reduce) {
  .intro-col { animation: none; }
  .intro[data-phase] .intro-tile { opacity: 1; }
  .intro-veil, .intro-line > span, .intro-hint, .intro-tile, .scene-act, .scene-act-head > *, .scene-act-foot { transition-duration: .01s !important; transition-delay: 0s !important; }
}

/* A blur of what is behind (backdrop-filter) is redone on every frame of moving footage. Over the
   homepage's films the chips and outline buttons keep their tint and drop the blur. */
.rle-home .chip, .rle-home .btn--ghost { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* Reading back through the opening uses normal scrolling between two panels. */
.intro-track--review > .intro { position: relative; }
.scene-gallery-review {
  position: relative; display: grid; align-content: center;
  gap: clamp(16px, 3vh, 32px); min-height: calc(100svh - var(--top));
  padding-block: var(--chapter-inset) max(56px, var(--chapter-inset));
  overflow: clip; background: var(--night);
  --card-w: clamp(220px, 34vw, 68vh);
  --card-h: calc(var(--card-w) * 9 / 16); --card-gap: 16px;
}
.scene-gallery-review :is(#scene-showcase, #scenes) { top: 0; scroll-margin-top: var(--top); }
.scene-gallery-review .strip-head {
  position: static; margin-inline: var(--chapter-left) var(--chapter-right);
  opacity: 1; transform: none; pointer-events: auto; align-items: flex-end;
}
.scene-gallery-review .strip { position: relative; top: auto; }
@media (max-width: 600px) {
  .scene-gallery-review .strip-head { flex-direction: column; align-items: flex-start; gap: 14px; }
}
