@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #172420;
  --ink-soft: #647069;
  --ink-faint: #96A19A;
  --paper: #F6F5F0;
  --surface: #FFFFFF;
  --line: #E6E3D8;

  --brand: #17875A;
  --brand-dark: #0F6544;
  --brand-light: #E5F4ED;
  --accent: #FF6B45;
  --accent-dark: #E5502B;

  --national: #2F6FED;
  --regional: #2F7A3D;
  --eurovelo: #E8962E;

  --easy: #2FA84F;
  --medium: #E8962E;
  --hard: #E1493D;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-full: 999px;

  --shadow-sm: 0 1px 2px rgba(23,36,32,0.06), 0 1px 3px rgba(23,36,32,0.06);
  --shadow-md: 0 6px 20px rgba(23,36,32,0.10);
  --shadow-lg: 0 16px 40px rgba(23,36,32,0.16);

  --ease: cubic-bezier(.32,.72,0,1);
  --sidebar-width: 50%;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .display { font-family: "Plus Jakarta Sans", "Inter", sans-serif; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D8D4C6; border-radius: var(--r-full); border: 2px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- layout shell ---------- */
#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  position: relative;
  z-index: 500;
}
.topbar .logo { font-family: "Plus Jakarta Sans", sans-serif; font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.topbar .logo img { height: 34px; width: auto; display: block; }

.main-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  background: none; border: none; font: inherit; font-size: 14px; font-weight: 700;
  color: var(--ink); cursor: pointer; padding: 9px 14px; display: flex; align-items: center; gap: 5px;
  border-radius: var(--r-full); transition: background 0.15s var(--ease);
}
.nav-dropdown-btn:hover { background: var(--paper); }
.nav-dropdown-btn .chev { font-size: 10px; opacity: 0.6; }
.nav-dropdown-panel {
  display: none;
  position: absolute; top: 100%; right: 0; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 10px; z-index: 2000;
  grid-template-columns: repeat(2, 1fr); gap: 2px;
  min-width: 380px;
}
.nav-dropdown:hover .nav-dropdown-panel,
.nav-dropdown:focus-within .nav-dropdown-panel { display: grid; animation: fadeInUp 0.18s var(--ease); }
.nav-dropdown-panel a {
  padding: 8px 12px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background 0.12s;
}
.nav-dropdown-panel a:hover { background: var(--brand-light); color: var(--brand-dark); }

#main { flex: 1; display: flex; min-height: 0; }

#sidebar {
  width: 50%;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#mapWrap { width: 50%; position: relative; min-width: 0; background: #E9EEE9; }
#map { position: absolute; inset: 0; }

/* ---------- discovery panel: search + chips ---------- */
.discovery-header { padding: 18px 20px 4px; }
.discovery-header h1 { font-size: 21px; margin: 0 0 14px; }

.search-box {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: var(--r-full);
  padding: 11px 16px; background: var(--paper);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.search-box:focus-within { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-light); }
.search-box input { border: none; outline: none; background: none; flex: 1; font-size: 14px; font-family: inherit; color: var(--ink); }
.search-box input::placeholder { color: var(--ink-faint); }
.search-box .icon { font-size: 15px; opacity: 0.6; }

.pill-row {
  display: flex;
  gap: 8px;
  padding: 14px 20px 12px;
  overflow-x: auto;
}
.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px 8px 12px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  font-weight: 600;
  transition: all 0.18s var(--ease);
}
.pill .icon {
  font-size: 13px; line-height: 1;
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--paper);
  transition: background 0.18s var(--ease);
}
.pill:hover { color: var(--ink); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.pill:active { transform: translateY(0); }
.pill.active {
  color: var(--brand-dark); background: var(--brand-light); border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--brand);
}
.pill.active .icon { background: #fff; }

.result-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 20px 10px;
}
.result-count { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.reset-link { font-size: 13px; font-weight: 700; color: var(--brand); background: none; border: none; cursor: pointer; padding: 0; }
.reset-link:hover { text-decoration: underline; }

/* ---------- route cards ---------- */
#cardList {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 4px 20px 20px;
  align-content: start;
}
.route-card {
  border-radius: var(--r-md);
  cursor: pointer;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  animation: fadeInUp 0.3s var(--ease) backwards;
}
.route-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.route-card .thumb {
  height: 130px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #EEF5F0, #DFEEE5);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  border-radius: var(--r-md) var(--r-md) 0 0;
  overflow: hidden;
}
.route-card .thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.35) 100%);
}
.route-card .thumb.no-photo::after { display: none; }
.route-card .thumb.no-photo { display: flex; align-items: center; justify-content: center; }
.route-card .thumb.no-photo .thumb-icon { font-size: 32px; opacity: 0.3; }
.route-card .network-badge {
  position: absolute; top: 10px; left: 10px; z-index: 1;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 4px 9px; border-radius: var(--r-full); color: white;
}
.route-card .difficulty-dot {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  width: 11px; height: 11px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.9);
}
.route-card .step-badge {
  position: absolute; top: 10px; left: 10px; z-index: 1;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 4px 9px; border-radius: var(--r-full); color: white; background: var(--brand-dark);
}
.route-card .body { padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.route-card .title {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.route-card .from-to { font-size: 12px; color: var(--ink-soft); }
.route-card .stat-row { display: flex; gap: 12px; margin-top: auto; padding-top: 2px; }
.route-card .stat-row .stat { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.route-card .stat-row .stat .icon { font-size: 12px; opacity: 0.8; }

.empty-state { grid-column: 1 / -1; padding: 40px 8px; color: var(--ink-faint); font-size: 13px; text-align: center; }

/* ---------- pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 12px 20px; border-top: 1px solid var(--line); flex-shrink: 0;
}
.pagination:empty { display: none; padding: 0; border-top: none; }
.page-btn {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: var(--r-full);
  padding: 7px 15px; font-size: 13px; font-weight: 700; cursor: pointer; transition: border-color 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.page-btn:disabled { opacity: 0.35; cursor: default; }
.page-info { font-size: 13px; color: var(--ink-soft); font-weight: 600; }

/* ---------- map legend ---------- */
.map-legend {
  position: absolute; bottom: 16px; left: 16px; z-index: 1000;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(6px);
  border-radius: var(--r-md);
  padding: 9px 14px; display: flex; gap: 16px; font-size: 12px; font-weight: 700;
  box-shadow: var(--shadow-md);
}
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend .icon.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- site footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 22px 24px;
  flex-shrink: 0;
}
.site-footer h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin: 0 0 10px; font-weight: 800; }
.footer-region-list { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.footer-region-list a { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.footer-region-list a:hover { color: var(--brand); }
.site-footer .attribution-note { padding: 16px 0 0; border-top: none; color: var(--ink-faint); }
.attribution-note { font-size: 11px; color: var(--ink-faint); }

/* ---------- route detail: hero ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 14px 20px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
}
.breadcrumb { padding: 8px 20px 0; font-size: 12px; color: var(--ink-faint); }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--brand); }

.route-hero {
  position: relative;
  flex-shrink: 0;
  margin: 14px 20px 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  height: 190px;
  background: linear-gradient(135deg, var(--brand-light), #DCEEE3);
  background-size: cover;
  background-position: center;
  animation: fadeIn 0.4s var(--ease);
}
.route-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,20,15,0) 40%, rgba(10,20,15,0.72) 100%);
}
.route-hero .hero-content { position: absolute; left: 20px; right: 20px; bottom: 16px; z-index: 1; color: #fff; }
.route-hero .network-badge {
  display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 10px; border-radius: var(--r-full); color: white; margin-bottom: 8px;
}
.route-hero h1 { font-size: 22px; margin: 0; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,0.25); }

.stat-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 4px;
  padding: 16px 20px; margin: 0;
}
.stat-strip .stat-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: "Plus Jakarta Sans", sans-serif; font-size: 14px; font-weight: 700; color: var(--ink);
  animation: fadeInUp 0.3s var(--ease) backwards;
}
.stat-strip .stat-sep { color: var(--line); font-weight: 400; margin: 0 2px; }
.stat-strip .diff-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.route-description { margin: 0; padding: 4px 20px 16px; font-size: 13.5px; line-height: 1.6; color: var(--ink-soft); }

.actions-row { display: flex; gap: 10px; padding: 0 20px 16px; flex-wrap: wrap; }
button.primary {
  background: var(--brand); color: white; border: none; padding: 11px 20px;
  border-radius: var(--r-full); cursor: pointer; font-size: 13.5px; font-weight: 700;
  transition: background 0.15s, transform 0.15s; box-shadow: var(--shadow-sm);
}
button.primary:hover { background: var(--brand-dark); transform: translateY(-1px); }
button.ghost {
  background: var(--surface); border: 1.5px solid var(--line); padding: 11px 20px;
  border-radius: var(--r-full); cursor: pointer; font-size: 13.5px; font-weight: 700;
  transition: border-color 0.15s;
}
button.ghost:hover { border-color: var(--brand); color: var(--brand); }

.photos-row { display: flex; gap: 10px; padding: 0 20px 20px; }
.photos-row figure { margin: 0; flex: 1; text-align: center; }
.photos-row img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--r-md); display: block; }
.photos-row figcaption { font-size: 12px; color: var(--ink-soft); margin-top: 6px; font-weight: 600; }

/* ---------- route detail: content sections ---------- */
.info-section { padding: 20px; border-top: 1px solid var(--line); }
.info-section h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }

.segments-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.segment-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); transition: border-color 0.15s;
}
.segment-card:hover { border-color: var(--brand); }
.segment-card .segment-label { font-size: 10.5px; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: 0.03em; }
.segment-card .segment-name { font-size: 13px; font-weight: 700; }
.segment-card .segment-dist { font-size: 11.5px; color: var(--ink-soft); }
.segment-card.placeholder { color: var(--ink-faint); font-size: 12px; justify-content: center; align-items: center; border-style: dashed; }

.elevation-stats { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 12px; }
.elevation-stats strong { color: var(--ink); font-weight: 800; }

.bars-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.bar-title { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; }
.stacked-bar { display: flex; height: 10px; border-radius: var(--r-full); overflow: hidden; background: var(--paper); }
.bar-legend { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.bar-legend-item { font-size: 11.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.bar-legend-item .swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

.station-row { font-size: 13px; padding: 5px 0; }

#relatedList { display: flex; flex-direction: column; gap: 6px; }
.related-link {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-md);
  font-size: 13px; font-weight: 700; transition: border-color 0.15s;
}
.related-link:hover { border-color: var(--brand); }
.related-link > span { flex-shrink: 0; }

.tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--paper);
  color: var(--ink-soft);
}
.tag.dist { background: var(--brand-light); color: var(--brand-dark); }
.tag.loop { background: #FFF0EA; color: var(--accent-dark); }
.route-header .meta-row, #routeMeta { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 8px; }
.route-header h1 { padding: 0 20px; font-size: 20px; margin: 6px 0 0; }

#poiList { padding: 0 20px 20px; font-size: 12.5px; }
#poiList div { padding: 3px 0; }

/* ---------- region / department hub pages ---------- */
.page-content { max-width: 1120px; margin: 0 auto; padding: 28px 24px 48px; width: 100%; }
.page-content h1 { font-size: 28px; margin: 0 0 12px; }
.page-content h2 {
  font-size: 18px; margin: 36px 0 14px; padding-top: 20px; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; font-weight: 700;
}
.page-content h2 a { color: var(--brand); font-size: 13px; }

.dept-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.dept-chip {
  padding: 9px 16px; border: 1.5px solid var(--line); border-radius: var(--r-full);
  font-size: 13px; font-weight: 700; background: var(--surface); transition: border-color 0.15s;
}
.dept-chip:hover { border-color: var(--brand); color: var(--brand); }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px; margin-top: 14px;
}
.card-grid .route-card .thumb { height: 140px; }

/* ---------- responsive mobile ---------- */
.mobile-view-toggle {
  display: none;
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 4000;
  align-items: center; gap: 8px;
  background: var(--ink); color: #fff; border: none; cursor: pointer;
  padding: 13px 24px; border-radius: var(--r-full);
  font-family: inherit; font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow-lg);
}
.mobile-view-toggle .icon { font-size: 16px; line-height: 1; }

@media (max-width: 768px) {
  .topbar { padding: 10px 14px; gap: 8px; flex-wrap: wrap; row-gap: 6px; }
  .topbar .logo { font-size: 14.5px; }
  .topbar .logo img { height: 26px; }
  .main-nav { gap: 0; }
  .nav-dropdown-btn { padding: 7px 10px; font-size: 13px; }
  .nav-dropdown-panel { grid-template-columns: 1fr; min-width: 0; width: 84vw; max-width: 320px; }

  #main { min-height: 0; }
  #sidebar { width: 100% !important; }
  #mapWrap { width: 100% !important; display: none; }
  body.mobile-map-active #sidebar { display: none; }
  body.mobile-map-active #mapWrap { display: block; }

  .mobile-view-toggle { display: flex; }

  #cardList { grid-template-columns: 1fr !important; }
  .card-grid { grid-template-columns: 1fr; }

  .page-content { padding: 20px 16px 100px; }
}
