/* Shared chalkboard theme. Loaded last so the exercise engines keep their
   semantic classes, geometry and behavior while sharing Craie's visual world. */
:root {
  --craie-paper: #1b1e1c;
  --craie-ink: #f4f1e6;
  --craie-accent: #f4f1e6;
  --craie-sage: #2b302c;
  --craie-clay: #343c35;
  --font-display: "CHAWP", "Patrick Hand", sans-serif;
  --font-body: "Patrick Hand", sans-serif;
  --font-data: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --bg: #1b1e1c;
  --panel: #222824;
  --ink: #f4f1e6;
  --muted: #d1d3c9;
  --line: #717b73;
  --accent: #f4f1e6;
  --accent-soft: #343f36;
  --lime: #2b302c;
  --coral: #e6ab80;
  --red: #b13a40;
  --black: #111613;
  --hint: #dbc07c;
  --ok: #a7d3ad;
  --warn: #dbc07c;
  --state-warm: #45382b;
  --state-green: #2a4030;
  --state-blue: #2d3548;
  --state-red: #432d2e;
  --state-purple: #d3b9fa;
  color-scheme: dark;
}

html { scrollbar-color: var(--line) var(--bg); }
body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.6;
  font-synthesis: none;
  background: var(--bg);
  color: var(--ink);
}
body::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: url("/assets/images/chalkboard-dust.webp") repeat;
  background-size: 64rem 64rem;
  opacity: 0.6;
  pointer-events: none;
}
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline-color: var(--ink); }
a { color: var(--ink); text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, select, input { caret-color: var(--ink); }
select { color: var(--ink); }
select option { background: var(--panel); color: var(--ink); }
.skip-link:focus { background: var(--ink); color: var(--bg); }

/* Writing and data have different jobs: inscriptions retain the chalk stroke;
   small numbers, labels, code and dense references retain open, unambiguous forms. */
.topbar, .site-header { background: transparent; }
.brand #brandName, .brand .name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.25;
}
.brand .tag { font-size: 18px; }
.pills button, .learn-link, .lang-switch, .cta-small, .lang {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 400;
  min-height: 44px;
}
.brand .logo { width: 30px; height: 30px; }
.layout { font-family: var(--font-data); font-size: 15px; line-height: 1.5; }
.layout button, .layout select { min-height: 44px; }
.sidebar h2, .modal-card h2, .hint-content h4 {
  font-family: var(--font-body);
  font-size: 23px;
  font-weight: 400;
  line-height: 1.3;
}
#logTitle { font-family: var(--font-body); font-size: 20px; font-weight: 400; }
.footer, .site-footer { font-size: 17px; }
.footer b, .site-footer b { font-weight: 400; }

/* Chalk lines outline the controls; selected controls reverse the inscription. */
.pills button.active, .btn.primary, .cta-small, .btn-practice {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.btn.primary:hover:not(:disabled), .cta-small:hover, .btn-practice:hover {
  background: #d1d3c9;
  border-color: #d1d3c9;
  color: var(--bg);
}
.hint-btn { border-color: var(--line); }
.hint-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--hint); }
.pills button.active:hover { color: var(--bg); }
.btn:disabled, .menu button:disabled, .sort-controls button:disabled { opacity: 0.55; }
.prompt-row, .stage-wrap, .hint-box, .log-box { background: rgb(27 30 28 / 78%); }
.card.props, .gestures, .card { background: transparent; }
.card.active, .card li.active { background: var(--state-warm); border-color: var(--hint); }
.skip-btn { background: var(--panel); }
.modal { background: rgb(0 0 0 / 68%); }
.modal-card {
  border-top: 0;
  outline: 1px solid var(--line);
  box-shadow: 0 20px 50px rgb(0 0 0 / 45%);
}
.modal-card .situation { background: var(--bg); }
.menu { outline: 1px solid var(--line); box-shadow: 0 10px 28px rgb(0 0 0 / 45%); }
.toast { background: var(--ink); color: var(--bg); }
.toast.good { background: var(--ok); color: var(--bg); }

/* Red and black still mean red and black. A light boundary preserves black
   nodes against the board; double black keeps its two concentric boundaries. */
.black, .swatch.black { border: 1.5px solid #c5cec6; }
.node.db, .swatch.db {
  background: var(--black);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--black), 0 0 0 5px var(--ink), 0 3px 10px rgb(0 0 0 / 35%);
}
.r { color: #ffaca7; }
.k { color: var(--ink); text-decoration: underline; text-decoration-style: double; text-underline-offset: 0.15em; }
.node.marked { outline-color: var(--hint); }
.node[data-order]::after { color: var(--bg); }
.slot { border: 1px solid var(--line); }
.slot.drop { background: var(--panel); border-color: var(--line); }
.trash { background: var(--panel); border-color: var(--line); }
body.is-dragging .trash { color: #ffaca7; border-color: #ffaca7; }
.trash.drop-over { background: var(--state-red); }
.edges line, .edges line.gedge { stroke: #a7b1a9; }
.edges line.null-edge { stroke: #8a958d; }
.edges line.tree, .edges line.chosen { stroke: var(--ink); }
.edges .hole { stroke: var(--line); }
.edges .pivot-mark { fill: var(--coral); }
.edges text.w { stroke: var(--bg); }
.edges line.cut { stroke: #ffaca7; }
.edges .cut-mark { fill: #ffaca7; }

/* Algorithm states stay explicit and independent of the decorative texture. */
.heap-array .cell.hint { background: var(--state-warm); }
.node.cell, .node.gleaf, .node.gvert { background: var(--panel); border-color: #a7b1a9; }
.node.cell.sorted, .cell-mini.done, .node.gvert.done { background: var(--state-green); border-color: var(--ok); }
.node.cell.cur { background: var(--accent-soft); border-color: var(--ink); }
.node.cell.pivot { background: var(--state-warm); border-color: var(--coral); }
.node.gnode polygon { fill: var(--panel); }
.node.gnode.max polygon { fill: var(--state-blue); }
.node.gnode.min polygon { fill: var(--state-red); }
.node.gvert.open { background: var(--state-warm); }
.gbadge { background: var(--ink); color: var(--bg); }
.gh { color: var(--state-purple); }

/* Lessons sit on the same board. Long prose is handwritten; technical tables,
   diagrams and code use the same legible data face as the exercise scene. */
.article { background: transparent; border-color: transparent; border-radius: 0; }
.article h1 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.3;
}
.article h2, .article h3, .topic-card h2 {
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.3;
}
.article h2 { font-size: 28px; }
.article h3 { font-size: 24px; }
.article .lead { font-size: 22px; line-height: 1.55; }
.article strong, .article b, .topics a[aria-current="page"] { font-weight: 400; }
.article strong, .article b { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 0.15em; }
.article pre, .article code { font-family: ui-monospace, Consolas, monospace; }
.article pre { background: #111613; color: var(--ink); border: 1px solid var(--line); }
.article code { font-size: 0.78em; }
.article pre code { font-size: inherit; }
.article table { font-family: var(--font-data); font-size: 15px; line-height: 1.6; }
.article table b, .article table strong { font-weight: 700; text-decoration: none; }
.article th { background: var(--panel); }
.article figcaption { font-size: 17px; }
.article figure svg { font-family: var(--font-data); }
.article figure svg text { fill: var(--ink); }
.article figure svg circle { stroke: #c5cec6; stroke-width: 1.5px; }
.article figure svg circle[fill="#3f51d6"] { fill: #5266c5; }
.article figure svg circle[fill="#3f51d6"] + text { fill: #fff; }
.topics { background: rgb(27 30 28 / 78%); }
.topics a { font-size: 18px; min-height: 44px; }
.topics a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.2em; }
.note, .pitfall, .practice { background: var(--accent-soft); border-radius: 4px; }
.pitfall { background: var(--state-warm); }
.practice h2 { font-size: 26px; }
.btn-practice { font-size: 19px; font-weight: 400; min-height: 44px; }
.topic-card h2 { font-size: 26px; }
.topic-card p { font-size: 19px; line-height: 1.5; }
.policy .muted { font-size: 17px; }
.policy .article h2 { font-size: 26px; }

/* Five sorting players: bright bars, numbered cells and textual role markers.
   Color continues to encode state; it never replaces the step explanation. */
.sorting-demo { font-family: var(--font-data); }
.article .sorting-demo h3 { font-family: var(--font-body); font-size: 24px; font-weight: 400; }
.sort-number { color: var(--ink); }
.sort-role { color: var(--bg); background: var(--coral); }
.sort-piece.has-role .sort-stick { background: var(--coral); border-color: var(--coral); }
.sort-piece.is-sorted .sort-stick { background: var(--ok); border-color: var(--ok); }
.sort-piece.is-sorted .sort-role { background: var(--ok); color: var(--bg); }
.sort-piece.is-sorted .sort-number { border-bottom-color: var(--ok); }
.sort-controls button[data-action="play"] { background: var(--ink); color: var(--bg); }
.sort-controls select { color: var(--ink); }

@media (max-width: 600px) {
  .brand #brandName, .brand .name { font-size: 25px; }
  .article { padding-inline: 2px; }
  .article h1 { font-size: 29px; }
  .policy .article h1 { font-size: 28px; }
  .article h2 { font-size: 26px; }
  .article h3 { font-size: 23px; }
}
