/* ════════════════════════════════════════════════════════════════════════
   shits.dog — Civic Editorial design system
   A public-records broadsheet meets a field guide. The map carries the color;
   the chrome is warm paper, ink, hairline rules, and one confident green.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Palette (locked) ─────────────────────────────────────────────── */
  --paper: #f4f1ea;
  --paper-2: #fffdf8;
  --ink: #16241b;
  --dim: #6a7a6d;
  --grass: #1f6b3b;
  --grass-2: #2e8b57;
  --line: rgba(28, 58, 42, 0.12);
  --line-strong: rgba(28, 58, 42, 0.22);

  /* heat ramp / status */
  --amber: #be8228;
  --danger: #a02d20;

  /* derived surfaces */
  --card: var(--paper-2);
  --tint-grass: rgba(31, 107, 59, 0.08);
  --tint-grass-2: rgba(31, 107, 59, 0.14);
  --tint-danger: rgba(160, 45, 32, 0.08);

  /* ── Type ─────────────────────────────────────────────────────────── */
  --display: 'Fraunces', Georgia, serif;
  --body: 'Hanken Grotesk', system-ui, sans-serif;

  /* fluid type scale */
  --t-xs: 0.72rem;
  --t-sm: 0.82rem;
  --t-base: 0.95rem;
  --t-md: 1.05rem;
  --t-lg: 1.3rem;
  --t-xl: clamp(1.45rem, 1.2rem + 1.1vw, 1.9rem);

  /* tracking for editorial labels */
  --track-label: 0.14em;

  /* ── Spacing scale ────────────────────────────────────────────────── */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.4rem;
  --sp-6: 1.8rem;

  /* ── Radii & elevation ────────────────────────────────────────────── */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-pill: 999px;
  --shadow-card: 0 16px 44px -20px rgba(16, 36, 27, 0.42);
  --shadow-fab: 0 12px 28px -10px rgba(31, 107, 59, 0.7);
  --shadow-sheet: 0 -12px 44px -12px rgba(16, 36, 27, 0.42);

  /* ── Chrome metrics ───────────────────────────────────────────────── */
  --topbar-h: 56px;

  /* ── Focus ring ───────────────────────────────────────────────────── */
  --focus: 0 0 0 2px var(--paper-2), 0 0 0 4px var(--grass-2);
}

/* ── Reset ──────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
/* The `hidden` attribute is how the JS shows/hides the sheet, About panel, admin
   token form, empty states, etc. A class that sets `display` (e.g. .admin-token)
   would otherwise override the UA `[hidden]` rule and leave the element on screen,
   so make `hidden` authoritative. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
  position: fixed;
  inset: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Unified, on-brand focus treatment */
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-sm);
}

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--sp-5) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  background: linear-gradient(to bottom, rgba(255, 253, 248, 0.96), rgba(255, 253, 248, 0.88));
  backdrop-filter: saturate(1.1) blur(8px);
  -webkit-backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: var(--t-lg);
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
  /* tiny editorial flourish: the dot in .dog reads as the accent */
}
.brand::after {
  content: '';
  display: block;
  width: 22px;
  height: 2px;
  margin-top: 3px;
  background: var(--grass);
  border-radius: 2px;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.count {
  font-family: var(--body);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.topbar-sep {
  width: 1px;
  height: 16px;
  background: var(--line-strong);
}
.about-btn {
  font: inherit;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink);
  background: none;
  border: none;
  padding: var(--sp-1) var(--sp-2);
  margin: calc(var(--sp-1) * -1) calc(var(--sp-2) * -1);
  min-height: 44px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: color 0.15s ease;
}
.about-btn:hover { color: var(--grass); }

/* ── Map ────────────────────────────────────────────────────────────── */
#map {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--paper);
}
.maplibregl-ctrl-top-right {
  margin-top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 8px);
}
/* fold the map controls into the editorial palette */
.maplibregl-ctrl-group {
  border-radius: var(--r-md) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow-card) !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button { background: var(--paper-2); }
.maplibregl-ctrl-attrib {
  background: rgba(255, 253, 248, 0.78) !important;
  font-family: var(--body);
}
.maplibregl-ctrl-attrib a { color: var(--dim); }

/* ── Empty state — a printed notice ─────────────────────────────────── */
.empty {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-6) var(--sp-5);
  text-align: center;
  z-index: 15;
  box-shadow: var(--shadow-card);
  max-width: min(86vw, 340px);
}
.empty-kicker {
  font-family: var(--body);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--grass);
  margin-bottom: var(--sp-3);
}
.empty-kicker::after {
  content: '';
  display: block;
  width: 28px;
  height: 2px;
  margin: var(--sp-2) auto 0;
  background: var(--grass);
  border-radius: 2px;
}
.empty-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--t-xl);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.empty .sub {
  font-family: var(--body);
  font-weight: 400;
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--dim);
  margin-top: var(--sp-3);
}

/* ── FAB — a stamped action button ──────────────────────────────────── */
.fab {
  position: fixed;
  left: 50%;
  bottom: calc(1.3rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font: inherit;
  font-weight: 700;
  font-size: var(--t-base);
  letter-spacing: 0.01em;
  color: var(--paper-2);
  background: var(--grass);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--r-pill);
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-fab);
  transition: background 0.18s ease, transform 0.1s ease, box-shadow 0.18s ease;
}
.fab-icon { font-size: 1.05em; line-height: 1; }
.fab-label { line-height: 1; }
.fab:hover {
  background: var(--grass-2);
  box-shadow: 0 16px 34px -10px rgba(31, 107, 59, 0.78);
}
.fab:active { transform: translateX(-50%) translateY(1px); }

/* ════════════════════════════════════════════════════════════════════
   Report sheet — refined design (Task 2)
   ════════════════════════════════════════════════════════════════════ */
.sheet-scrim { position: fixed; inset: 0; background: rgba(22,36,27,.55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--paper-2);
  background-image: repeating-linear-gradient(to bottom, transparent, transparent calc(1.65rem - 1px), rgba(28,58,42,.055) calc(1.65rem - 1px), rgba(28,58,42,.055) 1.65rem);
  background-attachment: local;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--sp-2) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 40px -10px rgba(0,0,0,.35);
  max-width: 560px; margin-inline: auto; max-height: 90svh; overflow-y: auto; overscroll-behavior: contain;
}
.sheet-handle { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: var(--sp-2) auto var(--sp-4); }
.sheet-header { display: flex; flex-direction: column; gap: var(--sp-1); padding-bottom: var(--sp-4); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.sheet h2 { font-family: var(--display); font-weight: 800; font-size: clamp(1.55rem, 1.25rem + 1.3vw, 1.95rem); line-height: 1.05; letter-spacing: -.025em; color: var(--ink); padding-top: var(--sp-3); position: relative; }
.sheet h2::before { content: ''; position: absolute; top: 0; left: 0; width: 40px; height: 3px; background: var(--grass); border-radius: 2px; }
.sheet-note { font-family: var(--body); font-size: var(--t-sm); line-height: 1.55; color: var(--dim); font-style: italic; }
.photo-drop { position: relative; display: flex; align-items: center; justify-content: center; min-height: 168px; border-radius: var(--r-md); background: var(--paper); cursor: pointer; overflow: hidden; text-align: center; padding: var(--sp-5); border: none; transition: background .2s ease; }
.photo-drop::before, .photo-drop::after { content: ''; position: absolute; width: 22px; height: 22px; border-color: var(--line-strong); border-style: solid; transition: border-color .2s ease, width .2s ease, height .2s ease; }
.photo-drop::before { top: 10px; left: 10px; border-width: 2px 0 0 2px; border-radius: 3px 0 0 0; }
.photo-drop::after { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; border-radius: 0 0 3px 0; }
.photo-drop:hover, .photo-drop:focus-within { background: var(--tint-grass); }
.photo-drop:hover::before, .photo-drop:focus-within::before, .photo-drop:hover::after, .photo-drop:focus-within::after { border-color: var(--grass); width: 28px; height: 28px; }
#photoLabel { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); font-family: var(--body); font-weight: 600; font-size: var(--t-base); color: var(--dim); pointer-events: none; }
.photo-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-sm); }
.loc-btn { margin-top: var(--sp-4); width: 100%; font: inherit; font-weight: 600; font-size: var(--t-base); background: var(--paper-2); color: var(--ink); border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); min-height: 44px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); transition: background .22s ease, color .22s ease, border-color .22s ease; }
.loc-btn.set { border-color: var(--grass-2); color: var(--grass); background: var(--tint-grass); }
.loc-btn:hover:not(.set) { background: var(--paper); border-color: var(--ink); }
.loc-status { font-family: var(--body); font-size: var(--t-xs); color: var(--dim); line-height: 1.5; margin-top: var(--sp-2); }
.ts-row { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); display: flex; justify-content: center; min-height: 65px; }
.sheet-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-5); }
.btn { flex: 1; font: inherit; font-weight: 700; font-size: var(--t-base); border: none; border-radius: var(--r-sm); padding: .95rem var(--sp-4); min-height: 44px; cursor: pointer; transition: background .18s ease, transform .1s ease, box-shadow .18s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grass); color: var(--paper-2); box-shadow: 0 4px 14px -4px rgba(31,107,59,.55); }
.btn-primary:hover:not(:disabled) { background: var(--grass-2); }
.btn-primary:disabled { background: rgba(31,107,59,.32); color: rgba(255,253,248,.55); cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--dim); border: 1.5px solid var(--line-strong); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); border-color: var(--ink); }
.sheet-msg { margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); font-family: var(--body); font-size: var(--t-sm); line-height: 1.5; border-left: 3px solid transparent; }
.sheet-msg.ok { background: var(--tint-grass); color: var(--grass); border-left-color: var(--grass); }
.sheet-msg.warn { background: var(--tint-danger); color: var(--danger); border-left-color: var(--danger); }

/* the draggable report pin marker */
.report-pin { font-size: 2rem; cursor: grab; filter: drop-shadow(0 3px 4px rgba(16, 36, 27, 0.4)); }

/* ── About panel ────────────────────────────────────────────────────── */
.sheet.about { padding-top: var(--sp-2); }
.sheet.about h2 { margin-bottom: var(--sp-5); }
.sheet.about > p {
  font-family: var(--body);
  font-size: var(--t-base);
  line-height: 1.65;
  color: var(--ink);
  max-width: 52ch;
  margin-bottom: var(--sp-4);
}
.sheet.about ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4);
  margin-bottom: var(--sp-5);
  background: var(--tint-grass);
  border-left: 3px solid var(--grass);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.sheet.about li {
  font-family: var(--body);
  font-size: var(--t-sm);
  line-height: 1.6;
  color: var(--ink);
}
.sheet.about li b { color: var(--grass); font-weight: 700; }
.sheet.about #aboutClose { display: block; margin-left: auto; flex: none; min-width: 9rem; }

/* ── Admin moderation page ──────────────────────────────────────────────────────────────────── */
body.admin { overflow: auto; position: static; inset: unset; }
.admin-main { padding: calc(var(--topbar-h) + var(--sp-5)) var(--sp-4) var(--sp-6); max-width: 720px; margin-inline: auto; }
.admin-token { display: flex; flex-direction: column; gap: var(--sp-3); background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-5); }
.admin-token input { font: inherit; padding: var(--sp-3); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--paper-2); color: var(--ink); }
.admin-queue { display: grid; gap: var(--sp-4); }
.admin-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.admin-photo img, .admin-photo .placeholder { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.admin-photo .placeholder { display: grid; place-items: center; background: var(--paper); color: var(--dim); font-size: var(--t-sm); }
.admin-meta { display: flex; flex-wrap: wrap; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); font-size: var(--t-sm); color: var(--dim); }
.badge-flagged { color: var(--danger); font-weight: 700; }
.admin-actions { display: flex; gap: var(--sp-3); padding: 0 var(--sp-4) var(--sp-4); }
.admin-main .empty { position: static; transform: none; box-shadow: none; margin: var(--sp-5) auto; }

/* ── Reduced motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
  .sheet, .sheet-scrim, .fab, .loc-btn, .about-btn, .btn, .photo-drop {
    transition: none !important;
    animation: none !important;
  }
}
