/* RV & Camping Mexico — one stylesheet for every page.
   Palette: desert sand, agave green, sunset clay. Dark mode included. */

:root {
  --sand-50: #fbf7f0;
  --sand-100: #f4ece0;
  --sand-200: #e7d9c5;
  --sand-300: #d4bfa3;
  --ink-900: #1d1a16;
  --ink-700: #3c362e;
  --ink-500: #6b6155;
  --ink-300: #9a8f80;
  --agave-700: #1f5c4a;
  --agave-600: #2a7a61;
  --agave-500: #3a9b7c;
  --agave-100: #d9ece4;
  --clay-600: #c2582b;
  --clay-500: #e06a35;
  --clay-100: #fbe4d7;
  --sky-600: #2f6f94;
  --sky-100: #dcebf4;
  --danger-600: #b3291e;
  --danger-100: #fbdedb;

  --bg: var(--sand-50);
  --bg-raised: #ffffff;
  --bg-sunken: var(--sand-100);
  --border: var(--sand-200);
  --border-strong: var(--sand-300);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --accent: var(--agave-600);
  --accent-soft: var(--agave-100);
  --warm: var(--clay-600);
  --warm-soft: var(--clay-100);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(29, 26, 22, 0.06), 0 8px 24px rgba(29, 26, 22, 0.06);
  --nav-height: 64px;
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --bg-raised: #1d1a16;
    --bg-sunken: #100e0c;
    --border: #322c25;
    --border-strong: #4a4137;
    --text: #f4ece0;
    --text-muted: #a99d8d;
    --accent: #4bb995;
    --accent-soft: #14352c;
    --warm: #ef8250;
    --warm-soft: #3a2015;
    --danger-100: #3a1512;
    --sky-100: #16303e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

/* overflow-x belongs on <html>. On <body> it silently kills position: sticky. */
html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 2rem); }
p { margin: 0 0 1em; }

.container {
  width: min(1240px, 100% - 32px);
  margin-inline: auto;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ navbar */

.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.25s ease, background 0.25s ease;
}
.navbar.scrolled { box-shadow: var(--shadow); }

.navbar-inner {
  display: flex; align-items: center; gap: 16px;
  min-height: var(--nav-height);
  width: min(1240px, 100% - 32px); margin-inline: auto;
}

.navbar-brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit; padding: 6px; margin: -6px; border-radius: var(--radius);
}
.navbar-brand:hover { background: var(--bg-sunken); }
.navbar-logo { width: 38px; height: 38px; flex: none; }
.navbar-brand-name { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.navbar-brand-tagline { font-size: 0.78rem; color: var(--text-muted); }

.navbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.navbar-links { display: flex; gap: 4px; }
.navbar-links a {
  color: var(--text-muted); text-decoration: none; padding: 8px 12px;
  border-radius: var(--radius-sm); font-size: 0.92rem; font-weight: 550;
}
.navbar-links a:hover, .navbar-links a.active { color: var(--text); background: var(--bg-sunken); }

/* The login control is a person silhouette, per the brief. */
.avatar-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--bg-raised);
  display: grid; place-items: center; cursor: pointer; color: var(--text-muted);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.avatar-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.avatar-btn svg { width: 22px; height: 22px; }
.avatar-initials { font-weight: 700; font-size: 0.85rem; color: var(--accent); }

section[id] { scroll-margin-top: calc(var(--nav-height) + 24px); }

/* ---------------------------------------------------------- lang selector */

.lang-selector-wrapper { position: relative; }
.lang-selector-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer;
  color: var(--text); font-size: 0.86rem; font-weight: 600; font-family: inherit;
}
.lang-selector-btn:hover { border-color: var(--accent); }
.lang-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 1100; overflow: hidden;
}
.lang-dropdown.open { display: block; }
.lang-search { padding: 8px; border-bottom: 1px solid var(--border); }
.lang-search input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-family: inherit;
}
.lang-list { list-style: none; margin: 0; padding: 4px; max-height: 320px; overflow-y: auto; }
.lang-list li {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9rem;
}
.lang-list li:hover { background: var(--bg-sunken); }
.lang-list li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.lang-endonym { color: var(--text-muted); font-size: 0.82rem; margin-left: auto; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 0.94rem; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff; transition: filter 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.btn-secondary { background: var(--bg-raised); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-sunken); }
.btn-warm { background: var(--warm); }
.btn-danger { background: var(--danger-600); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------- forms */

label { display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 5px; }
.field { margin-bottom: 16px; }
.hint { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], input[type="date"], input[type="url"], input[type="tel"], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 0.94rem;
  color: var(--text); background: var(--bg-raised);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible,
.avatar-btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 0 16px; }
legend { font-weight: 650; font-size: 0.86rem; padding: 0 6px; }

.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; }
.checkgrid label { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 0.88rem; margin: 0; }
.checkgrid input { width: auto; }

.alert {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 0.9rem;
  border: 1px solid transparent; margin-bottom: 14px;
}
.alert-error { background: var(--danger-100); border-color: var(--danger-600); color: var(--danger-600); }
.alert-ok { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.alert:empty { display: none; }

/* ------------------------------------------------------------------ splash */

.hero {
  padding: clamp(48px, 8vw, 96px) 0 48px;
  background:
    radial-gradient(1200px 400px at 12% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 400px at 92% 0%, var(--warm-soft), transparent 55%);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.hero p.lede { font-size: 1.12rem; color: var(--text-muted); max-width: 56ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); }
.stat-label { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.section { padding: 56px 0; }
.section-sunken { background: var(--bg-sunken); border-block: 1px solid var(--border); }
.section-head { margin-bottom: 28px; max-width: 70ch; }
.section-head p { color: var(--text-muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.card p { color: var(--text-muted); font-size: 0.92rem; margin: 0; }

.state-bars { display: grid; gap: 8px; }
.state-bar { display: grid; grid-template-columns: 190px 1fr 56px; align-items: center; gap: 12px; font-size: 0.9rem; }
.state-bar .track { background: var(--bg-sunken); border-radius: 999px; height: 12px; overflow: hidden; border: 1px solid var(--border); }
.state-bar .fill { background: linear-gradient(90deg, var(--agave-500), var(--agave-700)); height: 100%; }
.state-bar .count { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

footer.site-footer {
  border-top: 1px solid var(--border); padding: 32px 0; color: var(--text-muted); font-size: 0.86rem;
}
footer.site-footer a { color: var(--text-muted); }

/* ------------------------------------------------------------------- login */

.auth-shell { display: grid; place-items: center; min-height: calc(100vh - var(--nav-height)); padding: 32px 16px; }
.auth-card {
  width: min(430px, 100%); background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.6rem; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.8rem; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* --------------------------------------------------------------- app shell */

.app-shell { display: grid; grid-template-columns: 296px minmax(0, 1fr); gap: 20px; align-items: start; padding: 20px 0 48px; }
.sidebar {
  position: sticky; top: calc(var(--nav-height) + 16px);
  max-height: calc(100vh - var(--nav-height) - 32px); overflow-y: auto;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.sidebar h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 18px 0 8px; }
.sidebar h3:first-child { margin-top: 0; }

.facet-group { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 12px; }
.facet-group:last-child { border-bottom: none; }
.facet-values { display: grid; gap: 3px; max-height: 260px; overflow-y: auto; }
.facet-row { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; padding: 3px 4px; border-radius: var(--radius-sm); cursor: pointer; }
.facet-row:hover { background: var(--bg-sunken); }
.facet-row input { width: auto; margin: 0; }
.facet-count { margin-left: auto; color: var(--text-muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.range-row { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.range-row input { padding: 6px 8px; font-size: 0.85rem; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 14px;
}
.toolbar .search { flex: 1 1 260px; }
.result-count { color: var(--text-muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.view-toggle { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { border: none; background: var(--bg-raised); color: var(--text-muted); padding: 8px 14px; cursor: pointer; font: inherit; font-size: 0.86rem; }
.view-toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.table-wrap { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table.results { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.results th, table.results td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.results thead th {
  position: sticky; top: 0; background: var(--bg-sunken); z-index: 2;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  cursor: pointer; white-space: nowrap;
}
table.results tbody tr:hover { background: var(--bg-sunken); }
table.results tbody tr.selected { background: var(--accent-soft); }
table.results td.name { font-weight: 600; }
table.results td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; text-align: left; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 650; border: 1px solid transparent; white-space: nowrap;
}
.badge-open { background: var(--accent-soft); color: var(--accent); }
.badge-active { background: var(--sky-100); color: var(--sky-600); }
.badge-seasonal { background: var(--warm-soft); color: var(--warm); }
.badge-temporarily_closed { background: var(--warm-soft); color: var(--warm); }
.badge-closed { background: var(--danger-100); color: var(--danger-600); }
.badge-unknown, .badge-none { background: var(--bg-sunken); color: var(--text-muted); }
.badge-user { background: var(--sky-100); color: var(--sky-600); }

.completeness { display: flex; align-items: center; gap: 6px; }
.completeness .track { width: 46px; height: 6px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.completeness .fill { height: 100%; background: var(--accent); }

#map, #splash-map { height: 560px; border-radius: var(--radius); border: 1px solid var(--border); }
.leaflet-container { background: var(--bg-sunken); font: inherit; }

/* ------------------------------------------------------------ detail panel */

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--bg-raised); border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18); z-index: 1200;
  display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform 0.22s ease;
}
.drawer.open { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head h2 { margin: 0; font-size: 1.25rem; }
.drawer-body { padding: 18px 20px 40px; overflow-y: auto; flex: 1; }
.drawer-close { margin-left: auto; }

.detail-section { margin-bottom: 22px; }
.detail-section h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 8px; }
.detail-grid { display: grid; grid-template-columns: 132px 1fr; gap: 6px 14px; font-size: 0.9rem; }
.detail-grid dt { color: var(--text-muted); }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 0.8rem; }

.note {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 10px; background: var(--bg-sunken); font-size: 0.9rem;
}
.note-meta { font-size: 0.76rem; color: var(--text-muted); display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-actions { display: flex; gap: 6px; margin-top: 6px; }

.list-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.list-card h4 { margin: 0 0 2px; font-size: 0.98rem; }
.list-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ------------------------------------------------------------------ modal */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 18, 15, 0.55);
  display: none; place-items: center; z-index: 1300; padding: 24px;
}
.modal-backdrop.open { display: grid; }
.modal {
  width: min(760px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--bg-raised); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

.table-simple { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table-simple th, .table-simple td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table-simple th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

.muted { color: var(--text-muted); }
.small { font-size: 0.84rem; }
.mono { font-family: var(--mono); font-size: 0.84rem; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hidden { display: none !important; }

@media (max-width: 1000px) {
  .hero-grid { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .state-bar { grid-template-columns: 130px 1fr 48px; }
}
@media (max-width: 640px) {
  .navbar-links { display: none; }
  .container { width: calc(100% - 24px); }
  #map, #splash-map { height: 420px; }
}
