/* Equation Art. Snack Quests palette: plum, purple, aqua, yellow, mist. */
:root {
  --plum: #411d4b;
  --purple: #77398e;
  --aqua: #93ccd3;
  --yellow: #e3db49;
  --mist: #dff0f2;
  --paper: #fbf8f2;
  --ink: #2b1b30;
  --ink-soft: #5d4f63;
  --line: #d9cfe0;
  --red: #d63c34;
  --err: #b3261e;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--plum); color: var(--mist); }
body {
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--plum);
  border-bottom: 2px solid var(--purple);
}
.home { color: var(--aqua); text-decoration: none; font-weight: 700; white-space: nowrap; }
.home:hover { color: var(--yellow); }
h1 {
  margin: 0;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.04em;
  color: var(--yellow);
  line-height: 1;
}
.tabs { display: flex; gap: 4px; margin-left: auto; background: #2f1437; border-radius: 999px; padding: 4px; }
.tabs button {
  border: 0;
  background: transparent;
  color: var(--mist);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
}
.tabs button[aria-selected="true"] { background: var(--yellow); color: var(--plum); }
@media (max-width: 480px) {
  .home-label { display: none; }
  .tabs { margin-left: 0; width: 100%; }
  .tabs button { flex: 1; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  border: 0;
  background: var(--yellow);
  color: var(--plum);
  font-weight: 700;
  border-radius: var(--radius);
  padding: 9px 16px;
  margin: 4px 4px 4px 0;
}
.btn:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--plum); border: 2px dashed var(--purple); }

/* ---------- learn ---------- */
.learn { max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; }
.learn-intro { max-width: 720px; }
.learn-intro h2 {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  margin: 12px 0 10px;
  color: var(--yellow);
  letter-spacing: 0.02em;
}
.learn-intro p { margin: 0 0 10px; }
.did-you-know {
  margin: 14px 0 4px !important;
  padding: 12px 16px;
  background: var(--yellow);
  color: var(--plum);
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(20, 6, 26, 0.4);
}
.did-you-know span {
  display: block;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: 26px;
  letter-spacing: 0.04em;
  color: var(--purple);
}
.learn-intro .example {
  margin: 0 0 12px;
  background: rgba(147, 204, 211, 0.15);
  border-left: 5px solid var(--aqua);
  border-radius: 6px;
  padding: 8px 14px;
}
.learn-intro .example p { margin: 6px 0 2px; }
details.example summary, details.more summary {
  cursor: pointer;
  font-weight: 700;
  width: fit-content;
}
.learn-intro .example summary { color: var(--aqua); }
details.more {
  margin: 0 0 10px;
  background: #f1ebf5;
  border-left: 5px solid var(--purple);
  border-radius: 6px;
  padding: 6px 12px;
}
details.more summary { color: var(--purple); }
details.more p { margin: 6px 0 2px; }
.learn-big { font-size: 18px; font-weight: 700; color: #fff; }
.learn-big .c-r { color: #ff8a80; }
.learn-big .c-g { color: #7ee2a0; }
.learn-big .c-b { color: #90b8ff; }
.group-title {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: 28px;
  letter-spacing: 0.03em;
  color: var(--aqua);
  margin: 26px 0 10px;
}
.lesson-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.lesson-grid button {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  text-align: left;
  background: var(--aqua);
  color: var(--plum);
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(20, 6, 26, 0.4);
  transition: transform 0.12s ease;
}
.lesson-grid button:hover { transform: translateY(-2px); }
.lesson-grid canvas { display: block; width: 100%; aspect-ratio: 1; background: #fff; }
.lesson-grid .lt { padding: 8px 10px 10px; }
.lesson-grid .ln { font-size: 13px; opacity: 0.8; }
.lesson-grid strong { display: block; font-size: 17px; line-height: 1.2; }
.lesson-grid .lb { display: block; font-size: 14px; margin-top: 2px; }

/* ---------- studio ---------- */
.studio {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
}
.stage {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--plum);
  padding: 8px 16px 6px;
  box-shadow: 0 6px 12px rgba(20, 6, 26, 0.35);
}
.canvas-wrap {
  position: relative;
  margin: 0 auto;
  /* app.js sets a fixed pixel width so the drawing never changes size while scrolling. */
  width: min(100%, 46vh);
  width: min(100%, 46svh);
  max-width: 100%;
  aspect-ratio: 1;
}
#canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  touch-action: none;
  background: #fff;
  cursor: grab;
}
.studio.is-color #canvas { cursor: crosshair; background: #000; }
.inspect {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  background: rgba(43, 27, 48, 0.92);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1.35;
  pointer-events: none;
}
.inspect .sw { display: inline-block; width: 14px; height: 14px; border: 1px solid #fff; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.inspect .cr { color: #ff8a80; font-weight: 700; }
.inspect .cg { color: #7ee2a0; font-weight: 700; }
.inspect .cb { color: #90b8ff; font-weight: 700; }
.stage-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.tool {
  border: 1px solid var(--purple);
  background: #2f1437;
  color: var(--mist);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
}
.tool:hover { border-color: var(--aqua); }
.tool:disabled, .try:disabled { opacity: 0.45; cursor: default; }
.tool:disabled:hover { border-color: var(--purple); }
.try:disabled:hover { background: #fff; }
.tool-toggle::before { content: '○ '; }
.tool-toggle[aria-pressed="true"] { background: var(--purple); }
.tool-toggle[aria-pressed="true"]::before { content: '● '; }

.panel { padding: 12px 16px 48px; color: var(--ink); }
.controls, .sliders, .card, .keys {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.sliders:empty { display: none; }

@media (min-width: 900px) {
  .studio { grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); gap: 0 8px; align-items: start; }
  .stage { top: 0; box-shadow: none; padding-top: 16px; }
  .canvas-wrap { width: min(100%, calc(100vh - 110px)); width: min(100%, calc(100svh - 110px)); }
  .panel { padding-top: 16px; }
}

/* ---------- equation rows ---------- */
.eq-list { list-style: none; margin: 0 0 6px; padding: 0; }
.eq-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.eq-row:last-child { border-bottom: 0; }
.rgb-list .eq-row { grid-template-columns: auto 1fr; }
.dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  padding: 0;
}
.chan {
  width: 30px; height: 30px; border-radius: 6px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700;
}
.chan-r { background: #d63c34; }
.chan-g { background: #1f8a48; }
.chan-b { background: #2d6bd8; }
.eq-input {
  width: 100%;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
  display: block;
}
.eq-input:focus { border-color: var(--purple); outline: none; }
.eq-input.bad { border-color: var(--err); }
.del {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
.del:hover { background: #efe7f3; color: var(--ink); }
.eq-err { grid-column: 2 / -1; margin: 0; color: var(--err); font-size: 14px; }
.eq-err:empty { display: none; }
.eq-kind { grid-column: 2 / -1; margin: -2px 0 0; color: var(--ink-soft); font-size: 13px; }

.field { margin-top: 10px; }
.field label { display: flex; justify-content: space-between; font-weight: 700; }
.field output { font-weight: 400; font-variant-numeric: tabular-nums; }
.field input[type="range"] { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.hint { color: var(--ink-soft); font-size: 14px; margin: 6px 0 0; }

/* ---------- symbol keys ---------- */
.keys { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; }
.keys button {
  min-width: 40px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 5px 8px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  color: var(--ink);
}
.keys button:active { background: var(--mist); }

/* ---------- sliders ---------- */
.slider-row {
  display: grid;
  grid-template-columns: 28px 1fr 74px;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.slider-row .sv {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 18px;
  text-align: center;
  color: var(--purple);
}
.slider-row input[type="range"] { width: 100%; accent-color: var(--purple); }
.slider-row input[type="number"] {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
  color: var(--ink);
}
input[type="range"] { accent-color: var(--purple); }

/* ---------- lesson card ---------- */
.lesson-card h2 {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: 32px;
  letter-spacing: 0.02em;
  line-height: 1.05;
  margin: 0 0 6px;
  color: var(--plum);
}
.lesson-card .eyebrow { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--purple); font-weight: 700; }
.lesson-card p { margin: 0 0 10px; }
.lesson-card h3 { margin: 14px 0 6px; font-size: 17px; }
.tries { display: flex; flex-wrap: wrap; gap: 6px; }
.try {
  border: 2px solid var(--purple);
  background: #fff;
  color: var(--plum);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 15px;
}
.try:hover { background: var(--mist); }
.try.on { background: var(--purple); color: #fff; }
.try.reset { border-style: dashed; }
.note {
  margin-top: 10px;
  background: #fff7c2;
  border-left: 5px solid var(--yellow);
  border-radius: 6px;
  padding: 10px 12px;
}
.note:empty { display: none; }
.note b:first-child { display: block; margin-bottom: 2px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.ref summary { font-weight: 700; cursor: pointer; }
.ref dl { margin: 10px 0 0; }
.ref dt { font-weight: 700; margin-top: 8px; color: var(--purple); }
.ref dd { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(30px);
  background: var(--yellow);
  color: var(--plum);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- color mixer ---------- */
.mixer-intro { max-width: 720px; margin: 0 0 12px; }
.mixer-intro .c-r { color: #ff8a80; } .mixer-intro .c-g { color: #7ee2a0; } .mixer-intro .c-b { color: #90b8ff; }
.mixer-card { max-width: 720px; color: var(--ink); }
.mixer-details summary { font-weight: 700; cursor: pointer; color: var(--plum); }
.mixer-details[open] summary { margin-bottom: 10px; }
.mx-sum { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: nowrap; }
.mx-light { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.mx-dot {
  width: 54px; height: 54px; border-radius: 50%;
  background: #000; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.mx-big { width: 84px; height: 84px; border-radius: 14px; }
.mx-cap { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.1; }
.mx-op { font-size: 26px; font-weight: 700; color: var(--ink-soft); margin-bottom: 18px; }
@media (max-width: 400px) {
  .mx-dot { width: 42px; height: 42px; }
  .mx-big { width: 66px; height: 66px; }
  .mx-op { font-size: 20px; }
}
.mx-say { text-align: center; font-size: 17px; margin: 10px 0 12px; min-height: 3em; }
.mx-n { font-variant-numeric: tabular-nums; }
.mx-r { color: #c62f28; } .mx-g { color: #1b7a40; } .mx-b { color: #2459c0; }
.mx-row { display: grid; grid-template-columns: 30px 1fr 68px; gap: 10px; align-items: center; padding: 6px 0; }
.mx-key { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 700; }
.mx-key.mx-r { background: #d63c34; color: #fff; } .mx-key.mx-g { background: #1f8a48; color: #fff; } .mx-key.mx-b { background: #2d6bd8; color: #fff; }
.mx-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 26px; border-radius: 13px; margin: 0;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.mx-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.mx-range::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink);
}
.mx-range::-moz-range-track { background: transparent; }
.mx-num {
  width: 100%; border: 2px solid var(--line); border-radius: 6px; padding: 4px 6px;
  background: #fff; color: var(--ink); font-size: 17px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}
.mx-hint { font-size: 14px; color: var(--ink-soft); margin: 2px 0 10px; }
.mx-label { font-weight: 700; margin: 12px 0 6px; }
.mx-pick { display: block; width: 100%; height: auto; aspect-ratio: 3; border-radius: 8px; cursor: crosshair; touch-action: none; }
.mx-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; }
.mx-preset {
  height: 48px; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
  display: flex; align-items: flex-end; justify-content: center; padding: 0 0 3px;
}
.mx-preset span { font-size: 12px; font-weight: 700; background: rgba(255,255,255,0.85); color: var(--ink); border-radius: 4px; padding: 0 4px; }
details.more.mx-hex { margin: 14px 0 0; }

/* ---------- symbol glossary ---------- */
.glossary { color: var(--ink); }
.learn .glossary { max-width: 720px; margin: 6px 0 12px; }
.glossary summary { font-weight: 700; cursor: pointer; color: var(--plum); }
.gl-head { margin: 14px 0 6px; color: var(--purple); font-size: 16px; text-transform: uppercase; letter-spacing: 0.06em; }
.gl-list { display: grid; gap: 2px; }
.gl-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px solid var(--line); }
.gl-row:last-child { border-bottom: 0; }
.gl-sym {
  display: block; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 4px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; font-weight: 700; color: var(--plum);
}
.gl-tip, .gl-count { display: none; }
.gl-live .gl-tip { display: block; color: var(--ink-soft); font-size: 14px; margin: 8px 0 0; }
.gl-live .gl-count { display: inline; font-weight: 400; color: var(--ink-soft); }
.gl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #ff8c1a; vertical-align: middle; }
.gl-live .gl-row { cursor: pointer; border-radius: 8px; padding-left: 6px; padding-right: 6px; }
.gl-live .gl-row:hover, .gl-live .gl-row:focus-visible { background: #fff4e8; outline: none; }
.gl-live .gl-row.in-use .gl-sym { border-color: #ff8c1a; box-shadow: inset 4px 0 0 #ff8c1a; }
.gl-live .gl-row.on { background: #ffe3c4; }
.gl-live .gl-row.on .gl-sym { background: #ff8c1a; color: #fff; border-color: #ff8c1a; }
.eq-row.lit, .slider-row.lit { box-shadow: 0 0 0 3px #ff8c1a; border-radius: 8px; }
.tool.lit { border-color: #ff8c1a; box-shadow: 0 0 0 2px #ff8c1a; }
.gl-ex { display: block; color: var(--ink-soft); font-size: 14px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; margin-top: 2px; }

[hidden] { display: none !important; }
