:root {
  --red: #ff382b;
  --signal-dark: #151515;
  --signal-silver: #969696;
  --signal-type: #9d9d9d;
  --signal-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}
html, body, #design { background: var(--signal-dark); color: var(--signal-type); }
#design { transition: none; }
#design[data-chapter] { background: var(--signal-dark); }
#design .q-page[data-signal] {
  --surface: var(--signal-dark);
  --ink: #9d9d9d;
  --copy: #b2b2b2;
  --muted: #7f7f7f;
  --rule: #4a4a4a;
  background: var(--surface) !important;
  color: var(--ink) !important;
}
#design .q-page[data-signal='paper'] {
  --surface: var(--signal-silver);
  --ink: #151515;
  --copy: #242424;
  --muted: #424242;
  --rule: #666666;
}
#design .q-page[data-signal] h2,
#design .q-page[data-signal] h3,
#design .q-page[data-signal] .section-deck { color: var(--ink) !important; }
#design .q-page[data-signal] p,
#design .q-page[data-signal] li,
#design .q-page[data-signal] dd,
#design .q-page[data-signal] .q-row > span:last-child { color: var(--copy) !important; }
#design .q-page[data-signal] dt,
#design .q-page[data-signal] .style-hex { color: var(--muted) !important; }
#design .q-page[data-signal] dt,
#design .q-page[data-signal] .flow-gallery figcaption,
#design .q-page[data-signal] .style-hex,
#design .q-page[data-signal] .who-intro p,
#design .q-page[data-signal] .who-hint { font-family: var(--signal-mono) !important; }
.mate-specs > div,
.style-principles li,
.style-notes > div { border-color: var(--rule); }
.style-principles li > span { color: var(--red); }
.flow-gallery figcaption { color: var(--signal-type); }
.flow-gallery figcaption span { color: #8e8f88; }

/* Persistent registration marks and an orthogonal grid behind the content. */
.signal-grid { position: absolute; inset: 24px 38px; z-index: -1; display: block; pointer-events: none; color: var(--rule, #4a4a4a); }
.signal-grid::before {
  content: ''; position: absolute; inset: 0; opacity: .17;
  background:
    linear-gradient(90deg, currentColor 1px, transparent 1px) 0 0 / calc(100% / 6) 100%,
    linear-gradient(currentColor 1px, transparent 1px) 0 0 / 100% calc(100% / 4);
  border-right: 1px solid currentColor; border-bottom: 1px solid currentColor;
}
.signal-grid i {
  position: absolute; width: 25px; height: 25px; transform: translate(-50%, -50%);
  background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1px 100% no-repeat;
}
.signal-grid i:nth-child(1) { left: 0; top: 0; }
.signal-grid i:nth-child(2) { left: 50%; top: 0; }
.signal-grid i:nth-child(3) { left: 100%; top: 0; }
.signal-grid i:nth-child(4) { left: 0; top: 100%; }
.signal-grid i:nth-child(5) { left: 50%; top: 100%; }
.signal-grid i:nth-child(6) { left: 100%; top: 100%; }
.signal-seen .signal-grid::before { animation: signal-register .56s steps(3, end) both; }
@keyframes signal-register { 0% { opacity: .5; } 50% { opacity: .3; } 100% { opacity: .17; } }
.signal-title { position: relative; }
.signal-shutter { position: absolute; inset: -.02em 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; pointer-events: none; }
.signal-shutter i { background: var(--surface); opacity: 0; }
.signal-seen .signal-shutter i { animation: signal-uncover .3s steps(2, end) calc(var(--cell) * 32ms) both; }
@keyframes signal-uncover { from { opacity: 1; clip-path: inset(0); } to { opacity: 0; clip-path: inset(100% 0 0); } }

/* A small reusable texture shifts in discrete frames like the reference grain. */
.signal-grain {
  position: fixed; inset: -48px; z-index: 110; display: block; pointer-events: none;
  background: url('signal-grain.png') 0 0 / 192px 192px repeat;
  mix-blend-mode: soft-light; opacity: .32; animation: signal-grain .72s steps(1, end) infinite;
}
@keyframes signal-grain {
  0%, 100% { transform: translate(0, 0); }
  16% { transform: translate(-17px, 13px); } 33% { transform: translate(21px, -9px); }
  50% { transform: translate(-11px, -23px); } 66% { transform: translate(9px, 19px); }
  83% { transform: translate(25px, 7px); }
}
.signal-paused .signal-grain { animation-play-state: paused; }

/* Hide the presentation grain while the HUD is in view. */
body:has(#hud.signal-in-view) > .signal-grain { display: none; }

body > header { background: #171717; border-right: 1px solid #42433d; }
body > header a { color: #9c9d95; transition: none; }
body > header a.active, body > header a:hover { background: var(--red); color: #151515; }
a:focus-visible, button:focus-visible { outline-color: var(--red); }
#home, .home-type { background: var(--signal-dark); }
.home-type { color: var(--signal-type); }
.home-type p { color: var(--red); font-family: Arial, Helvetica, sans-serif; }
.home-scene { background: #111; }
.home-space { transform: none; transition: none; }
.home-space .home-visual { filter: grayscale(.6) saturate(.75) brightness(.8) contrast(1.1); }
#home-intro { background: var(--signal-dark); }
#home-intro > span { color: var(--red); font-family: var(--signal-mono); }
.intro-red { display: none; }
.intro-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(8, 1fr); }
.intro-grid i { background: var(--signal-dark); border: .5px solid #353630; }
#design #sim > h2, #design #hud .hud-heading h2 { color: var(--signal-type) !important; }
#design #hud .hud-footer { background: var(--signal-dark); }
#design #hud .hud-actions button { color: var(--signal-type); background: transparent; transition: none; }
#design #hud .hud-actions button:hover { color: var(--red); }
#design #hud .hud-actions button[aria-pressed='true'] { color: #151515; background: var(--red); }
/* Soften the road texture where the scene meets the controls. */
#hud .hud-picture::before {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 24%;
  z-index: 1;
  pointer-events: none;
  backdrop-filter: blur(3px);
  mask-image: linear-gradient(transparent, #000 70%);
}
#hud .hud-picture #hudShieldImage,
#hud .hud-picture #hudDrivingImage { z-index: 2; }
/* The Awareness image includes its speed readout in the scene artwork. */
#hud .hud-picture:has(#hudAwarenessImage.is-active)::before {
  mask-image:
    linear-gradient(transparent, #000 70%),
    radial-gradient(ellipse 9% 29% at 50% 61%, transparent 76%, #000 100%);
  mask-composite: intersect;
}
/* The physical windshield moves continuously, independent of grid refreshes. */
.hud-picture .hud-state { transition-timing-function: ease; }
.hud-picture .hud-state.shield-reveal {
  animation-timing-function: cubic-bezier(.22, 1, .36, 1);
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: reduce) {
  .hud-picture .hud-state.shield-reveal { will-change: auto; }
}
.signal-refresh {
  position: absolute; inset: 0; z-index: 10; opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, #ff382b 1px, transparent 1px) 0 0 / calc(100% / 8) 100%,
    linear-gradient(#ff382b 1px, transparent 1px) 0 0 / 100% calc(100% / 4);
}
.signal-simulator { --surface: #151515; background: var(--surface); isolation: isolate; }
.signal-simulator > .signal-grid { --rule: #4a4a4a; }
html[data-theme='red'] .signal-simulator button { color: #9d9d9d; font-family: var(--signal-mono); transition: none; }
html[data-theme='red'] .signal-simulator button:hover { color: var(--red); }
html[data-theme='red'] .signal-simulator button[aria-pressed='true'],
html[data-theme='red'] .signal-simulator button[aria-pressed='true']:hover { background: var(--red); color: #151515; }
html[data-theme='red'] .signal-simulator .stateinfo .muted { color: #8e8f88; }

/* Three grid behaviors keep performance, focus and awareness distinct. */
#who-red stop:first-child { stop-color: #626262; }
#who-red stop:last-child { stop-color: #999999; }
.who-material { background: #777777 !important; }
.who-film-layer { transition: opacity .18s steps(2, end); }
.who-material[data-film] .who-light {
  background: linear-gradient(90deg, #17191555 1px, transparent 1px) 0 0 / 80px 100%,
    linear-gradient(#17191555 1px, transparent 1px) 0 0 / 100% 80px, #999999;
}
.who-material[data-film] .who-light::before { inset: 0; width: auto; height: auto; border-radius: 0; opacity: 1; box-shadow: none; background: none; }
.who-material[data-film] .who-light::after { inset: 0; background: none; }
.who-material[data-film='0'] .who-light::before { background: repeating-linear-gradient(0deg, transparent 0 62px, #ff382b 63px 65px, transparent 66px 126px); }
.who-material[data-film='0'].active .who-light::before { animation: signal-rider-speed .9s steps(6, end) infinite; }
.who-material[data-film='1'] .who-light::before { inset: 100px 180px; border: 2px solid #ff382b; outline: 1px solid #24261f; outline-offset: 40px; }
.who-material[data-film='1'] .who-light::after {
  background: linear-gradient(#ff382b, #ff382b) center / 100% 2px no-repeat,
    linear-gradient(#ff382b, #ff382b) center / 2px 100% no-repeat;
}
.who-material[data-film='1'].active .who-light::before { animation: signal-rider-focus 2.4s steps(4, end) infinite alternate; }
.who-material[data-film='2'] .who-light::before { background: linear-gradient(#ff382b, #ff382b) left / 2px 100% no-repeat; }
.who-material[data-film='2'] .who-light::after { inset: 22% auto auto 68%; width: 12px; height: 12px; background: #ff382b; box-shadow: -340px 210px #ff382b, 160px 320px #ff382b; }
.who-material[data-film='2'].active .who-light::before { animation: signal-rider-awareness 3s steps(14, end) infinite; }
#who .who-detail { transition: opacity .16s steps(2, end); transform: translate(-50%, 0); }
#design #who .who-hint { color: var(--red) !important; }
#who .who-steps { height: 36px; background: #262721; }
#who .who-steps button { color: #9d9d9d; border-color: #63655b; transition: none; }
#who .who-steps button::before { background: #63655b; }
#who .who-steps button[aria-pressed='true'], #who .who-steps button:hover { background: var(--red); color: #151515; }
@keyframes signal-rider-speed { to { transform: translateY(-126px); } }
@keyframes signal-rider-focus { to { transform: scale(.84); } }
@keyframes signal-rider-awareness { to { transform: translateX(100%); } }
.finale-stage { background: var(--signal-dark); }
.finale-digit, .finale-copy { color: #b9b9b9; }
@media (max-width: 750px) {
  .signal-grid { inset: 18px 20px; }
  .signal-grid::before { background-size: calc(100% / 3) 100%, 100% calc(100% / 4); }
  .signal-grid i { width: 17px; height: 17px; }
  .signal-grain { opacity: .25; }
}
@media (prefers-reduced-motion: reduce) {
  .signal-grain, .signal-grid::before, .signal-seen .signal-shutter i,
  .who-material[data-film].active .who-light::before { animation: none !important; }
  .signal-shutter { display: none; }
  .who-film-layer, #who .who-detail { transition: none; }
}

/* M SERIES: a movable viewfinder over a full-bleed radar image. */
#design #mate {
  display: block;
  position: relative;
  height: 100svh !important;
  min-height: 0;
  padding: 0 !important;
  overflow: hidden !important;
  --series-x: 48%;
  --series-y: 34%;
}
.series-scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  container-type: size;
  overflow: hidden;
  background: #090909;
  pointer-events: none;
}
.series-radar {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, 177.75cqh);
  transform: translate(-50%, -50%);
}
.series-radar img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1) sepia(.85) saturate(2.7) hue-rotate(326deg) brightness(.87) contrast(1.07);
}
.series-radar::after {
  content: '';
  position: absolute;
  top: 49.2%;
  left: 50.4%;
  width: 35%;
  aspect-ratio: 2 / 1;
  border: 1px solid #e95742;
  border-bottom: 0;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  transform-origin: 50% 100%;
  pointer-events: none;
  opacity: 0;
  animation: series-radar-pulse 5.6s ease-out infinite paused;
}
:root:not(.signal-paused) #mate.signal-in-view .series-radar::after { animation-play-state: running; }
@keyframes series-radar-pulse {
  0% { transform: translate(-50%, -100%) scale(.27); opacity: 0; }
  16% { opacity: .55; }
  82%, 100% { transform: translate(-50%, -100%) scale(1); opacity: 0; }
}
.series-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 43%, #08080866 54%, #080808c4 70%, #090909f0 100%),
    radial-gradient(ellipse at 50% 43%, transparent 34%, #09090970 100%);
}
.series-axis { position: absolute; pointer-events: none; background: #aaa99c; opacity: .32; }
.series-axis-x { left: 0; right: 0; height: 1px; top: var(--series-y); }
.series-axis-y { top: 0; bottom: 0; width: 1px; left: var(--series-x); }
#mate .mate-heading { position: absolute; bottom: 92px; left: 38px; width: 43%; gap: 20px; pointer-events: none; }
#design #mate-title { color: #a7a7a7 !important; font-size: clamp(66px, 8.7vw, 152px) !important; }
#design #mate .section-deck { color: #a0a0a0 !important; font-size: clamp(14px, 1.4vw, 20px) !important; max-width: 32ch; }
#mate .mate-details { position: absolute; right: 38px; bottom: 64px; width: 43%; gap: 22px; pointer-events: none; }
#mate .mate-heading, #mate .mate-details { z-index: 4; }
#design #mate .mate-intro { font-size: clamp(14px, 1.2vw, 18px) !important; color: #b2b2b2 !important; }
#mate .mate-specs > div { padding-block: 8px; border-color: #77796c80; grid-template-columns: clamp(100px, 10vw, 150px) minmax(0, 1fr); }
#design #mate .mate-specs dt { font-size: 10px !important; color: #8a8a8a !important; }
#design #mate .mate-specs dd { font-size: 12px !important; color: #b2b2b2 !important; }
.series-preview {
  position: absolute; left: var(--series-x); top: var(--series-y);
  transform: translate(-50%, -50%);
  z-index: 3; width: clamp(200px, 24vw, 350px); padding: 0;
  margin: 0;
  border: 1px solid #b1b1a388; border-radius: 0; background: #111;
  color: #a7a89b; text-align: left;
  pointer-events: none;
}
.series-preview-window {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #090909;
}
.series-preview-window .series-radar {
  top: 50%;
  width: var(--series-detail-width, 100%);
  transform: translate(var(--series-detail-x, -50%), var(--series-detail-y, -50%));
}
.series-preview-label { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; font: 10px/1 var(--signal-mono); }
.series-preview-label > :last-child { color: var(--red); }
.series-preview > i { position: absolute; width: 4px; height: 4px; background: #b9bbad; }
.series-preview > i:nth-of-type(1) { top: -2px; left: -2px; }
.series-preview > i:nth-of-type(2) { top: -2px; right: -2px; }
.series-preview > i:nth-of-type(3) { bottom: -2px; left: -2px; }
.series-preview > i:nth-of-type(4) { bottom: -2px; right: -2px; }
@media (max-width: 850px) {
  #design #mate { min-height: 900px; }
  #mate .mate-heading { left: 24px; bottom: 320px; width: calc(100% - 48px); }
  #design #mate-title { font-size: clamp(52px, 13vw, 112px) !important; }
  #mate .mate-details { left: 24px; right: 24px; bottom: 38px; width: auto; gap: 16px; }
  .series-preview { width: min(62vw, 300px); }
}
@media (max-width: 480px) {
  #design #mate { min-height: 844px; }
  .series-radar { top: 44%; width: max(100cqw, 199.2cqh); }
  #mate .mate-heading { left: 20px; bottom: 354px; width: calc(100% - 40px); gap: 12px; }
  #mate .mate-details { left: 20px; right: 20px; bottom: 30px; gap: 16px; }
  #design #mate .mate-intro { font-size: 13px !important; }
  #mate .mate-specs > div { padding-block: 7px; grid-template-columns: 108px minmax(0, 1fr); gap: 8px; }
  #design #mate .mate-specs dd { font-size: 11px !important; }
  .series-preview-label { font-size: 8px; padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .series-radar::after { animation: none; }
}

/* Keep the supplied anchor, with short printed feedback instead of a spring. */
.cursor-body { transition: transform .14s steps(2, end); }
.cursor-body img { transition: opacity .1s steps(1, end), transform .16s steps(3, end); }
.cursor-lock { color: var(--red); transition: opacity .12s steps(2, end), transform .16s steps(3, end), color .1s; }
.cursor-pulse {
  left: -30px; top: -30px; width: 60px; height: 60px; border: 0; border-radius: 0;
  background: linear-gradient(var(--red), var(--red)) center / 100% 1px no-repeat,
    linear-gradient(var(--red), var(--red)) center / 1px 100% no-repeat;
}
.is-releasing .cursor-body { animation: signal-cursor-reset .22s steps(2, end) both; }
.is-releasing .cursor-pulse { animation: signal-cursor-print .22s steps(2, end) both; }
@keyframes signal-cursor-reset { from { transform: scale(.66); } to { transform: scale(var(--cursor-scale)); } }
@keyframes signal-cursor-print { from { transform: scale(.8); opacity: .7; } to { transform: scale(1.2); opacity: 0; } }
.who-material[data-film] .who-light::before { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .cursor-body, .cursor-body img, .cursor-lock { transition: none; }
  .is-releasing .cursor-body, .is-releasing .cursor-pulse { animation: none; }
}
