/* ---------- palette ---------- */

:root {
  --bg: #fbfbfe;
  --bg-wash: linear-gradient(180deg, #f4f5ff 0%, #fdfbff 38%, #fbfbfe 100%);
  --surface: #ffffff;
  --text: #14151a;
  --muted: #6b7280;
  --line: #e6e7ee;
  --line-strong: #d3d5e0;
  --field: #f3f4fa;

  --accent: #5b5bd6;
  --accent-soft: #ecebff;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c084fc 100%);
  --grad-soft: linear-gradient(135deg, #eef0ff 0%, #f6efff 100%);

  --closed: #9aa0ac;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20,21,26,.05), 0 6px 16px rgba(20,21,26,.05);
  --shadow-lift: 0 2px 6px rgba(20,21,26,.07), 0 12px 28px rgba(20,21,26,.08);

  /* Comfortable thumb target on a phone. */
  --tap: 44px;
}

/* Dark values appear twice on purpose: once for "follow the system" (unless
   light was explicitly chosen) and once for an explicit dark choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1116;
    --bg-wash: linear-gradient(180deg, #14162090 0%, #0f1116 45%);
    --surface: #191c24;
    --text: #eceef4;
    --muted: #9aa1b0;
    --line: #262a34;
    --line-strong: #333846;
    --field: #1f2430;
    --accent: #a5a3ff;
    --accent-soft: #23233a;
    --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c084fc 100%);
    --grad-soft: linear-gradient(135deg, #23253c 0%, #2a2340 100%);
    --closed: #7c8393;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.3);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.45), 0 12px 28px rgba(0,0,0,.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1116;
  --bg-wash: linear-gradient(180deg, #14162090 0%, #0f1116 45%);
  --surface: #191c24;
  --text: #eceef4;
  --muted: #9aa1b0;
  --line: #262a34;
  --line-strong: #333846;
  --field: #1f2430;
  --accent: #a5a3ff;
  --accent-soft: #23233a;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c084fc 100%);
  --grad-soft: linear-gradient(135deg, #23253c 0%, #2a2340 100%);
  --closed: #7c8393;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.3);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.45), 0 12px 28px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-wash);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 940px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- header ---------- */

.site-header { padding: 22px 0 14px; }

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.025em;
  font-weight: 700;
}

/* The title is a real button so it is keyboard reachable, but it should look
   exactly like the heading it replaced. */
.home-btn {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}

.home-btn:active { opacity: .6; }

.subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .9375rem;
}

.tips {
  list-style: none;
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: .8125rem;
  color: var(--text);
  background: var(--grad-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.theme-toggle {
  flex-shrink: 0;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.theme-toggle:active { transform: scale(.94); }

/* ---------- controls ---------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 500;
  padding: 10px 0 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* The field gets a filled background so it reads as an input rather than
   another button — everything used to be a white pill with a hairline. */
.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .875rem;
  opacity: .55;
  pointer-events: none;
}

#search {
  width: 100%;
  height: var(--tap);
  padding: 0 14px 0 38px;
  font: inherit;
  font-size: 1rem;             /* 16px stops iOS zooming on focus */
  color: var(--text);
  background: var(--field);
  border: 1px solid transparent;
  border-radius: 999px;
  appearance: none;
}

#search::placeholder { color: var(--muted); }

#search:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#search:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view-toggle {
  display: flex;
  flex-shrink: 0;
  height: var(--tap);
  padding: 3px;
  background: var(--field);
  border-radius: 999px;
}

.view-toggle button {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  padding: 0 14px;
  border-radius: 999px;
  cursor: pointer;
}

.view-toggle button.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 1px 3px rgba(99,102,241,.4);
}

/* Naming each group is what finally made these rows readable — three rows of
   similar pills gave no clue which was a category and which was a filter. */
.group-label {
  margin: 11px 0 5px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Once you start scrolling the labels have done their job, so the bar sheds
   them. Labelled when you arrive, compact while you browse.
   display:none rather than an animated max-height — the transition version
   silently failed to collapse in testing, and a sticky bar that does not
   shrink is worse than one that shrinks without a flourish. */
.controls.compact .group-label { display: none; }
.controls.compact .status-row { margin-top: 7px; }
.controls.compact .chip-scroller + .chip-scroller { margin-top: 7px; }

/* Chips scroll sideways; the fade tells you there is more off-screen. */
.chip-scroller {
  position: relative;
  margin-top: 0;
}

.chip-scroller::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--bg));
}

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 20px 2px 0;
  -webkit-overflow-scrolling: touch;
  scroll-padding: 16px;
}

.chips::-webkit-scrollbar { display: none; }

/* Categories are solid cards with shadow — the primary thing you pick. */
.chip {
  flex-shrink: 0;
  height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  border-radius: 12px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 12px rgba(99,102,241,.4);
}

/* Scrolls sideways rather than wrapping. Wrapping added a whole second row
   to a sticky bar that already claimed a third of a phone screen. */
.filter-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 20px 2px 0;
  -webkit-overflow-scrolling: touch;
}

.filter-row::-webkit-scrollbar { display: none; }
.filter-row > * { flex-shrink: 0; }

/* The area picker is a filled field like the search box, because it is an
   input holding 30-odd values — not an on/off switch like the toggles beside
   it. Making them look alike was the main source of confusion. */
.select-wrap { position: relative; }

.select-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: .8125rem;
}

.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
  font-size: .75rem;
}

select {
  height: 40px;
  padding: 0 30px 0 33px;
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--field);
  color: var(--text);
  appearance: none;
  cursor: pointer;
  max-width: 58vw;
}

select:focus { outline: none; border-color: var(--accent); }

/* Toggles stay outlined and lighter, so they read as switches. */
.toggle {
  height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}

/* Switched on reads as a tinted outline, not a filled card — that keeps it
   distinct from a selected category. */
.toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  min-height: 20px;
}

.result-count {
  margin: 0;
  font-size: .8125rem;
  color: var(--muted);
}

.link-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.result-count strong {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- cards ---------- */

.cards {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
}

/* Gradient hairline along the top edge — colour without shouting. */
.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--grad);
  opacity: 0;
  transition: opacity .15s ease;
}

.card:hover { box-shadow: var(--shadow-lift); }
.card:hover::before { opacity: .9; }

.card h3 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.012em;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  font-size: .78125rem;
  color: var(--muted);
}

.pill {
  background: var(--field);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.pill-chain {
  background: var(--grad-soft);
  color: var(--accent);
  font-weight: 600;
}

.badge-must {
  background: var(--grad);
  color: #fff;
  font-size: .71875rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge-closed {
  background: var(--closed);
  color: var(--surface);
  font-size: .71875rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.card .notes {
  margin: 1px 0 0;
  font-size: .9375rem;
  color: var(--text);
}

.tags {
  margin: 0;
  font-size: .78125rem;
  color: var(--muted);
}

.card-actions { margin-top: 4px; }

/* One link, not two: "View on Maps" and "Directions" landed in the same
   place. Sized as a proper tap target rather than inline text. */
.map-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
}

.map-link:active { transform: scale(.97); }

/* ---------- map ---------- */

#map {
  height: min(68vh, 560px);
  margin-top: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.map-fallback {
  margin-top: 14px;
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

/* Google's InfoWindow renders in its own light bubble, so these stay literal. */
.iw { color: #14151a; }
.iw h3 { margin: 0 0 4px; font-size: 1rem; }
.iw p { margin: 0 0 6px; font-size: .875rem; }
.iw a { color: #5b5bd6; font-weight: 600; }

/* ---------- archive ---------- */

.archive .card { opacity: .65; }
.archive .card::before { display: none; }

.archive-details {
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.archive-details summary {
  cursor: pointer;
  font-size: .8125rem;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}

.archive-details summary::-webkit-details-marker { display: none; }

.archive-details summary::before {
  content: '▸';
  font-size: .75rem;
  transition: transform .15s ease;
}

.archive-details[open] summary::before { transform: rotate(90deg); }
.archive-details summary:hover { color: var(--text); }

.archive-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .8125rem;
}

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

/* ---------- footer ---------- */

.site-footer {
  margin-top: 40px;
  padding: 18px 0 36px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8125rem;
}

.site-footer p { margin: 2px 0; }
.site-footer a { color: var(--accent); }

/* ---------- small phones ---------- */

@media (max-width: 380px) {
  .wrap { padding: 0 13px; }
  .site-header h1 { font-size: 1.45rem; }
  .view-toggle button { padding: 0 11px; }
  select { max-width: 52vw; }
}

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