/* A map bench with paper controls and a full-height relief map. */
:root {
  color-scheme: light;
  --ink: #202844; --muted: #515d70; --line: #cfd5de; --bg: #eef1f5;
  --panel: #fffefa; --accent: #304bca; --accent-ink: white; --warn: #8d411d;
  font: 100%/1.45 "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box }
[hidden] { display:none !important }
body { margin:0 }
header { display:flex; align-items:center; flex-wrap:wrap; gap:0 20px; background:#143f38; color:white; padding:13px 24px }
header a { color:#e3ede0; text-underline-offset:4px }
header .home { font-size:.9rem; padding-right:20px; border-right:1px solid #77928a; text-decoration:none }
h1, h2, #mapName { font-family:"Arial Black", "Helvetica Neue", Arial, sans-serif; font-weight:900; letter-spacing:-.035em; margin:0 }
header h1 { font-size:clamp(1.4rem,2vw,2rem) }
header .sub { color:#d1e2d2; font-size:.94rem }
#howLink { margin-left:auto; font-size:.9rem }
main { display:flex; height:calc(100dvh - 4.55rem); min-height:520px }
body { display:flex; flex-direction:column; min-height:100dvh }
@media(min-width:801px) { body {height:100dvh} main {flex:1;min-height:0} }
#panel { width:clamp(350px,32vw,465px); background:var(--panel); display:flex; flex-direction:column; border-right:1px solid var(--line); min-height:0 }
#controls { overflow:auto; flex:1; scrollbar-gutter:stable; padding:17px 19px 12px }
#controls h2 { font-size:1.6rem; margin:0 0 9px }
details { border-bottom:1px solid var(--line); padding:4px 0 }
summary { display:flex; align-items:center; gap:9px; cursor:pointer; font-weight:650; min-height:43px; list-style:none }
summary::-webkit-details-marker { display:none }
summary::after { content:'+'; font-weight:400; margin-left:auto; color:var(--muted) }
details[open]>summary::after { content:'−' }
summary .n { border:1px solid #97b4a4; color:#334482; border-radius:50%; font:.79rem/1.45 ui-monospace,monospace; width:23px;height:23px; display:grid;place-items:center }
summary .hint { font-size:.78rem; font-weight:400; color:var(--muted) }
.row { display:flex; align-items:center; gap:8px; margin:9px 0; flex-wrap:wrap }
.row>label { flex:1; min-width:130px }
.row.help, .info, .foot, #exportHelp { color:var(--muted); font-size:.88rem }
.row.help { display:block; margin:4px 0 12px }
.info { background:var(--bg); padding:9px 12px; border-radius:5px }
.info b { color:var(--ink) }
.warn { color:var(--warn) }
button, input, select { font:inherit; color:inherit }
button, select, .filebtn { cursor:pointer }
button, .filebtn, select, input:not([type=range]):not([type=color]):not([type=checkbox]) { border:1px solid #a3b4a8; border-radius:5px; background:white; padding:6px 9px; min-width:0 }
button:hover:enabled,.filebtn:hover { border-color:var(--accent); background:#eaf1e8 }
button:disabled { opacity:.52; cursor:default }
input[type=number] { width:78px }
input[type=checkbox],input[type=range] { accent-color:var(--accent) }
input[type=checkbox] { width:1.05em; height:1.05em; vertical-align:-.12em }
:focus-visible,.filebtn:focus-within { outline:3px solid #3554e6; outline-offset:2px }
.filebtn { flex:0 1 auto!important; min-width:0!important }
.sr { position:absolute; width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap }
.seg { display:inline-flex; flex-wrap:wrap; gap:3px; padding:3px; border-radius:6px; background:#e7ece4 }
.seg button,#tabs button { border:1px solid transparent; background:transparent; padding:5px 8px; font-size:.88rem }
.seg button.on,#tabs button.on { background:#fff; color:white; background-color:#3448a8; font-weight:650; box-shadow:0 1px 0 #202844 }
.penoption { font-weight:600 }
#gen { padding:11px 18px 9px; background:#f5f8f1; border-top:1px solid var(--line) }
button.primary, #search button { color:#fff; background:var(--accent); border-color:var(--accent); font-weight:650 }
button.primary:hover:enabled,#search button:hover:enabled { background:#25399e; color:#fff }
#go { width:100%; padding:10px }
#recipe {display:flex;align-items:center;gap:9px;margin:0 0 7px;color:var(--muted);font-size:.85rem}
#cardStack {display:flex;flex-direction:column;width:32px;height:19px;transform:skewX(-19deg);border:1px solid #84968a}
#cardStack i {flex:1;box-shadow:inset 0 -0.5px #76877e70}
#recipe .penoption {margin-left:auto;font-weight:500}
#cancel { margin-top:5px }
#progress { color:var(--muted); font-size:.85rem; margin-top:5px; min-height:1.25em }
#bar { height:3px; background:#dce4d9; margin-top:7px }
#bar>div { height:100%; width:0; background:var(--accent); transition:width .2s }
#right { flex:1; display:flex; flex-direction:column; min-width:0; background:#eef2eb }
#tabs { display:flex; align-items:center; gap:3px; padding:7px 16px; border-bottom:1px solid var(--line); background:#e9eee6 }
#mapview,#resultview { position:relative; flex:1; min-height:0 }
#map { position:absolute; inset:0; background:#b7cfd2 }
#mapbar { position:absolute; z-index:500; display:flex; flex-wrap:wrap; gap:6px; top:12px; right:12px; left:60px; justify-content:flex-end; pointer-events:none }
#mapbar>* { pointer-events:auto; font-size:.86rem; box-shadow:0 1px 5px #143a352b }
#mapbar .on { background:var(--ink); color:white }
#mapReadout { position:absolute; bottom:36px;left:16px; z-index:400; background:#fffef8ee; padding:8px 13px; border:1px solid #a6b5a4; border-radius:4px; pointer-events:none; max-width:calc(100% - 32px) }
#mapName { display:block; font-size:1.5rem; overflow-wrap:anywhere }
#coverage { display:block; font-size:.8rem; color:#455c50 }
.placeLabel.leaflet-tooltip { font:600 12px/1.3 "Segoe UI",sans-serif; color:#314c43; text-shadow:0 1px 2px #fff,1px 0 2px #fff; border:0; box-shadow:none; background:none; padding:0 }
.placeLabel::before { display:none }
#search { margin-top:4px }
#search label { font-weight:600; display:block; margin-bottom:4px; font-size:.92rem }
.searchline { display:flex; gap:5px }
#q { flex:1; width:100%; padding:9px }
#clipBadge { font-size:.9rem; justify-content:space-between; border-bottom:1px dashed var(--line); padding-bottom:7px }
#results { margin:6px 0 10px; border:1px solid #aec1b1; border-radius:5px; background:#f0f5ec; padding:6px; font-size:.88rem; max-height:260px; overflow:auto }
#results .x,#results .r { display:flex; align-items:center; gap:5px; padding:5px }
#results .r { border-top:1px solid var(--line); flex-wrap:wrap }
#results .x { justify-content:space-between }
#results .t { flex:1 1 100%; font-weight:650 }
#results .t small { color:var(--muted);font-weight:400 }
#results button { font-size:.86rem; padding:4px 7px }
.handle { width:14px; height:14px; margin:-7px 0 0 -7px; border-radius:50%; border:2px solid #1462ac; background:white }
.handle.mv { width:25px; height:25px; margin:-12px 0 0 -12px; display:grid;place-items:center; color:#14508f; cursor:move; border-radius:6px }
#resultview { overflow:auto; display:none; padding:clamp(12px,2vw,30px) }
#resultTitle { font-size:2rem; margin:0 0 12px; overflow-wrap:anywhere }
.wrap { display:flex; align-items:flex-start; flex-wrap:wrap; gap:18px }
#preview { max-width:min(100%,450px); max-height:66vh; width:auto; height:auto; border:1px solid var(--line); box-shadow:0 4px 18px #213d321a }
#side { flex:1; min-width:min(280px,100%) }
#stats { display:grid; grid-template-columns:1fr 1fr; gap:6px }
.stat { border:1px solid var(--line); border-radius:6px; background:var(--panel); padding:8px }
.stat .v { font-size:1.3rem; font-weight:600 }
.stat .k,.foot,.sep,#warnings { font-size:.83rem; color:var(--muted) }
#downloads,#swatches { display:flex; gap:6px; flex-wrap:wrap; margin:12px 0 }
.layers { width:100%; border-collapse:collapse; font-size:.85rem; margin-top:12px }
.layers td,.layers th { padding:5px;border-bottom:1px solid var(--line);text-align:left }
.chip {display:inline-block;width:16px;height:16px;border:1px solid #81907c;border-radius:3px;vertical-align:middle}
.crow {display:flex;align-items:center;gap:7px;padding:3px}
.crow.sel {background:#e7ebff;box-shadow:inset 3px 0 var(--accent)}
button.colourName {font-size:.9rem;flex:1;text-align:left;border:none;background:transparent}
.crow input {width:32px;height:24px;padding:0;border:0}
#swatches button {width:27px;height:27px}
.foot a {color:var(--accent)}
dialog {max-width:min(490px,90vw);border:1px solid var(--line);border-radius:8px;padding:24px;color:var(--ink);background:var(--panel)}
dialog::backdrop {background:#0e2928a8}
dialog form {text-align:right}
dialog h2 {font-size:1.8rem}
dialog li {margin:10px 0}
@media(max-width:800px) {
 header {padding:9px 12px;gap:0 10px} header .sub {display:none} header .home {padding-right:10px}
 main {flex-direction:column;height:auto;min-height:0} #right {order:-1;flex:none;height:clamp(290px,49dvh,450px)}
 #right:has(#resultview[style*="block"]) {height:auto;min-height:330px}
 #panel {width:100%;border:0} #controls {overflow:visible;padding:12px 16px}
 #gen {position:sticky;bottom:0;z-index:700} #mapName {font-size:1.1rem}
 #mapReadout {bottom:22px;left:9px;padding:4px 8px} #tabs {padding:4px 9px}
 #resultview {overflow:visible} #preview {max-height:40vh} header .home {font-size:.78rem}
}
@media(max-width:460px) {header .home {display:none} #howLink {font-size:.8rem} .row>select {max-width:100%}}
@media(prefers-reduced-motion:reduce) {*,*::before,*::after {transition:none!important;scroll-behavior:auto!important}}
.sourceNotes {width:min(100%,760px);margin:24px auto;padding:22px clamp(16px,4vw,42px);background:var(--panel);border:1px solid var(--line)}
.sourceNotes h2 {font-size:2.2rem}
.sourceNotes h3 {margin:24px 0 5px}
.sourceNotes p {margin:5px 0 15px}
.sourceNotes a {color:var(--accent)}
.gridImport {border:0}
.gridImport>summary {font-size:.88rem;font-weight:500;text-decoration:underline;text-underline-offset:3px}

#previewRetry {pointer-events:auto;margin-top:6px} #mapNotice:not(:empty) {display:block;max-width:36em;color:#74462e;margin-top:4px}

/* The workshop borrows the portfolio's ink, ruled paper and stamped maker's mark. */
header {
  flex-wrap:nowrap; flex-shrink:0; gap:12px; min-height:62px; padding:10px 22px;
  background-color:#202844;
  background-image:repeating-radial-gradient(ellipse at 84% 110%, transparent 0 17px, #b2baf318 18px 19px, transparent 20px 31px);
  background-size:660px 180px;background-repeat:no-repeat;background-position:right 100px bottom 40%;
  border-bottom:3px solid #a8d9bb;
}
header h1 {font-size:clamp(1.5rem,2.4vw,2.15rem);line-height:1;letter-spacing:-.057em}
header .sub {border-left:1px solid #687088;padding-left:14px;color:#e2e6f3}
.toolMark {display:block;width:38px;height:38px;flex:none}
#howLink {border:1px solid #8992ae;border-radius:20px;padding:6px 14px;background:#202844;color:white;font-weight:650;text-decoration:none;white-space:nowrap}
#howLink:hover {border-color:white;background:#354267}
.makerCredit {display:inline-flex;align-items:center;gap:10px;margin:3px 0 10px;font:bold .8rem/1.1 "Courier New",monospace;letter-spacing:.13em;text-transform:uppercase;text-decoration:none;color:#181818}
.pbMark {display:grid;place-items:center;width:29px;height:29px;background:#ffdc18;color:#151515;transform:rotate(-3deg);font:900 .8rem "Arial Black",Arial,sans-serif;letter-spacing:0}
.makerCredit:hover span:last-child {text-decoration:underline;text-underline-offset:4px}
#controls h2 {font-size:1.32rem;margin-bottom:12px}
#controls>details>summary {padding:5px 0}
#controls>details[open]>summary .n {color:#fff;background:#28385e;border-color:#28385e}
#controls>details>summary .n {border-radius:7px;border-color:#bbc6da;font-weight:bold}
#clipBadge {border:0;border-left:3px solid #98a2b6;background:#eef1f5;padding:7px 10px;border-radius:2px 5px 5px 2px}
#clipBadge.hasOutline {border-color:#a52964;background:#f9edf3}
#clipName {overflow-wrap:anywhere}
#clipBadge.hasOutline #clipName::before {content:'✓ ';color:#92305f}
#gen {background:#f7f8fe;border-top:2px solid #bac5df}
#go {border-radius:7px;font-weight:700;box-shadow:0 2px 0 #20348c}
#go:disabled {box-shadow:none}
.seg,.seg button {border-radius:6px}
.seg {background:#e9edf4}
#tabs {background:#f7f8fc;border-bottom:1px solid #c7cedb}
#tabs button {border-radius:6px}
#mapName {font-size:1.14rem;line-height:1.25;letter-spacing:-.02em}
#mapReadout {border:1px solid #bac2cf;border-left:4px solid #77859c;border-radius:6px;box-shadow:1px 2px 0 #28385426;background:#fffefaf7}
#mapReadout[data-state=ready] {border-left-color:#268466}
#mapReadout[data-state=loading] {border-left-color:#334fce}
#mapReadout[data-state=error] {border-left-color:#a53e27;background:#fff5ef}
#coverage {font-size:.83rem;color:#35435b}
#mapReadout[data-state=loading] #coverage::before {content:'';display:inline-block;width:.83em;height:.83em;margin-right:6px;border:2px solid #becafb;border-top-color:#334fce;border-radius:50%;animation:rotate .85s linear infinite}
#mapReadout[data-state=ready] #coverage::before {content:'✓ ';font-weight:bold;color:#176b50}
#drawBtn.on {background:#304bca;color:white;border-color:#25399e}
#resultview {background-color:#eef1f5;background-image:radial-gradient(#50678a28 1px,transparent 1px);background-size:12px 12px}
#preview {box-shadow:2px 3px 0 #34426533}
#side {padding:12px;background:#fffefa;border:1px solid var(--line);border-radius:9px}
button,.filebtn,.makerCredit {transition:background-color .13s,border-color .13s,transform .13s}
button:active:enabled,.filebtn:active {transform:translateY(1px)}
#controls input:focus-visible,#controls select:focus-visible {border-color:var(--accent)}
.crow.sel .colourName::after {content:' ✓';color:var(--accent);font-weight:bold}
#how,#activity {width:min(800px,calc(100vw - 32px));max-width:none;max-height:calc(100dvh - 34px);padding:clamp(16px,3vw,28px);border:1px solid #8391a6;border-radius:14px;box-shadow:0 5px 0 #18274435}
dialog::backdrop {background:#18243ad4}
dialog[open] {animation:appear .18s ease-out}
.guideHead,.guideFoot,.activityHead,.activityMeter {display:flex;align-items:center;justify-content:space-between;gap:14px}
.guideHead h2,#activityTitle {font-size:clamp(1.3rem,3vw,1.85rem);line-height:1.15}
.closeGuide {font-size:1.45rem;line-height:1;width:36px;height:36px;border-radius:50%}
.guideSteps {counter-reset:guide;list-style:none;margin:20px 0;padding:0;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.guideSteps li {counter-increment:guide;margin:0}
.guideSteps h3 {margin:13px 0 5px;font-size:1.02rem}
.guideSteps h3::before {content:counter(guide,decimal-leading-zero);font:700 .78rem "Courier New",monospace;color:#465da5;margin-right:7px}
.guideSteps p,.guideFoot p {margin:0;color:#455269;font-size:.93rem}
.guideArt {border:1px solid #c6cfcc;border-radius:9px;overflow:hidden;background-color:#e2efe4;background-image:linear-gradient(#768c9b1c 1px,transparent 1px),linear-gradient(90deg,#768c9b1c 1px,transparent 1px);background-size:15px 15px}
.cutArt {background-color:#e4eafb}.stackArt {background-color:#f3ead7}
.guideArt svg {display:block;width:100%}
.guideFoot {border-top:1px solid var(--line);padding-top:15px}
.guideFoot button {white-space:nowrap}
#activity {width:min(430px,calc(100vw - 32px))}
.activityHead {justify-content:flex-start}
#activityStage {min-height:1.5em;font-weight:650;color:#38435f;margin:18px 0 6px}
.activityMeter progress {flex:1;min-width:0;height:12px;border:0;border-radius:10px;overflow:hidden;background:#e1e6f4;accent-color:#344fc7}
.activityMeter progress::-webkit-progress-bar {background:#e1e6f4}
.activityMeter progress::-webkit-progress-value {background:#344fc7}
.activityMeter output {font:700 .94rem "Courier New",monospace;min-width:4ch;text-align:right}
#cancel {margin-top:18px}
@keyframes rotate {to {transform:rotate(360deg)}}
@keyframes appear {from {opacity:.2;transform:translateY(6px)}}
@keyframes frameSelection {0%,100% {transform:translate(0,0)} 25% {transform:translate(-10px,5px)} 55% {transform:translate(6px,-4px)}}
@keyframes cutLine {from {stroke-dasharray:0 310} to {stroke-dasharray:310 0}}
@keyframes blade {0% {transform:translate(0,0)} 45% {transform:translate(-12px,-12px)} 100% {transform:translate(0,0)}}
@keyframes seatLayer {from {transform:translateY(-14px)} to {transform:translateY(0)}}
@media(prefers-reduced-motion:no-preference) {
  #how[open] .guideFrame {animation:frameSelection 3.2s ease-in-out 1}
  #how[open] .guideCut {animation:cutLine 2.4s .3s ease-out both}
  #how[open] .guideBlade {animation:blade 2.4s .3s ease-in-out both}
  #how[open] .guideMiddle {animation:seatLayer .9s .55s ease-out both}
  #how[open] .guideTop {animation:seatLayer .95s 1.35s ease-out both}
}
@media(prefers-reduced-motion:reduce) {*,*::before,*::after {animation:none!important}}
@media(max-width:650px) {
 .guideSteps {grid-template-columns:1fr;margin:14px 0;gap:12px}
 .guideSteps li {display:grid;grid-template-columns:minmax(74px,28%) 1fr;column-gap:12px;align-content:center}
 .guideArt {grid-row:span 2;align-self:center}
 .guideSteps h3 {margin:0 0 3px}
 .guideFoot {flex-wrap:wrap}
 header {min-height:52px;padding:7px 12px}
}

#framePrompt {position:absolute;z-index:450;top:62px;left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 38px);text-align:center;background:#25399e;color:white;border-radius:18px;padding:6px 14px;font-weight:650;font-size:.9rem;pointer-events:none}

#activityTitle {font-size:clamp(1.2rem,2.1vw,1.55rem)}
#activityDismiss {margin-top:15px;text-align:left}
