/* Ctrl-F project page, combined variant: a dark full-bleed video hero, then the light page.
   Light variant notes: White and pale-grey bands, one typeface,
   large type contrast, generous space, media in rounded cards, colour only on buttons. */

:root {
  --page: #ffffff;
  --band: #f4f2ee;
  --fill: #ebe8e2;
  --hair: #dcd8d0;
  --ink: #17181b;
  --ink2: #6d6a64;
  --accent: #17181b;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter Tight", "Inter", "Helvetica Neue", Arial, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gut: 20px;
  --mid: 1050px;
  --copy: 760px;
  --sec: 96px;
  --r-lg: 24px;
  --r-md: 16px;
}
@media (min-width: 735px) { :root { --gut: 40px; --sec: 128px; } }
@media (min-width: 1069px) { :root { --sec: 144px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-family: var(--text); font-size: 17px; line-height: 1.47; letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--hair); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
img, video { display: block; width: 100%; height: auto; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; text-wrap: balance; }

/* layout */
.wrap, .wrap-mid { width: min(var(--mid), calc(100% - 2 * var(--gut))); margin-inline: auto; }
.wrap-copy { width: min(var(--copy), calc(100% - 2 * var(--gut))); margin-inline: auto; }
.sec { padding-block: var(--sec); }
.band { background: var(--band); }

/* type */
.title { font-size: 32px; line-height: 1.12; letter-spacing: -0.015em; margin: 28px 0 0; }
.hx { font-size: 32px; line-height: 1.1; letter-spacing: -0.012em; }
.hl-head { font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
.hl-sub { font-size: 19px; line-height: 1.25; letter-spacing: -0.01em; margin: 0 0 16px; }
.lede { color: var(--ink2); font-size: 17px; margin-top: 16px; }
.lede.big { color: var(--ink); }
.head { margin-bottom: 48px; }
.head.sub { margin-top: 96px; margin-bottom: 36px; }
.block { margin-top: 80px; }
.head + .block, .head + .wrap-mid { margin-top: 0; }
@media (min-width: 735px) {
  .title { font-size: 52px; line-height: 1.07; }
  .hx { font-size: 48px; line-height: 1.08; }
  .hl-head { font-size: 28px; }
  .hl-sub { font-size: 21px; }
  .lede { font-size: 19px; line-height: 1.42; }
  .lede.big { font-size: 21px; line-height: 1.45; letter-spacing: 0.002em; }
}
@media (min-width: 1069px) {
  .title { font-size: 64px; line-height: 1.05; letter-spacing: -0.02em; }
  .hx { font-size: 56px; line-height: 1.07; }
}

/* nav: a plain bar on the top edge. Solid white with a hairline over the page;
   transparent with light text while it sits over the dark hero (motion.js adds .over). */
.nav {
  position: fixed; z-index: 50; top: 0; left: 0; right: 0; height: 56px;
  display: flex; align-items: center; gap: 28px;
  padding: 0 max(var(--gut), calc((100% - var(--mid)) / 2));
  background: rgba(255,255,255,0.68);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 var(--hair);
  transition: background .35s ease, box-shadow .35s ease;
}
.nav-brand { display: inline-flex; gap: 4px; margin-right: auto; text-decoration: none !important; }
.nav-links { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  position: relative; padding: 6px 0; white-space: nowrap;
  color: var(--ink2); font-size: 13px; text-decoration: none; transition: color .35s ease;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.is-current { color: var(--ink); }
.nav-links a.is-current::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px; border-radius: 1px; background: currentColor;
}
.nav.over { background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.nav.over .nav-links a { color: rgba(244,242,238,0.72); }
.nav.over .nav-links a:hover, .nav.over .nav-links a.is-current { color: #f4f2ee; }
.nav.over .key { box-shadow: 0 0 0 1px rgba(255,255,255,0.18); background: rgba(244,242,238,0.94); }
@media (max-width: 734px) { .nav-links { display: none; } }

/* pills */
.pill {
  display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 15px;
  border-radius: 999px; font-size: 13px; white-space: nowrap; border: 1px solid transparent;
  text-decoration: none !important;
}
.pill.solid { background: var(--ink); color: #fff; }
.pill.solid:hover { background: #3a3a3d; }
.pill.out { border-color: var(--ink); color: var(--ink); }
.pill.out:hover { background: var(--ink); color: #fff; }
.pill.quiet { color: var(--ink2); background: var(--fill); }
.pill.lg { height: 44px; padding: 0 22px; font-size: 17px; }

/* hero */
.hero { padding-top: 120px; text-align: center; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 32px; }
.hero-stage { margin-top: 56px; }
.hero-video { aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-lg); background: var(--fill); }
@media (min-width: 735px) { .hero { padding-top: 140px; } .hero-stage { margin-top: 64px; } }

/* keycap wordmark: white caps on a light-grey body, like a laptop keyboard */
.wordmark {
  display: flex; align-items: center; justify-content: center; gap: 0.16em; margin: 0;
  font-family: var(--display); font-size: clamp(56px, 10vw, 112px); line-height: 1;
}
.key {
  display: inline-block; font-weight: 600; line-height: 1; letter-spacing: -0.02em;
  color: var(--ink); background: #fff; border-radius: 0.16em; padding: 0.18em 0.32em 0.22em;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 0.05em 0 0 #dcd8d0, 0 0.1em 0.3em rgba(0,0,0,0.08);
}
.key-sm { font-size: 12px; padding: 0.32em 0.52em 0.36em; border-radius: 4px; }
.plus { font-weight: 300; font-size: 0.5em; color: var(--ink2); margin: 0 0.04em; }

.hero .key { position: relative; padding: 0 0 0.12em; background: none; box-shadow: none; }
.hero .key::before { /* the key's body: starts one travel below the top, so nothing shows above a pressed cap */
  content: ""; position: absolute; left: 0; right: 0; top: 0.12em; bottom: 0;
  background: #dcd8d0; border-radius: 0.16em;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0 0.12em 0.4em rgba(0,0,0,0.10);
}
.hero .cap {
  display: block; position: relative; color: var(--ink); background: #fff;
  border-radius: 0.16em; padding: 0.18em 0.32em 0.22em;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06), inset 0 -0.03em 0 rgba(0,0,0,0.05);
}

/* media */
.card { border-radius: var(--r-lg); background: var(--fill); overflow: hidden; }
.card.white { background: #fff; }
#video video.card { aspect-ratio: 16 / 9; object-fit: cover; background: #fff; }   /* the film is white: no fill may show at its edges */
#video video.card:fullscreen { object-fit: contain; background: #fff; border-radius: 0; }   /* whole frame on a 16:10 screen, white letterbox */
#video video.card:-webkit-full-screen { object-fit: contain; background: #fff; border-radius: 0; }
.card.pad { padding: 24px; }
.band .card.white { box-shadow: none; }
img.card { background: #fff; }
.figcap { margin-top: 14px; color: var(--ink2); font-size: 14px; line-height: 1.45; }
.figcap.center { text-align: center; max-width: 640px; margin-inline: auto; }

/* comparison grids */
.grid { display: grid; gap: 10px 12px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.labeled.grid-2 { grid-template-columns: auto repeat(2, minmax(0, 1fr)); }
.grid.labeled.grid-3 { grid-template-columns: auto repeat(3, minmax(0, 1fr)); }
.gap-wide { gap: 40px 32px; }
.grid video { aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-md); background: var(--fill); }
.grid.portrait video { aspect-ratio: 8 / 9; object-position: 50% 40%; }
.hdr, .row { font-size: 13px; color: var(--ink2); line-height: 1.3; font-weight: 500; }
.hdr { padding: 0 2px 2px; }
.row { align-self: center; padding-right: 10px; }
.grid .grid { margin-top: 0; }

/* task tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 640px; margin-inline: auto; }
.tile { position: relative; }
.tile video { aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--r-md); background: var(--fill); }
.tile .tag { position: absolute; top: 10px; left: 12px; font-size: 13px; font-weight: 600; color: var(--ink); }

/* live demos: segmented control above a rounded stage */
.demo-tabs {
  display: flex; width: fit-content; max-width: 100%; margin: 0 auto 24px; padding: 3px; gap: 2px;
  border-radius: 999px; background: var(--fill); overflow-x: auto; scrollbar-width: none;
}
.demo-tabs button {
  padding: 8px 18px; border: 0; border-radius: 999px; background: none; white-space: nowrap;
  color: var(--ink2); font: inherit; font-size: 14px; cursor: pointer;
}
.demo-tabs button:hover { color: var(--ink); }
.demo-tabs button.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.10); }
.demo-frame { position: relative; height: 620px; border-radius: var(--r-lg); overflow: hidden; background: #0e0f12; }
.demo-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.demo-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #8a867e; font-size: 15px; }

/* citation */
pre {
  margin: 24px 0 0; padding: 20px 22px; overflow-x: auto;
  background: var(--band); border-radius: var(--r-md);
  color: var(--ink); font-family: var(--mono); font-size: 13px; line-height: 1.6;
}
.foot { margin-top: 20px; color: var(--ink2); font-size: 14px; }

/* load switch for the labelled grids: phones only (main.js builds it from the column headers) */
.load-switch { display: none; }

@media (max-width: 734px) {
  .grid.labeled.grid-2, .grid.labeled.grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid.labeled > div:first-child, .grid.labeled > .hdr, .grid.labeled > video.off { display: none; }
  .grid.labeled .row { padding: 8px 0 0; }
  .load-switch {
    display: flex; width: fit-content; margin: 0 0 14px; padding: 3px; gap: 2px;
    border-radius: 999px; background: var(--fill);
  }
  .load-switch button {
    padding: 6px 14px; border: 0; border-radius: 999px; background: none;
    color: var(--ink2); font: inherit; font-size: 13px; cursor: pointer;
  }
  .load-switch button.is-active { background: var(--seg-on, #fff); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.10); }
  .gap-wide { grid-template-columns: minmax(0, 1fr); }
  .grid { gap: 6px 8px; }
  .hdr { font-size: 12px; }
  .tiles { gap: 6px; }
  .tile .tag { font-size: 11px; top: 6px; left: 8px; }
  .demo-frame { height: 920px; }
  .card.pad { padding: 12px; }
}

/* ---- combined variant: dark full-bleed hero ---- */
.hero {
  position: relative; overflow: hidden; padding: 0; text-align: left;
  min-height: 100vh; min-height: 100svh;   /* full screen: the hero is held while the keys press, so a shorter one shows blank page below it */
  display: grid; align-items: end; background: #0e0f12; color: #f4f2ee;
}
.hero-video {
  position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto;
  object-fit: cover; object-position: 60% 50%; border-radius: 0; background: #0e0f12;
}
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.30) 62%, rgba(0,0,0,0.72) 100%); }
.hero-inner { position: relative; padding: 0 0 56px; }
.hero .wordmark { justify-content: flex-start; font-size: clamp(44px, 7vw, 88px); }
.hero .title { color: #f4f2ee; max-width: 15em; margin-top: 22px; }
.hero .links { justify-content: flex-start; margin-top: 28px; }
.hero .authors { color: #f4f2ee; max-width: 46em; margin: 20px 0 0; font-size: 16px; font-weight: 500; line-height: 1.5; text-wrap: balance; }
.hero .affil { color: rgba(244,242,238,.68); margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.hero .authors span, .hero .affil span { white-space: nowrap; }
@media (min-width: 735px) { .hero .authors { font-size: 18px; } .hero .affil { font-size: 15px; } }
.hero .pill.solid { background: #f4f2ee; color: var(--ink); }
.hero .pill.solid:hover { background: #fff; }
.hero .pill.out { border-color: rgba(244,242,238,0.8); color: #f4f2ee; }
.hero .pill.out:hover { background: #f4f2ee; color: var(--ink); }
.hero span.pill.out, .hero span.pill.out:hover { background: none; color: #f4f2ee; cursor: default; }   /* Code: no link yet */
.hero .pill .soon { margin-left: .4em; opacity: .6; font-weight: 400; }
.hero .pill.quiet { background: rgba(244,242,238,0.14); color: rgba(244,242,238,0.72); }
/* keycaps on the dark stage: pale caps on a grey body */
.hero .key::before { background: #8a867e; box-shadow: 0 0.14em 0.5em rgba(0,0,0,0.5); }
.hero .cap { background: #f4f2ee; box-shadow: none; }
@media (max-width: 734px) { .hero { min-height: max(560px, 100svh); } .hero-inner { padding: 76px 0 36px; } }

/* ---- motion pass ---- */
:root { --ease: cubic-bezier(.28,.11,.32,1); --spring: cubic-bezier(.34,1.32,.64,1); }

/* no grey bands: sections are white and separated by space alone */
.band { background: var(--page); }
.sec + .sec { padding-top: calc(var(--sec) * 0.75); }

/* Try it is the one dark stage: the demos are dark themselves */
.sec.dark { background: #0e0f12; color: #f4f2ee; margin-top: var(--sec); }
.sec.dark .lede { color: #a8a39a; }
.sec.dark .demo-tabs { background: rgba(255,255,255,0.10); }
.sec.dark .demo-tabs button { color: #a8a39a; }
.sec.dark .demo-tabs button:hover { color: #f4f2ee; }
.sec.dark .demo-tabs button.is-active { background: #f4f2ee; color: var(--ink); box-shadow: none; }
.sec.dark .demo-frame { background: #0e0f12; box-shadow: 0 0 0 1px rgba(255,255,255,0.08); }
.sec.dark + .sec { padding-top: var(--sec); }
#cite.sec { padding-block: 32px 40px; }   /* only the credits line until there is a citation */
#cite .foot { margin-top: 0; }
#cite pre + .foot { margin-top: 28px; }

/* reveal */
.js .rv { opacity: 0; transform: translateY(32px); transition: opacity .9s var(--ease), transform 1.1s var(--spring); }
.js .rv.in { opacity: 1; transform: none; }

/* hero settles into a card: --p runs 0 -> 1 over the first part of the scroll */
.hero { --p: 0; background: var(--page); }
.hero-media {
  position: absolute; inset: 0; overflow: hidden; background: #0e0f12;
  transform: scale(calc(1 - 0.06 * var(--p)));
  transform-origin: 50% 0%;
  border-radius: calc(28px * var(--p));
  /* a short lag with a little overshoot, so the card follows the scroll elastically */
  transition: transform .45s var(--spring), border-radius .45s var(--ease);
  will-change: transform;
}
.hero-inner {
  opacity: calc(1 - 1.5 * var(--p));
  transform: translateY(calc(-36px * var(--p)));
  transition: opacity .35s var(--ease), transform .45s var(--spring);
  will-change: opacity, transform;
}

/* method: the figure pinned on the left, the two stages scroll past on the right */
.method-pin { margin-top: 0; }
.fig-stages { position: relative; }
.fig-stages .veil {
  position: absolute; left: 0; right: 0; background: #fff; opacity: 0; pointer-events: none;
  transition: opacity .5s var(--ease);
}
.fig-stages .v1 { top: 0; height: 50.3%; }
.fig-stages .v2 { top: 50.3%; bottom: 0; }
.fig-stages[data-stage="2"] .v1 { opacity: 0.8; }
.fig-stages[data-stage="1"] .v2 { opacity: 0.8; }
.step .lede { margin-bottom: 28px; }
.step .stage-media { gap: 20px 12px; }
@media (min-width: 1069px) {
  .method-pin { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; align-items: start; }
  .method-pin .pin { position: sticky; top: calc(50vh - 240px); }
  .steps { display: grid; gap: 22vh; padding: 12vh 0 18vh; }
  .step { opacity: 0.35; transition: opacity .5s var(--ease); }
  .js .step.rv.in:not(.is-on) { opacity: 0.35; }
  .step.is-on, .js .step.rv.in.is-on { opacity: 1; }
  .step .stage-media { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1068px) {
  .steps { display: grid; gap: 72px; margin-top: 56px; }
  .fig-stages .veil { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .js .rv { opacity: 1; transform: none; transition: none; }
  .hero-media, .hero-inner { transform: none; opacity: 1; }
  .step, .fig-stages .veil { transition: none; }
}

/* ---- find bar: the nav is the browser's find bar searching for "force". It is closed over the hero,
   and the hero is held for a stretch of scroll in which Ctrl, then F, press down like real keys
   (a little give, then a click); that opens the bar (find.js), which counts the sections as matches. ---- */
/* the hold: the hero stays put while the keys press, then scrolls on and settles into its card */
.hero-pin > .hero { position: sticky; top: 0; }
.hero-hold { height: 60vh; }
@media (prefers-reduced-motion: reduce) { .hero-hold { height: 0; } }

/* the keys move only with the scroll. --d is the travel, 0 up to 1 fully down */
.hero .cap { transform: translateY(calc(var(--d, 0) * 0.1em)); transition: transform .08s linear, background .08s; }
.hero .cap.down { background: #dcd8d0; transition: transform .07s cubic-bezier(.5,0,.9,.4), background .07s; }
.hero .cap.up { transition: transform .32s cubic-bezier(.34,1.7,.64,1), background .25s; }

/* the bar: the live page's frosted glass, also over the hero, dropped in from the top edge */
.nav, .nav.over {
  background: rgba(255,255,255,0.68); box-shadow: 0 1px 0 var(--hair);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  transform: translateY(-100%); transition: transform .32s var(--ease);
}
.nav.open { transform: none; }
.nav.over .nav-links a { color: var(--ink2); }
.nav.over .nav-links a:hover, .nav.over .nav-links a.is-current { color: var(--ink); }
.nav.over .key { background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 0.05em 0 0 #dcd8d0, 0 0.1em 0.3em rgba(0,0,0,0.08); }
.nav-brand { margin-right: 4px; }

.find {
  display: flex; align-items: center; gap: 8px; height: 34px; margin-right: auto; padding: 0 4px 0 10px;
  width: 260px; border: 1px solid var(--hair); border-radius: 8px; background: rgba(255,255,255,0.75); font-size: 13px;
}
.find-ico { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--ink2); stroke-width: 1.6; stroke-linecap: round; }
.find-q { flex: 1; color: var(--ink); white-space: nowrap; overflow: hidden; }
.find-q.typing::after { content: ""; display: inline-block; width: 1px; height: 1.05em; margin-left: 1px; vertical-align: -0.15em; background: var(--ink); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.find-n { color: var(--ink2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.find-n b { font-weight: 500; color: var(--ink); }
.find-sep { width: 1px; height: 18px; background: var(--hair); }
.find-btn {
  display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--ink2); cursor: pointer;
}
.find-btn:hover { background: var(--fill); color: var(--ink); }
.find-btn:disabled { opacity: .35; cursor: default; background: none; }
.find-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* the section in view is the current match, marked like a pressed key in the keycap greys */
.nav-links a.is-current::after { display: none; }
.nav-links { padding: 0 6px; margin: 0 -6px; }   /* room for the marked link's 5px fill at the ends: the scroller clips overflow */
.nav-links a.is-current { background: var(--fill); border-radius: 5px; box-shadow: 0 0 0 5px var(--fill); color: var(--ink); }

@media (max-width: 734px) { .find { width: auto; flex: 1; } .nav-brand { margin-right: 0; } }
@media (prefers-reduced-motion: reduce) { .nav { transition: none; } }
