/* Robots’ Last Exam — homepage, Functional objects.
   One pinned stage scrubbed by the scroll (home-objects.js): a single clip fills the screen, then draws
   back into the middle of the upper of two rows of clips. The rows travel in opposite directions; the
   middle of the screen is in focus and brightest, and the sides fall away into the dark. The rows are the
   travelling row from home-strip.js. */

.objs { position: relative; z-index: 1; height: 340vh; background: var(--night); color: var(--cream); }
.objs-stage {
  --card-h: min(31vh, 21vw);
  --card-w: calc(var(--card-h) * 16 / 9);
  --card-gap: 14px;
  --rows-y: 54vh;                                      /* the line between the two rows */
  position: sticky; top: 0; height: 100vh; min-height: 560px; overflow: hidden;
}
.objs-row--upper { --row-y: calc(var(--rows-y) - var(--card-h) / 2 - var(--card-gap) / 2); }
.objs-row--lower { --row-y: calc(var(--rows-y) + var(--card-h) / 2 + var(--card-gap) / 2); }

/* Focus: --focus is 1 at the middle of the screen and 0 at its edges (home-strip.js). Clips dim and shrink
   toward the sides, and the stage's own edges finish the fade. The clips near the middle (is-lit) are also
   lifted a little brighter; only those few carry the filter, which is costly on playing footage. */
.objs .strip--focus .strip-card {
  --lit: clamp(0, (var(--focus, 1) - .22) / .46, 1);
  opacity: calc(var(--reveal, 0) * (.2 + .8 * var(--lit)));
  scale: calc((.88 + .12 * var(--reveal, 0)) * (.9 + .1 * var(--focus, 1)));
}
.objs .strip--focus .strip-card.is-lit { filter: brightness(calc(1 + .2 * clamp(0, (var(--focus, 1) - .45) / .23, 1))); }
.objs .strip-card.is-plain { cursor: default; }
.objs-feather { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .6s ease;
  background: linear-gradient(90deg, var(--night) 0, rgba(0,0,0,.5) 7%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 78%, rgba(0,0,0,.5) 93%, var(--ink) 100%); }
.objs.is-rows .objs-feather { opacity: 1; }

/* The line above the rows. */
.objs .strip-head { top: calc(var(--rows-y) - var(--card-h) - var(--card-gap) / 2 - 58px); z-index: 3; }
.objs.is-named .strip-head { opacity: 1; transform: none; pointer-events: auto; transition: opacity .7s ease .15s, transform .9s cubic-bezier(.2, .7, .2, 1) .15s; }

/* The clip the part opens on, laid out at the size of the screen and moved by transform. */
.objs-hero { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 2; overflow: hidden; background: #000000; transform-origin: 0 0; will-change: transform; transition: opacity .25s ease; }
.objs.is-live .objs-hero { opacity: 0; pointer-events: none; }
.objs-hero-media, .objs-hero-shade { position: absolute; inset: 0; }
.objs-hero-media img, .objs-hero-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.objs-hero-media img:not([src]) { visibility: hidden; }
/* The footage lies in layers: the next object's clip fades in over the one that has ended, and the words that
   belong to the clip (its name, its line, how it works) leave and come back quickly. */
.objs-hero-layer { position: absolute; inset: 0; opacity: 0; transition: opacity .7s ease; }
.objs-hero-layer.is-on { opacity: 1; }
.objs.is-open.is-turning .objs-head > *, .objs.is-open.is-turning .objs-foot, .objs.is-open.is-turning .objs-anatomy { opacity: 0; transition: opacity .22s ease; }
.objs-hero-media video { opacity: 0; transition: opacity .6s ease; }
.objs-hero-media video.is-playing { opacity: 1; }
.objs-hero-shade { pointer-events: none; transition: opacity .4s ease;
  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%); }
.objs.is-rows .objs-hero-shade { opacity: 0; }

/* The opening clip's own name on the base line, and one line about it beneath. */
.objs-head { position: absolute; left: calc(var(--rail) + var(--pad)); right: calc(var(--right) + var(--pad)); bottom: calc(100% - var(--base) + 30px); }
.objs-foot { position: absolute; left: calc(var(--rail) + var(--pad)); right: calc(var(--right) + var(--pad)); top: calc(var(--base) + 30px); }
.objs-foot p { max-width: 34em; font: 400 clamp(17px, 1.45vw, 23px)/1.3 var(--display); letter-spacing: -.008em; opacity: .9; }
.objs-head > *, .objs-foot { opacity: 0; transform: translateY(22px); transition: opacity .3s ease, transform .3s ease; }
.objs.is-open .objs-head > *, .objs.is-open .objs-foot { opacity: 1; transform: none; transition: opacity .9s cubic-bezier(.2, .7, .2, 1) calc(var(--i, 0) * .09s), transform 1.1s cubic-bezier(.2, .7, .2, 1) calc(var(--i, 0) * .09s); }
.objs-foot { --i: 1; }

/* ---------- how it works: beside the opening clip, in step with it ---------- */
.objs-stage { --anatomy-w: clamp(400px, 33vw, 500px); --anatomy-r: clamp(28px, 3vw, 56px); }
.objs-anatomy {
  position: absolute; top: calc(var(--top) + 4vh); right: var(--anatomy-r); width: var(--anatomy-w);
  padding: 18px 22px 20px; border: 1px solid rgba(232,232,237,.16); border-radius: 18px; background: rgba(0,0,0,.8);
  opacity: 0; transform: translateY(22px); transition: opacity .3s ease, transform .3s ease; pointer-events: none;
}
.objs.is-open .objs-anatomy { opacity: 1; transform: none; pointer-events: auto; transition: opacity .9s cubic-bezier(.2, .7, .2, 1) .22s, transform 1.1s cubic-bezier(.2, .7, .2, 1) .22s; }
/* The clip's own name keeps clear of the panel. */
.objs.has-anatomy .objs-head, .objs.has-anatomy .objs-foot { right: calc(var(--anatomy-w) + var(--anatomy-r) + 40px); }

/* The drawing: thin lines and faint fills. The parts of the current step stand out, the rest fall back,
   and a part's label shows only while the part is lit. */
.objs-drawing { margin-top: 8px; }
.objs-drawing svg { display: block; width: 100%; height: auto; overflow: visible; }
.objs-drawing .part { fill: none; stroke: var(--cream); stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; opacity: .36; transition: opacity .4s ease; }
.objs-drawing .part.is-lit { opacity: 1; }
.objs-drawing .shell { fill: rgba(245,245,247,.035); }
.objs-drawing .solid { fill: rgba(245,245,247,.12); }
.objs-drawing .thin { stroke-width: 1.1; }
.objs-drawing .lead { stroke-width: 1; stroke-dasharray: 2 4; opacity: .6; }
.objs-drawing .liquid { fill: rgba(245,245,247,.14); stroke: none; }
.objs-drawing .pearl { fill: rgba(245,245,247,.3); stroke: none; }
.objs-drawing .mask { fill: #1d1d1f; }                                   /* in front of what is behind it */
.objs-drawing .film { stroke-width: 4; }
.objs-drawing .pulse { fill: rgba(245,245,247,.22); stroke-width: 1; }  /* the moment the film takes */
.objs-drawing .tag { opacity: 0; transition: opacity .4s ease; }
.objs-drawing .part.is-lit .tag { opacity: 1; }
.objs-drawing text { fill: var(--cream); stroke: none; font: 500 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }

/* The cycle: five points on a line that fills as the clip plays. Each point takes the clip to its moment. */
.objs-track { position: relative; height: 28px; margin-top: 12px; }
.objs-track-line { position: absolute; left: 7px; right: 7px; top: 13px; height: 2px; background: rgba(255,255,255,.2); }
.objs-track-fill { position: absolute; inset: 0; background: var(--cream); transform: scaleX(0); transform-origin: 0 50%; }
.objs-track ol { position: relative; display: flex; justify-content: space-between; list-style: none; margin: 0; padding: 0; }
.objs-dot { position: relative; width: 28px; height: 28px; margin: 0 -7px; padding: 0; border: 0; background: none; cursor: pointer; }
.objs-dot::before { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: #1d1d1f; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.5); transition: transform .3s ease, background .3s ease, box-shadow .3s ease; }
.objs-dot:hover::before, .objs-dot:focus-visible::before { transform: scale(1.25); }
.objs-dot.is-done::before { background: var(--cream); box-shadow: none; }
.objs-dot.is-now::before { background: var(--cream); box-shadow: 0 0 0 6px rgba(255,255,255,.16); transform: scale(1.35); }

/* The words of the step the clip is at, and only those. */
.objs-say { min-height: 3.5em; margin-top: 12px; }
.objs-say-line { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: start; animation: objs-say .4s ease both; }
.objs-say .eyebrow { padding-top: 4px; }
.objs-say strong { display: block; font: 600 clamp(16px, 1.25vw, 19px)/1.2 var(--display); letter-spacing: -.012em; }
.objs-say small { display: block; margin-top: 3px; font-size: 13px; line-height: 1.3; opacity: .8; }
@keyframes objs-say { from { opacity: 0; transform: translateY(6px); } }

/* On return, the heading and both rows share the viewport below the navigation.
   They stay in normal document flow, so the next wheel or touch scroll moves on. */
.objs-review-heading, .statement--review { display: none; }
.objs:is(.objs--compact, .objs--static) {
  display: flex; flex-direction: column;
  min-height: calc(100svh - var(--top));
  scroll-margin-top: var(--top);
}
.objs:is(.objs--compact, .objs--static) .objs-review-heading {
  display: block;
  padding: var(--chapter-inset) var(--chapter-right) clamp(24px, 3.5svh, 42px) var(--chapter-left);
}
.objs-review-heading .display {
  margin-top: var(--chapter-title-gap); font-size: var(--chapter-title-size);
}
.objs:is(.objs--compact, .objs--static) .objs-stage {
  position: relative; flex: 1; height: auto; min-height: 210px;
  --rows-y: 50%;
  --base: 63%;
}
.objs:is(.objs--compact, .objs--static) .strip {
  --card-h: min(calc((100% - var(--card-gap) - 24px) / 2), 52vw);
}
.objs:is(.objs--compact, .objs--static) .strip-card {
  height: 100%; width: auto; aspect-ratio: 16 / 9;
}
.objs:is(.objs--compact, .objs--static) .strip-head {
  display: none;
}
.objs:is(.objs--compact, .objs--static) .strip--focus .strip-card {
  opacity: var(--reveal); scale: 1;
}
.objs.objs--compact .objs-feather, .objs.objs--static .objs-feather { opacity: .2; }
@media (prefers-reduced-motion: reduce) {
  .statement { display: none; }
}
.objs--compact .objs-anatomy { top: 12px; max-height: calc(100% - 24px); overflow-y: auto; }

/* Without motion: the two rows as stills. */
.objs--static { height: auto; }
.objs--static .objs-stage { position: relative; }
.objs--static .objs-hero { display: none; }
.objs--static .objs-feather, .objs--static .strip-head { opacity: 1; transform: none; }
