/* TERRA Lab · Teach it your land. Forest scope around a true-colour plate; gold is the deed line, teal is the data, sand marks what the owner placed. Square corners. */
:root {
  --forest-deep: #161e19; --forest: #1f2a23; --sand: #e8e2d6; --sand-2: rgba(232,226,214,.8);
  --sand-3: rgba(232,226,214,.62); --line: rgba(232,226,214,.18);
  --gold: #c6a76a; --teal: #34b294;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --descend: cubic-bezier(.22,1,.36,1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--forest-deep); color: var(--sand); font: 400 14px/1.5 var(--sans); }
button { font: inherit; color: inherit; }
a { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
.micro { margin: 0; font: 500 12px var(--mono); letter-spacing: .12em; color: var(--sand-3); text-transform: uppercase; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 6px 20px; border-bottom: 1px solid var(--line); }
.mark { font-weight: 500; letter-spacing: .22em; font-size: 15px; }
.lablink { display: inline-flex; align-items: center; min-height: 44px; color: var(--sand); text-decoration: none; }
.lablink span { margin-left: .5em; letter-spacing: .08em; font-weight: 400; color: var(--gold); }
.lablink:hover, .lablink:hover span { color: var(--gold); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.exp { font-size: 11px; letter-spacing: .12em; color: var(--gold); border: 1px solid rgba(198,167,106,.45); padding: 2px 7px; }

/* three blocks: intro and reading beside the plate on a wide screen, stacked in reading order on a phone */
.teach { display: grid; gap: 20px 28px; padding: 24px 20px 40px; max-width: 1280px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); grid-template-areas: "stage intro" "stage read"; align-items: start; }
.intro { grid-area: intro; display: flex; flex-direction: column; gap: 12px; }
.stagecol { grid-area: stage; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.read { grid-area: read; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 860px) {
  .teach { grid-template-columns: minmax(0, 1fr); grid-template-areas: "intro" "stage" "read"; padding: 16px 16px 32px; }
}

.eyebrow { margin: 0; font: 500 11px var(--mono); letter-spacing: .12em; color: var(--gold); text-transform: uppercase; }
h1 { margin: 0; font: 300 34px/1.1 var(--serif); letter-spacing: -.018em; }
.lede { margin: 0; font-size: 15px; line-height: 1.65; color: var(--sand-2); max-width: 44ch; }

.lands { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.land { min-height: 52px; padding: 8px 10px; text-align: left; background: transparent; border: 1px solid var(--line); cursor: pointer; transition: border-color .18s var(--descend), background-color .18s var(--descend); }
.land:hover { border-color: rgba(232,226,214,.5); }
.land[aria-pressed="true"] { background: var(--forest); border-color: var(--gold); }
.land b { display: block; font-weight: 500; font-size: 13.5px; }
.land span { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: var(--sand-3); }
.land[disabled] { opacity: .5; cursor: progress; }

.stage { position: relative; width: 100%; aspect-ratio: 1; max-height: 82vh; background: var(--forest); border: 1px solid rgba(232,226,214,.14); overflow: hidden; user-select: none; -webkit-user-select: none; }
/* on a wide screen the plate is sized to the window's height so the controls stay in view beneath it */
@media (min-width: 861px) { .teach { grid-template-columns: minmax(0, min(70vh, 820px)) minmax(300px, 380px); justify-content: center; } .stage { max-height: 70vh; } }
.stage > img, .stage > canvas, .stage > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage > img { object-fit: fill; }
/* the matches are drawn square by square, as the ground is read */
#lit { image-rendering: pixelated; image-rendering: crisp-edges; transition: opacity .18s var(--descend); }
.tapzone { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; background: transparent; border: 0; cursor: crosshair; touch-action: manipulation; }
.tapzone:focus-visible { outline-offset: -4px; }
.marks { position: absolute; inset: 0; pointer-events: none; }
/* a mark: the square of ground it samples (three 10 m squares a side), and its number */
.mk { position: absolute; transform: translate(-50%, -50%); min-width: 12px; min-height: 12px; border: 2px solid var(--sand); box-shadow: 0 0 0 1px rgba(22,30,25,.85), inset 0 0 0 1px rgba(22,30,25,.85); }
.mk b { position: absolute; left: calc(100% + 3px); bottom: calc(100% + 3px); min-width: 20px; padding: 1px 5px; font: 500 12px/18px var(--mono); text-align: center; color: var(--forest-deep); background: var(--sand); border: 1px solid rgba(22,30,25,.6); }
.mk.not { border-style: dashed; border-color: #f0d9c9; }
.mk.not b { background: var(--forest-deep); color: var(--sand); border-color: var(--sand); }
.mk.cur { min-width: 24px; min-height: 24px; border: 2px dashed var(--gold); box-shadow: 0 0 0 1px rgba(22,30,25,.7); }
.mk.cur b { display: none; }
.mk[hidden] { display: none; }
.hint { position: absolute; top: 10px; left: 12px; right: 56px; font-size: 11px; letter-spacing: .1em; color: var(--sand); text-shadow: 0 0 4px rgba(22,30,25,.95), 0 0 2px rgba(22,30,25,.95); pointer-events: none; transition: opacity .3s var(--descend); }
.hint.gone { opacity: 0; }
.north { position: absolute; top: 10px; right: 12px; font-size: 11px; letter-spacing: .08em; color: var(--sand); text-shadow: 0 0 4px rgba(22,30,25,.95); pointer-events: none; }
.scale { position: absolute; left: 12px; bottom: 10px; display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--sand); text-shadow: 0 0 4px rgba(22,30,25,.95); pointer-events: none; }
.scalebar { display: inline-block; height: 6px; border: 1px solid var(--sand); border-top: 0; box-shadow: 0 1px 0 rgba(22,30,25,.6); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; font-size: 12px; letter-spacing: .14em; color: var(--sand-3); background: var(--forest-deep); }
.loading[hidden] { display: none; }

.strict { display: flex; flex-direction: column; gap: 2px; }
.strictrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.strictrow output { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--sand); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: rgba(232,226,214,.35); }
input[type="range"]::-moz-range-track { height: 2px; background: rgba(232,226,214,.35); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 26px; margin-top: -12px; background: var(--sand); border: 1px solid var(--forest-deep); border-radius: 0; }
input[type="range"]::-moz-range-thumb { width: 18px; height: 26px; background: var(--sand); border: 1px solid var(--forest-deep); border-radius: 0; }
input[type="range"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ticks { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .08em; color: var(--sand-3); }

.controls { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { min-height: 44px; padding: 0 16px; border: 1px solid var(--sand); background: var(--sand); color: var(--forest-deep); font-weight: 500; font-size: 13px; cursor: pointer; transition: background-color .18s var(--descend), color .18s var(--descend), border-color .18s var(--descend); }
.btn:hover, .btn:active { background: transparent; color: var(--sand); }
.btn.ghost { background: transparent; color: var(--sand); border-color: rgba(232,226,214,.35); }
.btn.ghost:hover, .btn.ghost:active { border-color: var(--sand); }
.btn.ghost[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.btn[disabled], .btn[disabled]:hover { opacity: .45; cursor: not-allowed; background: transparent; color: var(--sand); border-color: rgba(232,226,214,.35); }
.legend { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 12px; color: var(--sand-3); }
.key { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sw { display: inline-block; width: 14px; height: 0; vertical-align: middle; }
.sw.parcel { border-top: 2px solid var(--gold); }
.sw.lit { height: 10px; background: rgba(52,178,148,.8); }
.sw.litout { height: 10px; background: rgba(52,178,148,.5); outline: 1px solid rgba(22,30,25,.5); }
.sw.num { width: auto; height: auto; font-size: 11px; line-height: 16px; color: var(--forest-deep); background: var(--sand); padding: 0 5px; }

.facts { margin: 0; font-size: 12px; letter-spacing: .1em; color: var(--sand-3); text-transform: uppercase; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.figs { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.figs dd { margin: 4px 0 0; font: 300 19px/1.4 var(--serif); color: var(--sand); }
.figs dd .n { font: 400 15px var(--mono); color: var(--sand); }
.figs dd .t { font: 400 15px var(--mono); color: var(--teal); }
.figs dd small { display: block; margin-top: 4px; font: 400 13px/1.55 var(--sans); color: var(--sand-2); }
.can { border-top: 1px solid var(--line); padding-top: 12px; }
.can p:not(.micro) { margin: 8px 0 0; font-size: 13px; line-height: 1.6; color: var(--sand-2); }
.notes { border-top: 1px solid var(--line); padding-top: 12px; }
.notes ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.55; color: var(--sand-2); }
.notes li::marker { color: var(--gold); }
.cta { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); text-decoration: none; }
.cta:hover, .cta:active { color: var(--sand); }

.foot { max-width: 1280px; margin: 0 auto; padding: 16px 20px 28px; border-top: 1px solid var(--line); font-size: 12px; letter-spacing: .04em; color: var(--sand-3); }
.foot a { display: inline-block; padding: 12px 0; }

@media (prefers-reduced-motion: reduce) {
  #lit, .land, .btn, .hint { transition: none; }
}
