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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #252525;
  --border: #333;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #4a9eff;
  --accent-hover: #6ab3ff;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.modal-open { overflow: hidden; }

/* =====================
   HOME — card grid
   ===================== */
body.home {
  min-height: 100dvh;
  overflow-y: auto;
}

.site-header {
  padding: 64px 40px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.site-header-inner {}

.site-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.site-desc {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 6px;
}

.view-all-btn {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

.view-all-btn:hover {
  background: var(--border);
  border-color: #555;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 0 40px 64px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 600px) {
  .site-header { padding: 40px 20px 32px; }
  .card-grid { padding: 0 20px 40px; gap: 12px; }
}

.city-card {
  position: relative;
  display: block;
  height: 340px;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.city-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.city-card-bg {
  position: absolute;
  inset: 0;
  background-image: var(--cover);
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
}

.city-card:hover .city-card-bg {
  transform: scale(1.04);
}

/* Gradient overlay — always present so text is readable even without a photo */
.city-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.88) 0%,
    rgba(0,0,0,0.4) 50%,
    rgba(0,0,0,0.1) 100%
  );
}

.city-card-content {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
  gap: 4px;
}

.spot-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  color: #fff;
  letter-spacing: 0.02em;
}

.city-name {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.city-date {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.city-excerpt {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.4;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =====================
   MAP VIEW
   ===================== */
body.map-view {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-back,
.nav-all {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.nav-back:hover,
.nav-all:hover,
.nav-all.active { color: var(--text); }

.nav-title {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 190px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}

.search-input {
  width: 100%;
  padding: 6px 10px 6px 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

/* hide the native ✕ button in webkit */
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.filter-pills::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0;
  padding: 5px 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--text);
  border-color: #555;
}

.filter-btn.active {
  background: var(--cat-color, var(--accent));
  border-color: var(--cat-color, var(--accent));
  color: #fff;
}

#map {
  flex: 1;
  min-height: 0;
  touch-action: pan-x pan-y;
}

/* =====================
   MODAL
   ===================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 860px;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.25rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}

.modal-close:hover { background: var(--border); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 480px;
}

@media (max-width: 600px) {
  .modal-body { grid-template-columns: 1fr; }
}

.modal-gallery {
  display: flex;
  flex-direction: column;
  background: #000;
  border-radius: var(--radius) 0 0 var(--radius);
  overflow: hidden;
  height: 100%;   /* fill the fixed modal-body height */
}

.modal-gallery.hidden { display: none; }

.modal-gallery.no-photos-state {
  align-items: center;
  justify-content: center;
}

.no-photos {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0.45;
}
.no-photos-emoji { font-size: 4rem; line-height: 1; }
.no-photos-text  { font-size: 0.9rem; letter-spacing: 0.03em; }

/* Hero — first photo, fills available space */
.gallery-hero {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: pointer;
}
.gallery-hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.gallery-hero img:hover { opacity: 0.88; }

/* Thumbnail strip — remaining photos */
.gallery-thumbs {
  display: flex;
  flex-direction: row;
  gap: 3px;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.gallery-thumbs::-webkit-scrollbar { display: none; }
.gallery-thumbs img {
  flex-shrink: 0;
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
  border: 2px solid transparent;
}
.gallery-thumbs img:hover   { opacity: 0.8; }
.gallery-thumbs img.active  { border-color: #fff; }

.modal-info {
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.modal-gallery.hidden + .modal-info {
  grid-column: 1 / -1;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-right: 40px;
}

#modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-parent {
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-top: 3px;
}

.modal-parent.hidden { display: none; }

.category-badge {
  flex-shrink: 0;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 20%, transparent);
  color: var(--cat-color, var(--accent));
  border: 1px solid color-mix(in srgb, var(--cat-color, var(--accent)) 40%, transparent);
}

.category-badge.hidden { display: none; }

.place-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Markdown-rendered notes */
.modal-notes {
  font-size: 0.95rem;
  line-height: 1.65;
  color: #ccc;
  flex: 1;
}

.modal-notes p { margin: 0 0 0.75em; }
.modal-notes p:last-child { margin-bottom: 0; }
.modal-notes ul, .modal-notes ol { padding-left: 1.4em; margin: 0 0 0.75em; }
.modal-notes li { margin-bottom: 0.25em; }
.modal-notes strong { color: var(--text); }
.modal-notes a { color: var(--accent); }
.modal-notes code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 0.875em; }

.modal-address {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-address.hidden { display: none; }
.address-icon { flex-shrink: 0; }
.address-text { flex: 1; }

.copy-addr-btn {
  flex-shrink: 0;
  padding: 2px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.copy-addr-btn:hover { color: var(--text); border-color: #555; }

/* ── Custom map markers ──────────────────────────────────────────────────── */
.map-marker {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.6);
}

.maps-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s;
  align-self: flex-start;
}

.maps-btn:hover { background: var(--accent-hover); }
.maps-btn.hidden { display: none; }

/* =====================
   LIGHTBOX
   ===================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.lightbox.active { display: flex; }

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
}

.lightbox-img-wrap {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90dvh;
  display: flex;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90dvh;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-prev,
.lightbox-next,
.lightbox-close {
  position: absolute;
  z-index: 2;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lightbox-prev:hover,
.lightbox-next:hover,
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-close { top: 16px; right: 16px; font-size: 1.25rem; }

/* Leaflet dark map tweaks */
.leaflet-container { background: #1a1a2e; }
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.leaflet-popup-tip { background: var(--surface); }

/* =====================
   MOBILE
   ===================== */
@media (max-width: 768px) {

  /* Home */
  .site-header {
    padding: 36px 20px 28px;
    gap: 12px;
  }
  .site-title { font-size: 1.75rem; }
  .card-grid {
    padding: 0 16px 40px;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  }
  .city-card { height: 280px; }

  /* Map nav */
  .map-nav {
    height: 44px;
    padding: 0 14px;
    gap: 8px;
  }
  .nav-back, .nav-all { font-size: 0.8rem; }
  .nav-title { font-size: 0.85rem; }

  /* Filter/search bar */
  .search-wrap { width: 140px; }

  /* Modal — bottom sheet */
  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal-content {
    border-radius: 20px 20px 0 0;
    max-height: 88dvh;
    width: 100%;
  }
  .modal-body {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }

  /* Gallery — mobile: fixed height, hero+thumbs stacked */
  .modal-gallery {
    border-radius: 20px 20px 0 0;
    height: 280px;
    flex-direction: column;
  }
  .gallery-hero { flex: 1; min-height: 0; }
  .gallery-hero img { object-fit: contain; }
  .gallery-thumbs img { width: 56px; height: 56px; object-fit: contain; }
  .modal-gallery.hidden + .modal-info { grid-column: unset; }

  /* Modal close button bigger tap target */
  .modal-close { width: 36px; height: 36px; }

  /* Maps button full-width on mobile */
  .maps-btn {
    align-self: stretch;
    justify-content: center;
  }

  /* Lightbox nav buttons — easier to tap */
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}

@media (max-width: 400px) {
  .search-wrap { width: 120px; }
  .filter-bar  { gap: 6px; padding: 6px 10px; }
}
