/* Auckland Waste & Recycling Services — civic utility design system */

@font-face {
  font-family: 'Public Sans';
  src: url('../vendor/fonts/public-sans-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1c2b33;
  --ink-soft: #46555e;
  --ink-faint: #6b7a83;
  --paper: #fbfbf8;
  --paper-dim: #f1f2ec;
  --hairline: #dfe2da;
  --accent: #0b605a;
  --accent-ink: #084b46;
  --danger: #a33a24;
  --warn-bg: #fdf3e0;
  --warn-border: #e5c98a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 43, 51, .06), 0 4px 14px rgba(28, 43, 51, .07);
  --font: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}
#app { display: flex; flex-direction: column; height: 100dvh; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* ---------- Header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--hairline);
  z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { display: grid; place-items: center; flex: none; }
.brand-text h1 { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; margin: 0; white-space: nowrap; }
.brand-sub { margin: 1px 0 0; font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }
.header-controls { display: flex; align-items: center; gap: 10px; }

/* ---------- Status chip ---------- */
.data-status { position: relative; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper-dim);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}
.status-chip:hover { background: #eaecdf; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.is-live .status-dot { background: #1c8a4e; box-shadow: 0 0 0 3px rgba(28, 138, 78, .15); }
.is-cached .status-dot { background: #2b6cb0; box-shadow: 0 0 0 3px rgba(43, 108, 176, .13); }
.is-stale .status-dot { background: #c07f16; box-shadow: 0 0 0 3px rgba(192, 127, 22, .15); }
.is-snapshot .status-dot { background: #706aa8; box-shadow: 0 0 0 3px rgba(112, 106, 168, .15); }
.is-checking .status-dot { background: var(--ink-faint); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.status-age { font-weight: 500; color: var(--ink-faint); }

.status-popover {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: min(420px, calc(100vw - 32px));
  background: #fff; border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  z-index: 1300;
}
.status-popover-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.status-table { margin: 0; }
.status-table > div { display: flex; gap: 12px; padding: 4.5px 0; border-top: 1px solid #eef0e8; }
.status-table > div:first-child { border-top: 0; }
.status-table dt { flex: none; width: 132px; font-size: 11.5px; color: var(--ink-faint); padding-top: 1px; }
.status-table dd { margin: 0; font-size: 12.5px; overflow-wrap: anywhere; }
.status-footnote { font-size: 11.5px; color: var(--ink-faint); margin: 10px 0 0; }

/* ---------- Layout ---------- */
.app-body { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 392px; flex: none;
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--hairline);
}
.sidebar > * { flex-shrink: 0; }
.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #e9edea; }

/* ---------- Search ---------- */
.search-box { position: relative; z-index: 1200; }
.search-input {
  width: 100%;
  font: inherit;
  padding: 11px 38px 11px 38px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-input::placeholder { color: var(--ink-faint); }
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); pointer-events: none; display: grid; place-items: center;
}
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink-faint);
  font-size: 17px; cursor: pointer; line-height: 1;
}
.search-clear:hover { background: var(--paper-dim); color: var(--ink); }
.search-box.is-loading::after {
  content: ''; position: absolute; right: 36px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--hairline); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto;
}
.search-results li {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 10px; border-radius: 7px; cursor: pointer;
}
.search-results li:hover, .search-results li.is-active { background: var(--paper-dim); }
.result-icon { color: var(--ink-faint); margin-top: 1px; flex: none; }
.result-text { display: flex; flex-direction: column; min-width: 0; }
.result-address { font-size: 13px; font-weight: 550; }
.result-locality { font-size: 11.5px; color: var(--ink-faint); }
.search-empty { cursor: default !important; color: var(--ink-soft); font-size: 13px; }
.search-empty:hover { background: transparent !important; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 13px 14px;
}
.card-title {
  margin: 0 0 9px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint);
}

/* ---------- Legend ---------- */
.legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.legend-item { display: flex; gap: 10px; padding: 7px 2px; cursor: pointer; border-radius: 7px; align-items: flex-start; }
.legend-item:hover { background: var(--paper-dim); }
.legend-item input { margin: 3px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; cursor: pointer; }
.swatch { width: 13px; height: 13px; border-radius: 4px; flex: none; margin-top: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.legend-text { display: flex; flex-direction: column; min-width: 0; }
.legend-label { font-size: 13px; font-weight: 600; }
.legend-count { font-size: 11px; color: var(--ink-faint); }
.legend-blurb { font-size: 11.5px; color: var(--ink-soft); margin-top: 1px; }

/* ---------- Details panel ---------- */
.details { min-height: 96px; }
.panel-idle h3, .panel-loading h3 { margin: 0 0 6px; font-size: 14px; }
.panel-idle p { margin: 0; font-size: 12.5px; color: var(--ink-soft); }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.panel-header h3 { margin: 0; font-size: 14px; }
.panel-context { margin: 2px 0 0; font-size: 11.5px; color: var(--ink-faint); overflow-wrap: anywhere; }

.svc-family { margin-top: 10px; }
.svc-family-title {
  display: flex; align-items: center; gap: 7px;
  margin: 0 0 4px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
}
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.svc-rows { list-style: none; margin: 0; padding: 0; }
.svc-row { border-top: 1px solid #eef0e8; padding: 7px 0; }
.svc-row-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.row-main { font-size: 13.5px; font-weight: 650; }
.row-note { flex-basis: 100%; font-size: 12px; color: var(--ink-soft); }
.warn-note { flex-basis: 100%; font-size: 12px; color: #8a5a00; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 6px; padding: 5px 8px; margin-top: 4px; }
.badges { display: inline-flex; gap: 5px; margin-right: 6px; vertical-align: middle; }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 999px;
}
.badge-day { background: #e3efe9; color: #14523c; }
.badge-week { background: #e8ecf7; color: #2c4a86; }
.code-chip {
  font-size: 10.5px; font-weight: 600; color: var(--ink-faint);
  border: 1px solid var(--hairline); border-radius: 5px; padding: 1.5px 6px;
  margin-left: auto; white-space: nowrap;
}
.attr-toggle {
  font: inherit; font-size: 11px; font-weight: 600; color: var(--accent);
  background: none; border: 0; padding: 2px 4px; cursor: pointer; border-radius: 5px;
}
.attr-toggle:hover { background: var(--paper-dim); }
.attr-table { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 11.5px; }
.attr-table th { text-align: left; color: var(--ink-faint); font-weight: 600; padding: 2.5px 8px 2.5px 0; width: 90px; vertical-align: top; }
.attr-table td { margin: 0; padding: 2.5px 0; overflow-wrap: anywhere; }
.panel-footnote { font-size: 11px; color: var(--ink-faint); margin: 12px 0 0; border-top: 1px solid #eef0e8; padding-top: 8px; }

/* ---------- States ---------- */
.panel-loading .skeleton {
  height: 13px; border-radius: 6px; margin-top: 9px;
  background: linear-gradient(100deg, #eceee6 40%, #f7f8f2 50%, #eceee6 60%);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
.skeleton-short { width: 62%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty-state { text-align: center; padding: 18px 8px 10px; color: var(--ink-soft); }
.empty-state svg { color: var(--ink-faint); }
.empty-state h3 { margin: 10px 0 6px; font-size: 14px; color: var(--ink); }
.empty-state p { margin: 0 0 8px; font-size: 12.5px; }
.empty-hint { color: var(--ink-faint); }
.coords-note { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.error-state { text-align: center; padding: 16px 8px; }
.error-state h3 { margin: 0 0 6px; font-size: 14px; color: var(--danger); }
.error-state p { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 10px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: #fff; background: var(--accent);
  border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer;
}
.btn:hover { background: var(--accent-ink); }
.btn-small { padding: 5px 11px; font-size: 11.5px; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--hairline); }
.btn-ghost:hover { background: var(--paper-dim); }

/* ---------- Sidebar footer ---------- */
.sidebar-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--hairline); }
.sidebar-footer p { margin: 0 0 4px; font-size: 11px; color: var(--ink-faint); }
.sidebar-footer a { color: var(--accent); }

/* ---------- Map overlays ---------- */
.coord-readout {
  position: absolute; bottom: 34px; left: 10px; z-index: 900;
  font-size: 10.5px; font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  background: rgba(255,255,255,.88);
  border: 1px solid var(--hairline); border-radius: 6px;
  padding: 2px 8px;
  pointer-events: none;
}
.offline-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  max-width: min(680px, calc(100% - 24px));
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 9px 14px;
  font-size: 12.5px; color: #5c4300;
}
.banner-actions { display: inline-flex; gap: 8px; }
.offline-banner .btn-ghost { border-color: var(--warn-border); color: #5c4300; }
.tile-notice {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%);
  z-index: 900;
  background: rgba(28,43,51,.85); color: #fff;
  font-size: 11.5px; border-radius: 999px; padding: 5px 14px;
  pointer-events: none;
}
.acw-pin { filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.acw-pin-inner { line-height: 0; }

.locate-btn { display: grid; place-items: center; color: var(--ink-soft); }
.locate-btn:hover { color: var(--ink); }

.legend-fab { display: none; }

/* ---------- Leaflet tweaks ---------- */
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.82); }
.leaflet-bar a { color: var(--ink-soft); }
.leaflet-tooltip { font-family: var(--font); font-size: 12px; }

/* ---------- Mobile sheets ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--hairline);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 30px rgba(28,43,51,.18);
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .22s ease-out;
  z-index: 1400;
  max-height: 72dvh; overflow-y: auto;
}
.sheet.is-open { transform: translateY(0); }
.sheet-handle-row { display: flex; align-items: center; justify-content: center; position: relative; margin-bottom: 6px; }
.sheet-handle { width: 42px; height: 4.5px; border-radius: 999px; background: var(--hairline); }
.sheet-close {
  position: absolute; right: -6px; top: -4px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: transparent; font-size: 21px; color: var(--ink-faint); cursor: pointer;
}
.sheet-close:hover { background: var(--paper-dim); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .app-body { position: relative; }
  .sidebar { display: none; }
  .map-wrap { flex: 1; }

  /* Keep Leaflet controls clear of the floating search bar */
  .leaflet-top { top: 64px; }

  .app-header { padding: 8px 12px; }
  .brand-sub { display: none; }
  .brand-text h1 { font-size: 13.5px; white-space: normal; line-height: 1.25; }

  /* Floating search over map */
  .search-box {
    position: fixed; top: calc(env(safe-area-inset-top) + 56px);
    left: 10px; right: 10px; z-index: 1150;
  }
  .search-results { max-height: 44dvh; }

  .legend-fab {
    display: inline-flex; align-items: center; gap: 6px;
    position: absolute; bottom: 46px; right: 10px; z-index: 1000; top: auto;
    font: inherit; font-size: 12.5px; font-weight: 600;
    color: var(--ink-soft);
    background: #fff; border: 1px solid var(--hairline); border-radius: 999px;
    padding: 9px 16px; min-height: 44px; cursor: pointer;
    box-shadow: var(--shadow);
  }
  .coord-readout { display: none; }
  .offline-banner { top: auto; bottom: 100px; }
  .tile-notice { bottom: auto; top: 118px; }
  .sheet-details { max-height: 66dvh; }
}

@media (max-width: 480px) {
  .status-label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .status-age { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
