/* The public page. The map is the page; the chrome is quiet, white and ink, and the depth ramp is
 * the only loud colour on screen (it also underlines the wordmark). */
:root {
  --ink: #0e2a3b;          /* deep river water: text, primary button */
  --ink-soft: #3d5a6c;     /* secondary text */
  --muted: #6b8292;        /* hints, labels */
  --paper: #ffffff;        /* chrome and drawer */
  --mist: #f0f4f7;         /* wells: drop zone, file list */
  --line: #d4dee5;         /* hairlines, borders */
  --channel: #1f63a8;      /* links, focus */
  --ok: #1c7a4c;
  --error: #b42318;
  --error-soft: #fdecea;
  --caution: #7a5300;      /* the not-for-navigation tag */
  --caution-soft: #fff4d1;
  --caution-line: #e9c25a;
  --ramp: linear-gradient(to right, #ff7f00, #ffd400, #7ad151, #22d3c5, #2a6fdb, #5b2bbf, #e01fbf);
  --shadow: 0 1px 2px rgba(14, 42, 59, 0.12), 0 6px 18px rgba(14, 42, 59, 0.14);
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue",
    Roboto, "Noto Sans", sans-serif;
  --gutter: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: #aad3df; /* OSM water, while tiles load */
  -webkit-text-size-adjust: 100%;
}

#map {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  background: #aad3df;
  font-family: var(--font);
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--channel); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- chrome over the map ---------- */

.chrome {
  position: fixed;
  z-index: 1000;
  background: var(--paper);
  border: 1px solid rgba(14, 42, 59, 0.08);
  box-shadow: var(--shadow);
}

.chip {
  top: calc(var(--gutter) + var(--safe-top));
  left: var(--gutter);
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 18px 0 14px;
  border-radius: 22px;
  cursor: pointer;
}
.chip:hover { background: var(--mist); }
.chip-burger { font-size: 17px; line-height: 1; color: var(--ink-soft); }

.wordmark {
  position: relative;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.015em;
  padding-bottom: 3px;
}
/* the signature: the wordmark sits on the depth ramp, shallow to deep */
.wordmark::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--ramp);
}

.lang-switch {
  display: flex;
  padding: 3px;
  border-radius: 22px;
}
#lang-switch {
  top: calc(var(--gutter) + var(--safe-top));
  right: var(--gutter);
  height: 44px;
  align-items: center;
}
.lang-switch button {
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* zoom buttons: under the language switch, same family of white controls */
.leaflet-top.leaflet-right { top: calc(68px + var(--safe-top)); }
.leaflet-right .leaflet-control { margin-right: var(--gutter); }
.leaflet-touch .leaflet-bar,
.leaflet-bar {
  border: 1px solid rgba(14, 42, 59, 0.08);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.leaflet-touch .leaflet-bar a,
.leaflet-bar a {
  width: 44px;
  height: 44px;
  line-height: 42px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 500;
  border-bottom-color: var(--line);
}
.leaflet-bar a:last-child { border-bottom: 0; }

.leaflet-control-attribution {
  font-size: 11px;
  line-height: 1.4;
  padding: 2px 8px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.85) !important;
  border-top-left-radius: 8px;
}
.leaflet-control-attribution a { color: var(--channel); }
.leaflet-bottom.leaflet-right { bottom: var(--safe-bottom); }
.leaflet-right .leaflet-control-attribution { margin-right: 0; }

/* depth legend, bottom left */
.legend {
  left: var(--gutter);
  bottom: calc(var(--gutter) + var(--safe-bottom));
  width: 200px;
  padding: 10px 12px 8px;
  border-radius: 12px;
}
.legend-title { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.legend-ramp { height: 10px; border-radius: 5px; background: var(--ramp); }
.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.legend.empty .legend-ramp { opacity: 0.35; }
.legend.empty .legend-labels { justify-content: flex-start; color: var(--muted); }

/* not for navigation, bottom right, above the attribution */
.tag {
  position: fixed;
  z-index: 1000;
  right: var(--gutter);
  /* --attrib-h: the attribution's height, measured by site.js (it wraps on phones) */
  bottom: calc(var(--attrib-h, 20px) + 8px + var(--safe-bottom));
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--caution-soft);
  border: 1px solid var(--caution-line);
  color: var(--caution);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ---------- drawer ---------- */

.drawer {
  position: fixed;
  z-index: 1100;
  top: 0;
  left: 0;
  width: min(420px, 100vw);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(14, 42, 59, 0.06), 12px 0 40px rgba(14, 42, 59, 0.18);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.28s;
}
.drawer.open {
  transform: none;
  visibility: visible;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s;
}
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer.open { transition: none; }
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(18px + var(--safe-top)) 16px 10px 24px;
}
.drawer-head .wordmark { font-size: 20px; margin-right: auto; }
.lang-switch.in-drawer { display: none; background: var(--mist); }

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  font-size: 18px;
  color: var(--ink-soft);
  cursor: pointer;
}
.icon-button:hover { background: var(--mist); color: var(--ink); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  position: relative;
  padding: 12px 8px;
  margin: 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  background: var(--ink);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 24px calc(32px + var(--safe-bottom));
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.panel h3 { margin: 28px 0 6px; font-size: 15px; font-weight: 700; }
.panel p { margin: 0 0 12px; }
.prose p { margin: 0 0 12px; color: var(--ink); }
.prose.small p, .note { font-size: 14px; color: var(--ink-soft); }
.note { padding-left: 12px; border-left: 3px solid var(--line); }

a { color: var(--channel); text-underline-offset: 2px; }
.links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.links a { font-weight: 600; }
.links:not(:has(a:not([hidden]))) { display: none; }

/* contribute form */
form { margin-top: 20px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 16px; /* no zoom-on-focus on phones */
  color: var(--ink);
  background: #fff;
}
.field input:focus { border-color: var(--channel); outline: 2px solid rgba(31, 99, 168, 0.18); outline-offset: 0; }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 20px;
  border: 1.5px dashed #a9bccb;
  border-radius: 14px;
  background: var(--mist);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--channel); background: #e6eff7; }
.drop-title { font-weight: 700; font-size: 16px; }
.drop-hint { font-size: 13px; color: var(--ink-soft); max-width: 30ch; }

.upload-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.upload-list[hidden] { display: none; }
.upload {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.upload:last-child { border-bottom: 0; }
.upload-name { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.upload-state { color: var(--muted); text-align: right; font-size: 13px; }
.state-stored .upload-state, .state-duplicate .upload-state { color: var(--ok); }
.state-stored .upload-state::before, .state-duplicate .upload-state::before { content: "✓ "; }
.state-skipped .upload-name { color: var(--muted); font-weight: 400; text-decoration: line-through; }
.upload.error { background: var(--error-soft); }
.upload.error .upload-state { color: var(--error); }

.check {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); }

.honeypot { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.summary { margin: 18px 0 0; font-size: 14px; font-weight: 600; color: var(--ok); }
.summary.error { color: var(--error); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.primary, .secondary {
  height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}
.primary { flex: 1; border: 0; background: var(--ink); color: #fff; }
.primary:hover:not(:disabled) { background: #173f57; }
.primary:disabled { background: #c9d4dc; color: #fff; cursor: not-allowed; }
.secondary { border: 1.5px solid var(--ink); background: #fff; color: var(--ink); }
.secondary[hidden] { display: none; }

/* contact */
.contact-list { list-style: none; padding: 0; margin: 16px 0; }
.contact-list li { display: flex; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.contact-list li[hidden] { display: none; }
.contact-list li > span { width: 84px; flex: none; font-size: 13px; font-weight: 600; color: var(--muted); }
.contact-list a { overflow-wrap: anywhere; font-weight: 600; }

/* ---------- phone ---------- */

@media (max-width: 600px) {
  :root { --gutter: 12px; }
  .lang-switch.in-drawer { display: flex; }
  .drawer { box-shadow: none; }
  .drawer-head { padding-left: 20px; padding-right: 10px; }
  .drawer-body { padding: 20px 20px calc(32px + var(--safe-bottom)); }
  .tabs { padding: 0 8px; }
  .legend { width: 136px; padding: 8px 10px 6px; }
  .leaflet-control-attribution { max-width: calc(100vw - 136px - 3 * var(--gutter)); font-size: 10px; }
  .tag { font-size: 12px; max-width: calc(100vw - 136px - 3 * var(--gutter)); }
}
