/* Chalk on an easel: paper for the page, ink for the figures, one hue per column. */
:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --border: #ddd8cd;
  --text: #1c1b19;
  --muted: #6d6a62;
  --accent: #bf3b2f;
  --accent-soft: #fbe7e3;
  --ok: #1f7a58;
  --danger: #b5462f;
  --felt: #eaf1e9;
  --felt-edge: #cfe0d2;
  --board: #fdfcf8;
  --board-edge: #e3ddd0;
  --radius: 10px;
  --ord-ink: #ffffff;
  --warn: #9a6207;
  --warn-soft: #fbf0dc;
  --tint: 16%;          /* how strongly a column hue washes its cells */
  --tint-lit: 34%;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1f242a;
    --border: #333a42;
    --text: #edeff1;
    --muted: #9aa3ac;
    --accent: #ff7d6b;
    --accent-soft: #3a211d;
    --ok: #55c99b;
    --danger: #ff8566;
    --felt: #16241e;
    --felt-edge: #294036;
    --board: #191d22;
    --board-edge: #2d343b;
    --ord-ink: #1a1613;
    --warn: #f0b95e;
    --warn-soft: #33290f;
    --tint: 22%;
    --tint-lit: 45%;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header, main, footer { max-width: 60rem; margin: 0 auto; }
header { border-bottom: 2px solid var(--accent-soft); margin-bottom: 1.5rem; }

h1 { font-size: 1.7rem; margin: 0 0 .2rem; }
h1 .qualifier { font-weight: 400; color: var(--muted); }
h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent);
}
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }

.tagline { margin: 0 0 .9rem; font-size: .95rem; color: var(--accent); }
.lede { color: var(--muted); margin: 0 0 1.25rem; }
.hint { font-size: .85rem; color: var(--muted); }
.hint a { color: var(--accent); }

.note {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  margin: 0 0 1.5rem;
  padding: .75rem .95rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.note::before {
  content: "i";
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: .12rem;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: var(--accent);
  color: var(--ord-ink);
  font: italic 700 .78rem/1 Georgia, "Times New Roman", serif;
}
.note p { margin: 0; font-size: .9rem; }

/* A worked example: same shape as the note, in the felt green. */
.example {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  margin: 0 0 1rem;
  padding: .75rem .95rem;
  background: var(--felt);
  border-left: 3px solid var(--ok);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.example::before {
  content: "e.g.";
  flex: none;
  margin-top: .15rem;
  padding: .05rem .4rem;
  border-radius: 99px;
  background: var(--ok);
  color: var(--ord-ink);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.example p { margin: 0; font-size: .9rem; }

/* Where the method came from. */
.ack {
  display: block;
  margin: 0 0 1rem;
  padding: .7rem .95rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.ack h2 {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .35rem;
}
.ack p { margin: 0 0 .5rem; font-size: .87rem; color: var(--muted); }
.ack p:last-child { margin-bottom: 0; }
.ack a { color: var(--accent); overflow-wrap: anywhere; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* The step number that runs down the left of each stage. */
.stagehead { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.stagehead h2 { margin-bottom: 1rem; }
.step {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: var(--accent);
  color: var(--ord-ink);
  font-size: .8rem;
  font-weight: 700;
}
.stagehead .spacer { flex: 1 1 auto; }

button {
  font: inherit;
  font-size: .9rem;
  padding: .45rem .85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(191, 59, 47, .35);
}
button.primary:hover { filter: brightness(1.07); }
button:disabled { opacity: .45; cursor: default; box-shadow: none; }
button.ghost { font-size: .85rem; padding: .35rem .7rem; }

.controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 1rem 0 .25rem;
}
.controls .spacer { flex: 1 1 auto; }

/* ---- setup ---- */

.setup {
  display: grid;
  grid-template-columns: max-content max-content 1fr;
  gap: .55rem .85rem;
  align-items: center;
  margin-bottom: .9rem;
}
.setup label { font-size: .9rem; }
.setup input {
  font: inherit;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  padding: .35rem .5rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.setup input[type="text"] { width: 7rem; letter-spacing: .08em; }
.setup input[type="date"] { width: auto; }
.setup select {
  font: inherit;
  font-size: .9rem;
  padding: .3rem .4rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.setup .aside { font-size: .8rem; color: var(--muted); }
.setup .aside strong { color: var(--text); font-variant-numeric: tabular-nums; }

#setupNote { margin: .9rem 0 0; }

/* ---- figures ---- */

.board {
  background: var(--board);
  border: 1px solid var(--board-edge);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
}

.fig {
  font: 600 1.35rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* The two subtractions, right-aligned under one another. */
.working { display: grid; grid-template-columns: 1.2em max-content; gap: 0 .35em; width: max-content; }
.working .op { color: var(--accent); text-align: right; }
.working .num { text-align: right; }
.working .rule { grid-column: 1 / -1; border-bottom: 2px solid var(--text); margin: .15em 0 .2em; }
.working .taken { color: var(--accent); }
.working .label {
  grid-column: 2;
  font: 400 .68rem/1.4 ui-sans-serif, -apple-system, sans-serif;
  color: var(--muted);
  text-align: right;
  letter-spacing: .04em;
}

/* One digit of the stack or of an easel line. */
.dcell {
  display: grid;
  place-items: center;
  min-width: 2.1rem;
  padding: .2rem .1rem;
  border-radius: 6px;
  background: hsl(var(--h) 65% 50% / var(--tint));
  border: 1px solid hsl(var(--h) 55% 45% / .45);
  transition: background .12s ease, transform .12s ease;
}
.dcell.lit { background: hsl(var(--h) 65% 50% / var(--tint-lit)); transform: translateY(-2px); }

.stack { display: grid; gap: .3rem; width: max-content; }
.stack .row { display: grid; gap: .3rem; grid-auto-flow: column; }
.stack .rowtag {
  align-self: center;
  font: 400 .7rem/1 ui-sans-serif, -apple-system, sans-serif;
  color: var(--muted);
  min-width: 3.6rem;          /* so every row's digits line up under each other */
  text-align: right;
  padding-right: .3rem;
  white-space: nowrap;
}

/* The turn: columns read downwards become the lines on the easel. */
.turnwrap { display: grid; grid-template-columns: max-content max-content max-content; gap: 1rem; align-items: center; }
.turnwrap .arrowcol {
  font-size: 1.6rem;
  color: var(--accent);
  text-align: center;
}
.turnwrap .arrowcol .glyph { display: block; line-height: 1; }
.turnwrap .arrowcol .cap { display: block; font: 400 .7rem/1.3 ui-sans-serif, sans-serif; color: var(--muted); }

.easel { display: grid; gap: .3rem; width: max-content; margin: 0; padding: 0; list-style: none; }
.easel li { display: grid; grid-auto-flow: column; gap: .3rem; align-items: center; }
.easel .tag {
  font: 400 .7rem/1 ui-sans-serif, -apple-system, sans-serif;
  color: var(--muted);
  min-width: 4.5rem;
  white-space: nowrap;
}
.easel .total {
  margin-top: .35rem;
  padding-top: .35rem;
  border-top: 2px solid var(--text);
  display: flex;
  gap: .5rem;
  align-items: baseline;
  justify-content: flex-end;
}
.easel .total .tick { color: var(--ok); font-size: 1.1rem; }

/* ---- the deal ---- */

.deal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }

.pickline {
  display: grid;
  grid-template-columns: max-content;      /* the tag; the chips follow across */
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
  gap: .4rem;
  align-items: center;
  margin-bottom: .45rem;
}

/* Six bites is a wide line on a narrow screen: let it scroll rather than wrap,
   since a wrapped line stops looking like one line of the easel. */
#picker { overflow-x: auto; padding-top: .45rem; }
.pickline .tag {
  font: 400 .72rem/1 ui-sans-serif, -apple-system, sans-serif;
  color: var(--muted);
  min-width: 4.2rem;
}
.chip {
  position: relative;
  min-width: 2.4rem;
  padding: .35rem .2rem;
  border-radius: 6px;
  font: 600 1.25rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: hsl(var(--h) 65% 50% / var(--tint));
  border: 1px solid hsl(var(--h) 55% 45% / .45);
  cursor: pointer;
}
.chip:hover { background: hsl(var(--h) 65% 50% / var(--tint-lit)); }
.chip.used { color: var(--muted); background: var(--bg); border-style: dashed; }
.chip.used::after {
  content: "";
  position: absolute;
  inset: 48% 10% auto;
  border-top: 2px solid var(--accent);
  transform: rotate(-14deg);
}
.chip .round {
  position: absolute;
  top: -.4rem;
  right: -.4rem;
  width: 1.05rem;
  height: 1.05rem;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: var(--accent);
  color: var(--ord-ink);
  font: 700 .62rem/1 ui-sans-serif, sans-serif;
}

.sums { display: grid; grid-template-columns: 1.2em max-content max-content; gap: .15rem .4rem; width: max-content; align-items: center; }
.sums .op { color: var(--accent); font: 600 1.35rem/1.5 ui-monospace, Menlo, monospace; }
.sums .num { display: grid; grid-auto-flow: column; gap: .3rem; }
.sums .who { font: 400 .7rem/1 ui-sans-serif, sans-serif; color: var(--muted); }
.sums .rule { grid-column: 1 / -1; border-bottom: 2px solid var(--text); margin: .2rem 0; }
.sums .blank { background: none; border: 1px dashed var(--border); color: var(--muted); }

.reveal {
  margin: 1rem 0 0;
  padding: .8rem .95rem;
  background: var(--felt);
  border-left: 3px solid var(--ok);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .95rem;
}
.reveal strong { color: var(--ok); }
.reveal.waiting { background: var(--accent-soft); border-left-color: var(--accent); }
.reveal.waiting strong { color: var(--accent); }
.reveal .big {
  font: 700 1.6rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
  display: block;
  margin: .3rem 0 .2rem;
}

/* ---- why ---- */

#why p { margin: 0 0 .8rem; }
#why p:last-child { margin-bottom: 0; }
#why .fact { color: var(--ok); font-weight: 600; }
#why ul { margin: 0 0 .8rem; padding-left: 1.2rem; }
#why li { margin-bottom: .35rem; }

.script { margin: 0 0 .8rem; }
.script:last-child { margin-bottom: 0; }

footer p { color: var(--muted); font-size: .85rem; }
footer a { color: var(--accent); }

/* The site masthead, styled exactly as on the landing page: the wordmark, the
   italic strapline, and the horizon from timhodson.com beneath. The whole
   block is the way back. */
.sitebar {
  display: block;
  max-width: 60rem;
  margin: 0 auto 1.4rem;
  text-decoration: none;
  color: var(--text);
}
.sitebar-name { display: block; font-size: 1.25rem; font-weight: 700; margin: 0 0 .1rem; }
.sitebar-sub {
  display: block;
  font: italic 13px Georgia, "Times New Roman", serif;
  color: var(--muted);
  letter-spacing: 0;
}
.sitebar:hover .sitebar-name { color: var(--accent); }
.sitebar-horizon {
  display: block;
  width: 100%;
  height: auto;
  margin: .5rem 0 0;
}
@media (prefers-color-scheme: dark) { .sitebar-horizon { filter: invert(1); } }

@media (max-width: 46rem) {
  .deal { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 34rem) {
  .fig { font-size: 1.15rem; }
  .dcell { min-width: 1.75rem; }
  .chip { min-width: 2rem; font-size: 1.1rem; }
  .turnwrap { grid-template-columns: max-content; gap: .6rem; justify-items: start; }
  .turnwrap .arrowcol { text-align: left; }
  .turnwrap .arrowcol .glyph { transform: rotate(90deg); }   /* the turn now goes downwards */
  .setup { grid-template-columns: 1fr; }
  .setup label { margin-bottom: -.35rem; }
}

/* The Bible reference picker: book, chapter, verse on one line. */
.ref { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.ref input[type="text"] { width: 3.2rem; text-align: center; letter-spacing: 0; }
.ref .colon { color: var(--muted); font-weight: 700; }
.ref select { max-width: 11rem; }

/* Only the rows belonging to the chosen source are in play. */
.setup [data-row][hidden] { display: none; }

/* Which way the deal is run: as it goes in the room, or wide open. */
.modes { display: flex; gap: .35rem; }
.mode {
  font-size: .8rem;
  padding: .3rem .6rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.mode.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* A locked line is still readable — it is on the easel, after all — but it is
   plainly not the one being asked for. */
.chip:disabled { cursor: default; opacity: .4; }
.chip:disabled:hover { background: hsl(var(--h) 65% 50% / var(--tint)); }
.chip.used:disabled { opacity: .55; }

.pickline.open .tag { color: var(--accent); font-weight: 700; }
.pickline.open .chip:not(:disabled) { box-shadow: 0 0 0 2px var(--accent-soft); }

/* Something to say about the number, in two strengths: a caution, which is
   advice, and a refusal, which means nothing changed. */
.callout {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  margin: .9rem 0 0;
  padding: .75rem .95rem;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .9rem;
}
.callout::before {
  content: "\26A0\FE0E";        /* the text triangle, not the emoji one */
  flex: none;
  margin-top: .05rem;
  color: var(--warn);
  font-size: 1.05rem;
  line-height: 1.3;
}
.callout.refusal { background: var(--accent-soft); border-left-color: var(--danger); }
.callout.refusal::before { color: var(--danger); }
.callout[hidden] { display: none; }

/* The subtraction boxes are generated, one per bite, but they belong to the
   setup grid rather than to a box of their own. */
.subs { display: contents; }
