/* Palette roles from the validated reference palette; state colors follow
   the salience inversion: `free` (rare, the point) is strongest, `booked`
   (the mass) is recessive. Locked is never hue-alone: stripes. */
:root {
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --link: #1c5cab;

  --st-free: #0ca30c;
  --st-locked: #fab219;
  --st-locked-stripe: #8a6510;
  --st-walkin: #2a78d6;
  /* unavailable family: a dull lightness ladder — out-of-season nearly
     invisible, booked quiet, closed clearly dark — so free/locked pop */
  --st-booked: #e0dfd6;
  --st-closed: #a6a49b;
  --st-oos: #f6f5f2;
  --glyph-on-quiet: #52514e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --link: #86b6ef;

    --st-walkin: #3987e5;
    --st-booked: #31312d;
    --st-closed: #54534d;
    --st-oos: #1f1f1e;
    --glyph-on-quiet: #c3c2b7;
  }
}

* { box-sizing: border-box; }
/* Any author display rule (e.g. .dropdown-menu label { display: flex })
   silently defeats the hidden attribute; this keeps hidden meaning hidden. */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  line-height: 1.45;
}
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
a { color: var(--link); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }

.site-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 1rem; background: var(--surface);
  border-bottom: 1px solid var(--grid);
}
.site-header .brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.site-header nav a { margin-left: 1rem; }
.site-footer {
  max-width: 1200px; margin: 2rem auto; padding: 0 1rem 2rem;
  color: var(--muted); font-size: 0.85rem;
}
.site-footer p { margin: 0.3rem 0; }
.site-footer .footer-links a { color: var(--muted); }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem; margin: 1rem 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.cal-nav a { margin-left: 0.75rem; }
.month-jump {
  margin-left: 0.75rem; padding: 0.2rem 0.4rem;
  border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); color: var(--ink); font-size: 0.9rem;
}
.refresh-btn {
  margin-left: 0.75rem; padding: 0.2rem 0.6rem; cursor: pointer;
  border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); color: var(--link); font-weight: 600;
}
.refresh-btn:hover { border-color: var(--link); }
.hint { color: var(--muted); font-size: 0.9rem; }
.callout {
  background: var(--st-oos); border: 1px solid var(--grid);
  padding: 0.5rem 0.8rem; border-radius: 6px;
}

/* Park picker */
.picker-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; }
#park-search, #state-filter {
  padding: 0.5rem 0.7rem; font-size: 1rem;
  border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); color: var(--ink);
}
#park-search { flex: 1 1 14rem; max-width: 28rem; }
.state-tag { font-size: 0.75rem; color: var(--muted); margin-left: 0.2rem; }
#search-results { margin: 0.4rem 0; max-width: 28rem; }
.state-grid {
  list-style: none; padding: 0; display: grid; gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  grid-auto-rows: 1fr;
}
.state-grid a {
  display: block; height: 100%; padding: 0.55rem 0.8rem; text-decoration: none;
  border: 1px solid var(--grid); border-radius: 8px; background: var(--surface);
}
.state-grid a:hover { border-color: var(--link); }
.state-grid .state-name { display: block; font-weight: 600; }
.state-grid .state-count { display: block; min-height: 1.3em; }
.breadcrumb { margin-bottom: 0; }
/* Alerts management */
.alerts-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.alerts-table th, .alerts-table td {
  text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--grid);
  vertical-align: top;
}
.alerts-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.alert-paused td { color: var(--ink-2); }
.alert-actions { white-space: nowrap; }
.alert-actions form { display: inline-block; margin-right: 0.3rem; }
.alert-actions button.danger { color: #b3261e; border-color: #b3261e; }
.alert-edit-row td { padding-top: 0; }
.alert-edit-row summary { cursor: pointer; color: var(--link); font-size: 0.85rem; }
.alert-edit-form { margin: 0.5rem 0 0.25rem; align-items: flex-end; }

.reservable-toggle {
  display: flex; align-items: center; gap: 0.4rem;
  margin: 0.5rem 0; font-size: 0.9rem; cursor: pointer;
}
.park-list { list-style: none; padding: 0; }
.park-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--grid); }
.park-list .untracked { color: var(--ink-2); }
.badge {
  font-size: 0.7rem; padding: 0.1rem 0.45rem; border-radius: 99px;
  border: 1px solid var(--border); color: var(--ink-2); vertical-align: middle;
}
.badge-tracked { background: var(--st-free); color: #fff; border: none; }
.badge-bookable { background: var(--st-free); color: #fff; border: none; }
.badge-pending {
  background: var(--st-locked); color: #0b0b0b; border: none;
  background-image: repeating-linear-gradient(45deg,
    transparent 0 4px, rgba(138, 101, 16, 0.35) 4px 6px);
}
.badge-stitched { background: var(--st-walkin); color: #fff; border: none; }

/* Heatmap */
.heatmap-scroll { overflow-x: auto; }
.heatmap { border-collapse: collapse; font-size: 0.75rem; }
.heatmap th { font-weight: 500; color: var(--ink-2); }
.heatmap thead th {
  text-align: center; padding: 2px 1px; vertical-align: bottom;
}
.heatmap thead th .dow { display: block; color: var(--muted); font-size: 0.65rem; }
.heatmap thead th .dom { display: block; font-variant-numeric: tabular-nums; }
.heatmap thead th .mon { display: block; font-weight: 700; color: var(--ink); }
.heatmap thead th.weekend .dom { font-weight: 700; color: var(--ink); }
.heatmap thead th.today .dom {
  background: var(--link); color: var(--surface); border-radius: 99px;
}
.heatmap .rowhead {
  position: sticky; left: 0; background: var(--surface); text-align: left;
  padding: 0 8px 0 2px; max-width: 11rem; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; z-index: 1;
}
.facility-row th {
  text-align: left; padding: 10px 2px 4px; color: var(--ink);
  font-weight: 700; font-size: 0.85rem;
  position: sticky; left: 0; background: var(--surface);
}
.facility-row .ext { font-weight: 400; font-size: 0.75rem; margin-left: 0.5rem; }
.heatmap td { padding: 1px; }

.cell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 4px;
  font-size: 0.65rem; font-weight: 700; color: var(--glyph-on-quiet);
  border: 1px solid var(--border);
}
.legend .cell { width: 14px; height: 14px; margin-right: 2px; vertical-align: text-bottom; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin: 0.6rem 0; font-size: 0.8rem; color: var(--ink-2); }

.c-free { background: var(--st-free); border-color: var(--st-free); }
a.c-free:hover { outline: 2px solid var(--ink); }
.c-locked {
  background: var(--st-locked); border-color: var(--st-locked);
  background-image: repeating-linear-gradient(45deg,
    transparent 0 4px, var(--st-locked-stripe) 4px 6px);
}
.c-walkin { background: var(--st-walkin); border-color: var(--st-walkin); color: #fff; }
.c-booked { background: var(--st-booked); }
.c-blocked { background: var(--st-booked); }
.c-closed { background: var(--st-closed); }
.c-oos { background: var(--st-oos); border-style: dashed; }
.c-nodata { background: transparent; border-style: dotted; }

/* Results tables & forms */
.results { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.results th, .results td {
  text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--grid);
}
.results th { color: var(--muted); font-weight: 500; }
.inline-form { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.75rem; }
.inline-form input[type="number"] { width: 4rem; }
.inline-form input, .inline-form button {
  padding: 0.3rem 0.5rem; border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); color: var(--ink); font-size: 0.9rem;
}
.inline-form button { cursor: pointer; font-weight: 600; }
.inline-form button:hover { border-color: var(--link); }
.htmx-indicator { opacity: 0; transition: opacity 150ms; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.filter-form { display: grid; gap: 0.5rem; margin-bottom: 0.75rem; }
.filter-more summary { cursor: pointer; color: var(--link); font-size: 0.9rem; }
.filter-more .inline-form { margin: 0.5rem 0 0; align-items: flex-start; }
.filter-form fieldset {
  border: 1px solid var(--grid); border-radius: 6px; padding: 0.3rem 0.6rem;
  display: flex; gap: 0.8rem; flex-wrap: wrap; font-size: 0.9rem;
}
.filter-form legend { color: var(--muted); font-size: 0.8rem; padding: 0 0.3rem; }
.dropdown { position: relative; }
.dropdown summary {
  cursor: pointer; list-style: none; padding: 0.3rem 0.6rem;
  border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); font-size: 0.9rem; user-select: none;
}
.dropdown summary::after { content: " ▾"; color: var(--muted); }
.dropdown[open] summary { border-color: var(--link); }
.dropdown-count { color: var(--link); font-weight: 700; }
.dropdown-menu {
  position: absolute; z-index: 10; top: calc(100% + 4px); left: 0;
  min-width: 16rem; max-height: 15rem; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--grid);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  padding: 0.5rem 0.7rem; display: grid; gap: 0.3rem; font-size: 0.9rem;
}
.dropdown-menu label { display: flex; gap: 0.45rem; align-items: center; white-space: nowrap; }
.dropdown-filter {
  padding: 0.25rem 0.4rem; border: 1px solid var(--grid); border-radius: 5px;
  background: var(--surface); color: var(--ink); font-size: 0.85rem;
  position: sticky; top: 0;
}

/* Site detail card */
.sitelink {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--link); cursor: pointer; text-align: left;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sitelink:hover { text-decoration: underline; }
#site-modal {
  width: min(92vw, 560px); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; background: var(--surface); color: var(--ink);
}
#site-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
.site-card-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.site-card-head h3 { margin: 0 0 0.5rem; }
.site-facts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: 0.95rem; margin-bottom: 0.5rem; }
.site-description { font-size: 0.9rem; color: var(--ink-2); margin: 0.5rem 0; }
.site-amenities {
  columns: 2; font-size: 0.9rem; padding-left: 1.2rem; margin: 0.3rem 0;
}
.site-card h4 { margin: 0.6rem 0 0.2rem; font-size: 0.95rem; }

/* Cancellation stats strip */
.cancel-stats {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem;
  padding: 0.5rem 0.8rem; margin-bottom: 0.5rem;
  background: var(--st-oos); border: 1px solid var(--grid); border-radius: 8px;
  font-size: 0.9rem;
}

/* Park map modal — near fullscreen, map fills the free space */
#map-modal {
  width: 96vw; height: 94vh; max-width: 96vw; max-height: 94vh;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.8rem; background: var(--surface); color: var(--ink);
}
#map-modal[open] { display: flex; flex-direction: column; }
#map-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
.map-head {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.map-head button { margin-left: auto; }
.map-head input[type="date"] {
  padding: 0.2rem 0.4rem; border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); color: var(--ink);
}
#map-canvas { flex: 1; min-height: 0; border-radius: 8px; }
.map-legend { margin-top: 0.6rem; flex: none; }

.feed { list-style: none; padding: 0; font-size: 0.9rem; }
.feed li { padding: 0.3rem 0; border-bottom: 1px solid var(--grid); }
.feed time { color: var(--muted); margin-right: 0.5rem; font-variant-numeric: tabular-nums; }
.feed .cell { width: 12px; height: 12px; margin-right: 4px; }
.stitched-plan li { margin: 0.25rem 0; }

/* ---- accounts (login / profile / admin) ---- */
.site-header nav { display: flex; align-items: center; flex-wrap: wrap; }
.logout-form { display: inline; margin-left: 1rem; }
.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--link); text-decoration: underline; font: inherit;
}
.auth-panel { max-width: 26rem; }
.stacked-form { display: flex; flex-direction: column; gap: 0.9rem; align-items: flex-start; }
.stacked-form > label { display: flex; flex-direction: column; gap: 0.25rem; min-width: 16rem; }
.stacked-form input[type="text"], .stacked-form input[type="password"],
.stacked-form input[type="email"] {
  padding: 0.35rem 0.5rem; border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); color: var(--ink);
}
.stacked-form button {
  padding: 0.4rem 0.9rem; border: 1px solid var(--grid); border-radius: 6px;
  background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 600;
}
.stacked-form button:hover { border-color: var(--link); }
.stacked-form fieldset {
  border: 1px solid var(--grid); border-radius: 8px;
  padding: 0.6rem 0.9rem 0.9rem; display: flex; flex-direction: column;
  gap: 0.4rem; align-items: flex-start; min-width: 20rem;
}
.stacked-form fieldset .hint { font-size: 0.85rem; color: var(--muted); }
.stacked-form fieldset label { display: flex; flex-direction: column; gap: 0.25rem; }
.stacked-form fieldset label:first-of-type { flex-direction: row; gap: 0.4rem; align-items: center; }

/* Favorites */
.inline-form { display: inline; }
h1 .fav-toggle { font-size: 0.55em; vertical-align: middle; margin-left: 0.5em; }
