/* Palette. One model is one slate: the patti a child in an Indian school writes on in chalk, wipes and writes on again, as keys
   are given, changed and the model trained again. The model and its keys are on slate in chalk; what is read beside them is on
   paper. One accent, the yellow chalk, means the person's own model: its bar, the slot a block is over, a passed gate. None of
   the other builders uses slate, chalk or this yellow (SYNTAX cobalt and amber, ungli violet, jaisa verdigris and copper,
   taali teal and plum, boardgameBuilder four accents on dark slate-grey). Kalam (Indian Type Foundry, named after the reed
   pen) is the chalk hand; Hind, from the same foundry, is the text. Every edge is 3:1 or more against what it sits on. */
@font-face { font-family: "Kalam"; font-weight: 400; font-display: swap; src: url(fonts/kalam-400.woff2) format("woff2"); }
@font-face { font-family: "Kalam"; font-weight: 700; font-display: swap; src: url(fonts/kalam-700.woff2) format("woff2"); }
@font-face { font-family: "Hind"; font-weight: 400; font-display: swap; src: url(fonts/hind-400.woff2) format("woff2"); }
@font-face { font-family: "Hind"; font-weight: 500; font-display: swap; src: url(fonts/hind-500.woff2) format("woff2"); }
@font-face { font-family: "Hind"; font-weight: 600; font-display: swap; src: url(fonts/hind-600.woff2) format("woff2"); }

:root {
  --slate: #243230; --slate-2: #2e3d3a; --slate-3: #3b4c48; --chalk: #efeee6; --chalk-dim: #b8c0ba; --dust: #8e9a94;
  --yellow: #e6cf4e;
  --paper: #f5f4ee; --paper-2: #e8e7df; --ink: #1d2523; --muted: #56605c; --line: #7d8682;
  --hand: "Kalam", "Segoe Print", "Bradley Hand", cursive; --text: "Hind", "Noto Sans", "Helvetica Neue", sans-serif;
  --r: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* the veil and the toast set their own display; hidden must still win */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--hand); font-weight: 700; line-height: 1.15; margin: 0; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* the header: a strip of slate */
header { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 20px; background: var(--slate); color: var(--chalk); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand svg { width: 34px; height: 34px; }
.brand b { font: 700 24px/1 var(--hand); }
.brand i { font-style: normal; font-size: 13px; color: var(--chalk-dim); }
.follows { font-size: 13px; color: var(--chalk-dim); }
header nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }
header nav button { background: none; border: 1px solid var(--dust); color: var(--chalk); border-radius: 999px; padding: 4px 13px; cursor: pointer; font-size: 14px; }
header nav button:hover { border-color: var(--chalk); background: var(--slate-2); }

/* three panes */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr) 330px; min-height: calc(100vh - 110px); }
.blocks { background: var(--paper-2); padding: 18px 16px 30px; border-right: 1px solid var(--line); }
.blocks h2 { font-size: 24px; }
.tray-toggle { display: none; border: 1px solid var(--line); background: #fbfaf6; border-radius: 999px; padding: 3px 12px; font: 500 13px var(--text); cursor: pointer; }
.blocks p { font-size: 13.5px; color: var(--muted); margin: 6px 0 14px; }
.group { margin: 0 0 14px; }
.group h3 { font: 700 15px/1.2 var(--hand); color: var(--ink); margin-bottom: 6px; }
.group h3 small { font: 400 12px var(--text); color: var(--muted); margin-left: 4px; }
.chip { display: inline-block; margin: 0 5px 6px 0; padding: 4px 10px 3px; background: var(--slate); color: var(--chalk); border-radius: 4px; font-size: 14px; cursor: grab; user-select: none; touch-action: none; box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.chip:hover { background: var(--slate-3); }
.chip.ghost { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -60%) rotate(-3deg); opacity: .92; }

main { padding: 22px 26px 40px; min-width: 0; }
.head input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; font: 700 30px/1.2 var(--hand); padding: 2px 0; }
.head textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--r); background: #fbfaf6; padding: 8px 10px; margin: 10px 0 6px; resize: vertical; }
.lede { color: var(--muted); font-size: 14.5px; max-width: 70ch; margin: 4px 0 18px; }

/* the slate */
.slate { position: relative; background: var(--slate); color: var(--chalk); border-radius: 12px; padding: 20px 20px 22px; border: 9px solid #4a3b2c;
  background-image: radial-gradient(120% 60% at 20% 10%, rgba(255,255,255,.05), transparent 60%), radial-gradient(80% 50% at 85% 90%, rgba(255,255,255,.04), transparent 60%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), 0 2px 0 rgba(0,0,0,.08); margin-bottom: 22px; }
.slate h2 { font-size: 26px; font-weight: 400; color: var(--chalk); }
.slate .sub { color: var(--chalk-dim); font-size: 14px; margin: 2px 0 14px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.slot { min-height: 92px; border: 1.5px dashed var(--dust); border-radius: var(--r); padding: 8px 10px 10px; position: relative; transition: border-color .15s, background .15s; }
.slot.opt { border-style: dotted; }
.slot .t { font: 700 15px/1.1 var(--hand); color: var(--chalk-dim); }
.slot .t small { font: 400 11.5px var(--text); margin-left: 4px; }
.slot .v { font: 400 23px/1.15 var(--hand); color: var(--chalk); margin-top: 8px; padding-right: 22px; }
.slot .empty { font-size: 13px; color: var(--dust); margin-top: 10px; }
.slot .note { font-size: 12px; color: var(--yellow); margin-top: 6px; }
.slot.over { border-color: var(--yellow); background: rgba(230, 207, 78, .08); border-style: solid; }
.slot.filled { border-style: solid; border-color: var(--dust); background: rgba(255,255,255,.03); }
.slot .x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--chalk-dim); cursor: pointer; font-size: 17px; line-height: 1; }
.slot .x:hover { background: var(--slate-3); color: var(--chalk); }

/* the sheets on paper under the slate */
.sheet { border-top: 1px solid var(--line); padding: 16px 0 18px; }
.sheet h2 { font-size: 23px; }
.sheet > p { margin: 4px 0 10px; color: var(--muted); font-size: 14.5px; max-width: 72ch; }
.kinds { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kind { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--r); padding: 3px 4px 3px 9px; background: #fbfaf6; }
.kind b { font: 700 15px var(--hand); color: var(--muted); }
.kind input { border: 0; background: none; width: 11ch; padding: 3px 0; }
.kind.fixed { border-style: dashed; color: var(--muted); padding-right: 10px; }
.btn { border: 1px solid var(--line); background: #fbfaf6; border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: 14.5px; }
.btn:hover { background: var(--paper-2); }
.btn.go { background: var(--slate); color: var(--chalk); border-color: var(--slate); }
.btn.go:hover { background: var(--slate-3); }
.btn.q { border-color: transparent; background: none; color: var(--muted); }
.btn.q:hover { color: var(--ink); background: var(--paper-2); }
.btn[aria-disabled="true"] { opacity: .55; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }

/* keys: a second slate, the tally of keys given and the empty strokes still to give */
.keys h2 { margin-bottom: 4px; }
.tally { display: block; width: 100%; max-width: 560px; height: auto; margin: 10px 0 6px; }
.count { font: 400 20px/1.2 var(--hand); }
.bars { display: grid; gap: 7px; margin: 12px 0 4px; max-width: 520px; }
.bar { display: grid; grid-template-columns: 140px 1fr 46px; gap: 10px; align-items: center; font-size: 14px; color: var(--chalk-dim); }
.bar .track { height: 12px; border-radius: 6px; background: var(--slate-3); overflow: hidden; }
.bar .fill { height: 100%; background: var(--chalk-dim); }
.bar.mine { color: var(--chalk); }
.bar.mine .fill { background: var(--yellow); }
.bar span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.verdict { font: 400 20px/1.3 var(--hand); margin: 12px 0 2px; color: var(--chalk); }
.verdict.ok { color: var(--yellow); }
.quiet { color: var(--chalk-dim); font-size: 13.5px; margin: 4px 0; }
.slate .btn { background: none; color: var(--chalk); border-color: var(--dust); }
.slate .btn:hover { background: var(--slate-3); }
.slate .btn.go { background: var(--chalk); color: var(--slate); border-color: var(--chalk); }
.slate .btn.go:hover { background: #fff; }
.locked { font-size: 13.5px; color: var(--muted); margin-top: 6px; }

/* the reading */
.reading { background: #fbfaf6; border-left: 1px solid var(--line); padding: 20px 20px 40px; }
.reading h2 { font-size: 24px; }
.reading h3 { font-size: 17px; margin: 20px 0 6px; }
.reading .gives { font-size: 15px; }
.reading .sub { color: var(--muted); font-size: 14px; }
.model { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin: 0 0 10px; background: var(--paper); }
.model h4 { font-size: 17px; }
.model p, .model li { font-size: 13.5px; margin: 3px 0; }
.model .what { color: var(--muted); }
.model ul { padding-left: 18px; margin: 6px 0; }
.warn { border-left: 3px solid var(--slate); padding: 4px 0 4px 10px; font-size: 13.5px; margin: 0 0 10px; }
.warn .from { color: var(--muted); font-size: 12.5px; }

footer { background: var(--slate); color: var(--chalk-dim); font-size: 13px; padding: 14px 20px; }
footer a { color: var(--chalk); }

/* dialogs */
.veil { position: fixed; inset: 0; background: rgba(20, 28, 26, .55); display: grid; place-items: center; z-index: 40; padding: 16px; }
.box { position: relative; background: var(--paper); border-radius: 12px; max-width: 760px; width: 100%; max-height: 88vh; overflow: auto; padding: 24px 26px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.box h2 { font-size: 28px; margin: 0 0 6px; padding-right: 70px; }
.box > p { max-width: 64ch; }
.box .close { position: absolute; top: 14px; right: 14px; }
.box textarea { width: 100%; min-height: 180px; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; background: #fbfaf6; }
.box.key { background: var(--slate); color: var(--chalk); }
.box.key .btn { background: none; color: var(--chalk); border-color: var(--dust); }
.box.key .btn:hover { background: var(--slate-3); }
.item { font-size: 20px; line-height: 1.5; background: var(--slate-2); border-radius: var(--r); padding: 16px 18px; margin: 14px 0; white-space: pre-wrap; max-height: 40vh; overflow: auto; }
.item .second { display: block; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--dust); }
.presses { display: flex; flex-wrap: wrap; gap: 8px; }
.presses .btn { display: flex; flex-direction: column; align-items: flex-start; min-width: 110px; border-radius: var(--r); padding: 8px 12px; text-align: left; }
.presses .btn b { font: 700 18px/1.1 var(--hand); }
.presses .btn small { color: var(--chalk-dim); font-size: 12px; }
.keyrow { display: grid; grid-template-columns: 1fr 150px auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.keyrow select { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: #fbfaf6; }
.list { display: grid; gap: 8px; margin-top: 12px; }
.entry { display: flex; justify-content: space-between; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.entry .d { color: var(--muted); font-size: 13.5px; }
.entry.off { border-style: dashed; }
.try { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
.try th { text-align: left; font: 700 15px var(--hand); border-bottom: 1px solid var(--line); padding: 6px; }
.try td { border-bottom: 1px solid var(--paper-2); padding: 6px; vertical-align: top; }
.try td.diff { font-weight: 600; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 14px; }
.steps li { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; }
.steps svg { width: 150px; height: auto; border-radius: var(--r); }
.steps li p { margin: 0; }
.steps li p:before { counter-increment: s; content: counter(s) ". "; font: 700 18px var(--hand); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--slate); color: var(--chalk); padding: 10px 16px; border-radius: var(--r); z-index: 60; max-width: min(92vw, 560px); font-size: 14.5px; }

@media (max-width: 1100px) { .app { grid-template-columns: 220px minmax(0, 1fr); } .reading { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); } }
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  /* the blocks become a tray along the bottom of the screen, so a block and its slot are on screen together */
  .blocks { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 38vh; overflow-y: auto; scroll-padding-top: 48px; padding: 8px 14px calc(10px + env(safe-area-inset-bottom, 0px)); border: 0; border-top: 2px solid var(--slate); box-shadow: 0 -8px 24px rgba(0,0,0,.18); }
  .blocks h2 { position: sticky; top: -8px; display: flex; align-items: center; justify-content: space-between; font-size: 19px; padding: 4px 0; background: var(--paper-2); z-index: 1; }
  .blocks p { display: none; }
  .group { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; margin: 0 0 6px; }
  .group h3 { flex: 0 0 100%; margin: 4px 0 4px; font-size: 14px; }
  .tray-toggle { display: inline-block; }
  .chip { padding: 4px 6px 4px 10px; }
  body { padding-bottom: 40vh; }
  body.tray-closed { padding-bottom: 60px; }
  body.tray-closed .blocks { max-height: 52px; overflow: hidden; }
  main { padding: 16px; }
  .slate { border-width: 6px; padding: 14px; }
  .bar { grid-template-columns: 100px 1fr 42px; }
  .steps li { grid-template-columns: 1fr; }
  .keyrow { grid-template-columns: 1fr; }
  header nav { margin-left: 0; }
}
@media (prefers-reduced-motion: no-preference) { .slot, .chip { transition: background .15s, border-color .15s; } }
.count-paper { font: 400 19px/1.3 var(--hand); margin: 4px 0; }
.slot .note + .note { display: none; }
.tester textarea { width: 100%; min-height: 70px; border: 1px solid var(--dust); border-radius: var(--r); padding: 9px 11px; background: var(--slate-2); color: var(--chalk); margin-bottom: 8px; }
.tester textarea::placeholder { color: var(--dust); }
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.answers div { border: 1px solid var(--dust); border-radius: var(--r); padding: 8px 12px; }
.answers small { display: block; color: var(--chalk-dim); font-size: 12.5px; }
.answers b { font: 400 24px/1.25 var(--hand); }
.answers .mine { border-color: var(--yellow); }
.answers .mine b { color: var(--yellow); }

/* the ? on a block, and what it opens: the element's own words and its drawing in chalk on a piece of slate */
.info { width: 18px; height: 18px; margin-left: 6px; padding: 0; border: 1px solid var(--dust); border-radius: 50%; background: none; color: var(--chalk-dim); font: 600 11px/16px var(--text); cursor: pointer; vertical-align: 1px; }
.info:hover { border-color: var(--chalk); color: var(--chalk); }
.slot .v .info { vertical-align: 4px; }
.box .eyebrow { margin: 0 0 2px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.box .drawing { margin: 14px 0 10px; padding: 14px; background: var(--slate); border: 9px solid #4a3b2c; border-radius: var(--r); max-width: 420px; }
.box .drawing svg { display: block; width: 100%; height: auto; }
.box .meaning { font-size: 18px; margin: 0 0 6px; }
.box .quiet { color: var(--muted); }
@media (max-width: 720px) { .info { width: 28px; height: 28px; font-size: 14px; line-height: 26px; margin-left: 4px; } .slot .v .info { vertical-align: 2px; } }
