/* Five shapes in a row: one full-bleed stage. The colours come from the chosen theme (set from script):
   --ground behind everything, --ink for text, --soft for secondary text, --accent for the one highlight. */
:root {
  --ground: #121010;
  --ink: #f1eee8;
  --soft: #a9a49b;
  --line: #2c2a28;
  --accent: #e0703a;
  --pad: clamp(16px, 3.2vw, 44px);
  --r: 6px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--sans);
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.5s var(--ease), color 0.5s var(--ease);
}
h1, p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 3px; }

.walk { position: relative; height: 100dvh; min-height: 520px; overflow: hidden; }
.walk canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: background-color 0.5s var(--ease); }
/* The canvas in front must not cover the row behind it; the engine gives every canvas a background. */
#walker { background: transparent !important; }

/* Top bar */
.top {
  position: absolute; inset: 0 0 auto 0; z-index: 2;
  display: flex; align-items: center; gap: 18px;
  padding: 16px var(--pad);
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.brand svg { width: 20px; height: 20px; }
.top nav { display: flex; gap: 2px; margin-right: auto; }
.top nav a { padding: 6px 10px; color: var(--soft); text-decoration: none; font-size: 14px; border-radius: var(--r); }
.top nav a:hover { color: var(--ink); }

.themes { display: flex; gap: 8px; }
.themes button {
  width: 28px; height: 28px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--soft);
  background: linear-gradient(135deg, var(--a) 0 50%, var(--b) 50% 100%);
  transition: transform 0.15s var(--ease);
}
.themes button:hover { transform: scale(1.08); }
.themes button:active { transform: scale(0.94); }
.themes button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 3px; }

.note { position: absolute; inset: 45% 0 auto 0; z-index: 1; text-align: center; color: var(--soft); pointer-events: none; }
.note:empty { display: none; }

/* Caption: the current figure */
.caption {
  position: absolute; z-index: 1; left: var(--pad); top: 76px;
  max-width: min(34rem, calc(100% - 2 * var(--pad)));
  pointer-events: none;
}
.index { font: 500 12px/1 var(--mono); letter-spacing: 0.08em; color: var(--accent); }
.caption h1 {
  margin-top: 10px;
  font-size: clamp(24px, 3.6vw, 46px); line-height: 1.02; letter-spacing: -0.03em; font-weight: 600;
  text-wrap: balance;
}
.when { margin-top: 10px; font-size: 15px; font-weight: 500; }
.fact { margin-top: 2px; color: var(--soft); max-width: 40ch; }

/* Controls: play, the rail with a stop under each figure, and the notes */
.controls {
  position: absolute; z-index: 2; inset: auto 0 0 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 14px;
  padding: 0 var(--pad) calc(18px + env(safe-area-inset-bottom));
}
.play {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin-top: 2px; padding: 0;
  background: var(--ink); color: var(--ground);
  border: 0; border-radius: 50%; cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.play:active { transform: scale(0.94); }
.play svg { width: 16px; height: 16px; }
.play .icon-pause, .play[data-playing] .icon-play { display: none; }
.play[data-playing] .icon-pause { display: block; }

/* --inset is how far the first and last figure stand from the stage's edges, so each stop sits under its
   figure. The rail spans the whole stage width, which is why it breaks out of the grid cell. */
.rail { --inset: 12%; position: relative; height: 64px; grid-column: 1 / -1; grid-row: 1; margin: 0 calc(-1 * var(--pad)); pointer-events: none; }
.rail-line { position: absolute; left: var(--inset); right: var(--inset); top: 22px; height: 1px; background: var(--line); }
.rail-fill { height: 1px; width: 0; background: var(--accent); }
.stops { position: absolute; left: var(--inset); right: var(--inset); top: 0; height: 100%; display: flex; justify-content: space-between; }
.stops button {
  position: relative; width: 0; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center;
}
.stops button::before { content: ""; position: absolute; left: -22px; top: 0; width: 44px; height: 100%; }
.stops i {
  width: 9px; height: 9px; margin-top: 18px; border-radius: 50%;
  background: var(--ground); border: 1px solid var(--soft);
  transition: background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.stops span { margin-top: 10px; font-size: 12px; white-space: nowrap; color: var(--soft); transition: color 0.2s var(--ease); }
.stops button:hover span { color: var(--ink); }
.stops button[aria-current="true"] i { background: var(--accent); border-color: var(--accent); transform: scale(1.35); }
.stops button[aria-current="true"] span { color: var(--ink); }
/* The slider itself is for keyboards and screen readers; pointers use the stops. */
#timeline { position: absolute; left: var(--inset); right: var(--inset); top: 12px; width: auto; height: 22px; margin: 0; opacity: 0; pointer-events: none; }
#timeline:focus-visible { opacity: 1; accent-color: var(--accent); }

.play, .about { grid-row: 1; position: relative; z-index: 1; }
.play { grid-column: 1; }
.about { grid-column: 3; justify-self: end; margin-top: 12px; font-size: 13px; }
.about summary { list-style: none; cursor: pointer; color: var(--soft); padding: 4px 0; }
.about summary::-webkit-details-marker { display: none; }
.about summary:hover { color: var(--ink); }
.about-body {
  position: absolute; right: 0; bottom: calc(100% + 10px); width: min(26rem, calc(100vw - 2 * var(--pad)));
  padding: 14px 16px; display: grid; gap: 10px;
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--soft);
}

@media (max-width: 760px) {
  .brand span, .top nav a:nth-child(2) { display: none; }
  .caption { top: 64px; }
  .stops span { display: none; }
  .rail { height: 44px; }
  .controls { row-gap: 2px; }
  .play, .about { grid-row: 2; }
  .about { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  body, .walk canvas, .themes button, .play, .stops i, .stops span { transition: none; }
}
