/* ParkVision P4 — public client styles.
   Self-contained (no external fonts/assets), responsive, WCAG AA contrast, and
   theme-aware (light default + prefers-color-scheme: dark). State is ALWAYS conveyed
   by icon + text as well as colour (FR-P4-9) — never colour alone. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #14181f;
  --text-muted: #4a5461;
  --border: #d4dae2;
  --brand: #0b5cad;
  --brand-ink: #ffffff;
  --focus: #0b5cad;

  /* State colours — all AA against their light text/backgrounds. */
  --avail: #1a7f37;
  --avail-bg: #e6f4ea;
  --limited: #8a5300;
  --limited-bg: #fbf1de;
  --full: #b02a37;
  --full-bg: #fbe6e8;
  --stale: #55606e;
  --stale-bg: #e9edf2;

  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 24, 31, 0.08), 0 4px 14px rgba(20, 24, 31, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c232d;
    --text: #eaeef4;
    --text-muted: #a7b1bd;
    --border: #2a323d;
    --brand: #4c9be8;
    --brand-ink: #06121f;
    --focus: #79b8ff;
    --avail: #4ac06a;
    --avail-bg: #12301c;
    --limited: #e2b23c;
    --limited-bg: #332a12;
    --full: #f28b93;
    --full-bg: #35171a;
    --stale: #9aa4b1;
    --stale-bg: #20262f;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

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

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--brand); color: var(--brand-ink); padding: 10px 14px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------- header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(14px, 4vw, 40px);
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 22px;
}
.app-header h1 { font-size: clamp(1.1rem, 2.6vw, 1.4rem); margin: 0; letter-spacing: -0.01em; }
.tagline { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.last-updated {
  font-size: 0.85rem; color: var(--text-muted); white-space: nowrap;
  background: var(--surface-2); padding: 6px 10px; border-radius: 999px;
}

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 10px;
  margin: 12px clamp(14px, 4vw, 40px) 0; padding: 10px 14px;
  background: var(--limited-bg); color: var(--limited);
  border: 1px solid color-mix(in srgb, var(--limited) 40%, transparent);
  border-radius: 10px; font-size: 0.92rem; font-weight: 600;
}
.banner[hidden] { display: none; }
.banner-icon { font-size: 1.1rem; }

/* ---------- layout ---------- */
.app-main { padding: clamp(14px, 4vw, 40px); max-width: 1180px; margin: 0 auto; }
.section-heading { font-size: 1.05rem; margin: 26px 0 12px; }

/* ---------- filters ---------- */
.filter-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); transition: background .12s, border-color .12s;
}
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] {
  background: var(--brand); color: var(--brand-ink); border-color: var(--brand);
}
.summary { color: var(--text-muted); font-size: 0.9rem; font-weight: 600; }

/* ---------- map ---------- */
.map-figure { margin: 0; }
.map {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.map svg { display: block; width: 100%; height: auto; }
.map-legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px;
  color: var(--text-muted); font-size: 0.85rem;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ---------- site grid ---------- */
.site-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-name { margin: 0; font-size: 1.05rem; font-weight: 700; }
.card-area { color: var(--text-muted); font-size: 0.82rem; text-transform: capitalize; }

.avail-line { display: flex; align-items: baseline; gap: 8px; }
.avail-number { font-size: 2.4rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.avail-total { color: var(--text-muted); font-size: 1rem; font-weight: 600; }
.avail-label { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; }

/* Occupancy meter — width by %, but state is also labelled in text (not colour-only). */
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--text-muted); transition: width .3s; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.updated { color: var(--text-muted); font-size: 0.8rem; }

/* state chip: icon + text + colour (belt & suspenders for FR-P4-9) */
.state {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.82rem;
  padding: 5px 10px; border-radius: 999px; border: 1.5px solid transparent;
}
.state-icon { font-size: 0.9rem; }
.state--available { color: var(--avail); background: var(--avail-bg); border-color: color-mix(in srgb, var(--avail) 35%, transparent); }
.state--limited   { color: var(--limited); background: var(--limited-bg); border-color: color-mix(in srgb, var(--limited) 35%, transparent); }
.state--full      { color: var(--full); background: var(--full-bg); border-color: color-mix(in srgb, var(--full) 35%, transparent); }
.state--stale,
.state--unknown   { color: var(--stale); background: var(--stale-bg); border-color: color-mix(in srgb, var(--stale) 35%, transparent); }
.card.is-stale { opacity: 0.82; }
.card.is-stale .meter-fill { background: repeating-linear-gradient(45deg, var(--stale) 0 6px, transparent 6px 12px); }

.empty { color: var(--text-muted); padding: 20px 0; }

/* ---------- footer ---------- */
.app-footer {
  max-width: 1180px; margin: 20px auto 40px; padding: 0 clamp(14px, 4vw, 40px);
  color: var(--text-muted); font-size: 0.82rem;
}
.provenance { font-size: 0.72rem; opacity: 0.8; word-break: break-word; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
