:root {
  --bg: #0c0c0f;
  --bg-elev: #15151a;
  --bg-card: #1a1a21;
  --border: rgba(244, 239, 230, 0.1);
  --border-strong: rgba(230, 169, 86, 0.38);
  --text: #f4efe6;
  --text-muted: #a69f93;
  --amber: #e6a956;
  --amber-bright: #f6c478;
  --amber-dim: rgba(230, 169, 86, 0.16);
  --teal: #4ecdc4;
  --radius: 14px;
  --font-serif: "Playfair Display", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

.film-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: radial-gradient(rgba(255,255,255,0.6) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

/* ==================== HEADER ==================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(12, 12, 15, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 28px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid var(--border-strong);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.5vw, 32px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-elev);
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.tab-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--amber);
  color: #12100d;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(230, 169, 86, 0.3);
}

.stats-bar {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px 12px;
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.stat-item strong {
  color: var(--text);
  font-weight: 600;
}

/* ==================== VIEWS ==================== */
.view { display: none; position: relative; z-index: 2; }
.view.active { display: block; }

/* ==================== CONTROLS & SCRUBBER ==================== */
.controls-bar {
  max-width: 1440px;
  margin: 22px auto 14px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1 1 340px;
  max-width: 560px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 16px 11px 40px;
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus { border-color: var(--amber); }

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s;
}

.pill:hover { color: var(--text); border-color: rgba(244,239,230,0.28); }
.pill.active {
  background: var(--text);
  color: #111;
  border-color: var(--text);
  font-weight: 600;
}
.pill-accent { border-color: var(--border-strong); color: var(--amber-bright); }
.pill-accent.active { background: var(--amber); color: #12100d; border-color: var(--amber); }

.decade-scrubber-wrap {
  max-width: 1440px;
  margin: 0 auto 22px;
  padding: 0 28px;
}

.decade-scrubber {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
}

.decade-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}

.decade-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.decade-btn.active {
  background: var(--amber-dim);
  border-color: var(--border-strong);
  color: var(--amber-bright);
  font-weight: 600;
}
.decade-count {
  font-size: 11px;
  opacity: 0.7;
}

/* ==================== TIMELINE GRID ==================== */
.timeline-container {
  max-width: 1440px;
  margin: 0 auto 80px;
  padding: 0 28px;
}

.year-section {
  margin-bottom: 42px;
}

.year-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.year-heading h2 {
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--amber-bright);
}

.year-heading span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

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

.media-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.card-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #08080a;
  overflow: hidden;
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.media-card:hover .card-thumb { transform: scale(1.04); }

.card-badges-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(10, 10, 13, 0.78);
  backdrop-filter: blur(6px);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
}

.badge-ai {
  background: rgba(230, 169, 86, 0.92);
  color: #12100d;
  font-weight: 600;
  border-color: transparent;
}

.badge-local {
  background: rgba(78, 205, 196, 0.18);
  color: var(--teal);
  border-color: rgba(78, 205, 196, 0.4);
}

.card-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(10, 10, 13, 0.82);
  color: #fff;
}

.card-body {
  padding: 14px 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.38;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.place-tag {
  font-size: 11px;
  color: var(--amber);
  background: var(--amber-dim);
  padding: 2px 8px;
  border-radius: 999px;
}

.moments-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ==================== FAMILY TRIP MAP ==================== */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: calc(100vh - 132px);
  min-height: 560px;
}

.map-canvas-wrap {
  position: relative;
  height: 100%;
}

#family-map {
  width: 100%;
  height: 100%;
  background: #0d1117;
}

.map-quick-jumps {
  position: absolute;
  top: 14px;
  left: 56px;
  z-index: 500;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.jump-btn {
  background: rgba(15, 15, 20, 0.9);
  backdrop-filter: blur(8px);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.jump-btn:hover { background: var(--amber); color: #12100d; }
.jump-btn.style-btn.active { background: var(--amber); color: #12100d; font-weight: 600; }
.jump-sep { color: var(--border-strong); align-self: center; font-size: 12px; padding: 0 2px; }

.map-drawer {
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--amber);
}

.drawer-header h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  margin-top: 4px;
}

.drawer-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.45;
}

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

.drawer-item {
  display: flex;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.drawer-item:hover { border-color: var(--border-strong); }

.drawer-item img {
  width: 96px;
  height: 66px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.drawer-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.drawer-item-year {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
}

.drawer-item-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Custom Leaflet marker */
.amber-pin {
  background: radial-gradient(circle at 35% 35%, #ffe0a3, #e6a956 65%, #a86818);
  border: 2px solid #fff7e6;
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(230, 169, 86, 0.85);
  color: #141008;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.amber-pin:hover { transform: scale(1.18); }

/* ==================== MODAL & BEFORE/AFTER SLIDER ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 8, 0.86);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  z-index: 2;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(1060px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.7);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(10, 10, 14, 0.78);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.modal-stage {
  background: #050507;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  max-height: 64vh;
  overflow: hidden;
}

.modal-stage video,
.modal-stage img.lightbox-img {
  width: 100%;
  max-height: 64vh;
  object-fit: contain;
  display: block;
}

/* Synchronized Before/After Video Compare */
.compare-wrap {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 4 / 3;
  max-height: 62vh;
  background: #000;
  overflow: hidden;
  user-select: none;
}

.compare-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.compare-after-layer {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 50%);
}

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: var(--amber);
  box-shadow: 0 0 12px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 6;
}

.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--amber);
  color: #12100d;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.65);
}

.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 8;
}

.compare-label {
  position: absolute;
  top: 12px;
  z-index: 7;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(10, 10, 14, 0.78);
  border: 1px solid rgba(255,255,255,0.18);
  pointer-events: none;
}
.compare-label.left { left: 12px; color: var(--text-muted); }
.compare-label.right { right: 12px; color: var(--amber-bright); border-color: var(--border-strong); }

.compare-controls {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 10px;
  background: rgba(10, 10, 14, 0.85);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.compare-controls button {
  background: var(--amber);
  color: #12100d;
  border: 0;
  padding: 5px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.modal-body {
  padding: 22px 26px 28px;
}

.modal-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.meta-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--amber-dim);
  color: var(--amber-bright);
}

.meta-format, .meta-res {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}

.modal-body h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  line-height: 1.25;
}

.modal-summary {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}

.ai-banner {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--amber-dim);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.ai-banner.hidden { display: none; }

.ai-banner-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
}
.ai-banner-text strong { color: var(--amber-bright); }
.ai-banner-text span { color: var(--text-muted); font-size: 12px; }

.ai-mode-btns { display: flex; gap: 8px; }
.mode-btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}
.mode-btn.active {
  background: var(--amber);
  color: #12100d;
  border-color: var(--amber);
  font-weight: 600;
}

.moments-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.moments-section.hidden { display: none; }

.moments-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  padding: 2px 7px;
  border-radius: 999px;
}

.moments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.moment-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color 0.15s;
}
.moment-card:hover { border-color: var(--amber); }

.moment-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
  margin-bottom: 4px;
}

.moment-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.moment-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.loading-state, .empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

@media (max-width: 900px) {
  .map-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 52vh 1fr;
    height: auto;
  }
  .map-drawer { border-left: 0; border-top: 1px solid var(--border); }
}
