/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #242848;
  --bg-secondary: #1e2a4a;
  --bg-tertiary: #1a2340;
  --text-primary: #f0e4d0;
  --text-secondary: #a89880;
  --accent-gold: #e6a04e;
  --accent-gold-dim: rgba(230, 160, 78, 0.3);
  --font-serif: 'Georgia', 'Times New Roman', serif;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-serif);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.hidden { display: none !important; }

/* === Hero === */
#hero {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}
#hero.fade-out { opacity: 0; pointer-events: none; }
#hero-content { text-align: center; }
#hero-title {
  font-size: clamp(2rem, 5vw, 4rem);
  color: var(--text-primary);
  opacity: 0;
  transition: opacity 1s ease;
}
#hero-title.visible { opacity: 1; }
#hero-subtitle {
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  color: var(--text-secondary);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 1rem;
  opacity: 0;
  transition: opacity 1s ease 0.5s;
}
#hero-subtitle.visible { opacity: 1; }
#hero-skip {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: 1px solid var(--text-secondary);
  color: var(--text-secondary);
  padding: 0.4rem 1rem;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.2s, border-color 0.2s;
}
#hero-skip:hover { color: var(--text-primary); border-color: var(--text-primary); }

/* === Explorer Layout === */
#explorer {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 1fr 80px;
  height: 100vh;
  width: 100vw;
}

/* === Sidebar === */
#sidebar {
  grid-row: 1 / -1;
  background: var(--bg-tertiary);
  overflow-y: auto;
  padding: 1rem;
  border-right: 1px solid rgba(232, 213, 183, 0.1);
}
#sidebar-header h2 {
  font-size: 1.3rem;
  color: var(--accent-gold);
  margin-bottom: 1rem;
}
#search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid rgba(232, 213, 183, 0.15);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
#search-input::placeholder { color: var(--text-secondary); }
#search-input:focus { outline: none; border-color: var(--accent-gold); }
.filter-section { margin-bottom: 1.25rem; }
.filter-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
#composer-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}
#composer-list li {
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-radius: 3px;
  transition: background 0.15s;
}
#composer-list li:hover { background: var(--bg-secondary); }
#composer-list li.active { color: var(--accent-gold); background: var(--accent-gold-dim); }
.toggle-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.toggle-btn {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-family: var(--font-serif);
  background: var(--bg-secondary);
  border: 1px solid rgba(232, 213, 183, 0.15);
  color: var(--text-secondary);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle-btn.active {
  background: var(--accent-gold-dim);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}
.period-group {
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-radius: 3px;
  transition: background 0.15s;
}
.period-group:hover { background: var(--bg-secondary); }
.period-group.active { color: var(--accent-gold); background: var(--accent-gold-dim); }
#reset-filters {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.5rem;
  background: none;
  border: 1px solid rgba(232, 213, 183, 0.15);
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.2s, border-color 0.2s;
}
#reset-filters:hover { color: var(--text-primary); border-color: var(--text-primary); }

/* === Map === */
#map-container {
  position: relative;
  overflow: hidden;
}
#map { width: 100%; height: 100%; }

/* Map controls */
.maplibregl-ctrl-group {
  background: rgba(15, 26, 46, 0.9) !important;
  border: 1px solid var(--accent-gold-dim) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}
.maplibregl-ctrl-group button {
  background-color: transparent !important;
  border-bottom: 1px solid rgba(232, 213, 183, 0.15) !important;
  color: var(--text-primary) !important;
}
.maplibregl-ctrl-group button:hover {
  background-color: var(--accent-gold-dim) !important;
}
.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(0.85) sepia(0.4) saturate(1.5) hue-rotate(10deg);
}
.maplibregl-ctrl-group button svg {
  color: var(--text-primary);
}



/* === Fantasy Realm === */
#fantasy-realm {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  width: 250px;
  height: 180px;
  background: var(--bg-primary);
  border: 1px solid var(--accent-gold-dim);
  border-radius: 4px;
  z-index: 10;
  padding: 0.5rem;
  overflow: hidden;
}
#fantasy-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-gold);
  text-align: center;
  margin-bottom: 0.5rem;
}
#fantasy-realm::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(1px 1px at 20% 30%, rgba(232,213,183,0.3) 0%, transparent 100%),
              radial-gradient(1px 1px at 60% 70%, rgba(232,213,183,0.2) 0%, transparent 100%),
              radial-gradient(1px 1px at 80% 20%, rgba(232,213,183,0.25) 0%, transparent 100%),
              radial-gradient(1px 1px at 40% 80%, rgba(232,213,183,0.15) 0%, transparent 100%),
              radial-gradient(1px 1px at 10% 60%, rgba(232,213,183,0.2) 0%, transparent 100%);
  animation: starDrift 20s linear infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes starDrift {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}
#fantasy-pins { position: relative; z-index: 1; height: calc(100% - 1.5rem); }

.btn-report {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: 1px solid var(--text-secondary);
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.2s, border-color 0.2s;
}
.btn-report:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

/* === Timeline === */
#timeline-container {
  background: var(--bg-tertiary);
  border-top: 1px solid rgba(232, 213, 183, 0.1);
  padding: 0.5rem 1rem;
}
#timeline { width: 100%; height: 100%; }

/* === Detail Panel === */
#detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 350px;
  height: 100vh;
  background: var(--bg-tertiary);
  border-left: 1px solid rgba(232, 213, 183, 0.1);
  z-index: 100;
  padding: 1.5rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
#detail-panel.visible {
  transform: translateX(0);
}
.btn-close-detail {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.5rem;
  background: none;
  border: 1px solid rgba(232, 213, 183, 0.15);
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.2s, border-color 0.2s;
}
.btn-close-detail:hover { color: var(--text-primary); border-color: var(--text-primary); }
.detail-title {
  font-size: 1.4rem;
  color: var(--accent-gold);
  margin-bottom: 0.25rem;
}
.detail-composer {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.detail-field {
  margin-bottom: 0.75rem;
}
.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 0.15rem;
}
.detail-value {
  font-size: 0.95rem;
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 3px;
  border: 1px solid rgba(232, 213, 183, 0.2);
  color: var(--text-secondary);
}
.badge-exact { border-color: var(--accent-gold); color: var(--accent-gold); }
.badge-real { border-color: #5b8c5b; color: #7bac7b; }
.badge-fictional { border-color: #8b5b8b; color: #ab7bab; }
.location-list { list-style: none; margin-top: 0.75rem; }
.location-list li {
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-radius: 3px;
  transition: background 0.15s;
}
.location-list li:hover { background: var(--bg-secondary); }
.location-list li.active {
  background: var(--accent-gold-dim);
  color: var(--accent-gold);
}
.btn-show-all {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: var(--accent-gold-dim);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 3px;
}
.btn-show-all:hover { background: var(--accent-gold); color: var(--bg-primary); }

/* === Tooltip === */
.map-tooltip {
  position: absolute;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-gold-dim);
  padding: 0.4rem 0.6rem;
  border-radius: 3px;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
}
.map-tooltip .tooltip-opera { color: var(--text-primary); }
.map-tooltip .tooltip-composer { color: var(--text-secondary); font-size: 0.75rem; }

/* === Mobile === */
@media (max-width: 768px) {
  #explorer {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  #sidebar { display: none; }
  #timeline-container { display: none; }
  #fantasy-realm { width: 180px; height: 130px; }
  #detail-panel { width: 100vw; }

  #mobile-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--bg-tertiary);
    border-top: 1px solid rgba(232, 213, 183, 0.1);
    border-radius: 12px 12px 0 0;
    z-index: 200;
    transform: translateY(calc(100% - 3rem));
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding: 0 1rem 1rem;
  }
  #mobile-sheet.expanded { transform: translateY(0); }
  #mobile-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--text-secondary);
    border-radius: 2px;
    margin: 0.75rem auto;
    cursor: grab;
  }
}
