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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Skip links for keyboard users */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  background: #e94560;
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 4px 4px;
  z-index: 10000;
  font-size: 14px;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

#title-bar {
  background: #16213e;
  padding: 6px 16px;
  border-bottom: 1px solid #0f3460;
}

#title-bar h1 {
  font-size: 16px;
  font-weight: 700;
  color: #e0e0e0;
}

#title-bar .title-sep {
  color: #0f3460;
}

#title-bar .title-sub {
  color: #4ecdc4;
  font-weight: 600;
}

#title-bar .title-hint {
  font-size: 12px;
  color: #b0b0c0;
  margin-top: 1px;
}

#controls {
  background: #16213e;
  padding: 10px 16px;
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid #0f3460;
}

#chapter-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 300px;
}

#format-select,
#jump-select,
#chapter-select {
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
}

#chapter-select {
  max-width: 280px;
}

#chapter-slider {
  flex: 1;
  accent-color: #e94560;
}

#chapter-label {
  font-size: 14px;
  color: #d0d0e0;
  min-width: 200px;
}

#filter-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

#filter-control label {
  font-size: 14px;
}

#detail-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

#detail-control label {
  font-size: 14px;
  white-space: nowrap;
}

#detail-slider {
  width: 80px;
  accent-color: #4ecdc4;
}

#detail-label {
  font-size: 13px;
  color: #d0d0e0;
  white-space: nowrap;
  min-width: 90px;
}

#type-filter-wrapper {
  position: relative;
}

#type-filter-btn {
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 14px;
  cursor: pointer;
}

#type-filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 6px 0;
  z-index: 1000;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

#type-filter-dropdown label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

#type-filter-dropdown label:hover {
  background: #1a1a3e;
}

#type-filter-dropdown .type-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

#type-filter-dropdown input[type="checkbox"] {
  accent-color: #e94560;
}

#toggle-control label {
  font-size: 14px;
  cursor: pointer;
}

#secondary-controls {
  display: contents;
}

#filters-toggle {
  display: none;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

#filters-toggle:hover {
  background: #1a1a3e;
}

#map-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#map {
  flex: 1;
  background: #1a3a5c;
}

#sidebar-toggle {
  display: none;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

#sidebar-toggle:hover {
  background: #1a1a3e;
}

#sidebar {
  width: 300px;
  background: #16213e;
  border-left: 1px solid #0f3460;
  overflow-y: auto;
  padding: 12px;
}

@media (max-width: 768px) {
  #sidebar-toggle {
    display: block;
  }

  #map-container {
    position: relative;
  }

  #sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    z-index: 999;
    box-shadow: -4px 0 12px rgba(0,0,0,0.4);
    transition: transform 0.2s ease;
  }

  #sidebar.collapsed {
    transform: translateX(100%);
  }

  #filters-toggle {
    display: block;
  }

  #secondary-controls {
    display: none;
    width: 100%;
  }

  #secondary-controls.open {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
  }
}

#sidebar h2 {
  font-size: 18px;
  margin-bottom: 4px;
  color: #f06080;
}

#location-search {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  font-size: 14px;
}

#location-search::placeholder {
  color: #808090;
}

#sidebar-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

#sidebar-actions button {
  flex: 1;
  padding: 4px 8px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

#sidebar-actions button:hover {
  background: #1a1a3e;
}

#location-count {
  font-size: 13px;
  color: #c8c8d8;
  margin-bottom: 8px;
}

#location-list {
  list-style: none;
}

#location-list li {
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#location-list li:hover,
#location-list li:focus-visible {
  background: #1a1a3e;
  outline: none;
}

#location-list li:focus-visible {
  box-shadow: inset 0 0 0 2px #e94560;
}

.loc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.loc-eye {
  width: 20px;
  flex-shrink: 0;
  font-size: 12px;
  color: #b0b0c0;
  cursor: pointer;
  text-align: center;
}

.loc-locate {
  background: none;
  border: 1px solid #0f3460;
  border-radius: 3px;
  color: #b0b0c0;
  font-size: 14px;
  line-height: 1;
  padding: 2px 5px;
  cursor: pointer;
  flex-shrink: 0;
}

.loc-locate:hover {
  background: #0f3460;
  color: #e0e0e0;
}

.loc-name { flex: 1; }

.loc-type {
  font-size: 12px;
  color: #b0b0c0;
}

#location-list li.loc-hidden {
  opacity: 0.35;
}

#location-list li.loc-hidden .loc-name {
  text-decoration: line-through;
}

/* Map labels */
:root {
  --label-scale: 1;
}

.map-label {
  background: none !important;
  border: none !important;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  pointer-events: none;
  letter-spacing: 0.5px;
  transform: scale(var(--label-scale));
  transform-origin: center bottom;
}

/* The Wandering Inn special marker */
.wandering-inn-marker {
  background: none !important;
  border: none !important;
}

.inn-icon {
  font-size: 28px;
  color: #ffd700;
  text-shadow: 0 0 8px #ff8c00, 0 0 16px #ff6600, 0 0 24px rgba(255,140,0,0.5);
  animation: inn-glow 3s ease-in-out infinite alternate;
  line-height: 32px;
  text-align: center;
}

@keyframes inn-glow {
  from { text-shadow: 0 0 8px #ff8c00, 0 0 16px #ff6600; }
  to   { text-shadow: 0 0 12px #ffd700, 0 0 24px #ff8c00, 0 0 36px rgba(255,200,0,0.4); }
}

.inn-label span {
  font-weight: 800 !important;
}

.map-label span {
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0 0 6px #000,
     0 0 10px rgba(0,0,0,0.8) !important;
}

/* Leaflet attribution contrast fix */
.leaflet-control-attribution a {
  color: #005f87 !important;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  background: #16213e;
  color: #e0e0e0;
  border-radius: 6px;
}

.leaflet-popup-tip { background: #16213e; }

.leaflet-popup-content h2 {
  color: #f06080;
  margin-bottom: 4px;
  font-size: 16px;
}

.leaflet-popup-content .popup-type {
  font-size: 13px;
  color: #c8c8d8;
  margin-bottom: 6px;
}

.leaflet-popup-content .popup-desc {
  font-size: 14px;
  margin-bottom: 6px;
}

.leaflet-popup-content .popup-visual {
  font-size: 13px;
  color: #b0c4de;
  font-style: italic;
  margin-bottom: 6px;
  border-left: 2px solid #4ecdc4;
  padding-left: 8px;
}

.leaflet-popup-content .popup-meta {
  font-size: 12px;
  color: #b0b0c0;
}

/* Ghost provenance labels */
.ghost-label {
  background: none !important;
  border: none !important;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  pointer-events: none;
  letter-spacing: 0.5px;
  transform: scale(var(--label-scale));
  transform-origin: center bottom;
}

.ghost-label span {
  opacity: 0.4;
  font-size: 10px;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0 0 6px #000;
}

/* Screen-reader-only live region for popup announcements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Global focus style for accessibility */
:focus-visible {
  outline: 2px solid #e94560;
  outline-offset: 2px;
}
