/* A survey sheet: the country on pale land, the grid as the sheet's own lines, letters and numbers in the margins.
   Untouched cells stay bare paper, so what is done is what shows. */
:root {
  --paper: #dfe5dd; --land: #f3f5ef; --panel: #fbfcf9; --ink: #17262b; --mute: #5a6a6e; --line: #c6cfc6;
  --water: #9ec5d8; --road: #7d8b8d; --wip: #dc9c00; --done: #2a8a55; --sel: #17262b;
  --font: 'Bricolage Grotesque', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1517; --land: #152024; --panel: #111a1d; --ink: #e7edea; --mute: #8fa1a4; --line: #2a393d;
    --water: #1f4254; --road: #6f8083; --wip: #f1b62e; --done: #48bb7e; --sel: #ffffff;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.45 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, p, ol { margin: 0; }
ol { padding: 0; list-style: none; }

.sheet { display: grid; grid-template-columns: minmax(0, 1fr) 372px; height: 100dvh; }
.map { position: relative; overflow: hidden; background: var(--paper); }
svg { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
svg.drag { cursor: grabbing; }

/* the map's marks */
.land { fill: var(--land); }
.border { fill: none; stroke: var(--ink); stroke-opacity: .8; stroke-width: 1.5px; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.grid { fill: none; stroke: var(--ink); stroke-opacity: .13; stroke-width: 1px; vector-effect: non-scaling-stroke; pointer-events: none; }
.rivers { fill: none; stroke: var(--water); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.road { fill: none; stroke: var(--road); stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.road.trunk { stroke-width: 1.3; stroke-opacity: .9; } .road.primary { stroke-width: .9; stroke-opacity: .7; } .road.secondary { stroke-width: .5; stroke-opacity: .5; }
.area { fill: none; stroke: var(--ink); stroke-opacity: .42; stroke-width: 1px; vector-effect: non-scaling-stroke; pointer-events: none; }
.cells-done { fill: var(--done); fill-opacity: .78; }
.cells-wip { fill: url(#hatch); }
.hatch-bg { fill: var(--wip); fill-opacity: .42; } .hatch-line { stroke: var(--wip); stroke-width: 2.4; }
.picked { fill: none; stroke: var(--sel); pointer-events: none; }
.name { font-family: var(--font); font-weight: 600; fill: var(--ink); text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: var(--land); stroke-linejoin: round; }
.name tspan { font-weight: 400; fill: var(--mute); }
.town { font-family: var(--font); font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--land); stroke-linejoin: round; pointer-events: none; }
.town-dot { fill: var(--ink); stroke: var(--land); pointer-events: none; }

/* the sheet's margins: column letters along the top, row numbers down the side */
.ruler { position: absolute; pointer-events: none; color: var(--mute); font-size: 11px; font-weight: 600; background: color-mix(in srgb, var(--paper) 86%, transparent); }
.ruler span { position: absolute; display: grid; place-items: center; }
.ruler-x { inset: 0 0 auto 0; height: 22px; border-bottom: 1px solid var(--line); }
.ruler-x span { top: 0; height: 22px; border-left: 1px solid var(--line); }
.ruler-y { inset: 22px auto 0 0; width: 30px; border-right: 1px solid var(--line); }
.ruler-y span { left: 0; width: 30px; border-top: 1px solid var(--line); }
.ruler[hidden] { display: none; }

.zoom { position: absolute; right: 14px; bottom: 14px; display: grid; gap: 6px; }
.zoom button { width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1; }
.offline { position: absolute; left: 50%; bottom: 14px; translate: -50% 0; padding: 8px 14px; border-radius: 8px; background: var(--ink); color: var(--panel); font-size: 13px; }

/* the legend beside the sheet */
.panel { overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 26px 24px 40px; display: grid; gap: 26px; align-content: start; }
h1 { font-size: 27px; line-height: 1.08; font-weight: 700; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: 13px; font-weight: 600; color: var(--mute); margin-bottom: 8px; }
.lede { margin-top: 10px; color: var(--mute); max-width: 34ch; }
.fine { font-size: 13px; color: var(--mute); }
code { font: inherit; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }

.tally { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 12px 10px; }
.count b { display: block; font-size: 34px; line-height: 1; font-weight: 700; letter-spacing: -.03em; }
.count span { font-size: 13px; color: var(--mute); }
.bar { grid-column: 1 / -1; display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--paper); }
.bar i { display: block; height: 100%; } .bar .d { background: var(--done); } .bar .w { background: var(--wip); }
.tally .fine { grid-column: 1 / -1; }

button, input, textarea { font: inherit; color: inherit; }
button { padding: 8px 13px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 500; }
button:hover { border-color: var(--mute); }
button:focus-visible, input:focus-visible, textarea:focus-visible, .rows button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
button[disabled] { opacity: .45; cursor: default; }
input, textarea { padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--land); min-width: 0; width: 100%; }
textarea { resize: vertical; min-height: 92px; }
label { font-size: 13px; font-weight: 600; color: var(--mute); }

.find, #keyForm { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.find .msg { grid-column: 1 / -1; font-size: 13px; color: var(--mute); min-height: 0; }
.find .msg:empty { display: none; }
.jumps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -14px; }
.jumps button { padding: 5px 10px; font-size: 13px; }

.card { border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 10px; background: var(--land); }
.card h3 { margin: 0; font-size: 30px; line-height: 1; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 10px; }
.state { font-size: 13px; font-weight: 600; letter-spacing: 0; padding: 3px 9px; border-radius: 99px; border: 1px solid currentColor; }
.state.todo { color: var(--mute); } .state.wip { color: var(--wip); } .state.done { color: var(--done); }
.card .where { color: var(--mute); font-size: 14px; }
.card .note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.card form { display: grid; gap: 8px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.card .pick { display: flex; gap: 6px; flex-wrap: wrap; }
.card .err { color: #c2412d; font-size: 13px; }

.rows { display: grid; }
.rows li { border-top: 1px solid var(--line); }
.rows li:last-child { border-bottom: 1px solid var(--line); }
.rows button { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 2px 10px; width: 100%; padding: 9px 0; border: 0; border-radius: 0; background: none; text-align: left; font-weight: 400; }
.rows button:hover b { text-decoration: underline; }
.rows b { font-weight: 700; }
.rows .when { color: var(--mute); font-size: 13px; }
.rows .sub { grid-column: 2 / -1; color: var(--mute); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .empty { padding: 10px 0; color: var(--mute); font-size: 14px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.dot.done { background: var(--done); } .dot.wip { background: var(--wip); } .dot.todo { background: none; box-shadow: inset 0 0 0 1.5px var(--mute); }

@media (max-width: 860px) {
  .sheet { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56dvh auto; height: auto; min-height: 100dvh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 22px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); }
  h1 { font-size: 23px; }
}
@media (prefers-reduced-motion: no-preference) {
  .cells-done, .cells-wip { transition: fill-opacity .3s; }
}
