/* ============================================================
   Sweden Hiking Trails — style.css
   Aesthetic: Nordic nature — deep forest greens, birch whites,
   granite greys. Playfair Display for headings, DM Sans for UI.
   ============================================================ */

/* ── Dark theme (default) ── */
:root {
  /* Semantic tokens */
  --bg:             #162016;
  --bg-panel:       rgba(22, 35, 22, 0.94);
  --bg-hover:       rgba(255,255,255,0.08);
  --border:         rgba(255,255,255,0.07);
  --border-light:   rgba(255,255,255,0.13);
  --text-primary:   #f5f0e8;
  --text-secondary: #8a8a7a;
  --shadow:         rgba(10, 20, 10, 0.45);

  /* Trail colours */
  --c-national: #e67e22;
  --c-stf:      #8e44ad;
  --c-regional: #27ae60;
  --c-local:    #2980b9;
  --c-other:    #95a5a6;

  /* Layout */
  --toolbar-h:  56px;
  --sidebar-w:  340px;
  --radius:     10px;
  --font-ui:    'DM Sans', sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
}

/* ── Light theme ── */
:root.light {
  --bg:             #edeae2;
  --bg-panel:       rgba(248, 245, 238, 0.97);
  --bg-hover:       rgba(0,0,0,0.06);
  --border:         rgba(0,0,0,0.09);
  --border-light:   rgba(0,0,0,0.16);
  --text-primary:   #1a2e1a;
  --text-secondary: #5a6b5a;
  --shadow:         rgba(30, 50, 30, 0.14);
}

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

html, body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  overflow: hidden;
}

/* ── Map ── */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.leaflet-container {
  background: #2a3d2a;
  font-family: var(--font-ui);
}

/* ── Toolbar ── */
.toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--toolbar-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px var(--shadow);
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  color: var(--c-regional);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 300;
  white-space: nowrap;
}

/* ── Filter chips ── */
.toolbar-filters {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
}
.toolbar-filters::-webkit-scrollbar { display: none; }

.filter-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.filter-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.filter-chip:not(.active) {
  opacity: 0.45;
}

.chip-line {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Toolbar action buttons ── */
.toolbar-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.menu-btn { display: none; }

/* ── Mobile menu ── */
.mobile-menu {
  position: fixed;
  top: var(--toolbar-h);
  left: 0; right: 0;
  z-index: 999;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.mobile-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}

.mobile-menu-item:hover { color: var(--text-primary); }

/* ── Search panel ── */
.search-panel {
  position: fixed;
  top: var(--toolbar-h);
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  z-index: 1001;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 32px var(--shadow);
}

.search-panel-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text-primary);
  caret-color: var(--c-regional);
}

.search-input::placeholder { color: var(--text-secondary); }

.search-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.search-close:hover { color: var(--text-primary); }

.search-results {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
}

.search-results li {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.search-results li:last-child { border-bottom: none; }
.search-results li:hover { background: var(--bg-hover); }

.search-result-name {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

.search-result-meta {
  font-size: 0.73rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.search-no-results {
  padding: 16px 14px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-style: italic;
}

/* ── Trail sidebar ── */
.trail-sidebar {
  position: fixed;
  top: var(--toolbar-h);
  right: 0;
  width: var(--sidebar-w);
  bottom: 0;
  z-index: 800;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 32px var(--shadow);
}

.trail-sidebar.visible {
  transform: translateX(0);
}

.trail-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.trail-category-badge {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg-hover);
  color: var(--text-primary);
}

.trail-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.trail-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.trail-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.trail-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 14px;
}

.trail-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}

.trail-meta-row {
  display: flex;
  gap: 8px;
  font-size: 0.8rem;
}

.trail-meta-label {
  color: var(--text-secondary);
  width: 72px;
  flex-shrink: 0;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  padding-top: 1px;
}

.trail-meta-value {
  color: var(--text-primary);
  opacity: 0.85;
}

.trail-description {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.trail-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trail-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--c-regional);
  text-decoration: none;
}
.trail-link:hover { opacity: 0.8; }

.trail-sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.trail-osm-link {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
}
.trail-osm-link:hover { color: var(--text-primary); }

/* ── About modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(10,18,10,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  width: min(460px, 100%);
  box-shadow: 0 24px 64px var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(16px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
  padding: 18px 20px 22px;
}

.modal-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 14px;
}

.about-legend {
  background: var(--bg-hover);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-primary);
  opacity: 0.85;
}

.legend-line {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.about-source {
  font-size: 0.75rem !important;
  color: var(--text-secondary) !important;
}

.about-source a {
  color: var(--c-regional);
  text-decoration: none;
}
.about-source a:hover { text-decoration: underline; }

/* ── Map controls ── */
/* ── Locate button — matches sl-map exactly ── */
.locate-btn {
  position: absolute;
  bottom: 54px;
  right: 12px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px var(--shadow);
  transition: all 0.15s;
}

.locate-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

/* ── Zoom controls — matches sl-map exactly ── */
.leaflet-control-zoom {
  position: fixed !important;
  bottom: 100px;
  right: 12px;
  z-index: 1000;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leaflet-control-zoom a {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 1.2rem !important;
  background: var(--bg-panel) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border) !important;
  border-radius: 2px !important;
  box-shadow: none !important;
  transition: all 0.15s !important;
}

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

/* ── Leaflet attribution ── */
.leaflet-control-attribution {
  background: var(--bg-panel) !important;
  color: var(--text-secondary) !important;
  border-top: 1px solid var(--border) !important;
  font-size: 0.62rem !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* ── Leaflet popup ── */
.leaflet-popup-content-wrapper {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border-radius: 2px !important;
  border: 1px solid var(--border-light) !important;
  box-shadow: 0 8px 32px var(--shadow) !important;
}

.leaflet-popup-tip {
  background: var(--bg-panel) !important;
}

.popup-name {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.popup-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.popup-hint {
  font-size: 0.72rem;
  color: var(--c-regional);
  margin-top: 6px;
  cursor: pointer;
}

/* ── Status bar — matches sl-map exactly ── */
.status-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px var(--shadow);
  color: var(--text-secondary);
  font-size: 0.72rem;
  white-space: nowrap;
  gap: 6px;
  backdrop-filter: blur(8px);
}

.status-bar a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.status-bar a:hover { color: var(--text-primary); }

.status-sep {
  color: var(--border-light);
}

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.5s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text-primary);
  font-weight: 600;
}

.loading-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--c-regional);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .toolbar-filters { display: none; }
  .toolbar-actions { margin-left: auto; }
  .menu-btn { display: flex; }
  .action-btn:not(.menu-btn):not(#search-btn) { display: none; }

  .trail-sidebar {
    width: 100%;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65vh;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
  }

  .trail-sidebar.visible {
    transform: translateY(0);
  }

  .locate-btn {
  bottom: 54px;
  right: 12px;
  z-index: 1001;
  }
}