/* simple-digipin — map-first surface. Tokens per DESIGN.md. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(vendor/fonts/AtkinsonHyperlegibleNext-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(vendor/fonts/AtkinsonHyperlegibleNext-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.965 0.005 160);
  --surface-3: oklch(0.93 0.006 160);
  --ink: oklch(0.24 0.012 160);
  --ink-2: oklch(0.44 0.016 160);
  --line: oklch(0.89 0.008 160);
  --primary: oklch(0.50 0.12 160);
  --primary-ink: oklch(0.42 0.11 160);
  --primary-soft: oklch(0.93 0.045 160);
  --you: oklch(0.56 0.17 250);
  --warn: oklch(0.92 0.08 85);
  --danger: oklch(0.52 0.19 25);
  --elev: 0 1px 2px oklch(0 0 0 / .3), 0 2px 6px 2px oklch(0 0 0 / .15);
  --radius: 8px;
  --peek: 152px;
  --peek-intro: 212px;
  --bar-h: 48px;
  --panel-w: 400px;
  --inset: 12px;
  --top: max(var(--inset), env(safe-area-inset-top, 0px));
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --z-map: 0;
  --z-pin: 1;
  --z-controls: 2;
  --z-sheet: 3;
  --z-search: 4;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  font-family: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
h2 { font-size: 1.125rem; font-weight: 600; text-wrap: balance; }
a { color: var(--primary-ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Icons: one set, Material Symbols outlined, recoloured through mask. */
.icon {
  display: inline-block; width: 24px; height: 24px; flex: none;
  background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat;
}
.i-search { --i: url(vendor/icons/search.svg); }
.i-close { --i: url(vendor/icons/close.svg); }
.i-my_location { --i: url(vendor/icons/my_location.svg); }
.i-add { --i: url(vendor/icons/add.svg); }
.i-remove { --i: url(vendor/icons/remove.svg); }
.i-content_copy { --i: url(vendor/icons/content_copy.svg); }
.i-check { --i: url(vendor/icons/check.svg); }
.i-shield { --i: url(vendor/icons/shield.svg); }
.i-lock { --i: url(vendor/icons/lock.svg); }

/* Map and the fixed centre pin */
#map { position: fixed; inset: 0; z-index: var(--z-map); background: var(--surface-2); }
.pin {
  position: fixed; left: 50%; top: 50%; z-index: var(--z-pin);
  pointer-events: none;
  transform: translate(-50%, -100%);
  transition: transform .12s var(--ease-out);
}
body.is-dragging .pin { transform: translate(-50%, calc(-100% - 8px)); }
.pin svg { display: block; filter: drop-shadow(0 2px 2px oklch(0 0 0 / .35)); }

/* Attribution sits just above the sheet on phones */
.maplibregl-ctrl-bottom-right { bottom: calc(var(--peek) + var(--bottom-safe)); }
.maplibregl-ctrl-attrib { font-family: inherit; font-size: .75rem; }

/* Floating search bar */
.search {
  position: fixed; top: var(--top); left: var(--inset); right: var(--inset); z-index: var(--z-search);
  height: var(--bar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px 0 14px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--elev);
  color: var(--ink-2);
}
.search:focus-within { box-shadow: var(--elev), 0 0 0 2px var(--you); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 1rem; color: var(--ink); letter-spacing: .02em;
}
.search input::placeholder { color: var(--ink-2); opacity: 1; }
.clear { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; padding: 0; }
.clear:hover { background: var(--surface-2); color: var(--ink); }
.clear:focus-visible { outline: 2px solid var(--you); outline-offset: 0; }
.clear[hidden] { display: none; }

.search-msg {
  position: fixed; top: calc(var(--top) + var(--bar-h) + 8px); left: var(--inset); right: var(--inset); z-index: var(--z-search);
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--elev);
  font-size: .9375rem; line-height: 1.4; text-wrap: pretty;
}
.search-msg[hidden] { display: none; }
.search-msg.error { color: var(--danger); }
.search-msg.warn { background: var(--warn); }

/* Round map controls */
.controls {
  position: fixed; right: var(--inset); z-index: var(--z-controls);
  bottom: calc(var(--peek) + var(--bottom-safe) + 44px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
.ctl {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--ink); box-shadow: var(--elev);
  display: grid; place-items: center; cursor: pointer;
  transition: background-color .15s;
}
.ctl:hover { background: var(--surface-2); }
.ctl:active { background: var(--surface-3); }
.ctl:focus-visible { outline: 2px solid var(--you); outline-offset: 2px; }
.ctl.is-on { color: var(--you); }
.ctl.is-busy .icon { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.zoom { display: flex; flex-direction: column; border-radius: 22px; background: var(--surface); box-shadow: var(--elev); overflow: hidden; }
.zoom .ctl { box-shadow: none; border-radius: 0; }
.zoom .ctl + .ctl { border-top: 1px solid var(--line); }
.zoom .ctl:focus-visible { outline-offset: -2px; }

/* Sheet (phone) / panel (desktop) */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet);
  height: calc(100vh - 80px); height: calc(100dvh - 80px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px 16px 0 0;
  box-shadow: 0 -1px 2px oklch(0 0 0 / .2), 0 -2px 8px 2px oklch(0 0 0 / .12);
  transform: translateY(calc(100% - var(--peek)));
  transition: transform .22s var(--ease-out);
}
.sheet.has-intro { --peek: var(--peek-intro); }
.sheet[data-snap="half"] { transform: translateY(50%); }
.sheet[data-snap="full"] { transform: none; }
.sheet.is-dragging { transition: none; }
.handle { flex: none; height: 24px; width: 100%; border: 0; background: transparent; display: grid; place-items: center; cursor: grab; touch-action: none; padding: 0; }
.handle:active { cursor: grabbing; }
.handle:focus-visible { outline: 2px solid var(--you); outline-offset: -4px; border-radius: 12px; }
.grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet-body { flex: 1; min-height: 0; overflow: hidden; padding: 0 16px calc(24px + var(--bottom-safe)); }
.sheet[data-snap="half"] .sheet-body, .sheet[data-snap="full"] .sheet-body { overflow-y: auto; }
.sheet[data-snap="peek"] .sheet-body { touch-action: none; }

/* Code block: the one big thing */
.brand { display: flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 500; color: var(--ink-2); }
.brand .icon { width: 18px; height: 18px; color: var(--primary-ink); }
.brand-note { font-weight: 400; }
.brand-note::before { content: "\00b7"; margin: 0 4px 0 2px; }
.code-row { display: flex; align-items: center; gap: 8px; min-height: 48px; margin-top: 4px; }
.code {
  flex: 1; min-width: 0;
  font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: .06em;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.code.is-empty { font-size: 1.25rem; font-weight: 500; letter-spacing: 0; color: var(--ink-2); }
.meta { font-size: .8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; text-wrap: pretty; }
.help { font-size: .9375rem; color: var(--ink-2); margin: 4px 0 8px; text-wrap: pretty; }

/* Buttons and fields */
.btn {
  height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; transition: background-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn:focus-visible { outline: 2px solid var(--you); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-ink); }
.btn-primary:active { background: var(--primary-ink); }
.btn-icon { width: 44px; padding: 0; }
.btn .icon { width: 20px; height: 20px; }
.btn.is-done { color: var(--primary-ink); border-color: var(--primary); }

.intro { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.intro[hidden] { display: none; }

.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: .8125rem; font-weight: 500; margin-bottom: 4px; }
.field input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
  font: inherit; color: var(--ink);
}
.field input::placeholder { color: var(--ink-2); opacity: 1; }
.field input:focus-visible { outline: 2px solid var(--you); outline-offset: 0; border-color: transparent; }

section, .how { margin-top: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.card {
  margin: 8px 0 0; padding: 12px; border-radius: var(--radius);
  background: var(--surface-2); font: inherit; font-size: .9375rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.card.is-empty { color: var(--ink-2); }

.privacy { padding: 12px 14px; border-radius: var(--radius); background: var(--primary-soft); color: var(--ink); }
.privacy h2 { display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.privacy h2 .icon { width: 20px; height: 20px; color: var(--primary-ink); }
.privacy p { margin-top: 6px; font-size: .9375rem; text-wrap: pretty; }

.how summary { cursor: pointer; font-weight: 500; padding: 8px 0; }
.how summary:focus-visible { outline: 2px solid var(--you); outline-offset: 2px; border-radius: 4px; }
.how p { margin-top: 8px; font-size: .9375rem; text-wrap: pretty; }
.how .meta { margin-top: 12px; }

/* Desktop: the sheet becomes a fixed left panel; the map fills the rest */
@media (min-width: 1024px) {
  :root { --inset: 16px; }
  #map { left: var(--panel-w); }
  .pin { left: calc(var(--panel-w) + (100vw - var(--panel-w)) / 2); }
  .search { top: 16px; left: 16px; right: auto; width: calc(var(--panel-w) - 32px); }
  .search-msg { top: calc(16px + var(--bar-h) + 8px); left: 16px; right: auto; width: calc(var(--panel-w) - 32px); }
  .sheet {
    top: 0; bottom: 0; left: 0; right: auto; width: var(--panel-w); height: auto;
    border-radius: 0; transform: none !important; transition: none;
    box-shadow: 1px 0 0 var(--line), 0 0 24px oklch(0 0 0 / .08);
  }
  .handle { display: none; }
  .sheet-body { overflow-y: auto; padding-top: 80px; }
  .controls { bottom: 44px; }
  .maplibregl-ctrl-bottom-right { bottom: 0; }
}

@media (pointer: coarse) {
  .clear { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .pin, .ctl, .btn { transition: none; }
  .ctl.is-busy .icon { animation: none; opacity: .5; }
}
