/* Snakes, Ladders, Exact: screen layout, the sheet, the board, print. */
/* Five colours only: cream, ink, moss, brick, mustard. Right angles everywhere. */

:root {
  --paper: var(--c-cream);
  --ink: #1A1A1A;
  --tint: rgb(26 26 26 / 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; border-radius: 0; }

html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font-family: var(--font-body); font-size: 14px; line-height: 1.4; }

.desk {
  display: grid;
  grid-template-columns: minmax(0, 820px) 180px;
  gap: 32px;
  justify-content: center;
  align-items: start;
  padding: 32px 24px 48px;
}

/* the sheet */

.sheet { background: var(--paper); border: 1px solid var(--ink); padding: 28px 32px 32px; min-width: 0; }

.sheet input.title {
  display: block; width: 100%; margin: 0 0 14px; padding: 0;
  font: 700 20pt/1.2 var(--font-body); color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid transparent;
}
.sheet input.title:hover { border-bottom-color: rgb(26 26 26 / 0.3); }
.sheet input.title:focus { outline: none; border-bottom-color: var(--ink); }

.board-wrap { margin: 0; }
#board { fill: var(--ink); display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }

.cell { stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; fill: var(--paper); }
.cell.alt { fill: var(--tint); }
.cell.end { fill: var(--c-mustard); fill-opacity: 0.55; }
.edge { fill: none; stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.start-tick { stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.start { font-size: 26px; text-anchor: middle; fill: var(--ink); }

.ladder path { stroke: var(--c-moss); fill: none; stroke-linecap: butt; }
.snake path { stroke: var(--c-brick); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.snake circle { fill: var(--c-brick); }
.provisional { opacity: 0.45; }

#nums text, #tags text {
  fill: var(--ink); stroke: var(--paper); stroke-width: 7px; stroke-linejoin: round;
  paint-order: stroke; font-variant-numeric: tabular-nums;
}
#nums text { font-size: 25px; }
#tags text { font-size: 21px; font-weight: 700; text-anchor: end; letter-spacing: 0.04em; }

.handle { fill: transparent; stroke: var(--ink); stroke-width: 2.5; }
.handle.sel { stroke-width: 5; }
.pending { fill: none; stroke: var(--ink); stroke-width: 6; }

/* the back of the box */

.panel { border: 1px solid var(--ink); margin-top: 28px; padding: 8px 12px 10px; font-size: 8pt; line-height: 1.38; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--ink); margin-bottom: 8px; }
.head { font-size: 7.5pt; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
h2.head { margin: 0 0 3px; break-after: avoid; }

.cols { column-count: 2; column-gap: 24px; column-rule: 1px solid var(--ink); }
.block { break-inside: avoid; margin: 0 0 7px; padding-bottom: 7px; border-bottom: 1px solid var(--tint); }
.block:last-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
p.block { margin-top: 0; }

#rules { margin: 0; padding-left: 1.6em; }
#rules li { padding-left: 0.2em; }

.row { display: flex; align-items: baseline; }
.row .k { flex: 1 1 auto; display: flex; align-items: baseline; white-space: nowrap; }
/* the leader: a row of ink dots drawn as a background, never characters */
.row .k::after {
  content: ""; flex: 1 1 auto; min-width: 10px; height: 0.5em; margin: 0 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27800%27 height=%274%27%3E%3Cpath d=%27M1.5 3H800%27 stroke=%27%231A1A1A%27 stroke-width=%271.2%27 stroke-linecap=%27round%27 stroke-dasharray=%270 3.6%27/%3E%3C/svg%3E") left bottom / 800px 4px no-repeat;
}
.row .v { flex: 0 1 auto; text-align: right; }

.lg { display: grid; grid-template-columns: 2.4em 5.6em minmax(0, 1fr); align-items: baseline; padding: 1px 2px; cursor: pointer; }
.lg.sel { background: var(--tint); }
.lg .tag { font-weight: 700; }
.lg .ft { font-variant-numeric: tabular-nums; }
.lg .words { display: inline-block; min-width: 6em; min-height: 1.3em; border-bottom: 1px solid rgb(26 26 26 / 0.3); cursor: text; outline: none; overflow-wrap: anywhere; }
.lg .words:focus { border-bottom-color: var(--ink); }
.empty { margin: 0; }

.add { display: flex; flex-wrap: wrap; align-items: end; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--tint); }
.add label { display: flex; flex-direction: column; font-size: 7.5pt; letter-spacing: 0.08em; text-transform: uppercase; }
.add label.grow { flex: 1 1 8em; }
.add input { width: 4.2em; }
.add .grow input { width: 100%; }

.colophon p { margin: 2px 0 0; }
.wordmark { font-size: 8pt; letter-spacing: -0.01em; }
.wordmark b { font-weight: 700; }
.wordmark .is { font-weight: 200; }
.wordmark .dead { font-style: italic; }

.fold { display: none; }

/* controls */

input, button { font: inherit; color: var(--ink); }
input[type="number"], input[type="text"] {
  background: var(--paper); border: 1px solid var(--ink); padding: 3px 5px; font-size: 13px;
  appearance: textfield; -moz-appearance: textfield;
}
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { appearance: none; margin: 0; }
button {
  background: var(--paper); border: 1px solid var(--ink); padding: 5px 10px; cursor: pointer; font-size: 13px;
}
button:hover { background: var(--tint); }
button:active { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.rail { position: sticky; top: 24px; font-size: 13px; }
.rail fieldset { border: 0; border-top: 1px solid var(--ink); margin: 0; padding: 8px 0 12px; min-width: 0; }
.rail fieldset:first-child { border-top: 0; padding-top: 0; }
.rail legend { float: left; width: 100%; padding: 0 0 6px; font-size: 7.5pt; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.rail legend label { cursor: default; }
.rail legend + * { clear: left; }
.seg { display: flex; }
.seg label { flex: 1 1 0; position: relative; cursor: pointer; }
.seg label + label span { border-left: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.seg span { display: block; text-align: center; border: 1px solid var(--ink); padding: 4px 0; font-variant-numeric: tabular-nums; }
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; position: relative; z-index: 1; }
.line { display: flex; align-items: center; gap: 6px; }
#within { width: 5em; }
.buttons { display: flex; gap: 6px; border-top: 1px solid var(--ink); padding: 10px 0 0; margin-bottom: 8px; }
.buttons button { flex: 1 1 0; }
.buttons + .buttons { border-top: 0; padding-top: 0; }
.note, .status { margin: 0 0 10px; font-size: 12px; }
.status:empty, .note:empty { display: none; }
.status { border-left: 2px solid var(--ink); padding-left: 8px; }

@media (max-width: 899px) {
  .desk { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 32px; gap: 20px; }
  .rail { position: static; }
}
@media (max-width: 620px) {
  .sheet { padding: 16px 12px 18px; }
  .cols { column-count: 1; }
  .sheet input.title { font-size: 17pt; }
  #nums text { font-size: 30px; }
}

/* print: the sheet alone, light, one page */

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: var(--paper); }
  .screen, .rail { display: none !important; }
  .desk { display: block; padding: 0; }
  .sheet { border: 0; padding: 9mm 13mm 0; }
  .sheet input.title { margin-bottom: 3mm; border-bottom: 0; }
  /* ponytail: fixed board widths sized so a 20 entry legend with long words still fits one page */
  .board-wrap { width: 130mm; margin: 0 auto; break-inside: avoid; }
  body.letter .board-wrap { width: 118mm; }
  #nums text { font-size: 27px; }
  body.letter #nums text { font-size: 30px; }
  .fold { display: block; border-top: 1px dashed var(--ink); margin: 3.5mm -13mm 3.5mm; }
  .panel { margin-top: 0; padding: 2mm 3mm 2.5mm; break-inside: avoid; }
  .panel-head { padding-bottom: 1.5mm; margin-bottom: 2mm; }
  .block { margin-bottom: 1.6mm; padding-bottom: 1.6mm; }
  .legend-block { break-inside: auto; }
  /* the printed legend runs on like an index: each entry stays whole up to the person's words */
  #legend { line-height: 1.32; }
  .lg { display: inline; padding: 0; margin-right: 0.9em; white-space: nowrap; cursor: auto; }
  .lg.sel { background: none; }
  .lg .tag { margin-right: 0.15em; }
  .lg .words { display: inline; white-space: normal; border-bottom: 0; min-width: 0; min-height: 0; }
}
