/* ============================================
   Roman Empire Interactive Map - Styles
   ============================================ */

:root {
  --gold: #c9a84c;
  --gold-dark: #8b7530;
  --parchment: #f4e8c1;
  --dark-bg: #1a1a2e;
  --darker-bg: #0f0f1e;
  --panel-bg: rgba(15, 15, 30, 0.92);
  --text-light: #e8e0d0;
  --text-muted: #a09880;
  --border-gold: rgba(201, 168, 76, 0.3);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Crimson Text', Georgia, serif;
  background: var(--darker-bg);
  color: var(--text-light);
}

/* ---- Loading Screen ---- */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--darker-bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-content h1 {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  color: var(--gold);
  letter-spacing: 5px;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.loading-content p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 12px;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: rgba(201, 168, 76, 0.15);
  border-radius: 2px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-fill {
  width: 0%;
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  animation: loadProgress 2s ease-in-out forwards;
}

@keyframes loadProgress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* ---- Map ---- */
#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #1a2744;
}

/* Leaflet overrides for antique feel */
.leaflet-tile-pane {
  filter: sepia(0.3) saturate(0.7) brightness(0.85) contrast(1.05);
}

.leaflet-control-zoom {
  border: 1px solid var(--border-gold) !important;
  border-radius: 4px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: var(--panel-bg) !important;
  color: var(--gold) !important;
  border-color: var(--border-gold) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(201, 168, 76, 0.2) !important;
}

/* ---- Title Overlay ---- */
#title-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  text-align: center;
  pointer-events: none;
  padding: 8px 24px;
  background: var(--panel-bg);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#title-overlay h1 {
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 3px;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  white-space: nowrap;
}

#title-overlay .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ---- Info Panel ---- */
#info-panel {
  position: absolute;
  top: 80px;
  left: 12px;
  z-index: 1000;
  width: 260px;
  padding: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  transition: all 0.4s ease;
}

#period-badge {
  width: 24px;
  height: 4px;
  border-radius: 2px;
  margin-bottom: 8px;
  transition: background-color 0.6s ease;
}

#period-name {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1.3;
}

#period-year {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 4px 0 8px;
  letter-spacing: 1px;
}

#period-description {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-light);
  opacity: 0.9;
}

/* ---- Timeline ---- */
#timeline-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 18px;
  background: linear-gradient(transparent, rgba(15, 15, 30, 0.95) 30%);
}

#play-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: var(--panel-bg);
  color: var(--gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#play-btn:hover {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold);
}

#play-btn:active {
  transform: scale(0.95);
}

#slider-wrapper {
  flex: 1;
  position: relative;
}

/* Custom range slider */
#timeline-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(201, 168, 76, 0.15);
  outline: none;
  cursor: pointer;
}

#timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--darker-bg);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(201, 168, 76, 0.5);
  transition: transform 0.15s ease;
}

#timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#timeline-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--darker-bg);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(201, 168, 76, 0.5);
}

#timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 2px;
}

.timeline-label {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
}

.timeline-label:hover,
.timeline-label.active {
  color: var(--gold);
}

/* ---- Legend ---- */
#legend {
  position: absolute;
  bottom: 90px;
  right: 12px;
  z-index: 1000;
  background: var(--panel-bg);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  max-width: 200px;
}

#legend-toggle {
  padding: 8px 14px;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  color: var(--gold);
  cursor: pointer;
  letter-spacing: 1px;
  text-align: center;
}

#legend-content {
  display: none;
  padding: 0 14px 10px;
}

#legend-content.open {
  display: block;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.legend-item:hover,
.legend-item.active {
  opacity: 1;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.legend-label {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
}

/* ---- Cities Toggle ---- */
#cities-toggle {
  position: absolute;
  top: 80px;
  right: 12px;
  z-index: 1000;
  background: var(--panel-bg);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 6px 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#cities-toggle label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-light);
}

#cities-toggle input[type="checkbox"] {
  accent-color: var(--gold);
}

/* ---- City markers ---- */
.city-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.city-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  border: 1.5px solid rgba(0,0,0,0.5);
  box-shadow: 0 0 6px rgba(201, 168, 76, 0.6);
}

.city-dot.capital {
  width: 12px;
  height: 12px;
  background: #ff6b35;
  box-shadow: 0 0 10px rgba(255, 107, 53, 0.7);
}

.city-label {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  color: var(--parchment);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 6px rgba(0,0,0,0.6);
  white-space: nowrap;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* City popup */
.leaflet-popup-content-wrapper {
  background: var(--panel-bg) !important;
  border: 1px solid var(--border-gold) !important;
  border-radius: 6px !important;
  color: var(--text-light) !important;
}

.leaflet-popup-tip {
  background: var(--panel-bg) !important;
  border: 1px solid var(--border-gold) !important;
}

.leaflet-popup-content {
  font-family: 'Crimson Text', serif !important;
  font-size: 0.85rem !important;
  line-height: 1.4 !important;
}

.leaflet-popup-content strong {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 0.9rem;
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#info-panel {
  animation: fadeIn 0.5s ease;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
  #title-overlay {
    padding: 6px 16px;
  }

  #title-overlay h1 {
    font-size: 1rem;
    letter-spacing: 2px;
  }

  #title-overlay .subtitle {
    font-size: 0.65rem;
  }

  #info-panel {
    top: auto;
    bottom: 100px;
    left: 8px;
    right: 8px;
    width: auto;
    padding: 12px;
    max-height: 140px;
    overflow-y: auto;
  }

  #period-name {
    font-size: 0.95rem;
  }

  #period-description {
    font-size: 0.8rem;
  }

  #timeline-container {
    padding: 8px 12px 14px;
  }

  #play-btn {
    width: 36px;
    height: 36px;
  }

  .timeline-label {
    font-size: 0.5rem;
  }

  #legend {
    bottom: 80px;
    right: 8px;
  }

  #cities-toggle {
    top: 70px;
    right: 8px;
  }

  .city-label {
    font-size: 8px;
  }
}

@media (max-width: 480px) {
  #title-overlay h1 {
    font-size: 0.85rem;
    letter-spacing: 1px;
  }

  #info-panel {
    max-height: 120px;
  }

  .timeline-label {
    font-size: 0.45rem;
  }

  .city-label {
    display: none;
  }
}

/* ---- Transition effects for territory changes ---- */
.leaflet-overlay-pane svg path {
  transition: d 0.8s ease-in-out, fill 0.6s ease, opacity 0.6s ease;
}
