/* =========================================================
   Egg Eats — Main Styles
   ========================================================= */

:root {
  --color-bg: #1c1c24;
  --color-surface: #24242e;
  --color-surface-2: #2c2c38;
  --color-border: #38384a;
  --color-text: #eeeef2;
  --color-text-muted: #888899;
  --color-accent: #c0253a;
  --color-positive: #4ade80;
  --color-negative: #c0253a;
  --color-neutral: #888899;
  --color-mixed: #f59e0b;
  --font-title: 'Alfa Slab One', serif;
  --font-heading: 'Oswald', sans-serif;
  --font: 'Barlow', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Site Header (centered title) ────────────────────── */
.site-header {
  text-align: center;
  padding: 20px 20px 16px;
  flex-shrink: 0;
  position: relative;
  background: var(--color-surface);
}

.kofi-header-link {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  line-height: 0;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.kofi-header-link:hover {
  opacity: 1;
}

.kofi-header-link img {
  height: 32px;
  width: auto;
}

.site-header h1 {
  font-family: var(--font-title);
  font-size: 36px;
  font-weight: 400; /* Alfa Slab One is inherently heavy */
  color: var(--color-accent);
  letter-spacing: 1px;
}

.site-header .subtitle {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.admin-link {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: color 0.2s, border-color 0.2s;
}

.admin-link:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

/* ── App Wrapper: three-column layout ────────────────── */
.app-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Left: Filter Panel ──────────────────────────────── */
.filter-panel {
  width: 200px;
  background: var(--color-surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}


/* ── Center: City bar + Map ──────────────────────────── */
.map-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;  /* allow drawer body to extend into map area without being clipped */
  padding: 0 5%;
  background: var(--color-surface);
  position: relative;
}

#map {
  flex: 1;
  min-height: 0;
  overflow: hidden; /* clip the mapbox canvas to its container */
}

.city-bar {
  background: var(--color-surface);
  padding: 10px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  width: 100%;
}

.city-select {
  padding: 7px 32px 7px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 200px;
}

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

#map {
  flex: 1;
}

/* ── Unlocated drawer (handle below map, body overlays map when open) ── */
.unlocated-drawer {
  /* In-flow: sits below the map, does not overlap it when collapsed */
  flex-shrink: 0;
  position: relative;
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  /* Lift content above the browser's bottom UI chrome (iOS Safari bar, Android nav) */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.unlocated-drawer-handle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  height: 44px;
  cursor: pointer;
  background: var(--color-surface-2);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius);
  color: var(--color-text);
  width: calc(100% - 32px);
  margin: 6px 16px;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

.unlocated-drawer-handle:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(245, 158, 11, 0.6);
}

.unlocated-drawer-pill {
  /* repurposed as a chevron icon via border trick */
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-text-muted);
  border-top: 2px solid var(--color-text-muted);
  transform: rotate(-45deg) translateY(2px);
  flex-shrink: 0;
  transition: transform 0.25s;
}

.unlocated-drawer.open .unlocated-drawer-pill {
  transform: rotate(135deg) translateY(2px);
}

.unlocated-drawer-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

#unlocated-drawer-label {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(245, 158, 11, 0.85);
  line-height: 1;
}

.unlocated-drawer-badge {
  display: none;
}

.unlocated-drawer-body {
  /* Slides up over the map when open; hidden below handle when closed */
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  /* max-height set dynamically in JS to exactly match #map height */
  max-height: 80vh; /* fallback only */
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.35);
  z-index: 20; /* above Mapbox controls (z-index ~1-3) */
  /* Closed state */
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.unlocated-drawer.open .unlocated-drawer-body {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.unlocated-item {
  padding: 14px 16px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.unlocated-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.unlocated-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
}

.unlocated-item-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.unlocated-item-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
}

/* ── List view (virtual / no-fixed-location city) ────── */
.list-view-header {
  padding: 14px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.list-view-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-view-empty {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 20px 0;
}

.list-card {
  display: flex;
  gap: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.list-card-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
  border: 2px solid rgba(255,255,255,0.2);
}

.list-card-content {
  flex: 1;
  min-width: 0;
}

.list-card-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.list-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
}

/* ── Filters ─────────────────────────────────────────── */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
}

select.filter-select {
  width: 100%;
  padding: 7px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

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

.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--color-text-muted) !important;
  cursor: pointer;
}

/* Sentiment buttons */
.sentiment-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sentiment-btn {
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.sentiment-btn:hover,
.sentiment-btn.active {
  color: var(--color-text);
}

.sentiment-btn[data-sentiment="positive"].active {
  background: rgba(76, 175, 80, 0.2);
  border-color: var(--color-positive);
  color: var(--color-positive);
}

.sentiment-btn[data-sentiment="negative"].active {
  background: rgba(217, 43, 58, 0.2);
  border-color: var(--color-negative);
  color: var(--color-negative);
}

.sentiment-btn[data-sentiment="neutral"].active,
.sentiment-btn[data-sentiment="mixed"].active {
  background: rgba(122, 156, 197, 0.2);
  border-color: var(--color-neutral);
  color: var(--color-text);
}


.filter-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 13px;
  font-family: var(--font);
}

.filter-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.date-preset-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.date-btn {
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: var(--font);
}

.date-btn:hover,
.date-btn.active {
  color: var(--color-text);
}

.date-btn.active {
  background: rgba(192, 37, 58, 0.15);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.date-custom-range {
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.date-range-sep {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── Business Info Panel (overlays the map) ──────────── */
.info-panel {
  /* Desktop: in-flow flex item that collapses when closed */
  position: relative;
  width: 0;
  flex-shrink: 0;
  align-self: stretch;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  transition: width 0.25s ease;
  box-shadow: var(--shadow);
}

.info-panel.open {
  width: 360px;
}

.info-panel-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.info-panel-header .business-name {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.25;
}

.close-btn {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  margin-top: 2px;
}

.close-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.info-panel-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 0;
}

.panel-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}

.panel-nav-btn {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.panel-nav-btn:hover:not(:disabled) {
  background: var(--color-border);
  border-color: var(--color-text-muted);
}

.panel-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.panel-nav-counter {
  flex: 1;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}

.badge-category {
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.badge-sentiment-positive { background: rgba(74,222,128,0.12);  color: var(--color-positive); }
.badge-sentiment-negative { background: rgba(192,37,58,0.15);   color: var(--color-negative); }
.badge-sentiment-neutral,
.badge-sentiment-mixed    { background: rgba(136,136,153,0.15); color: var(--color-text-muted); }

.badge-closed {
  background: rgba(192, 37, 58, 0.12);
  color: #e57373;
  border: 1px solid rgba(192, 37, 58, 0.3);
}

.info-panel-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px 16px;
}

.mention-card {
  margin-top: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--color-border);
}

.mention-card .video-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.mention-card .quote {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.65;
  font-style: italic;
  padding-left: 10px;
  border-left: 2px solid var(--quote-color, var(--color-accent));
  margin-bottom: 8px;
}

.mention-card .watch-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mention-card .watch-link:hover {
  background: var(--color-accent);
  color: #fff;
}

.mention-card .watch-link.active {
  background: var(--color-accent);
  color: #fff;
}

.yt-embed-wrap {
  margin-top: 10px;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}

.yt-embed-wrap iframe {
  width: 100%;
  height: 100%;
  display: block;
}

.info-panel-address {
  font-size: 12px;
  color: var(--color-text-muted);
  min-height: 0;
}

.info-panel-address:empty {
  display: none;
}

.address-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.info-panel-address a.street-view-link {
  color: #60a5fa;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}

.info-panel-address a.street-view-link:hover {
  text-decoration: underline;
}


/* ── Bottom bar ──────────────────────────────────────── */
.bottom-bar {
  height: 90px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Loading overlay ─────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
  gap: 16px;
}

#loading.hidden {
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Mobile filter drawer elements (hidden on desktop) ── */
.mobile-filter-btn {
  display: none !important;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-filter-btn:hover {
  background: var(--color-border);
  border-color: var(--color-text-muted);
}

.filter-panel-drag-handle {
  width: 36px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto;
  flex-shrink: 0;
}

.filter-panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

.filter-panel-close:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 190;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mobile-overlay.visible {
  opacity: 1;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  /* Compact header */
  .site-header {
    padding: 12px 16px 10px;
  }

  .site-header h1 {
    font-size: 24px;
  }

  .kofi-header-link {
    display: none;
  }

  .site-header .subtitle {
    font-size: 11px;
    letter-spacing: 1.5px;
    margin-top: 4px;
  }

  /* City bar: row with city select + filter button */
  .city-bar {
    gap: 10px;
    padding: 8px 12px;
    justify-content: space-between;
  }

  .city-select {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    padding: 8px 32px 8px 12px;
  }

  .mobile-filter-btn {
    display: flex !important;
  }


  /* Map: full width, no horizontal padding, slightly shorter so drawer handle is visible */
  .map-wrapper {
    padding: 0;
    width: 100%;
  }

  #map {
    max-height: 62vh;
  }

  /* Filter panel → fixed bottom drawer */
  .filter-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 75vh;
    z-index: 200;
    border-radius: 14px 14px 0 0;
    border-top: 1px solid var(--color-border);
    border-left: none;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    overflow-y: auto;
    padding-top: 20px;
    gap: 20px;
  }

  .filter-panel.open {
    transform: translateY(0);
  }

  .filter-panel-drag-handle {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Overlay behind drawer */
  .mobile-overlay {
    display: block;
    pointer-events: none;
  }

  .mobile-overlay.active {
    pointer-events: all;
  }

  /* Bottom bar hidden on mobile (save space) */
  .bottom-bar {
    display: none;
  }

  /* Info panel → full-width bottom sheet on mobile */
  .info-panel {
    position: fixed;
    width: 100%;
    top: auto;
    bottom: 0;
    left: 0;
    height: 72vh;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--color-border);
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .info-panel.open {
    width: 100%;
    transform: translateY(0);
  }

  /* Larger touch targets for markers (applied via JS) */
  .map-marker-touch {
    width: 24px !important;
    height: 24px !important;
  }

  /* Slightly smaller text in panel on mobile */
  .info-panel-header .business-name {
    font-size: 19px;
  }

  .mention-card .video-title {
    font-size: 11px;
  }

  .mention-card .quote {
    font-size: 15px;
  }

  /* Navigation controls: move to top-right on mobile to avoid bottom sheet overlap */
  .mapboxgl-ctrl-bottom-right {
    bottom: 80px !important;
  }

}

