/* memoryPath.css — Digital Adriatic Memory Paths */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital@0;1&family=Open+Sans:wght@400;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:           #f9f7f1;
  --surface:      #ffffff;
  --surface-alt:  #f4f2ed;
  --text:         #2a2a2a;
  --text-muted:   #666;
  --border:       #e0dbd0;
  --navy:         #1e3c72;
  --navy-dark:    #162447;
  --accent:       #ff9800;
  --shadow:       0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.13);
  --header-h:     64px;
  --sidebar-w:    400px;
  --radius:       14px;
  --font-serif:   'Libre Baskerville', Georgia, serif;
  --font-sans:    'Open Sans', sans-serif;
  --transition:   all 0.3s ease;
}

body.dark-mode {
  --bg:          #141414;
  --surface:     #1e1e1e;
  --surface-alt: #242424;
  --text:        #eeeeee;
  --text-muted:  #999;
  --border:      #333;
  --navy:        #90b8f0;
  --shadow:      0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
}

/* ── Reset / Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Skip link ──────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  background: var(--navy);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  font-weight: 700;
  z-index: 9999;
  transition: top 0.2s;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ── Header ─────────────────────────────────────────────── */
.mp-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: linear-gradient(135deg, #162447, #1f4068, #1b1b2f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  gap: 12px;
}

.mp-back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
}
.mp-back-link:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.mp-back-link::after { display: none; }

.mp-header-center {
  text-align: center;
  flex: 1;
  min-width: 0;
}
.mp-header-center h1 {
  font-family: var(--font-serif);
  font-size: clamp(1em, 2.2vw, 1.35em);
  font-weight: normal;
  letter-spacing: 0.4px;
  color: #fff;
}
.mp-header-sub {
  font-size: 0.78em;
  color: rgba(255,255,255,0.65);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-theme-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  flex-shrink: 0;
  transition: var(--transition);
}
.mp-theme-btn:hover { background: rgba(255,255,255,0.22); }
.mp-theme-btn .moon-icon { display: none; }
body.dark-mode .mp-theme-btn .sun-icon  { display: none; }
body.dark-mode .mp-theme-btn .moon-icon { display: block; }

/* ── Layout ─────────────────────────────────────────────── */
.mp-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--header-h);
}

/* ── Sidebar ────────────────────────────────────────────── */
.mp-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* Route list panel */
.mp-routes-panel {
  border-bottom: 1px solid var(--border);
  overflow-y: auto;
  max-height: 42%;
  padding: 16px;
  flex-shrink: 0;
}

.mp-panel-heading {
  font-family: var(--font-serif);
  font-size: 0.95em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mp-panel-heading i { color: var(--accent); }

.mp-loading {
  color: var(--text-muted);
  font-size: 0.9em;
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Route cards */
.mp-route-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-route-card {
  display: flex;
  align-items: stretch;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition: var(--transition);
}
.mp-route-card:hover {
  box-shadow: var(--shadow);
  transform: translateX(3px);
}
.mp-route-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,152,0,0.2);
}
.mp-route-card.active .mp-route-card-body { background: rgba(255,152,0,0.04); }

.mp-route-card-accent {
  width: 5px;
  flex-shrink: 0;
}

.mp-route-card-body {
  padding: 10px 12px;
  flex: 1;
  min-width: 0;
}

.mp-route-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.mp-cat-badge {
  font-size: 0.72em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.mp-transport {
  font-size: 0.78em;
  color: var(--text-muted);
  white-space: nowrap;
}

.mp-route-card-title {
  font-family: var(--font-serif);
  font-size: 0.92em;
  font-weight: normal;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 5px;
}

.mp-route-path {
  font-size: 0.78em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.mp-route-path i { color: var(--accent); font-size: 0.85em; }

.mp-route-witness {
  font-size: 0.75em;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}
.mp-route-witness i { margin-right: 4px; }

/* ── Narrative panel ────────────────────────────────────── */
.mp-narrative {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

.mp-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  gap: 14px;
}
.mp-placeholder-icon {
  font-size: 3em;
  opacity: 0.25;
}
.mp-placeholder p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1em;
  line-height: 1.6;
}

/* Narrative content */
.mp-narrative-header {
  border-left: 4px solid;
  padding-left: 14px;
  margin-bottom: 20px;
}
.mp-narrative-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.mp-cat-badge-lg {
  font-size: 0.78em;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.mp-period {
  font-size: 0.82em;
  color: var(--text-muted);
  font-style: italic;
}
.mp-narrative-title {
  font-family: var(--font-serif);
  font-size: 1.25em;
  font-weight: normal;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 8px;
}
.mp-narrative-route {
  font-size: 0.8em;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Testimony */
.mp-testimony {
  background: var(--surface-alt);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 16px 18px;
  margin: 20px 0;
}
.mp-testimony p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.93em;
  line-height: 1.8;
  color: var(--text);
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.mp-testimony cite {
  display: block;
  margin-top: 10px;
  font-size: 0.82em;
  color: var(--text-muted);
  font-style: normal;
  font-weight: 600;
}

/* Audio player */
.mp-audio-wrapper {
  margin: 18px 0;
  padding: 14px 16px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.mp-audio-label {
  font-size: 0.8em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mp-audio-label i { color: var(--accent); }
.mp-audio {
  width: 100%;
  accent-color: var(--accent);
}

/* Waypoints */
.mp-waypoints {
  margin-top: 20px;
}
.mp-waypoints h4 {
  font-size: 0.82em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mp-waypoints h4 i { color: var(--accent); }

.mp-waypoint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid;
  padding-left: 12px;
  margin-bottom: 2px;
}
.mp-waypoint:last-child { border-bottom: none; }

.mp-waypoint-num {
  color: #fff;
  font-size: 0.75em;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.mp-waypoint-info strong {
  display: block;
  font-size: 0.9em;
  color: var(--text);
  margin-bottom: 3px;
}
.mp-waypoint-info p {
  font-size: 0.82em;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Map ────────────────────────────────────────────────── */
.mp-map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* Custom markers */
.mp-marker-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
.mp-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.82em;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  font-family: var(--font-sans);
}
.mp-marker.is-start {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}
.mp-marker.is-start span {
  transform: rotate(45deg);
  font-size: 0.9em;
}

/* Legend */
.mp-legend {
  position: absolute;
  bottom: 24px;
  right: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-width: 180px;
  max-width: 250px;
  z-index: 500;
  display: none;
}
.mp-legend.visible { display: block; }

.mp-legend-title {
  font-family: var(--font-serif);
  font-size: 0.88em;
  font-weight: normal;
  color: var(--text);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.mp-legend-stops {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mp-legend-stop {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78em;
  color: var(--text-muted);
}
.mp-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.7);
}

/* ── Scrollbar ──────────────────────────────────────────── */
.mp-routes-panel::-webkit-scrollbar,
.mp-narrative::-webkit-scrollbar,
.mp-testimony p::-webkit-scrollbar {
  width: 5px;
}
.mp-routes-panel::-webkit-scrollbar-thumb,
.mp-narrative::-webkit-scrollbar-thumb,
.mp-testimony p::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }

  html, body { overflow: auto; }

  .mp-layout {
    flex-direction: column;
    height: auto;
  }

  .mp-sidebar {
    width: 100%;
    max-height: none;
    overflow: visible;
  }

  .mp-routes-panel { max-height: none; }

  .mp-map-wrapper {
    height: 60vh;
    min-height: 300px;
  }

  .mp-header-sub { display: none; }

  .mp-narrative { overflow: visible; }
}

/* ── Dark mode refinements ──────────────────────────────── */
body.dark-mode .mp-header {
  background: linear-gradient(135deg, #0d0d0d, #1a1a1a, #222);
}
body.dark-mode .mp-route-card { background: var(--surface-alt); }
body.dark-mode .mp-testimony { background: var(--surface-alt); }
body.dark-mode .mp-audio-wrapper { background: var(--surface-alt); }
body.dark-mode .mp-legend { background: var(--surface); }
body.dark-mode .leaflet-tile { filter: brightness(0.7) saturate(0.8); }
