/* Demo page: one dark theme, one radius (6px), system type. The stage takes its colour from the chosen
   Wada combination; the panel stays neutral so the colours are judged against a steady surround. */
:root {
  --bg: #0b0b0c;
  --surface: #111113;
  --raised: #18181b;
  --hover: #202024;
  --line: #242428;
  --edge: #6c6b72;
  --text: #eeede8;
  --muted: #a8a7a0;
  --r: 6px;
  --gutter: 20px;
  --panel-w: 372px;
  --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 { background: var(--bg); }
body {
  margin: 0;
  font: 13px/1.5 var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, select, input { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.demo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  min-height: 100dvh;
}

/* Stage */
.stage {
  --ground: var(--bg);
  --ink: var(--text);
  position: sticky;
  top: 0;
  height: 100dvh;
  background: var(--ground);
  transition: background-color 0.4s var(--ease);
  overflow: hidden;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: background-color 0.4s var(--ease);
}
.caption {
  position: absolute;
  left: 24px;
  bottom: 22px;
  right: 24px;
  color: var(--ink);
  pointer-events: none;
}
.caption-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.caption-names {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 6px;
  font: 12px/1.4 var(--mono);
}
.caption-names li { display: flex; align-items: center; gap: 7px; }
.caption-names i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 45%, transparent);
}
.stage-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--ink);
  pointer-events: none;
}
.stage-note:empty { display: none; }

/* Panel */
.panel {
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding-bottom: 28px;
}
.panel-head { padding: 22px var(--gutter) 18px; }
.panel-head h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head p { margin-top: 4px; color: var(--muted); }

.group { padding: 18px var(--gutter) 6px; border-top: 1px solid var(--line); }
.group h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 12px; }
.field-label output { font-family: var(--mono); color: var(--text); }
.row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }

select, .btn, .segments button, .glyphs button, .grounds button {
  background: var(--raised);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}
select { width: 100%; height: 36px; padding: 0 10px; }
.btn { height: 32px; padding: 0 14px; white-space: nowrap; }
select:hover, .btn:hover, .segments button:hover, .glyphs button:hover { background: var(--hover); }
.btn:active, .segments button:active, .glyphs button:active, .grounds button:active { transform: scale(0.97); }

input[type="range"] { width: 100%; height: 24px; margin: 0; accent-color: var(--text); cursor: pointer; }

.segments { display: flex; flex-wrap: wrap; gap: 6px; }
.segments button { height: 30px; padding: 0 11px; text-transform: capitalize; }
.segments button[aria-pressed="true"],
.glyphs button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

.glyphs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.glyphs button { height: 40px; display: grid; place-items: center; }
.glyph-icon { width: 20px; height: 20px; }
.glyph-icon .o, .glyph-icon .s { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.glyph-icon .f { fill: currentColor; }

/* Background choice: dark, or one colour of the combination */
.grounds { display: flex; gap: 8px; }
.grounds button {
  flex: 1;
  height: 38px;
  min-width: 0;
  padding: 0;
  background: var(--swatch);
  border-color: color-mix(in srgb, var(--text) 28%, transparent);
  font-size: 12px;
  color: var(--swatch-ink);
}
.grounds button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }

/* Combination browser */
.combo-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.combos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 268px;
  overflow-y: auto;
  padding: 4px;
  margin: 0 -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}
.combos button {
  display: flex;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  background: none;
  transition: transform 0.1s var(--ease);
}
.combos button:hover { transform: scale(1.06); }
.combos button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.combos button[hidden] { display: none; }
.combos span { flex: 1; }

.check { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--text); }

.credits { padding: 18px var(--gutter) 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.credits p { margin-bottom: 8px; max-width: 65ch; }

/* Narrow screens: the sculpture stays in view on top while the controls scroll beneath it */
@media (max-width: 860px) {
  .demo { display: block; }
  .stage { height: 54dvh; z-index: 1; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .caption { left: 16px; right: 16px; bottom: 14px; }
  :root { --gutter: 16px; }
  .combos { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Five-step example: one button per shape */
.steps { display: grid; gap: 6px; }
.steps button {
  height: 34px;
  padding: 0 12px;
  text-align: left;
  background: var(--raised);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), transform 0.1s var(--ease);
}
.steps button:hover { background: var(--hover); }
.steps button:active { transform: scale(0.98); }
.steps button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
