/* Contour Engine
   Layout idea: the editor is the hero. The page borrows the editor's own
   colours (dark neutral chrome, one amber accent, cyan for portals) and lets
   one large live view carry the colour. Single dark theme by choice. */

:root {
  color-scheme: dark;
  --bg: #0f1115;          /* page ground */
  --chrome: #0b0d10;      /* status bar, masthead */
  --panel: #16191f;       /* panels, code, placeholders */
  --field: #1b1e25;
  --line: #23272f;
  --line2: #2c313a;
  --text: #e6e8ec;
  --text2: #c9cfd8;
  --muted: #9aa3af;
  --faint: #8b94a3;
  --accent: #f2b33d;      /* active, selected */
  --on-accent: #17120a;
  --portal: #28d6e8;

  --sans: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* Navy blueprint ground. blueprint.js paints the same gradient with a grid
   and wireframes on a fixed canvas; this is what shows without it. */
html { scroll-behavior: smooth; background: #050d1e radial-gradient(ellipse 90% 75% at 50% 0%, #0b1d3b 0, #081630 45%, #050d1e 100%) fixed; }

body {
  position: relative;
  z-index: 0;            /* own stacking context, so the scattered game pieces can sit behind everything */
  margin: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

::selection { background: var(--accent); color: var(--on-accent); }
a { color: var(--text); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1240px; margin-inline: auto; padding-inline: var(--gutter); }
.stage { max-width: 1720px; margin-inline: auto; padding-inline: var(--gutter); }

/* The top of the page starts on an old monitor and fades into the present:
   scanlines, a slow rolling bar and a blue phosphor cast. The scanlines are
   solid over the masthead and fade to nothing at the bottom of the first line
   of the headline: site.js measures both and sets --scan-solid (where the fade
   starts) and --scan-end (where it ends). Without it they thin out over the top of the page as before. */
.retro-top {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--scan-end, clamp(460px, 56vw, 860px));
  z-index: 15;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.38) 2px 4px);
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 var(--scan-solid, 24%), transparent var(--scan-end, 84%));
  mask-image: linear-gradient(to bottom, #000 0, #000 var(--scan-solid, 24%), transparent var(--scan-end, 84%));
  overflow: hidden;
}
.retro-top::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent, rgba(120, 190, 255, 0.1), transparent) 0 0 / 100% 28% no-repeat;
  animation: roll 6s linear infinite;
}
@keyframes roll { from { background-position: 0 -40%; } to { background-position: 0 140%; } }

/* The blueprint grid canvas sits behind everything, the game pieces just above it */
.blueprint { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -2; pointer-events: none; }

/* Game pieces scattered faintly in the background below the hero (scatter.js) */
main[data-view="home"] { position: relative; }
.scatter { position: absolute; left: 0; right: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.scatter .bit {
  position: absolute;
  opacity: 0.28;
  transform: rotate(var(--tilt));
  filter: drop-shadow(0 0 6px rgba(var(--glow), 0.7));
  animation: bit-bob var(--bob) ease-in-out var(--delay) infinite alternate;
}
.scatter .bit.twinkle { animation: bit-twinkle var(--bob) ease-in-out var(--delay) infinite alternate; }
@keyframes bit-bob { from { transform: translateY(-5px) rotate(var(--tilt)); } to { transform: translateY(5px) rotate(var(--tilt)); } }
@keyframes bit-twinkle { from { opacity: 0.1; } to { opacity: 0.34; } }
@media (max-width: 760px) { .scatter .bit { opacity: 0.2; } }

/* Scroll progress */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 30; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }

/* Masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 21, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms, background-color 200ms;
}
.js:not(.scrolled) .masthead { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.js:not(.scrolled) .masthead nav a { color: #7fbcff; font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; text-shadow: 0 0 8px rgba(88, 170, 255, 0.7); }
.wordmark img { filter: drop-shadow(0 0 8px rgba(237, 28, 36, 0.55)); }
.scrolled .masthead { border-bottom-color: var(--line); }
.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 32px;
  padding-block: 14px;
  transition: padding 200ms var(--ease);
}
.scrolled .masthead-row { padding-block: 8px; }

.wordmark { display: inline-flex; align-items: center; padding-block: 4px; }
.wordmark img { display: block; height: 24px; width: auto; transition: height 200ms var(--ease), filter 200ms; }
.scrolled .wordmark img { height: 20px; }
.wordmark:hover img { filter: brightness(1.2); }

.masthead ul { display: flex; flex-wrap: wrap; gap: 0 22px; margin: 0; padding: 0; list-style: none; }
.masthead nav a {
  position: relative;
  display: inline-block;
  padding-block: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  transition: color 120ms;
}
.masthead nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 4px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 220ms var(--ease);
}
.masthead nav a:hover { color: var(--text); }
.masthead nav a:hover::after, .masthead nav a:focus-visible::after { transform: scaleX(1); }

/* Hero */
.hero { padding-block: clamp(28px, 5vw, 64px) clamp(40px, 6vw, 80px); }

h1 {
  margin: 0;
  font-stretch: 85%;
  font-weight: 700;
  font-size: clamp(2.25rem, 7.4vw, 6.25rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
}
h1 .w { display: inline-block; }
h1 .w > span { display: inline-block; animation: power 700ms steps(6) both; animation-delay: calc(var(--i) * 150ms + 1500ms); }
@keyframes power { 0% { opacity: 0; } 30% { opacity: 1; } 45% { opacity: 0.2; } 60% { opacity: 1; } 75% { opacity: 0.6; } 100% { opacity: 1; } }
/* first line still on the old tube, second line in the present */
h1 .w.old { color: #a9d6ff; text-shadow: 0 0 8px rgba(120, 190, 255, 0.9), 0 0 34px rgba(88, 170, 255, 0.6), 0 0 80px rgba(88, 170, 255, 0.3); }
h1 .w:not(.old) { text-shadow: 0 0 30px rgba(88, 170, 255, 0.28); }

.lede {
  max-width: 33em;
  margin: clamp(18px, 2.6vw, 28px) 0 0;
  font-size: clamp(1.125rem, 1.6vw, 1.3125rem);
  line-height: 1.5;
  color: var(--muted);
  animation: fade 900ms 2600ms both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Calls to action */
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin: clamp(18px, 2.4vw, 28px) 0 0; animation: fade 900ms 2800ms both; }
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--line2);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font: 600 1rem var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms, border-color 140ms, color 140ms, transform 140ms var(--ease), box-shadow 140ms;
}
.btn:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 0 rgba(242, 179, 61, 0.5); animation: beacon 2.4s ease-out 4s infinite; }
.btn.primary:hover { background: #ffc452; color: var(--on-accent); }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); padding-inline: 6px; text-decoration: underline; text-underline-offset: 0.2em; }
.btn.quiet:hover { color: var(--text); border-color: transparent; }
@keyframes beacon { 0% { box-shadow: 0 0 0 0 rgba(242, 179, 61, 0.45); } 70%, 100% { box-shadow: 0 0 0 14px rgba(242, 179, 61, 0); } }

/* Hero: the words on the left, the animation beside them, so the whole
   animation fits on screen. Stacks on narrow screens. */
.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 40fr) minmax(0, 60fr);
  gap: clamp(28px, 3.4vw, 64px);
  align-items: center;
}
.hero-row h1 { font-size: clamp(2rem, 3.3vw, 4.25rem); }
.hero-row .lede { font-size: clamp(1.0625rem, 1.15vw, 1.25rem); }

/* The hero animation: a city that turns into a game */
.city {
  position: relative;
  z-index: 16;           /* above the scanlines: those belong to the words */
  margin: 0;
  animation: settle 900ms 2000ms var(--ease) both;
}
.city-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line2);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.city-stage { container-type: size; }
.city-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.city.live .city-stage canvas { display: block; }
.city-stage .city-raster { opacity: 0; image-rendering: pixelated; image-rendering: crisp-edges; }
.city-fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
.city.live .city-fallback { display: none; }
.city-hidden { display: none !important; }   /* panels the original file keeps switched off */
.city-big { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.45); border: 0; cursor: pointer; color: #f2efe8; font: 2cqw var(--mono); letter-spacing: 0.3em; }
.city-big:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.city-err { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 8cqw; text-align: center; font-size: 1.6cqw; line-height: 1.5; background: #000; color: #f2efe8; }

/* Tools: the words beside a smaller editor illustration */
.tools-band { padding-block: clamp(40px, 5.5vw, 80px); }
.tools-row {
  display: grid;
  grid-template-columns: minmax(0, 32fr) minmax(0, 68fr);
  gap: clamp(28px, 3.4vw, 64px);
  align-items: center;
}
.tools-row .ed-surface { height: clamp(260px, 29vw, 520px); }

/* The editor frame */
.editor { margin: 0; }
@keyframes settle { from { opacity: 0; transform: translateY(28px) scale(0.985); } to { opacity: 1; transform: none; } }

.ed-body {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 232px;
  background: #0a0b0e;
  border: 1px solid var(--line2);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.ed-rail { display: grid; align-content: start; justify-items: center; gap: 3px; padding: 7px 0; background: #14171c; }
.tool {
  display: grid;
  place-items: center;
  width: 40px;
  height: 38px;
  border-radius: 7px;
  color: #aeb6c2;
  transition: background-color 160ms, color 160ms;
}
.tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool.on { background: rgba(242, 179, 61, 0.16); color: var(--accent); }

.ed-view {
  display: grid;
  grid-template-rows: 32px minmax(0, 1fr);
  margin: 4px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(242, 179, 61, 0.35);
  overflow: hidden;
  min-width: 0;
}
.ed-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 10px;
  background: #1c2027;
  font-size: 0.8125rem;
  white-space: nowrap;
}
.ed-type { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.ed-type svg { width: 10px; height: 10px; fill: none; stroke: var(--faint); stroke-width: 1.6; }
.seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 6px;
  background: var(--field);
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 250ms;
}
.seg span { padding: 1px 9px; border-radius: 4px; color: var(--text2); transition: background-color 200ms, color 200ms; }
[data-phase="turn"] .seg, [data-phase="build"] .seg, [data-phase="hold"] .seg, [data-phase="walk"] .seg { opacity: 1; }
[data-phase="turn"] .seg span:first-child,
[data-phase="build"] .seg span:last-child,
[data-phase="hold"] .seg span:last-child,
[data-phase="walk"] .seg span:last-child { background: var(--accent); color: var(--on-accent); }
.ed-info { margin-left: auto; overflow: hidden; text-overflow: ellipsis; color: var(--faint); font-family: var(--mono); font-size: 0.75rem; }
.ed-btn {
  min-width: 58px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--line2);
  border-radius: 5px;
  background: var(--field);
  color: var(--text2);
  font: 500 0.75rem var(--sans);
  cursor: pointer;
  transition: background-color 120ms, color 120ms;
}
.ed-btn:hover { background: #252a33; color: var(--text); }
.ed-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.ed-modes { display: inline-flex; gap: 4px; margin-left: auto; }
.ed-modes .ed-btn { min-width: 0; }
.ed-height { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text2); }
.ed-height .ed-btn { min-width: 28px; padding: 0; font-size: 0.9375rem; }
.ed-height output { min-width: 3ch; text-align: center; font-family: var(--mono); color: var(--accent); }
.paused .seg, .paused .ed-info { display: none; }
.ed-note {
  position: absolute;
  left: 10px;
  top: 10px;
  display: none;
  margin: 0;
  padding: 5px 9px;
  border-radius: 5px;
  background: rgba(10, 12, 15, 0.7);
  color: #d3d8e0;
  font-size: 0.75rem;
  pointer-events: none;
}
.ed-note kbd { padding: 1px 5px; border: 1px solid var(--line2); border-radius: 4px; background: var(--field); font: 500 0.6875rem var(--mono); color: var(--text); }
.paused[data-mode="walk"] .ed-note { display: block; }
.paused .ed-surface { touch-action: none; cursor: crosshair; }
.paused[data-mode="walk"] .ed-surface { cursor: grab; }
.ed-surface:focus-visible { outline-offset: -2px; }

.ed-surface { position: relative; height: clamp(280px, 48vw, 780px); background: #15171b; }
.ed-surface canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.live .ed-surface canvas { display: block; }
.ed-fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
.ed-fallback polygon { fill: none; stroke: rgb(236, 240, 245); stroke-width: 1.4; }
.live .ed-fallback { display: none; }

.ed-props { background: var(--panel); border-left: 1px solid var(--line); font-size: 0.78125rem; overflow: hidden; }
.pp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 30px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.pp-label { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.85px; text-transform: uppercase; color: var(--faint); }
.pp-what { font-weight: 500; color: var(--text2); white-space: nowrap; }
.pp-cat { display: flex; align-items: center; gap: 6px; height: 24px; margin-top: 4px; padding: 0 8px; font-weight: 600; }
.pp-cat svg { width: 9px; height: 9px; fill: none; stroke: var(--muted); stroke-width: 1.6; }
.pp-cat i { flex: 0 0 24px; height: 1px; margin-left: 4px; background: var(--line); }
.pp-row { display: grid; grid-template-columns: 40% 1fr; min-height: 26px; margin: 0 4px; padding: 2px 8px 2px 22px; align-items: center; border-radius: 4px; }
.pp-row > span { color: var(--muted); border-right: 1px solid var(--line); align-self: stretch; display: flex; align-items: center; }
.pp-row b { padding-left: 8px; font: 400 0.75rem var(--mono); color: var(--text); display: flex; align-items: center; gap: 6px; min-width: 0; }
.pp-row em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-tex canvas { flex: none; width: 22px; height: 22px; border-radius: 3px; background: var(--field); image-rendering: pixelated; }

.ed-status {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  height: 26px;
  padding: 0 10px;
  align-items: center;
  background: var(--chrome);
  border: 1px solid var(--line2);
  border-top-color: var(--line);
  border-radius: 0 0 10px 10px;
  font-size: 0.75rem;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
}
.ed-status span { overflow: hidden; text-overflow: ellipsis; }
.ed-right { color: var(--muted); flex: none; }

.editor figcaption { max-width: 46em; margin-top: 14px; font-size: 0.9375rem; color: var(--muted); }

/* Sections */
.band {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 28px clamp(32px, 7vw, 112px);
  align-items: center;
  padding-block: clamp(40px, 5.5vw, 80px);
}
.band.wide { grid-template-columns: minmax(0, 1fr); gap: clamp(24px, 3vw, 40px); }
.copy { display: grid; gap: 18px; align-content: start; }
.band.wide .copy { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px clamp(32px, 7vw, 112px); }

h2 {
  margin: 0;
  font-stretch: 90%;
  font-weight: 650;
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
h2::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 16px;
  background: var(--accent);
  transform-origin: 0 50%;
}
.js h2.reveal::after { transform: scaleX(0); transition: transform 700ms 350ms var(--ease); }
.js h2.reveal.in::after { transform: scaleX(1); }

.prose { display: grid; gap: 1em; max-width: 34em; color: var(--muted); }
.prose p { margin: 0; }

/* Arriving on scroll (only when scripting is on) */
.js .reveal { opacity: 0; transform: translateY(26px); }
.js .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
  transition-delay: calc(var(--d, 0) * 110ms);
}

.plates { display: grid; gap: 20px; }
.plates.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plate { margin: 0; }
.plate figcaption, .listing figcaption { margin-top: 10px; font-size: 0.9375rem; color: var(--muted); }

/* Media placeholders: an empty view waiting for a picture */
.blank {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line2);
  border-radius: 6px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    #15171b;
  text-align: center;
  overflow: hidden;
  animation: drift 14s linear infinite;
  transition: border-color 200ms;
}
.blank:hover { border-color: var(--accent); }
@keyframes drift { to { background-position: 32px 32px, 32px 32px, 0 0; } }
.blank::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(242, 179, 61, 0.09) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: sweep 4.5s ease-in-out infinite;
}
@keyframes sweep { 55%, 100% { transform: translateX(100%); } }
.blank span {
  position: relative;
  padding: 7px 14px;
  border: 1px solid var(--line2);
  border-radius: 5px;
  background: var(--panel);
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text2);
}
.blank.split::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line2); }

/* Code */
.listing { margin: 0; min-width: 0; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); overflow: hidden; }
.listing-head { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; background: var(--field); font: 500 0.75rem var(--mono); color: var(--muted); }
.listing-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.listing pre {
  margin: 0;
  padding: 20px 22px;
  overflow-x: auto;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.7;
  tab-size: 4;
}
.listing .c { color: var(--faint); }
.listing pre.typing code::after { content: ""; display: inline-block; width: 0.55em; height: 1.1em; margin-left: 1px; vertical-align: text-bottom; background: var(--accent); animation: blink 700ms steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.listing figcaption { margin: 0; padding: 10px 14px 12px; border-top: 1px solid var(--line); }

/* Bee Script: a script flows left to right into the game.
   Three steps at different heights, with arrows carrying it between them. */
.bee-band { padding-block: clamp(40px, 5.5vw, 80px); }
.bee-copy { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px clamp(32px, 7vw, 112px); }
.pipeline { margin: clamp(28px, 4vw, 56px) auto 0; min-width: 0; }
.pipe-flow {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) 72px minmax(0, 1fr) 72px minmax(0, 1.5fr);
  gap: 14px;
  align-items: start;
}
.pipe { display: grid; grid-template-rows: auto 1fr; min-width: 0; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); overflow: hidden; transition: border-color 250ms, box-shadow 250ms, opacity 300ms; }
.pipe-script { transform: rotate(-1.2deg); }
.pipe-asm { margin-top: 84px; transform: rotate(0.8deg); }
.pipe-run { margin-top: 30px; border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); }
.pipe-head { display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 12px; background: var(--field); font: 600 0.8125rem var(--sans); color: var(--text2); white-space: nowrap; }
.pipe-head b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; background: var(--line2); color: var(--text); font: 500 0.6875rem var(--mono); transition: background-color 250ms, color 250ms; }
.pipe-head span { margin-left: auto; overflow: hidden; text-overflow: ellipsis; font: 400 0.6875rem var(--mono); color: var(--faint); }
.pipe pre { margin: 0; padding: 14px; overflow: hidden; font: 400 0.75rem/1.55 var(--mono); color: var(--text); tab-size: 2; }
.pipe pre.is-asm { color: var(--portal); }
.pipe pre mark { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 12px rgba(242, 179, 61, 0.7); }
.pipe-game { position: relative; background: #0a0b0e; aspect-ratio: 220 / 200; }
.pipe-game canvas { display: none; width: 100%; height: 100%; image-rendering: pixelated; }
.pipe-still { margin: 0; padding: 16px 14px; font-size: 0.9375rem; color: var(--muted); }

/* arrows between the steps */
.flow { align-self: center; display: grid; justify-items: center; gap: 2px; margin-top: 60px; color: var(--line2); font: 500 0.6875rem var(--mono); transition: color 300ms; }
.flow { position: relative; z-index: 1; }
.flow span { padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--faint); }
.flow.lit span { color: var(--accent); }
.flow svg { width: 64px; height: 120px; overflow: visible; }
.flow-line { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 7 7; animation: flow 600ms linear infinite; }
.flow-head { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.flow-dot { fill: #fff3c9; offset-path: path("M4 60 C 18 14, 40 106, 54 60"); animation: travel 1.4s cubic-bezier(0.5, 0, 0.5, 1) infinite; }
.flow:nth-of-type(4) .flow-dot { animation-delay: -0.6s; }
@keyframes flow { to { stroke-dashoffset: -14; } }
@keyframes travel { 0% { offset-distance: 0%; opacity: 0; } 15%, 85% { opacity: 1; } 100% { offset-distance: 100%; opacity: 0; } }
.pipeline:not(.live) .flow, .flow.lit { color: var(--accent); }
.flow.lit svg { filter: drop-shadow(0 0 6px rgba(242, 179, 61, 0.6)); }

.pipeline.live .pipe-game canvas { display: block; position: absolute; inset: 0; }
.pipeline.live .pipe-still { display: none; }
.pipeline.live .pipe { opacity: 0.5; }
.pipeline.live .pipe.on, .pipeline.live .pipe.done { opacity: 1; }
.pipeline.live .pipe.on { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(242, 179, 61, 0.35), 0 0 30px rgba(242, 179, 61, 0.14); }
.pipeline.live .pipe.on .pipe-head b { background: var(--accent); color: var(--on-accent); }
.pipeline figcaption { max-width: 60em; margin-top: clamp(20px, 3vw, 36px); font-size: 0.9375rem; color: var(--muted); }

/* code colours, shared with the reference */
.bee .k { color: #f2b33d; }
.bee .t { color: #6aa8ff; }
.bee .s { color: #8bd17c; }
.bee .n { color: #e3a27a; }
.bee .c { color: var(--faint); }

/* Two views: the site and the Bee Script reference */
.js[data-route="home"] [data-view="docs"], .js[data-route="docs"] [data-view="home"], .js[data-route="docs"] .retro-top { display: none; }
.js[data-route="docs"] .masthead { background: rgba(15, 17, 21, 0.9); border-bottom-color: var(--line); }
.docs { padding-block: clamp(28px, 4vw, 56px) clamp(48px, 6vw, 96px); border-top: 1px solid var(--line); }
.docs-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.docs-nav { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; font-size: 0.9375rem; }
.docs-back { display: inline-block; margin-bottom: 18px; color: var(--muted); }
.docs-nav ol { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.docs-nav li a { display: flex; gap: 10px; padding: 6px 10px; border-radius: 5px; color: var(--text2); text-decoration: none; }
.docs-nav li a span { flex: none; width: 1.5em; font: 500 0.75rem/1.7 var(--mono); color: var(--faint); }
.docs-nav li a:hover { background: var(--field); color: var(--accent); }
.doc { min-width: 0; max-width: 46em; }
.doc-kicker { margin: 0 0 8px; font: 500 0.8125rem var(--mono); color: var(--accent); }
.doc h1 { font-size: clamp(2.25rem, 5vw, 3.75rem); line-height: 1.02; letter-spacing: -0.03em; font-stretch: 90%; color: var(--text); text-shadow: none; }
.doc h2 { display: flex; align-items: baseline; gap: 14px; margin: 2.4em 0 0.6em; padding-top: 1.1em; border-top: 1px solid var(--line); font-size: clamp(1.5rem, 2.6vw, 2rem); scroll-margin-top: 80px; }
.doc h2::after { display: none; }
.doc-num { font: 500 0.875rem var(--mono); color: var(--accent); letter-spacing: 0; }
.doc h3 { margin: 1.8em 0 0.5em; font-size: 1.1875rem; font-weight: 650; letter-spacing: -0.01em; }
.doc p, .doc li { color: var(--text2); }
.doc p { margin: 0.8em 0; }
.doc ul, .doc ol { margin: 0.8em 0; padding-left: 1.3em; display: grid; gap: 0.35em; }
.doc strong { color: var(--text); }
.doc code { padding: 0.1em 0.35em; border-radius: 4px; background: var(--field); font: 400 0.875em var(--mono); color: var(--text); }
.doc pre { margin: 1em 0; padding: 16px 18px; overflow-x: auto; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); font: 400 0.875rem/1.6 var(--mono); color: var(--text); tab-size: 4; }
.doc pre code { padding: 0; background: none; font: inherit; }
.doc-table { margin: 1em 0; overflow-x: auto; border: 1px solid var(--line2); border-radius: 8px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.doc th, .doc td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.doc th { background: var(--field); font-weight: 600; color: var(--text); white-space: nowrap; }
.doc tr:last-child td { border-bottom: 0; }
.doc td { color: var(--text2); }
.doc em { color: var(--muted); }

/* Sound demo */
.sound { margin: 0; min-width: 0; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); overflow: hidden; }
.sound-view { position: relative; background: #0a0b0e; }
.sound-view canvas { display: none; width: 100%; aspect-ratio: 520 / 300; touch-action: none; }
.sound.live .sound-view canvas { display: block; }
.sound-fallback { display: block; width: 100%; height: auto; }
.sound.live .sound-fallback { display: none; }
.sound-fallback .ear { fill: none; stroke: var(--portal); stroke-width: 4; }
.sound-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; padding: 12px 14px; border-top: 1px solid var(--line); }
.sound-bar .btn { min-height: 40px; padding: 0 16px; font-size: 0.9375rem; animation: none; }
.meter { display: inline-flex; align-items: center; gap: 9px; font: 500 0.75rem var(--mono); color: var(--faint); }
.meter i { font-style: normal; }
.meter b { display: block; width: clamp(70px, 9vw, 120px); height: 8px; border-radius: 2px; background: var(--field); overflow: hidden; }
.meter u { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0.6); transition: transform 160ms var(--ease); }
.meter + .meter u { background: var(--portal); }
.sound-status { margin: 0; padding: 0 14px 12px; font-size: 0.9375rem; color: var(--text2); min-height: 2.4em; }
.sound figcaption { margin: 0; padding: 10px 14px 12px; border-top: 1px solid var(--line); font-size: 0.9375rem; color: var(--muted); }

/* Sound */
.sketch { margin: 0; }
.sketch svg { display: block; width: 100%; height: auto; overflow: visible; }
.room-fill { fill: #15171b; }
.walls { fill: none; stroke: rgb(236, 240, 245); stroke-width: 1.6; stroke-linejoin: round; }
.rings circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.45);
  opacity: 0.5;
  animation: ring 4s linear infinite;
  animation-delay: calc(var(--n) * -0.8s);
}
@keyframes ring { from { transform: scale(0.02); opacity: 0.95; } to { transform: scale(1); opacity: 0; } }
.source { fill: var(--accent); transform-box: fill-box; transform-origin: center; animation: thump 0.8s ease-out infinite; }
@keyframes thump { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }

.eq { display: flex; align-items: flex-end; gap: 4px; height: 34px; margin-top: 6px; }
.eq i { width: 6px; height: 100%; background: var(--accent); border-radius: 1px; transform-origin: 50% 100%; transform: scaleY(0.4); animation: eq 900ms ease-in-out infinite alternate; }
.eq i:nth-child(3n) { animation-duration: 620ms; }
.eq i:nth-child(3n + 1) { animation-duration: 780ms; animation-delay: -300ms; }
.eq i:nth-child(4n) { animation-duration: 1100ms; animation-delay: -500ms; background: var(--portal); }
.eq i:nth-child(5n) { animation-delay: -700ms; }
@keyframes eq { from { transform: scaleY(0.12); } to { transform: scaleY(1); } }

/* Multiplayer link */
.link { display: block; width: 100%; max-width: 320px; height: auto; margin-top: 6px; }
.link rect { fill: #15171b; stroke: var(--text2); stroke-width: 1.5; }
.link .thin { stroke: var(--line2); stroke-width: 1.5; }
.link .wire { fill: none; stroke: var(--line2); stroke-width: 1.5; stroke-dasharray: 4 5; animation: wire 1s linear infinite; }
@keyframes wire { to { stroke-dashoffset: -18; } }
.link .packet { fill: var(--accent); animation: packet 1.8s var(--ease) infinite alternate; }
.link .packet.back { fill: var(--portal); animation-delay: -1.8s; animation-direction: alternate-reverse; }
@keyframes packet { to { transform: translateX(176px); } }

/* Footer */
.colophon { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-block: 28px 56px; font-size: 0.9375rem; color: var(--muted); }
.colophon p { margin: 0; }
.colophon-logo { display: block; height: 18px; width: auto; }

@media (max-width: 1100px) {
  /* the flow turns to run down the page */
  .pipe-flow { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 4px; }
  .pipe { width: min(100%, 520px); }
  .pipe-script, .pipe-asm { transform: none; }
  .pipe-asm, .pipe-run { margin-top: 0; }
  .flow { margin-top: 0; grid-auto-flow: column; align-items: center; gap: 10px; }
  .flow svg { width: 44px; height: 82px; transform: rotate(90deg); }
}
@media (max-width: 1240px) and (min-width: 941px) {
  /* the editor is in a narrow column here: drop its property panel */
  .tools-row .ed-body { grid-template-columns: 52px minmax(0, 1fr); }
  .tools-row .ed-props { display: none; }
}
@media (max-width: 940px) {
  /* one column: words above, picture below */
  .hero-row, .tools-row { grid-template-columns: minmax(0, 1fr); }
  .hero-row h1 { font-size: clamp(2.25rem, 7.4vw, 4.75rem); }
  .city { margin-top: 8px; }
  .tools-row .ed-surface { height: clamp(260px, 56vw, 520px); }
}
@media (max-width: 980px) {
  .docs-grid { grid-template-columns: minmax(0, 1fr); }
  .docs-nav { position: static; max-height: none; }
  .docs-nav ol { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .ed-body { grid-template-columns: 52px minmax(0, 1fr); }
  .ed-props { display: none; }
}
@media (max-width: 760px) {
  .band, .band.wide .copy, .plates.two { grid-template-columns: minmax(0, 1fr); }
  .bee-copy { grid-template-columns: minmax(0, 1fr); }
  .ed-body { grid-template-columns: minmax(0, 1fr); }
  .ed-rail, .ed-right, .ed-info { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rings circle:nth-child(1) { transform: scale(0.2); }
  .rings circle:nth-child(2) { transform: scale(0.4); }
  .rings circle:nth-child(3) { transform: scale(0.6); }
  .rings circle:nth-child(4) { transform: scale(0.8); }
  .rings circle:nth-child(5) { transform: scale(1); }
}
