/* M8trix training-system loop — November 2026
   Palette: Ink #0A0A0B · Snowy White #FDFDFF · Red Orange #F42902 · Yellow Punk #C8FD00 */
@font-face {
  font-family: "M8 Display";
  src: url("../assets/BarlowSemiCondensed-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

:root {
  --ink: #0a0a0b;
  --board: #121214;
  --board-raised: #1c1c1f;
  --white: #fdfdff;
  --muted: #b4b4ba;
  --signal: #f42902;
  --punk: #c8fd00;
  --line: rgba(253, 253, 255, .2);

  /* Standalone (dark board) */
  --track: #2c2c31;
  --lane: rgba(253, 253, 255, .2);
  --node: var(--white);
  --node-ring: var(--board);
  --label: var(--white);
  --sub: var(--muted);
  --orbit: rgba(253, 253, 255, .16);

  --cycle: 12s;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --display: "M8 Display", "Arial Narrow", sans-serif;
  --body: "Aptos", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--ink); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--white);
  background: var(--ink);
  font-family: var(--body);
  overflow-x: hidden;
}
::selection { color: var(--ink); background: var(--punk); }
button { font: inherit; }

.blueprint-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--board);
}

.prototype-header,
.prototype-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.1rem clamp(1.1rem, 3vw, 3rem);
  border-color: var(--line);
  background: rgba(10, 10, 11, .5);
}
.prototype-header { border-bottom: 1px solid var(--line); }
.prototype-note { border-top: 1px solid var(--line); }
.prototype-header > div:first-child { display: flex; align-items: baseline; gap: 1rem; }
.prototype-header span,
.prototype-note span {
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.prototype-header strong { font-family: var(--display); font-size: 1.05rem; letter-spacing: .02em; }
.prototype-note p { max-width: 64ch; margin: 0; font-size: .95rem; }

.controls { display: flex; gap: .55rem; }
.controls button {
  min-height: 42px;
  padding: .6rem .9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--white);
  background: transparent;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.controls button:hover { color: var(--ink); border-color: var(--punk); background: var(--punk); }
.controls button:focus-visible { outline: 3px solid var(--punk); outline-offset: 3px; }
#motion-toggle { display: inline-flex; align-items: center; gap: .55rem; }
.pause-icon { width: 10px; height: 12px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
#motion-toggle[aria-pressed="true"] .pause-icon {
  width: 0;
  height: 0;
  border: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid currentColor;
}

.blueprint-stage { min-height: 0; display: grid; place-items: center; padding: 1rem; overflow: hidden; }
#blueprint { display: block; width: 100%; height: auto; max-height: calc(100vh - 170px); margin: auto; }

/* Track */
.track { fill: none; stroke: var(--track); stroke-width: 54; }
.track-lane { fill: none; stroke: var(--lane); stroke-width: 2; stroke-dasharray: 5 11; }
.track-chevron { fill: none; stroke: rgba(253, 253, 255, .5); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

/* Signal: a Yellow Punk run with a Red Orange lead */
.pulse {
  fill: none;
  stroke: var(--punk);
  stroke-width: 24;
  stroke-linecap: round;
  stroke-dasharray: 8 92;
  stroke-dashoffset: -4.5;
  animation: pulse-run var(--cycle) linear infinite;
}
.pulse-head {
  fill: none;
  stroke: var(--signal);
  stroke-width: 24;
  stroke-linecap: round;
  stroke-dasharray: .01 99.99;
  stroke-dashoffset: -12.5;
  animation: head-run var(--cycle) linear infinite;
}

/* Orbits */
.orbit { fill: none; stroke: var(--orbit); stroke-width: 1.5; stroke-dasharray: 3 9; transform-box: fill-box; transform-origin: center; }
.orbit-a { animation: orbit-turn 48s linear infinite; }
.orbit-b { animation: orbit-turn 48s linear infinite reverse; }

/* Stations */
.node {
  fill: var(--node);
  stroke: var(--node-ring);
  stroke-width: 6;
  transform-box: fill-box;
  transform-origin: center;
  animation: node-lit var(--cycle) var(--ease) infinite;
  animation-delay: var(--d);
}
.node-num {
  fill: var(--ink);
  font-family: var(--display);
  font-size: 23px;
  letter-spacing: .5px;
  text-anchor: middle;
  dominant-baseline: central;
}
.stage-label,
.stage-sub { font-family: var(--display); }
.stage-label { fill: var(--label); font-size: 31px; letter-spacing: 1.2px; }
.stage-sub { fill: var(--sub); font-size: 13.5px; letter-spacing: 2.1px; }
.side-left .stage-label,
.side-left .stage-sub { text-anchor: end; }
.stage-bar {
  fill: var(--signal);
  transform-box: fill-box;
  transform: scaleX(0);
  animation: bar-grow var(--cycle) var(--ease) infinite;
  animation-delay: var(--d);
}
.side-left .stage-bar { transform-origin: right center; }
.side-right .stage-bar { transform-origin: left center; }

@keyframes pulse-run { to { stroke-dashoffset: -104.5; } }
@keyframes head-run { to { stroke-dashoffset: -112.5; } }
@keyframes orbit-turn { to { transform: rotate(360deg); } }
@keyframes node-lit {
  0% { fill: var(--node); transform: scale(1); }
  2.5%, 21% { fill: var(--punk); transform: scale(1.16); }
  25%, 100% { fill: var(--node); transform: scale(1); }
}
@keyframes bar-grow {
  0% { transform: scaleX(0); }
  4%, 21% { transform: scaleX(1); }
  25%, 100% { transform: scaleX(0); }
}

/* Homepage embed: transparent, on Snowy White */
.is-embed,
.is-embed body,
.is-embed .blueprint-shell { width: 100%; height: 100%; min-height: 0; overflow: hidden; }
.is-embed {
  color-scheme: light;
  background: transparent;
  --track: #0a0a0b;
  --lane: rgba(253, 253, 255, .22);
  --node: #fdfdff;
  --node-ring: #0a0a0b;
  --label: #0a0a0b;
  --sub: #56565c;
  --orbit: rgba(10, 10, 11, .2);
}
.is-embed body { background: transparent; }
.is-embed .blueprint-shell { display: block; background: transparent; }
.is-embed .prototype-header,
.is-embed .prototype-note { display: none; }
.is-embed .blueprint-stage { width: 100%; height: 100%; padding: 0; }
.is-embed #blueprint { width: 100%; height: 100%; max-height: none; }

@media (max-width: 760px) {
  .prototype-header { align-items: flex-start; }
  .prototype-header > div:first-child { display: grid; gap: .1rem; }
  .prototype-header span { font-size: .62rem; }
  .prototype-header strong { font-size: .92rem; }
  #restart { display: none; }
  .control-label { font-size: .82rem; }
  .prototype-note { align-items: flex-start; flex-direction: column; gap: .45rem; }
  .prototype-note p { font-size: .85rem; }
}

/* Small frames: drop the fine print so the stage names stay legible */
@media (max-width: 480px) {
  .stage-sub { display: none; }
  .stage-label { font-size: 31px; }
  .side-left .stage-label { transform: translateY(12px); }
  .side-right .stage-label { transform: translateY(12px); }
  .stage-bar { transform-box: fill-box; }
}

@media (prefers-reduced-motion: reduce) {
  .motion { animation: none !important; }
  .node { fill: var(--punk); }
  .stage-bar { transform: scaleX(1); }
}
