/* style.css — design tokens + component styles */

:root,
[data-theme='light'] {
  /* Surfaces — warm ivory, restrained */
  --color-bg: #faf8f4;
  --color-surface: #ffffff;
  --color-surface-2: #fdfcf9;
  --color-surface-offset: #f2efe7;
  --color-divider: #ebe6da;
  --color-border: #e0dacb;

  /* Text */
  --color-text: #201d19;
  --color-text-muted: #6f6a60;
  --color-text-faint: #a89f8f;
  --color-text-inverse: #faf8f4;

  /* Primary accent — muted wine / oxblood */
  --color-primary: #7c2d3b;
  --color-primary-hover: #642432;
  --color-primary-active: #4d1c27;
  --color-primary-highlight: #f1dfe1;

  /* Star gold — used sparingly for star glyphs */
  --color-gold: #9c7a2d;
  --color-gold-highlight: #ece3c8;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 40 / 0.06);
  --shadow-md: 0 4px 16px oklch(0.2 0.02 40 / 0.10);
  --shadow-lg: 0 16px 40px oklch(0.2 0.02 40 / 0.16);

  --sidebar-width: 380px;
  --header-height: 64px;

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Switzer', 'Work Sans', 'Helvetica Neue', sans-serif;
}

[data-theme='dark'] {
  --color-bg: #15130f;
  --color-surface: #1b1915;
  --color-surface-2: #201e19;
  --color-surface-offset: #201d18;
  --color-divider: #2b2721;
  --color-border: #383228;

  --color-text: #ece6d9;
  --color-text-muted: #a89f8f;
  --color-text-faint: #6f6a60;
  --color-text-inverse: #201d19;

  --color-primary: #d38b98;
  --color-primary-hover: #dea3ae;
  --color-primary-active: #e8bac2;
  --color-primary-highlight: #3a2429;

  --color-gold: #d3b464;
  --color-gold-highlight: #3a3220;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.5);
}

/* Type scale */
:root {
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.84rem + 0.2vw, 0.9375rem);
  --text-base: clamp(1rem, 0.97rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.3rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.9vw, 1.75rem);
  --text-2xl: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
}

/* ===== App shell ===== */
html,
body {
  height: 100%;
  overscroll-behavior: none;
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ===== Header ===== */
.site-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  flex-shrink: 0;
}

.brand svg {
  width: 26px;
  height: 26px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-style: italic;
  letter-spacing: 0.01em;
  line-height: 1;
}

.brand-tagline {
  display: none;
}

@media (min-width: 640px) {
  .brand-tagline {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    border-left: 1px solid var(--color-border);
    padding-left: var(--space-4);
    margin-left: var(--space-1);
    max-width: 26ch;
    line-height: 1.3;
  }
}

.header-spacer {
  flex: 1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  border: 1px solid transparent;
}

.icon-btn:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.sidebar-toggle {
  display: inline-flex;
}

@media (min-width: 900px) {
  .sidebar-toggle {
    display: none;
  }
}

/* ===== Main layout ===== */
.main {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 0;
}

@media (max-width: 899px) {
  .main {
    grid-template-columns: 1fr;
  }
}

/* ===== Sidebar ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  z-index: 15;
}

@media (max-width: 899px) {
  .sidebar {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    transform: translateY(100%);
    transition: transform var(--transition-interactive);
    border-right: none;
    border-top: 1px solid var(--color-divider);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open {
    transform: translateY(0);
  }
}

.sidebar-controls {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex-shrink: 0;
}

.search-field {
  position: relative;
}

.search-field svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-faint);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-8);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.search-field input::placeholder {
  color: var(--color-text-faint);
}

.search-field input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.filter-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.region-field {
  position: relative;
}

.region-field svg:first-child {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-faint);
  pointer-events: none;
}

.region-field .region-chevron {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--color-text-faint);
  pointer-events: none;
}

.region-field select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: var(--space-3) var(--space-8) var(--space-3) var(--space-8);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--color-text);
  cursor: pointer;
}

.region-field select:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.region-field select:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--color-text-faint);
  color: var(--color-text);
}

.chip[aria-pressed='true'] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.chip .star-glyph {
  width: 12px;
  height: 12px;
  color: currentColor;
  flex-shrink: 0;
}

.result-count {
  padding: var(--space-3) var(--space-5) 0;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.restaurant-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0 var(--space-4);
}

.restaurant-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  cursor: pointer;
}

.restaurant-card:hover,
.restaurant-card:focus-visible {
  background: var(--color-surface-offset);
}

.restaurant-card.is-active {
  background: var(--color-primary-highlight);
}

.card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--color-text);
  line-height: 1.25;
}

.card-stars {
  display: inline-flex;
  gap: 2px;
  flex-shrink: 0;
  color: var(--color-gold);
}

.card-stars svg {
  width: 13px;
  height: 13px;
}

.card-meta {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.card-meta .dot::before {
  content: '\00b7';
  margin-right: var(--space-2);
  color: var(--color-text-faint);
}

.empty-state {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.5;
}

.sidebar-footer a {
  color: var(--color-text-muted);
}

/* Ad slot — reserved for future AdSense placement. Hidden until activated. */
.ad-slot {
  display: none;
  flex-shrink: 0;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-divider);
}

/* ===== Map ===== */
.map-wrap {
  position: relative;
  min-height: 0;
}

#map {
  height: 100%;
  width: 100%;
  background: var(--color-surface-offset);
  /* Establish a stacking context so Leaflet's internal panes (which use
     z-index up to 700 for popups) are contained within #map and don't
     escape to paint over sibling UI like .mobile-list-pill. */
  position: relative;
  z-index: 0;
}

/* Leaflet marker + popup restyling for an understated look */
.leaflet-container {
  font-family: var(--font-body);
  background: var(--color-surface-offset);
}

.leaflet-popup-content-wrapper {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.leaflet-popup-tip {
  background: var(--color-surface);
}

.leaflet-popup-content {
  margin: var(--space-3) var(--space-4);
  min-width: 200px;
}

.popup-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  margin-bottom: var(--space-1);
}

.popup-stars {
  display: inline-flex;
  gap: 2px;
  color: var(--color-gold);
  margin-bottom: var(--space-2);
}

.popup-stars svg {
  width: 13px;
  height: 13px;
}

.popup-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
  line-height: 1.5;
}

.popup-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: 600;
  margin-top: var(--space-1);
}

.popup-link svg {
  width: 12px;
  height: 12px;
}


.leaflet-control-attribution {
  background: color-mix(in oklab, var(--color-surface) 85%, transparent) !important;
  color: var(--color-text-faint) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--color-text-muted) !important;
}

.marker-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  color: var(--color-primary);
}

.marker-pin.stars-3 {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.marker-cluster-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: color-mix(in oklab, var(--color-primary) 88%, transparent);
  color: var(--color-text-inverse);
  font-weight: 600;
  font-size: var(--text-xs);
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

/* Mobile backdrop for sidebar drawer */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 899px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: oklch(0.15 0.02 40 / 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-interactive);
    z-index: 14;
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Floating "show list" pill visible on mobile when drawer closed */
.mobile-list-pill {
  display: none;
}

@media (max-width: 899px) {
  .mobile-list-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    position: absolute;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: var(--color-text-inverse);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 12;
  }

  [data-theme='dark'] .mobile-list-pill {
    background: var(--color-primary);
  }

  .mobile-list-pill svg {
    width: 16px;
    height: 16px;
  }
}
