/* Radar Titan: colour chapters. Mint = floor is safe, pink = edge, alert. */
:root {
  --bg: #f8f8f8; --surface: #eeeeee; --ink: #0a0a0a; --muted: #4a4a4a;
  --accent: #1f6b3a; --accent-ink: #ffffff;
  --mint: #c3edce; --pink: #f8c7c9; --white: #ffffff;
  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(2.25rem, 1.3rem + 3.6vw, 4.5rem);
  --step-display: clamp(3.25rem, 8.6vw, 8.25rem);
  --m: clamp(16px, 2.2vw, 32px);
  --r: 12px;
  --ease: cubic-bezier(.2,.7,.2,1);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--step-body)/1.45 "Schibsted Grotesk", system-ui, sans-serif; letter-spacing: -0.01em;
}
h1, h2, h3 { font-weight: 800; letter-spacing: -0.05em; line-height: 0.92; margin: 0; }
p { margin: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.small { font-size: var(--step-small); font-weight: 600; }

/* Buttons: square corners, flat fill. */
.btn {
  font: 600 var(--step-body)/1 inherit; font-family: inherit; letter-spacing: -0.01em;
  background: var(--accent); color: var(--accent-ink); border: 0; padding: 18px 28px; cursor: pointer;
  transition: transform .18s var(--ease), background-color .18s;
}
.btn:hover { background: #17552e; }
.btn:active { transform: scale(.97); }
.btn[disabled] { background: #6a8f77; cursor: progress; }
.btn-ghost { background: var(--ink); color: #fff; }
.btn-ghost:hover { background: #333; }

/* Fixed bar: appears after the hero, takes the colour of the chapter under it. */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20; display: flex; gap: 28px; align-items: center;
  padding: 14px var(--m); background: var(--bar-bg, #fff); color: var(--bar-ink, var(--ink));
  font-weight: 600; transform: translateY(-100%); transition: transform .35s var(--ease), background-color .3s, color .3s;
}
.bar.on { transform: none; }
.bar a { text-decoration: none; }
.bar a:hover { text-decoration: underline; text-underline-offset: 4px; }
.bar-mark { font-weight: 800; letter-spacing: -0.04em; margin-right: auto; font-size: var(--step-lead); }

/* ---------- Hero: 3D panel beside the swatch column ---------- */
.hero { display: grid; grid-template-columns: 10fr 2fr; gap: 0; padding: 10px; height: 100svh; min-height: 640px; }
.panel { position: relative; border-radius: var(--r) 0 0 var(--r); overflow: hidden; background: var(--mint); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage.hovering { cursor: pointer; }
.mark { position: absolute; top: 24px; left: 28px; font-weight: 800; font-size: var(--step-lead); letter-spacing: -0.04em; text-decoration: none; z-index: 2; }
.hero-head { position: absolute; top: 9%; left: 0; right: 0; text-align: center; pointer-events: none; z-index: 1; padding: 0 var(--m); }
.hero h1 { font-size: var(--step-display); max-width: 9ch; margin: 0 auto; }
.lede { position: absolute; left: 28px; bottom: 36px; max-width: 30ch; font-size: var(--step-body); z-index: 2; }
#run { position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%); z-index: 2; }
#run:active { transform: translateX(-50%) scale(.97); }

.controls { position: absolute; right: 28px; top: 40%; z-index: 2; display: grid; gap: 10px; justify-items: end; text-align: right; max-width: 260px; }
.mode { border: 0; padding: 0; margin: 0; display: flex; gap: 0; }
.mode legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mode label { cursor: pointer; }
.mode input { position: absolute; opacity: 0; }
.mode label span, .mode label { display: inline-block; padding: 10px 14px; font-weight: 600; background: rgba(255,255,255,.6); transition: background-color .2s, color .2s; }
.mode label:has(input:checked) { background: var(--ink); color: #fff; }
.mode label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.knob { display: grid; gap: 4px; font-weight: 600; }
.knob output { font-weight: 800; }
.knob input { width: 220px; accent-color: var(--accent); }
.controls .small { max-width: 220px; font-weight: 400; }
.sound { font: 600 var(--step-small) inherit; font-family: inherit; background: transparent; border: 0; padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; color: var(--ink); }

.hud { position: absolute; right: 28px; bottom: 36px; margin: 0; display: grid; gap: 6px; z-index: 2; min-width: 220px; }
.hud div { display: flex; justify-content: space-between; gap: 18px; background: rgba(255,255,255,.7); padding: 8px 12px; }
.hud dt { font-weight: 400; }
.hud dd { margin: 0; font-weight: 800; }
.hud .hud-state { background: var(--ink); color: #fff; transition: background-color .25s, color .25s; }
.hud .hud-state.edge, .hud .hud-state.obstacle { background: #d72638; color: #fff; }
.hud .hud-state.clear { background: var(--accent); color: #fff; }

.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 10px; font-weight: 600; font-size: var(--step-small); opacity: 0; transform: translate(-50%, -140%); transition: opacity .15s; white-space: nowrap; }
.tip.on { opacity: 1; }
.focus .hero-head, .focus .lede, .focus .controls, .focus .hud, .focus #run { pointer-events: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; z-index: 1; pointer-events: none; transition: opacity .4s; }
.loading.done { opacity: 0; }

.swatches { list-style: none; margin: 0; padding: 0; display: grid; grid-template-rows: repeat(5, 1fr); }
.swatches li { background: var(--c); color: var(--i); }
.swatches li:last-child { border-radius: 0 0 var(--r) 0; }
.swatches li:first-child { border-radius: 0 var(--r) 0 0; }
.swatches a { display: block; height: 100%; padding: 20px; text-decoration: none; font-weight: 600; transition: padding-left .25s var(--ease); }
.swatches a:hover, .swatches a:focus-visible { padding-left: 28px; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Chapters ---------- */
.chapter { min-height: 92svh; padding: clamp(96px, 11vw, 160px) var(--m) clamp(72px, 8vw, 120px); }
.parts { background: var(--white); display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; align-items: end; }
.part-list { grid-column: 1 / span 5; grid-row: 1; display: grid; gap: 22px; align-content: end; }
.part-list h2 { font-size: clamp(28px, 2.9vw, 44px); letter-spacing: -0.04em; line-height: 1.05; color: var(--muted); }
#partList { list-style: none; margin: 0; padding: 0; }
#partList li { font-size: clamp(28px, 2.9vw, 44px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.15; color: #7a7a7a; cursor: pointer; transition: color .2s, transform .25s var(--ease); }
#partList li:hover { color: #333; transform: translateX(6px); }
#partList li[aria-selected="true"] { color: var(--ink); }
#partList li:focus-visible { outline-offset: 2px; }
.part-role { max-width: 44ch; }
.part-list .btn { justify-self: start; }
.disc-wrap { grid-column: 5 / span 8; grid-row: 1; position: relative; aspect-ratio: 1 / 1; max-height: 78svh; justify-self: center; width: min(100%, 78svh); }
.disc { position: absolute; inset: 6%; border-radius: 50%; background: var(--mint); transition: background-color .3s; }
#partStage { position: absolute; inset: 0; width: 100%; height: 100%; }
.fact { position: absolute; right: 0; bottom: 4%; max-width: 22ch; font-size: 17px; font-weight: 600; text-align: right; }

.why { background: var(--mint); }
.mosaic { display: grid; grid-template-columns: repeat(12, 1fr); grid-auto-rows: 96px; gap: 8px; }
.t { margin: 0; padding: 24px; background: #b0e2bd; overflow: hidden; position: relative; }
.t figcaption { position: absolute; left: 0; bottom: 0; background: var(--ink); color: #fff; padding: 8px 12px; font-size: var(--step-small); font-weight: 600; }
.t img { width: 100%; height: 100%; object-fit: cover; }
figure.t { padding: 0; }
.t-head { grid-column: 1 / span 6; grid-row: 1 / span 3; background: transparent; padding-left: 0; display: grid; align-content: start; gap: 18px; }
.t-head h2 { font-size: max(4vw, 2.5rem); }
.t-head p { font-size: var(--step-lead); max-width: 26ch; }
.t-photo1 { grid-column: 7 / span 6; grid-row: 1 / span 5; }
.t-fig { grid-column: 1 / span 3; grid-row: 4 / span 3; background: var(--white); display: grid; align-content: start; gap: 8px; }
.t-list { grid-column: 4 / span 3; grid-row: 4 / span 3; background: var(--pink); }
.t-list h3 { font-size: 24px; letter-spacing: -0.03em; margin-bottom: 12px; }
.t-list ul { margin: 0; padding: 0; list-style: none; font-size: 20px; line-height: 1.35; }
.t-who { grid-column: 7 / span 6; grid-row: 6 / span 4; background: var(--ink); color: #fff; display: grid; align-content: start; gap: 8px; }
.t-photo2 { grid-column: 1 / span 3; grid-row: 7 / span 3; }
.t-photo3 { grid-column: 4 / span 3; grid-row: 7 / span 3; }
.t-curb { grid-column: 1 / span 6; grid-row: 10 / span 3; background: var(--white); display: grid; align-content: start; gap: 12px; }
.t-photo4 { grid-column: 7 / span 6; grid-row: 10 / span 3; }
.big { font-size: clamp(44px, 6vw, 96px); font-weight: 800; letter-spacing: -0.05em; line-height: 0.95; }
.mid { font-size: clamp(24px, 2.2vw, 32px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; max-width: 24ch; }

.logic { background: var(--pink); }
.logic-intro { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; margin-bottom: 64px; }
.logic-intro h2 { grid-column: 1 / span 5; font-size: clamp(36px, 4vw, 60px); }
.logic-intro p { grid-column: 7 / span 5; font-size: 18px; }
.flow { margin: 0; }
.flow-scroll { overflow-x: auto; }
#flow { width: 100%; max-width: 1080px; min-width: 760px; height: auto; display: block; font-family: inherit; }
#flow .node { cursor: pointer; outline: none; }
#flow .node rect, #flow .node path { fill: #ffffff; transition: fill .2s; }
#flow .node.alert rect { fill: #0a0a0a; } #flow .node.alert text { fill: #fff; }
#flow .node.clear rect { fill: var(--accent); } #flow .node.clear text { fill: #fff; }
#flow .node:hover rect, #flow .node:hover path, #flow .node:focus-visible rect, #flow .node:focus-visible path { fill: #fde7e8; }
#flow .node.alert:hover rect, #flow .node.alert:focus-visible rect { fill: #333; }
#flow .node.clear:hover rect, #flow .node.clear:focus-visible rect { fill: #17552e; }
#flow .node:focus-visible rect, #flow .node:focus-visible path { stroke: var(--accent); stroke-width: 4; }
#flow .node.live rect, #flow .node.live path { fill: #c3edce; }
#flow .node.alert.live rect { fill: #d72638; }
#flow .node.clear.live rect { fill: #2fa35a; }
#flowExplain { margin-top: 28px; font-size: var(--step-lead); font-weight: 600; max-width: 52ch; min-height: 3em; }

/* ---------- Footer of tiles ---------- */
.foot { background: var(--ink); color: #fff; padding: 10px; }
.tiles { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; }
.tile { padding: 24px; background: #1c1c1c; min-height: 220px; display: grid; align-content: start; gap: 14px; }
.tile h2 { font-size: 28px; letter-spacing: -0.03em; }
.tile ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.t-state { grid-column: 1 / span 4; align-content: space-between; }
.t-state > p:first-child { font-size: 24px; letter-spacing: -0.02em; line-height: 1.2; }
.credits { color: #d0d0d0; font-weight: 400; }
.t-team { grid-column: 5 / span 3; }
.t-src { grid-column: 8 / span 5; }
.t-word { grid-column: 1 / span 8; min-height: 320px; background: var(--white); color: var(--ink); place-content: center; }
.word { font-size: 9vw; font-weight: 800; letter-spacing: -0.06em; line-height: 0.9; white-space: nowrap; }
.t-cta { grid-column: 9 / span 4; min-height: 320px; background: var(--accent); color: #fff; text-decoration: none; display: flex; flex-direction: column; justify-content: space-between; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; transition: background-color .2s; }
.t-cta svg { align-self: flex-end; transition: transform .25s var(--ease); }
.t-cta:hover { background: #17552e; } .t-cta:hover svg { transform: translateY(-6px); }

/* ---------- Magnified part view (floats, so it may cast a shadow) ---------- */
.detail {
  position: fixed; z-index: 30; top: 10px; right: 10px; bottom: 10px; width: min(440px, calc(100vw - 20px));
  background: #fff; color: var(--ink); padding: 24px; overflow-y: auto; display: grid; gap: 16px; align-content: start;
  border-radius: var(--r); box-shadow: 0 24px 60px rgba(0,0,0,.25); /* taste-skill-ignore: floating dialog */
}
.detail[hidden] { display: none; }
.detail-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.detail h2 { font-size: 32px; letter-spacing: -0.04em; line-height: 1; }
.x { font: 600 var(--step-small) inherit; font-family: inherit; background: var(--surface); border: 0; padding: 10px 14px; cursor: pointer; }
.x:hover { background: #ddd; }
#dStage { width: 100%; aspect-ratio: 4 / 3; display: block; background: var(--mint); border-radius: 8px; }
#dSpecs { margin: 0; display: grid; gap: 4px; }
#dSpecs div { display: flex; justify-content: space-between; gap: 16px; background: var(--bg); padding: 8px 12px; }
#dSpecs dt { font-weight: 400; } #dSpecs dd { margin: 0; font-weight: 600; text-align: right; }
.wiring span:first-child { font-weight: 800; display: block; }
.detail-nav { display: flex; gap: 8px; }
.detail-nav .btn { padding: 14px 16px; font-size: var(--step-small); flex: 1; }

/* ---------- Tablet & phone ---------- */
@media (max-width: 960px) {
  .controls { max-width: 200px; }
  .knob input { width: 180px; }
  .lede { display: none; }
  .hud { min-width: 0; }
}
@media (max-width: 700px) {
  .hero { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; min-height: 0; padding: 8px; }
  .panel { display: flex; flex-direction: column; gap: 12px; padding: 64px 16px 16px; border-radius: var(--r) var(--r) 0 0; }
  .panel > * { position: static !important; transform: none !important; }
  .hero-head { padding: 0; order: 0; }
  .hero h1 { font-size: 12vw; }
  #stage { position: relative !important; order: 1; height: 50svh; min-height: 320px; margin: 0 -16px; width: calc(100% + 32px); }
  .loading { position: absolute !important; }
  .tip { position: absolute !important; }
  .hud { order: 2; display: grid; grid-template-columns: 1fr 1fr; min-width: 0; }
  .hud .hud-state { grid-column: 1 / -1; }
  .hud div { padding: 6px 10px; font-size: var(--step-small); }
  .controls { order: 3; max-width: none; justify-items: start; text-align: left; grid-template-columns: auto 1fr; align-items: end; }
  .controls .small, .sound { display: none; }
  .knob input { width: 100%; }
  #run { order: 4; width: 100%; }
  .lede { display: block; order: 5; max-width: none; }
  .mark { position: absolute !important; left: 16px; top: 18px; }
  .swatches { grid-template-rows: none; }
  .swatches li { height: 52px; }
  .swatches a { padding: 15px 16px; font-size: 15px; }
  .swatches li:first-child { border-radius: 0; }
  .swatches li:last-child { border-radius: 0 0 var(--r) var(--r); }
  .parts { display: block; }
  .disc-wrap { width: 100%; max-height: none; margin-bottom: 24px; }
  .fact { display: none; }
  #partList { display: flex; gap: 24px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
  #partList li { font-size: 26px; white-space: nowrap; }
  .mosaic { grid-template-columns: 1fr 1fr; grid-auto-rows: auto; gap: 6px; }
  .mosaic > * { grid-column: 1 / -1 !important; grid-row: auto !important; }
  .mosaic > .t-fig, .mosaic > .t-list, .mosaic > .t-photo2, .mosaic > .t-photo3 { grid-column: auto !important; }
  figure.t { aspect-ratio: 4 / 3; }
  .t-photo2, .t-photo3 { aspect-ratio: 1 / 1 !important; }
  .t-list ul { font-size: 17px; }
  .logic-intro { display: block; } .logic-intro p { margin-top: 18px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 6px; }
  .tiles > * { grid-column: 1 / -1 !important; }
  .t-team, .t-src { grid-column: auto !important; }
  .t-word { order: -2; min-height: 160px; } .t-cta { order: -1; min-height: 160px; }
  .tile { min-height: 0; padding: 20px; }
  .detail { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 78svh; }
  .bar a:not(.bar-mark) { display: none; }
}
