/* The playgrounds at /problems/<id>/. The page shell is the gallery's
   (scripts/generate_problems.py PAGE_HEAD) and the chart box is the landing
   page's climb figure (template.html .climb*), copied here so the pages
   share the site's look without a build step. */

:root {
  --bg: #0b0d0e;
  --panel: #131719;
  --fg: #e8eaec;
  --muted: #9099a0;
  --faint: #676f76;
  --border: #232a2e;
  --cyan: #2ee6e6;
  --bad: #ff6b6b;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }   /* the harness hides links and buttons with the attribute */
body {
  font-family: var(--sans);
  color: var(--fg);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
/* Wider than the landing page: the stage and the chart sit side by side. */
main { max-width: 1280px; margin: 0 auto; padding: 0 24px 80px; }
header { padding: 64px 0 28px; }
/* One way back, at the very top: the landing page's nav is not repeated here. */
.home a { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; color: var(--fg); }
.home a span { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.home a:hover span { text-decoration-color: var(--cyan); }
.home svg { width: 15px; height: 15px; flex: none; }
.home { display: flex; align-items: center; gap: 24px; }
.home .esc { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.home .esc kbd { font: inherit; color: var(--muted); border: 1px solid var(--border); padding: 0 5px; }
h1 { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; margin-top: 10px; color: var(--cyan); }
header p { color: var(--muted); max-width: 640px; margin-top: 12px; }
header p code, .play-how code { font-family: var(--mono); font-size: 0.87em; color: var(--fg); }
a { color: var(--fg); }

/* --- the stage --------------------------------------------------------------- */

/* The stage takes the left column and the numbers + chart the right, so a
   move and its mark on the curve are in view together. The chart grows to
   the stage's height (play.js); on a phone the columns stack. */
@media (min-width: 900px) {
  .play-grid {
    display: grid;
    grid-template-columns: minmax(0, 11fr) minmax(0, 9fr);
    gap: 18px;
    align-items: start;
  }
  .play-grid .play-stats { margin-top: 0; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .play-grid .climb-plot { min-width: 0; }
}

.play {
  border: 1px solid var(--border);
  background: #0e1113;
}
.play-head, .climb-head {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}
.play-head b, .climb-head b { color: var(--fg); font-weight: 500; }
.play-head .bad { color: var(--bad); }
.play-head .note { color: var(--fg); }
.play-stage { position: relative; }
.play-stage canvas {
  display: block;
  width: 100%;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}
.play-stage canvas:focus-visible { box-shadow: inset 0 0 0 1px var(--cyan); }
.play-stage canvas.grab { cursor: grab; }
.play-stage canvas.grabbing { cursor: grabbing; }
.play-stage canvas.pointer { cursor: pointer; }
.play-stage canvas.move { cursor: move; }
.play-stage canvas.resize { cursor: ew-resize; }

/* The tools sit between the caption and the stage, where the eye already is. */
.play-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
}
.play-tools button {
  background: none;
  border: 0;
  padding: 2px 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 3px;
}
.play-tools button:hover, .play-tools button:focus-visible { color: var(--cyan); text-decoration-color: var(--cyan); outline: none; }
.play-tools button:disabled { color: var(--faint); text-decoration-color: transparent; cursor: default; }
.play-tools .kbd { color: var(--faint); }
.play-tools .count { color: var(--cyan); font-variant-numeric: tabular-nums; }
.play-tools label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
/* Two digits plus the browser's spinner, with the digits never hidden under it. */
.play-tools input[type="number"] {
  width: 7.5ch;
  padding: 2px 4px 2px 8px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  color-scheme: dark;
}
.play-tools input[type="number"]:focus-visible { outline: none; border-color: var(--cyan); }

/* --- the numbers ------------------------------------------------------------- */

.play-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 18px;
  border: 1px solid var(--border);
  background: var(--panel);
}
.play-stats > div { padding: 12px 16px; border-left: 1px solid var(--border); min-width: 0; }
.play-stats > div:first-child { border-left: 0; }
.play-stats dt {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.play-stats dd { font-family: var(--mono); font-size: 20px; color: var(--fg); margin-top: 4px; line-height: 1.2; overflow-wrap: anywhere; }
.play-stats dd.bad { color: var(--bad); }
.play-stats dd .who { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

/* --- the best-so-far chart: template.html lines 371-450 --------------------- */

.climb {
  margin-top: 18px;
  border: 1px solid var(--border);
  background: #0e1113;
}
.climb-scroll { overflow-x: auto; }
.climb-plot {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}
.climb-plot .axis { stroke: #2b3237; stroke-width: 1; }
.climb-plot .grid { stroke: #1a2024; stroke-width: 1; }
.climb-plot .tick {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--faint);
}
.climb-plot .step { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.climb-plot .miss { fill-opacity: 0.7; }   /* brighter than the landing page's: fewer dots, each one a move */
.climb-plot .hit { fill-opacity: 1; }
.climb-plot .ref { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 4 4; }
.climb-plot .ref-label {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--muted);
}
.climb-legend {
  display: flex;
  flex-direction: column;     /* a row of reference lines, then the session's series */
  gap: 0;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
}
.climb-legend > div { display: flex; flex-wrap: wrap; gap: 6px 18px; }
/* Each entry is a toggle for its series; an entry clicked off is dimmed. */
.climb-legend > div > span, .climb-legend > div > button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  color: var(--muted);
  background: none;
  border: 0;
  font: inherit;
}
.climb-legend button { cursor: pointer; }
.climb-legend button:hover, .climb-legend button:focus-visible { outline: none; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.climb-legend button.off { opacity: 0.4; }
.climb-legend i {
  width: 14px;
  height: 0;
  border-top: 2px solid currentColor;
  flex: none;
}
.climb-legend .val { color: var(--fg); }
.climb-legend .ref i { border-top-style: dashed; color: var(--faint); }

/* --- below the figures ------------------------------------------------------- */

.play-how { color: var(--muted); font-size: 14px; margin-top: 18px; }
.play-how kbd { font-family: var(--mono); font-size: 0.87em; color: var(--fg); }
/* The problem's own links (docs, code, the gallery) sit under its description. */
.links { display: flex; flex-wrap: wrap; gap: 10px 24px; font-family: var(--mono); font-size: 12px; margin-top: 14px; }
.links a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--fg); }
.links a span { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.links a:hover { color: var(--cyan); }
.links a:hover span { text-decoration-color: var(--cyan); }
.links svg { width: 13px; height: 13px; flex: none; }

@media (prefers-reduced-motion: no-preference) {
  .home a span, .links a span, .play-tools button { transition: text-decoration-color 120ms ease, color 120ms ease; }
}

@media (max-width: 480px) {
  main { padding: 0 20px 60px; }
  header { padding: 48px 0 20px; }
  h1 { font-size: 22px; }
  .play-stats { grid-template-columns: 1fr 1fr; }
  .play-stats > div:nth-child(odd) { border-left: 0; }
  .play-stats > div:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .play-stats dd { font-size: 17px; }
}
