/* Cards on a baize table: red for the cards, green for the felt, ink for text. */
: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;
  --radius: 10px;
  --ord-ink: #ffffff;
  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;
    --ord-ink: #1a1613;
  }
}

* { 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); }

.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; font-size: .87rem; color: var(--muted); }
.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;
}

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

/* One row per value: label, box, and the range it accepts. */
.setup {
  display: grid;
  grid-template-columns: max-content max-content max-content;
  gap: .55rem .85rem;
  align-items: center;
  margin-bottom: .9rem;
}
.setup label { font-size: .9rem; }
.setup input {
  width: 4rem;
  font: inherit;
  font-size: .9rem;
  padding: .35rem .5rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.range {
  font-size: .75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#setupNote { margin: .9rem 0 0; }
#setupNote + .hint { margin: .5rem 0 0; }
#setupNote.warn { color: var(--danger); }

/* ---- the row of cards ---- */

.stagehead { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.stagehead h2 { margin-bottom: 1rem; }
.modes { margin-left: auto; 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; }

.line {
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
  padding: 1.1rem .9rem .9rem;
  background: var(--felt);
  border: 1px solid var(--felt-edge);
  border-radius: var(--radius);
}

.slot { display: flex; flex-direction: column; align-items: center; gap: .3rem; }

/* The signature, inked across the face of the card. */
.sig {
  width: 80%;
  height: auto;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sig .flourish { stroke-width: 1.1; opacity: .6; }
.sig.ghost { opacity: .38; }   /* one of the possibilities, not the known card */

/* The moves open to the card from where it is. */
.moves {
  display: flex;
  gap: .3rem;
  font-size: .95rem;
  line-height: 1.2;
  color: var(--accent);
}
.moves .arrow { opacity: .55; }
.moves .arrow.forced { opacity: 1; font-weight: 700; }
.legend { margin: .6rem 0 0; }
.legend[hidden] { display: none; }

.card {
  position: relative;
  width: 3.4rem;
  aspect-ratio: 5 / 7;          /* poker proportions */
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: 1.1rem;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.card .pip {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: .6rem;
  font-weight: 700;
  color: var(--muted);
}
.card.possible { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card.here { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-5px); }
.card.gone { opacity: .3; border-style: dashed; }
.card.gone::after {
  content: "";
  position: absolute;
  inset: 45% 8% auto;
  border-top: 2px solid var(--muted);
  transform: rotate(-16deg);
}
.slot.leaving .card { animation: pluck .5s ease; }
@keyframes pluck {
  40% { transform: translateY(-14px) rotate(-6deg); }
  100% { transform: none; }
}

/* ---- controls ---- */

.controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 1rem 0 .25rem;
}
.controls .spacer { flex: 1 1 auto; }
.choices { display: inline-flex; gap: .35rem; margin-left: .5rem; }
.choices[hidden] { display: none; }   /* an explicit display beats the UA [hidden] rule */

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; }

.explain {
  margin: .5rem 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;
}
.explain strong { color: var(--ok); }

/* ---- lattice ---- */

#lattice { overflow-x: auto; margin: .5rem 0 .25rem; }
#lattice svg { display: block; }
.lat-label { font-size: 11px; fill: var(--muted); }
.lat-row-now { fill: var(--accent-soft); }
.lat-edge { stroke: var(--border); stroke-width: 1.5; fill: none; }
.lat-node { fill: var(--muted); }
.lat-node.now { fill: var(--accent); }
.lat-count { font-size: 10px; font-weight: 700; fill: var(--bg); }
.lat-divider { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; }
.lat-divider-text { font-size: 10px; fill: var(--accent); }
.lat-gone { fill: var(--border); opacity: .35; }

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

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

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

@media (max-width: 34rem) {
  .card { width: 2.7rem; }
  .line { gap: .45rem; }
}

/* rows of the chart are clickable when every path is shown */
.lat-hit { fill: transparent; cursor: pointer; }
.lat-hit:hover { fill: var(--accent-soft); opacity: .5; }

/* ---- the removal explorer ---- */

.gapmode {
  font-size: .8rem;
  padding: .3rem .6rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.gapmode.on { background: var(--ok); border-color: var(--ok); color: #fff; }

#exLine .card.pickable { cursor: pointer; }
#exLine .card.pickable:hover { border-color: var(--ok); box-shadow: 0 0 0 2px var(--felt-edge); transform: translateY(-3px); }
#exLine .card.unsafe:hover { border-color: var(--danger); box-shadow: 0 0 0 2px var(--accent-soft); }
.card .face { font-size: 1rem; font-weight: 600; color: var(--muted); }
.card.possible .face, .card.here .face { color: var(--text); }

#exVerdict { border-left-color: var(--ok); }
#exVerdict.broken { border-left-color: var(--danger); }
#exVerdict.broken strong { color: var(--danger); }

/* An empty position the signed card could be sitting in: still a position. */
#exLine .card.gone.possible {
  opacity: 1;
  border-style: dashed;
  border-color: var(--accent);
  background: none;
}
#exLine .card.gone.possible::after { display: none; }

/* Projected futures in the explorer chart. */
.lat-node.proj { fill: none; stroke: var(--muted); stroke-width: 1.6; opacity: .75; }
.lat-label.proj { font-style: italic; opacity: .8; }
.lat-proj-divider { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: .7; }

.outlook { margin: .4rem 0 0; }
.outlook strong { color: var(--ok); }

button.linkish {
  all: unset;
  cursor: pointer;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: .85rem;
}

/* The author's reason for a section, in their own voice. */
.rationale {
  margin: 0 0 1rem;
  font-size: .95rem;
  color: var(--text);
}

@media (max-width: 30rem) {
  /* Long labels get their own line rather than squeezing the boxes. */
  .setup { grid-template-columns: 1fr max-content; }
  .setup label { grid-column: 1 / -1; margin-bottom: -.35rem; }
  .setup input { justify-self: start; }
}

/* 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); } }
