/* intelligy — the 3D experience shell (#41).
 *
 * Two layouts share one document:
 *   - default (no JS, no module support, no WebGL, or html.no-webgl): the beats
 *     flow top to bottom as a normal page, and the stage layers are hidden;
 *   - html.xp (set by the head script and confirmed by initShell): a fixed
 *     canvas stage with the beats layered over it, driven by scroll.
 * Every fixed-stage rule is scoped under html.xp so the fallback never needs
 * its own overrides. Single dark world by design: one machine in a dark room.
 */

:root {
  color-scheme: dark;
  --void: #050608;
  --ink: #e9eef4;
  --dim: #8b97a7;
  --faint: #4a5566;
  --cyan: #5fd4ff;
  --gold: #d8b46a;
  --display: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --body: "Outfit", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --serif: "Newsreader", Georgia, serif;
}

/* Self-hosted Latin variable cuts of the Google fonts (#59), so no page contacts
   Google; assets/fonts/OFL.txt carries their licence. Newsreader keeps its opsz axis. */
@font-face { font-family: "Familjen Grotesk"; font-style: normal; font-weight: 500 700; font-display: swap; src: url("assets/fonts/familjen-grotesk-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("assets/fonts/jetbrains-mono-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 500 600; font-display: swap; src: url("assets/fonts/newsreader-latin-opsz.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 300 500; font-display: swap; src: url("assets/fonts/outfit-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

*, *::before, *::after { box-sizing: border-box; }
html, body { background: var(--void); color: var(--ink); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font-family: var(--body); font-weight: 300; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* ---------- Type (both layouts) ---------- */
.wm { margin: 0; font: 600 clamp(58px, 12vw, 148px)/.86 var(--display); letter-spacing: -.045em; }
.wm .i { color: var(--cyan); }
.beat h2 { margin: 10px 0 0; font: 600 clamp(28px, 4.2vw, 52px)/1.02 var(--display); letter-spacing: -.02em; text-wrap: balance; }
.beat p { margin: 14px 0 0; font: 300 clamp(16px, 1.45vw, 20px)/1.55 var(--body); color: #cfd8e3; max-width: 33rem; text-wrap: pretty; }
.kicker { font: 400 11px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--cyan); }
.cue { margin-top: 26px; display: flex; align-items: center; gap: 12px; font: 400 11px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
.cue .line { width: 44px; height: 1px; background: linear-gradient(90deg, transparent, var(--cyan)); animation: cue 2.4s ease-in-out infinite; transform-origin: left; }
@keyframes cue { 0%, 100% { transform: scaleX(.35); opacity: .5; } 50% { transform: scaleX(1); opacity: 1; } }

.beat.close { text-align: center; }
.beat.close .wm { font-size: clamp(52px, 9vw, 120px); }
.beat.close .era { margin: 16px auto 0; font: 400 11px/1 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--dim); max-width: none; }
.beat.close .mail { display: inline-block; margin: 12px auto 0; font: 400 15px/1 var(--mono); color: var(--ink); text-decoration: none; user-select: all; }
.beat.close .mail:hover { color: var(--cyan); }
/* The legal line (#59): the close beat in html.xp, the page's last line in the static layout. */
.beat.close .legal { margin: 22px auto 0; font: 400 10.5px/1.6 var(--mono); letter-spacing: .12em; color: var(--dim); max-width: none; }
.legal a { color: var(--ink); text-underline-offset: 3px; }
.legal a:hover { color: var(--cyan); }

/* ---------- Release card (mounted by shell.js only when NEWS has a released entry) ---------- */
.dispatch {
  margin-top: 18px; display: grid; gap: 6px; max-width: 26rem; padding: 12px 14px;
  border: 1px solid rgba(216,180,106,.35); border-radius: 10px; background: rgba(10,12,16,.72); text-shadow: none;
  color: inherit; text-decoration: none;
}
.dispatch:hover { border-color: rgba(216,180,106,.7); }
.dispatch .d-k { font: 500 10px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--gold); display: flex; align-items: center; gap: 8px; }
.dispatch .d-k::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 0 rgba(216,180,106,.7); animation: beacon 1.8s ease-out infinite; }
@keyframes beacon { 0% { box-shadow: 0 0 0 0 rgba(216,180,106,.7); } 100% { box-shadow: 0 0 0 10px rgba(216,180,106,0); } }
.dispatch b { font: 500 16px/1.35 var(--display); color: var(--ink); }
.dispatch .d-meta { font: 400 11px/1.4 var(--mono); color: var(--dim); }

/* ---------- Product caption (filled by the product ring, epic #40 child 4) ---------- */
.pc-inner { transition: opacity .35s ease, transform .35s ease; }
.pc-inner.swap { opacity: 0; transform: translateY(8px); }
.pc-top { display: flex; gap: 14px; align-items: center; }
.pc-idx { font: 400 11px/1 var(--mono); letter-spacing: .16em; color: var(--faint); font-variant-numeric: tabular-nums; }
.status { font: 500 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); border: 1px solid rgba(216,180,106,.45); border-radius: 999px; padding: 5px 10px; }
.status:empty { display: none; }

/* ---------- Principals (filled by epic #40 child 5) ---------- */
.people-row { margin-top: 26px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.people-row:empty { display: none; }
.person { margin: 0; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; align-items: start; padding: 14px; border-radius: 12px; background: rgba(7,9,12,.72); border: 1px solid rgba(255,255,255,.06); text-shadow: none; }
.person img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; filter: grayscale(.25) contrast(1.05); }
.person .role { display: block; font: 400 10px/1.3 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.person b { display: block; margin-top: 6px; font: 600 18px/1.2 var(--display); color: var(--ink); }
.person p { margin: 8px 0 0; font: 300 13.5px/1.5 var(--body); color: #c3ccd7; }

/* ---------- Domains and their standards (the "What we do" beat, #43) ---------- */
.domain-list { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.domain-list:empty { display: none; }
.domain-list li { padding-left: 14px; border-left: 1px solid rgba(216,180,106,.35); }
.domain-list b { display: block; font: 600 17px/1.25 var(--display); color: var(--ink); }
.domain-list span { display: block; margin-top: 4px; font: 400 10.5px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }

/* ---------- The office floor (scene 5) and the product list ---------- */
.legend { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px 18px; font: 400 10.5px/1.4 var(--mono); letter-spacing: .08em; color: var(--dim); text-shadow: none; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px; border: 1.5px solid currentColor; }
.legend .lp { border-radius: 50%; color: var(--gold); }
.legend .la { border-radius: 3px; color: #a585f5; }
.legend .lf { width: 18px; height: 0; border: 0; border-top: 2px dashed var(--gold); vertical-align: 3px; }
.product-list { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.product-list:empty { display: none; }
.product-list b { font: 600 16px/1.3 var(--display); color: var(--ink); }
.product-list span { font: 400 10.5px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
#pc-release:empty { display: none; }

/* ---------- Press release pages (/news/) ---------- */
.news { max-width: 42rem; margin: 0 auto; padding: 10vh 1.5rem; }
.news h1 { margin: 12px 0 0; font: 600 clamp(30px, 4.5vw, 48px)/1.08 var(--display); letter-spacing: -.02em; text-wrap: balance; }
.news p, .news li { font: 300 17px/1.6 var(--body); color: #cfd8e3; }
.news .kicker a { color: var(--cyan); text-decoration: none; }
.news-list { padding: 0; list-style: none; display: grid; gap: 10px; }
.news-list time { margin-left: 10px; font: 400 11px/1 var(--mono); color: var(--dim); }
.news h2 { margin: 36px 0 0; font: 600 20px/1.25 var(--display); letter-spacing: -.01em; }
.news ul { padding-left: 1.2rem; }
body.news-page .legal { max-width: 42rem; margin: 0 auto; padding: 0 1.5rem 8vh; font: 400 10.5px/1.6 var(--mono); letter-spacing: .12em; color: var(--dim); }

/* ---------- The pause control (#59, WCAG 2.2.2) ---------- */
/* Only the film shows it; main.js drops [hidden] once the stage exists. */
.motion-toggle { display: none; }
html.xp .motion-toggle:not([hidden]) {
  position: fixed; z-index: 5; top: calc(env(safe-area-inset-top, 0px) + 14px); right: max(16px, 2.4vw);
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 11px;
  border: 1px solid rgba(233,238,244,.16); border-radius: 999px; background: rgba(5,6,8,.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font: 400 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); cursor: pointer;
  transition: color .25s, border-color .25s, background-color .25s; appearance: none;
}
html.xp .motion-toggle:hover { color: var(--ink); border-color: rgba(233,238,244,.32); }
html.xp .motion-toggle[aria-pressed="true"] { color: var(--ink); border-color: rgba(95,212,255,.55); background: rgba(95,212,255,.10); }
.mt-icon {
  flex: none; width: 10px; height: 10px; background: currentColor;
  clip-path: polygon(0 0, 36% 0, 36% 100%, 64% 100%, 64% 0, 100% 0, 100% 100%, 0 100%);
  transition: clip-path .22s cubic-bezier(.2,.7,.2,1);
}
/* Both glyphs have 8 points, so the pause bars fold into the play triangle. */
.motion-toggle[aria-pressed="true"] .mt-icon { color: var(--cyan); clip-path: polygon(8% 0, 54% 25%, 54% 75%, 54% 75%, 54% 25%, 100% 50%, 100% 50%, 8% 100%); }
/* Paused: the CSS loops hold too. */
html[data-motion="paused"] .cue .line, html[data-motion="paused"] .dispatch .d-k::before { animation-play-state: paused; }

/* ---------- Default layout: a normal readable page ---------- */
#stage, #flash, #labels, .rail-nav, #scroll { display: none; }
.beat { max-width: 42rem; margin: 0 auto; padding: 12vh 1.5rem; opacity: 1; }
/* The static page has no pause control, so its loops stop within 5 s (WCAG 2.2.2). */
html:not(.xp) .cue .line, html:not(.xp) .dispatch .d-k::before { animation-iteration-count: 2; animation-fill-mode: forwards; }
html:not(.xp) .beat[data-beat="product"] .pc-inner { display: none; }

/* ---------- html.xp: the fixed stage ---------- */
html.xp #stage { display: block; position: fixed; inset: 0; z-index: 0; }
html.xp #stage canvas { display: block; width: 100%; height: 100%; }
html.xp #scroll { display: block; height: 1140vh; }   /* timeline.js SCROLL_VH: (SCREENS + 1) × 100 */

html.xp #flash {
  display: block; position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(236,248,255,1) 0%, rgba(150,215,255,.85) 32%, rgba(20,40,70,0) 78%);
}
html.xp #flash.rm { background: var(--void); }

html.xp #labels { display: block; position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
html.xp .node-label { position: absolute; left: 0; top: 0; white-space: nowrap; text-align: center; opacity: 0; will-change: transform, opacity; }
html.xp .node-label b { display: block; font: 500 15px/1.2 var(--display); letter-spacing: .01em; color: var(--ink); text-shadow: 0 0 18px rgba(4,6,10,.95); }
html.xp .node-label span { display: block; margin-top: 5px; font: 400 10px/1.35 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
html.xp .node-label.portal b { font: 500 11px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); }
html.xp .node-label.office b { font: 500 13px/1.2 var(--display); }
html.xp .node-label.office span { margin-top: 4px; font-size: 9px; letter-spacing: .14em; color: var(--dim); }
html.xp .node-label.office.person b { font-size: 15px; color: var(--gold); }
html.xp .node-label.office.person span { color: var(--gold); }
/* The ring shows one product at a time; the full list stays the beat's accessible text. */
html.xp .product-list { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
/* The 3D labels carry the list visually; it stays the beat's accessible text. */
html.xp .domain-list { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

html.xp .beats { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
html.xp .beat {
  position: absolute; left: max(16px, 5vw); right: max(16px, 5vw); max-width: 36rem; margin: 0; padding: 0;
  opacity: 0; will-change: opacity, transform;
  text-shadow: 0 0 28px rgba(4,6,10,.95), 0 0 2px rgba(4,6,10,.9);
}
html.xp .beat.hero { bottom: max(48px, 9vh); opacity: 1; }
html.xp .beat.b1, html.xp .beat.b2 { bottom: max(56px, 12vh); }
html.xp .beat.b3 { bottom: max(48px, 8vh); }
html.xp .beat.product { display: block; bottom: max(40px, 7vh); max-width: 34rem; }
html.xp .beat.people { top: calc(env(safe-area-inset-top, 0px) + 12vh); max-width: 46rem; }
html.xp .beat.close { bottom: max(48px, 10vh); left: 0; right: 0; max-width: none; }
html.xp .beat.floor { bottom: max(40px, 7vh); max-width: 30rem; }
/* Wide screens: the floor plan sits between the text column and the rail. */
@media (min-aspect-ratio: 23/20) {
  html.xp .beat.floor { top: 22vh; bottom: auto; max-width: min(30rem, 31vw); }
  html.xp .beats .beat.people { max-width: min(27rem, 33vw); top: calc(env(safe-area-inset-top, 0px) + 8vh); }
  html.xp .beat.people .people-row { grid-template-columns: 1fr; gap: 12px; }
  html.xp .beat.people .person p { font-size: 12.5px; }
}

html.xp .rail {
  position: fixed; z-index: 4; right: max(16px, 2.4vw); top: 50%; transform: translateY(-50%);
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px;
}
html.xp .rail-nav { display: block; }
html.xp .rail button {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 6px 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  font: 400 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
  transition: color .35s;
}
html.xp .rail button::after { content: ""; width: 16px; height: 1px; background: currentColor; transition: width .35s, background .35s; }
html.xp .rail button:hover { color: var(--dim); }
html.xp .rail li.on button { color: var(--ink); }
html.xp .rail li.on button::after { width: 34px; background: var(--cyan); }

@media (max-width: 720px) {
  .people-row { grid-template-columns: 1fr; gap: 12px; }
  .person p { font-size: 12.5px; }
  html.xp .beat.people { top: calc(env(safe-area-inset-top, 0px) + 64px); }
}
@media (max-width: 640px) {
  /* Visually hidden, still the button's accessible name. */
  html.xp .rail button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  /* Long notes wrap instead of clipping off a phone's edges. */
  html.xp .node-label { white-space: normal; max-width: 62vw; }
  html.xp .node-label b { font-size: 13px; white-space: nowrap; }
  html.xp .node-label span { font-size: 9px; }
  html.xp .node-label.office span { display: none; }
  html.xp .node-label.office b { font-size: 11px; }
  /* The pause control becomes an icon-only circle; the label stays its accessible name. */
  html.xp .motion-toggle:not([hidden]) { width: 40px; height: 40px; padding: 0; justify-content: center; }
  html.xp .motion-toggle .mt-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}
/* Short landscape screens (phones on their side): smaller type, the floor text starts higher,
   and the principals sit side by side under their lit seats (#58). floor.js SHORT_H must match. */
@media (max-height: 500px) and (orientation: landscape) {
  html.xp .beat h2 { font-size: clamp(22px, 3vw, 28px); line-height: 1.04; margin-top: 8px; }
  html.xp .beat > p, html.xp .pc-inner > p { margin-top: 10px; font-size: 14.5px; line-height: 1.45; }
  html.xp .beats .beat.floor { top: calc(env(safe-area-inset-top, 0px) + 14px); bottom: auto; }
  html.xp .beat.floor .legend { display: none; }
  html.xp .beats .beat.people { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); right: max(64px, 8vw); max-width: 46rem; }
  html.xp .beat.people .people-row { margin-top: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  html.xp .beat.people .person { grid-template-columns: 56px minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
  html.xp .beat.people .person img { width: 56px; height: 56px; }
  html.xp .beat.people .person b { margin-top: 4px; font-size: 16px; }
  html.xp .beat.people .person p { margin-top: 6px; font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
  /* Visually hidden, still the button's accessible name. */
  html.xp .rail button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  html.xp .motion-toggle:not([hidden]) { top: calc(env(safe-area-inset-top, 0px) + 10px); }
}
@media (max-height: 500px) and (orientation: landscape) and (min-width: 641px) {
  html.xp .motion-toggle:not([hidden]) { height: 28px; }
}
/* Portrait: the bottom copy in scenes 1–2 sits over the lit screen and cryostat; a soft scrim keeps it legible (#58). */
@media (orientation: portrait) {
  html.xp .beat.hero::before, html.xp .beat.b1::before, html.xp .beat.b2::before {
    content: ""; position: absolute; z-index: -1; top: -96px; bottom: -30vh; left: calc(-1 * max(16px, 5vw)); width: 100vw; pointer-events: none;
    background: linear-gradient(to bottom, rgba(5,6,8,0), rgba(5,6,8,.62) 96px, rgba(5,6,8,.8));
  }
}
@media (prefers-reduced-motion: reduce) {
  .cue .line { animation: none; }
  .dispatch .d-k::before { animation: none; }
  .mt-icon, html.xp .motion-toggle:not([hidden]) { transition: none; }
}
