:root {
  --bg: #060a10;
  --panel: rgba(13, 18, 28, 0.82);
  --panel-solid: #0d1220;
  --panel-2: #161f30;
  --border: #253449;
  --text: #eef1f7;
  --text-dim: #8b96ab;
  --accent: #d9a656;
  --accent-dim: rgba(217, 166, 86, 0.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; overflow: hidden; }

#app { position: relative; width: 100vw; height: 100vh; display: flex; }

/* ---------- Globe area ---------- */
#globe-stage { flex: 1; position: relative; min-width: 0; overflow: hidden; }
#globe-container { position: absolute; inset: 0; z-index: 1; }
#globe-container canvas { display: block; }
/* globe.gl clears/replaces the contents of #globe-container, so all overlay UI
   lives in a separate sibling layer instead of as children of that mount point. */
#globe-overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
#globe-overlay > * { pointer-events: auto; }

/* ---------- Loading overlay ---------- */
#loading-overlay {
  position: absolute; inset: 0; z-index: 30; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  transition: opacity 0.5s ease; pointer-events: none;
}
#loading-overlay.hidden { opacity: 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid #1e2a40; border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading-overlay span { font-size: 12px; color: var(--text-dim); letter-spacing: 0.4px; }

/* ---------- globe.gl native tooltips ---------- */
.poly-tooltip, .pt-tooltip {
  background: #0d1220; border: 1px solid #253449; border-radius: 7px;
  padding: 7px 10px; font-size: 11.5px; max-width: 220px; box-shadow: 0 8px 20px rgba(0,0,0,0.45);
  color: #eef1f7; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
.pt-tooltip strong { display: block; font-weight: 600; margin-bottom: 2px; }
.pt-tooltip span { color: #d9a656; font-size: 10.5px; }
/* Debounced point-hover tooltip (see onPointHover/handlePointHover in app.js) -
   lives in #globe-overlay and is positioned in JS via pointermove, so it needs
   its own absolute+none-pointer-events rules rather than the ones globe.gl
   applies internally to its own (unused, for points) tooltip element. */
.pt-tooltip-follow { position: absolute; top: 0; left: 0; z-index: 6; pointer-events: none; display: none; }

#title-bar { position: absolute; top: 18px; left: 22px; z-index: 5; pointer-events: none; }
#title-bar h1 { font-size: 17px; font-weight: 700; margin: 0 0 2px 0; letter-spacing: 0.3px; color: var(--text); }
#title-bar p { font-size: 11px; margin: 0; color: var(--text-dim); }

#top-right-controls { position: absolute; top: 18px; right: 22px; z-index: 5; display: flex; gap: 8px; }
#reset-view-btn, #quality-toggle {
  background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); color: var(--text-dim);
  padding: 7px 13px; border-radius: 7px; font-size: 11px; cursor: pointer; transition: all 0.15s;
}
#reset-view-btn:hover, #quality-toggle:hover { color: var(--text); border-color: var(--accent); }
#quality-toggle.perf-active { color: #e0c85c; border-color: #e0c85c; }

/* ---------- Legend ---------- */
#legend {
  position: absolute; top: 60px; right: 22px; z-index: 5;
  display: flex; flex-direction: column; gap: 5px;
  background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px;
}
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-dim);
  cursor: pointer; user-select: none; opacity: 0.4; transition: opacity 0.15s; }
.legend-item.active { opacity: 1; color: var(--text); }
.legend-item:hover { opacity: 0.85; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Detail panel ---------- */
#detail-panel {
  position: absolute; bottom: 118px; left: 22px; z-index: 6; width: 320px; max-width: calc(100vw - 380px);
  background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px;
  display: none; box-shadow: 0 16px 40px rgba(0,0,0,0.55);
}
#detail-panel.open { display: block; animation: slideUp 0.25s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
#detail-panel h3 { margin: 8px 0 4px 0; font-size: 16.5px; line-height: 1.3; }
#detail-panel p { margin: 8px 0 10px 0; font-size: 12.5px; line-height: 1.6; color: #c7cede; }
.detail-year { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: 0.3px; }
.detail-region { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.badge { display: inline-block; font-size: 10px; padding: 3px 9px; border-radius: 20px; border: 1px solid; margin-bottom: 6px; font-weight: 600; }
#detail-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--text-dim);
  font-size: 20px; cursor: pointer; line-height: 1; }
#detail-close:hover { color: var(--text); }

/* ---------- Timeline (bottom bar) ---------- */
#timeline-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 5;
  background: linear-gradient(180deg, rgba(6,10,16,0) 0%, rgba(6,10,16,0.94) 32%, rgba(6,10,16,0.99) 100%);
  padding: 34px 24px 18px 24px;
}
#year-display-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 12px; }
#year-display { font-size: 27px; font-weight: 700; letter-spacing: 0.5px; min-width: 150px; text-align: center;
  font-variant-numeric: tabular-nums; }
.transport-btn {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.transport-btn:hover { border-color: var(--accent); color: var(--accent); }
#speed-select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 11px; border-radius: 7px; padding: 6px 7px; cursor: pointer;
}

#slider-row { display: flex; align-items: center; gap: 10px; max-width: 900px; margin: 0 auto; }
#year-slider { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, #212e42, #35496a); outline: none; }
#year-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; box-shadow: 0 0 0 5px var(--accent-dim); }
#year-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: none; box-shadow: 0 0 0 5px var(--accent-dim); }
.slider-label { font-size: 10.5px; color: var(--text-dim); min-width: 50px; font-variant-numeric: tabular-nums; }
.slider-label.right { text-align: right; }

#era-row { display: flex; justify-content: center; gap: 6px; margin-top: 13px; flex-wrap: wrap; }
.era-btn {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 10.5px; padding: 6px 11px; border-radius: 14px; cursor: pointer; transition: all 0.15s;
}
.era-btn:hover { color: var(--bg); border-color: var(--accent); background: var(--accent); }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 320px; flex-shrink: 0; background: var(--panel-solid); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; transition: margin-right 0.2s ease;
}
body.sidebar-collapsed #sidebar { margin-right: -320px; }
#sidebar-header { padding: 18px 16px 12px 16px; border-bottom: 1px solid var(--border); }
#sidebar-header h2 { font-size: 12.5px; margin: 0 0 10px 0; color: var(--text-dim); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px; }
#search-input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 11px; border-radius: 7px; font-size: 12px; outline: none; transition: border-color 0.15s;
}
#search-input:focus { border-color: var(--accent); }
#event-list { flex: 1; overflow-y: auto; padding: 7px; min-height: 0; }

/* ---------- Membership promo card ---------- */
#promo-card {
  flex-shrink: 0; margin: 10px; padding: 16px 17px; position: relative; overflow: hidden;
  background: linear-gradient(155deg, rgba(217,166,86,0.22), rgba(217,166,86,0.05));
  border: 1px solid rgba(217,166,86,0.5); border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(217,166,86,0.08), 0 10px 28px rgba(217,166,86,0.10);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#promo-card:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(217,166,86,0.16), 0 14px 34px rgba(217,166,86,0.18); }
/* soft animated sheen sweeping across the card — keeps it feeling alive instead of static */
#promo-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.10) 45%, transparent 60%);
  background-size: 220% 100%; background-position: 120% 0;
  animation: promoSheen 5.5s ease-in-out infinite;
}
@keyframes promoSheen { 0%, 40% { background-position: 120% 0; } 70%, 100% { background-position: -20% 0; } }
/* one-time attention pulse — triggered by JS after the visitor has actually engaged
   (viewed a couple of events), so the nudge feels earned rather than a static ad. */
#promo-card.promo-pulse { animation: promoPulse 1.4s ease-out 2; }
@keyframes promoPulse {
  0% { box-shadow: 0 0 0 0 rgba(217,166,86,0.55), 0 10px 28px rgba(217,166,86,0.10); }
  70% { box-shadow: 0 0 0 9px rgba(217,166,86,0), 0 10px 28px rgba(217,166,86,0.10); }
  100% { box-shadow: 0 0 0 0 rgba(217,166,86,0), 0 10px 28px rgba(217,166,86,0.10); }
}
#promo-card .promo-eyebrow {
  display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); margin-bottom: 7px;
}
#promo-card .promo-eyebrow .spark { font-size: 12px; filter: drop-shadow(0 0 4px rgba(217,166,86,0.7)); }
#promo-card .promo-headline { margin: 0 0 5px 0; font-size: 14px; font-weight: 700; line-height: 1.35; color: #fff; }
#promo-card p { margin: 0 0 12px 0; font-size: 12px; line-height: 1.55; color: #d7dbe6; }
#promo-card a.promo-cta {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, #eec076, var(--accent)); color: #14100a; text-decoration: none;
  font-size: 12.5px; font-weight: 800; padding: 10px 12px; border-radius: 9px;
  transition: filter 0.15s, transform 0.15s; box-shadow: 0 4px 14px rgba(217,166,86,0.28);
}
#promo-card a.promo-cta:hover { filter: brightness(1.08); transform: translateY(-1px); }
#promo-card a.promo-cta:active { transform: translateY(0); }
#promo-card .promo-subtext { margin-top: 8px; font-size: 10px; color: var(--text-dim); text-align: center; }
@media (prefers-reduced-motion: reduce) {
  #promo-card::before { animation: none; }
  #promo-card.promo-pulse { animation: none; }
}

.event-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 9px; border-radius: 8px; cursor: pointer; transition: background 0.12s; }
.event-item:hover { background: var(--panel-2); }
.event-item.selected { background: var(--accent-dim); }
.event-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; box-shadow: 0 0 6px currentColor; }
.event-item-title { font-size: 12.5px; line-height: 1.4; }
.event-item-year { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; font-variant-numeric: tabular-nums; }
.empty-hint { padding: 24px 12px; font-size: 12px; color: var(--text-dim); text-align: center; line-height: 1.6; }

#sidebar-toggle {
  position: absolute; top: 18px; right: 338px; z-index: 6;
  background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 7px; cursor: pointer; font-size: 13px; transition: all 0.15s;
}
#sidebar-toggle:hover { color: var(--text); border-color: var(--accent); }
body.sidebar-collapsed #sidebar-toggle { right: 22px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #24304a; border-radius: 4px; }

@media (max-width: 760px) {
  #sidebar { position: absolute; top: 0; right: 0; bottom: 0; z-index: 20; width: 86vw; }
  body.sidebar-collapsed #sidebar { margin-right: -86vw; }
  #sidebar-toggle { top: 62px; right: 22px; }
  body:not(.sidebar-collapsed) #sidebar-toggle { right: calc(86vw + 10px); }
  #detail-panel { max-width: calc(100vw - 40px); bottom: 128px; }
  #legend { display: none; }
  #top-right-controls { flex-direction: column; align-items: flex-end; }
}
