/* ============================================================
   Map — modern styles for overlay controls, labels, and drawer
   ============================================================ */

#mapbox, #map {
  width: auto;
  height: 100%;
}

html, body, #container {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* ---- Map labels ---- */

.state-label {
  font-family: 'Inter', 'Helvetica', sans-serif;
  font-weight: 600;
  font-size: 12px;
  color: rgba(220, 250, 250, 0.92);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.5);
  background: none;
  border: none;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
}

.state-label-big {
  font-size: 13px;
  letter-spacing: 0.03em;
}

.state-label-small {
  font-size: 11px;
}

.other-societies-label {
  font-family: 'Inter', 'Helvetica', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: rgba(180, 230, 228, 0.8);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  background: none;
  border: none;
  white-space: nowrap;
}

.city-label {
  font-family: 'Inter', 'Helvetica', sans-serif;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  white-space: nowrap;
}

.city-div-icon {
  background: white;
  width: 5px;
  height: 5px;
  border: 1px solid rgba(0, 0, 0, 0.9);
  border-radius: 50%;
}

/* ---- Year display (top-right) ---- */

.overlay {
  position: absolute;
  z-index: 9999;
}

.overlay-year {
  top: 14px;
  right: 14px;
  z-index: 900;
  text-align: right;
  pointer-events: none;
}

.year-heading {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--year-heading-color);
  margin-bottom: 2px;
}

.year-label {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  font-size: 2.6rem;
  color: var(--text-heading);
  text-shadow: 0 2px 16px var(--text-shadow-strong), 0 1px 4px var(--text-shadow-medium);
  line-height: 1;
  white-space: nowrap;
}

/* ---- Year timeline (right side) ---- */

#overlay-slider {
  /* Start below the year label (top-right, ~80px tall) with a safe gap */
  top: 100px;
  bottom: 90px;
  right: 20px;
  z-index: 900;
  display: flex;
  align-items: center;    /* vertically center the pill within the available space */
  pointer-events: none;   /* let map clicks through the empty area */
}

#year-timeline {
  pointer-events: all;    /* re-enable clicks on the pill itself */
}

/* Push zoom controls left to match */
.leaflet-control-zoom {
  right: 20px !important;
}

#year-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg-medium);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 10px 14px 10px 8px;
  box-shadow: 0 8px 32px var(--panel-shadow);
  /* top offset (100px) + bottom offset (90px) + small breathing room (20px) */
  max-height: calc(100vh - 210px);
}

/* Scrollable inner list — arrows sit outside this so they're always visible */
.year-timeline-list {
  flex: 1;
  overflow-x: clip;     /* allow scaled dots + glow to not get clipped horizontally */
  overflow-y: auto;
  scrollbar-width: none;
  position: relative;
  padding-right: 6px;   /* room for scaled dots + glow to not get clipped */
  /* Fade top/bottom edges to hint at overflow */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 4%, black 96%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 4%, black 96%, transparent 100%);
}

.year-timeline-list::-webkit-scrollbar {
  display: none;
}


/* Vertical track line — dot is 8px wide, list has padding-right: 6px → dot center = 6+4 = 10px from list right → track center at 10px → right: 9px */
.year-timeline-list::before {
  content: '';
  position: absolute;
  right: 9px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--track-line);
  border-radius: 1px;
  pointer-events: none;
}

/* Up/down scroll arrows */
.year-timeline-arrow {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 18px;
  cursor: pointer;
  color: transparent;
  font-size: 8px;
  letter-spacing: 0;
  pointer-events: none;
  transition: color 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.year-timeline-arrow.visible {
  color: var(--arrow-color);
  pointer-events: all;
}

.year-timeline-arrow:hover {
  color: var(--arrow-hover);
}

.year-timeline-header {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--year-header-color);
  margin-bottom: 2px;
  padding-right: 0;
  text-align: center;
  white-space: nowrap;
}

.year-stop {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
  position: relative;
  z-index: 1;
}

.year-stop-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--year-label-color);
  letter-spacing: 0.04em;
  transition: color 0.2s;
  user-select: none;
  white-space: nowrap;
}

.year-stop-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--dot-bg);
  border: 1.5px solid var(--dot-border);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.year-stop:hover .year-stop-label {
  color: var(--year-label-hover);
}

.year-stop:hover .year-stop-dot {
  background: var(--dot-hover-bg);
  border-color: var(--dot-hover-border);
  transform: scale(1.3);
}

.year-stop.active {
  cursor: default;
}

.year-stop.active .year-stop-label {
  color: var(--accent-teal);
  font-weight: 600;
}

.year-stop.active .year-stop-dot {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2), 0 0 10px var(--accent-teal-glow);
  transform: scale(1.4);
}

/* ---- Loading overlay ---- */

#loading {
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  position: fixed;
  display: block;
  background: var(--loading-bg);
  text-align: center;
  z-index: 99999;
}

#loading-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: var(--loading-spinner);
  z-index: 100;
}

/* ---- Misc ---- */

.disabled-content {
  pointer-events: none;
}

.enabled-content {
  pointer-events: auto;
}

.disabledContent {
  pointer-events: none;
}

/* ---- Right-side info drawer ---- */

#info-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100%;
  background: var(--panel-bg-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-light);
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -4px 0 32px var(--panel-shadow);
}

#info-drawer.open {
  transform: translateX(0);
}

#info-drawer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-hover);
  background: var(--close-btn-bg);
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s, color 0.15s;
}

#info-drawer-close:hover {
  background: var(--hover-bg-strong);
  color: var(--text-heading);
}

#info-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 20px 20px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  padding-top: 56px; /* space for close button */
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

#info-drawer-content::-webkit-scrollbar {
  width: 4px;
}

#info-drawer-content::-webkit-scrollbar-track {
  background: transparent;
}

#info-drawer-content::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 2px;
}

/* Content styles inside drawer */
#info-drawer-content .drawer-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.3;
}

#info-drawer-content .drawer-dates {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-meta);
  margin-bottom: 16px;
  font-style: italic;
}

#info-drawer-content .drawer-meta {
  background: var(--active-bg-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-info);
}

#info-drawer-content .drawer-body {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-body);
}

#info-drawer-content .drawer-source {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Generic link style in drawer */
#info-drawer-content a {
  color: var(--accent-teal);
  text-decoration: none;
  transition: color 0.15s;
}

#info-drawer-content a:hover {
  color: var(--accent-teal-hover);
  text-decoration: underline;
}

/* Infobox metadata styling */
#info-drawer-content p small {
  display: block;
  background: var(--active-bg-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-info);
}

#info-drawer-content p {
  margin-bottom: 10px;
}

#info-drawer-content h2,
#info-drawer-content h3 {
  font-family: 'Cinzel', Georgia, serif;
  color: var(--text-heading);
}

/* Section title for About / Contact drawers */
.drawer-section-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-heading);
  text-align: center;
  margin: 0 0 20px 0;
  letter-spacing: 0.04em;
}

/* Contact creator links */
.contact-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--active-bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-primary) !important;
  text-decoration: none !important;
  font-size: 0.875rem;
  transition: background 0.15s, border-color 0.15s;
}

.contact-link:hover {
  background: var(--accent-teal-contact) !important;
  border-color: var(--accent-teal-contact-border) !important;
  color: var(--accent-teal) !important;
  text-decoration: none !important;
}

.contact-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

#info-drawer-content ul {
  padding-left: 18px;
  color: var(--text-body);
}

#info-drawer-content li {
  margin-bottom: 4px;
}

/* Center title div from getStateContent */
#info-drawer-content div[style*="text-align:center"],
#info-drawer-content div[style*="text-align: center"] {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 14px;
  line-height: 1.4;
}

/* Source italic */
#info-drawer-content p i:only-child {
  display: block;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 500px) {
  #info-drawer {
    width: 100%;
  }
}

/* ---- Leaflet zoom controls ---- */

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 16px var(--panel-shadow) !important;
  border-radius: 10px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: var(--zoom-bg) !important;
  color: var(--zoom-text) !important;
  border-color: var(--border-light) !important;
  font-size: 1.1rem !important;
  font-weight: 300 !important;
  line-height: 28px !important;
  width: 30px !important;
  height: 30px !important;
  backdrop-filter: blur(10px);
  transition: background 0.15s, color 0.15s;
}

.leaflet-control-zoom a:hover {
  background: var(--zoom-hover-bg) !important;
  color: var(--zoom-hover-text) !important;
}

.leaflet-control-zoom-in {
  border-bottom: 1px solid var(--border-light) !important;
}

/* ---- Leaflet attribution ---- */

.leaflet-control-attribution {
  background: var(--attr-bg) !important;
  color: var(--attr-text) !important;
  font-size: 10px !important;
  font-family: 'Inter', sans-serif !important;
  padding: 3px 8px !important;
  border-radius: 6px 0 0 0 !important;
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution a {
  color: var(--accent-teal-muted) !important;
}

.leaflet-control-attribution a:hover {
  color: var(--accent-teal) !important;
}

/* ---- Leaflet tooltips (hover labels on territories) ---- */

.leaflet-tooltip {
  background: var(--tooltip-bg) !important;
  border: 1px solid var(--border-medium) !important;
  color: var(--text-primary) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  border-radius: 6px !important;
  padding: 5px 10px !important;
  box-shadow: 0 4px 12px var(--panel-shadow) !important;
  white-space: nowrap;
}

.leaflet-tooltip::before {
  border-top-color: var(--border-medium) !important;
}

.leaflet-tooltip-bottom::before {
  border-bottom-color: var(--border-medium) !important;
}

.leaflet-tooltip-left::before {
  border-left-color: var(--border-medium) !important;
}

.leaflet-tooltip-right::before {
  border-right-color: var(--border-medium) !important;
}

/* ---- Mobile: compact year timeline ---- */

@media (max-width: 480px) {
  #overlay-slider {
    right: 10px;
    top: 80px;
    bottom: 70px;
  }

  #year-timeline {
    padding: 8px 10px 8px 6px;
    max-height: calc(100vh - 150px);
    border-radius: 10px;
  }

  .year-timeline-header {
    font-size: 0.5rem;
    letter-spacing: 0.06em;
    margin-bottom: 0;
  }

  .year-timeline-arrow {
    height: 14px;
    font-size: 7px;
  }

  .year-stop {
    gap: 6px;
    padding: 3px 0;
  }

  .year-stop-label {
    font-size: 9px;
  }

  .year-stop-dot {
    width: 6px;
    height: 6px;
  }

  /* Mobile dot is 6px wide → center = 6+3 = 9px from right → right: 8px */
  .year-timeline-list::before {
    right: 8px;
  }

  .leaflet-control-zoom {
    right: 10px !important;
  }
}
