/* Cheat — clean & minimal. One accent, a lot of air, photos do the talking. */

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #17181a;
  --muted: #77726c;
  --hairline: #e5e1db;
  --accent: #b8482f;
  --accent-soft: #f3e4df;
  --shadow: 0 1px 2px rgb(23 24 26 / 0.05), 0 8px 24px -16px rgb(23 24 26 / 0.3);

  --radius: 10px;
  --gap: clamp(1rem, 3vw, 1.75rem);
  --wrap: 1180px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314;
    --surface: #1b1c1e;
    --ink: #eceae7;
    --muted: #9b958e;
    --hairline: #2e3033;
    --accent: #e2836a;
    --accent-soft: #33221d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -16px rgb(0 0 0 / 0.8);
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

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

a { color: inherit; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

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

.skip {
  position: absolute; left: 0.5rem; top: -3rem;
  background: var(--accent); color: #fff;
  padding: 0.5rem 0.9rem; border-radius: var(--radius);
  z-index: 100; transition: top 0.15s;
}
.skip:focus { top: 0.5rem; }

:where(button, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- masthead ---------- */

.masthead { padding-block: clamp(2.25rem, 7vw, 4rem) clamp(1.25rem, 3vw, 2rem); }

.wordmark {
  font-family: var(--serif);
  font-size: clamp(2.75rem, 11vw, 4.5rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.95;
  margin: 0;
}
.wordmark span { color: var(--accent); }

.tagline {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

/* ---------- toolbar ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
  padding-block: 0.85rem;
}

.search-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

.search {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding-inline: 0.75rem;
  min-width: 0;
}
.search:focus-within { border-color: var(--accent); }

.search-icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: var(--muted); stroke-width: 1.6;
  stroke-linecap: round;
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  padding-block: 0.7rem;
  outline: none;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.5); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  background: var(--surface);
  color: inherit;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }

.btn[aria-pressed="true"],
.btn.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.is-busy { opacity: 0.65; pointer-events: none; }

.pin-icon {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round;
}
.btn.is-on .pin-icon circle:first-child { fill: currentColor; }

/* The view toggle is mobile-only; desktop shows list and map side by side. */
.btn-view { display: none; }
.view-list-label { display: none; }
.btn-view[aria-pressed="true"] .view-map-label { display: none; }
.btn-view[aria-pressed="true"] .view-list-label { display: inline; }

.status {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
}

/* ---------- filters ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  margin-top: 0.7rem;
}

.filter-group {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.filter-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  flex: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip {
  border: 1px solid var(--hairline);
  background: none;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.18rem 0.65rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.meta-row {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-top: 0.6rem;
}

.count {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.link-btn {
  border: 0; background: none; padding: 0;
  font: inherit; font-size: 0.8rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  padding-block: var(--gap) 3rem;
  align-items: start;
}

@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .map-panel {
    position: sticky;
    top: calc(var(--toolbar-h, 170px) + 1rem);
  }
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--gap);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.card:hover, .card.is-active {
  box-shadow: var(--shadow);
  border-color: var(--muted);
}
.card.is-active { border-color: var(--accent); }

.card-photo {
  position: relative;
  aspect-ratio: 3 / 2;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.card-photo img[hidden] { display: none; }

/* Shown when a place has no photo: the initial, quietly. */
.card-initial {
  font-family: var(--serif);
  font-size: 2.6rem;
  color: var(--accent);
  opacity: 0.4;
}

.card-body {
  padding: 0.85rem 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.card-name {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 400;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.01em;
}

.card-rating {
  flex: none;
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.card-sub {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-distance { color: var(--accent); }
.card-distance:empty { display: none; }

.card-notes {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
  opacity: 0.82;
}
.card-notes:empty { display: none; }

.card-corners {
  list-style: none;
  margin: auto 0 0;
  padding: 0.15rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}
.card-corners li {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
}

.card-address {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.card-address:empty { display: none; }

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

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

.map-panel { display: flex; flex-direction: column; gap: 0.5rem; }

#map {
  height: clamp(320px, 60vh, 620px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  z-index: 1;
}

.map-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Keep OSM tiles from glaring in dark mode without shipping a second tile set. */
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9); }
}

.leaflet-container { font: inherit; background: var(--surface); }

.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 0.7rem 0.9rem; }

.pop-name {
  font-family: var(--serif);
  font-size: 1rem;
  display: block;
}
.pop-meta {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.marker {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.35);
}
.marker.is-active { transform: scale(1.45); }

.marker-you {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #2f6fed;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 6px rgb(47 111 237 / 0.2);
}

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

.footer {
  border-top: 1px solid var(--hairline);
  padding-block: 1.25rem 2.5rem;
  color: var(--muted);
  font-size: 0.78rem;
}
.footer p { margin: 0; }

/* ---------- mobile: one pane at a time ---------- */

@media (max-width: 899px) {
  .btn-view { display: inline-flex; }

  .map-panel { display: none; }
  #map { height: min(70vh, 520px); }

  body.show-map .results { display: none; }
  body.show-map .map-panel { display: flex; }

  /* Two columns beats one on a phone: more places per glance, and the photo
     stops dominating the card. */
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr));
    gap: 0.75rem;
  }
  .card-body { padding: 0.65rem 0.7rem 0.75rem; }
  .card-name { font-size: 1rem; }
  .card-notes { font-size: 0.82rem; }

  /* The search field needs the full width; the two buttons share the row below. */
  .search-row { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .btn-near { flex: 1 1 auto; justify-content: center; }

  .filters { gap: 0.45rem; }
  .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    width: 100%;
  }

  /* Scroll the chips sideways rather than stacking three rows of them above
     the content. */
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
    scroll-snap-type: x proximity;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; scroll-snap-align: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
