/* ============================================================
   MAP PAGE — layout, panel, marker styles
   Final Album palette: #eff2fb / #161e50 / #1638b0
   ============================================================ */

/* ── Theme baseline ──────────────────────────────────────── */

:root {
  --color-bg:               #eff2fb;
  --color-bg-alt:           #dfe5f4;
  --color-text:             #161e50;
  --color-accent:           #1638b0;
  --color-accent-secondary: #0f2a98;
  --font-heading:           'Playfair Display', serif;
  --font-body:              'Lato', sans-serif;
  --border-radius:          2px;

  --map-panel-width: 380px;
  --map-header-h:    58px; /* matches .site-header height */
}

/* ── Full-height body so map fills viewport ──────────────── */

html {
  height: 100%;
}

body.map-page {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  /* overflow:hidden is intentionally omitted — on iOS Safari it interferes
     with Leaflet's layer pane stacking and clips markers */
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}

body.map-page .site-footer {
  display: none;
}

/* ── Main layout ─────────────────────────────────────────── */

#map-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-layout {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* ── Map container ───────────────────────────────────────── */

.map-container {
  flex: 1;
  min-width: 0;
  position: relative;
}

#gig-map {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

/* ── Side panel ──────────────────────────────────────────── */

.map-panel {
  width: var(--map-panel-width);
  flex-shrink: 0;
  background: var(--color-bg);
  border-left: 1px solid var(--color-accent);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal);
}

.map-panel[hidden] {
  display: none;
}

.map-panel__close {
  align-self: flex-end;
  margin: var(--space-sm) var(--space-sm) 0;
  padding: var(--space-xs);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  opacity: 0.5;
  transition: opacity var(--transition-fast);
  border-radius: var(--border-radius);
  line-height: 0;
}

.map-panel__close:hover,
.map-panel__close:focus-visible {
  opacity: 1;
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.map-panel__close svg {
  width: 20px;
  height: 20px;
}

.map-panel__venue {
  padding: var(--space-md) var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--color-bg-alt);
}

.map-panel__venue-name {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: var(--space-xs);
}

.map-panel__venue-city {
  font-size: var(--text-sm);
  color: var(--color-accent);
  letter-spacing: 0.04em;
}

.map-panel__gig-count {
  font-size: var(--text-sm);
  opacity: 0.65;
  margin-top: var(--space-xs);
}

.map-panel__gigs {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* ── Gig card inside the panel ───────────────────────────── */

.map-gig-card {
  background: var(--color-bg-alt);
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  padding: var(--space-md);
  scroll-margin-top: var(--space-sm);
  transition: border-color var(--transition-fast);
}

.map-gig-card--highlighted {
  border-color: var(--color-accent);
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.map-gig-card__type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.map-gig-card__title {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  line-height: 1.3;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.map-gig-card__date {
  font-size: var(--text-sm);
  opacity: 0.7;
  margin-bottom: var(--space-sm);
}

.map-gig-card__members {
  font-size: var(--text-sm);
  opacity: 0.75;
  font-style: italic;
  margin-bottom: var(--space-sm);
}

.map-gig-card__description {
  font-size: var(--text-sm);
  line-height: 1.55;
  margin-bottom: var(--space-sm);
}

/* Rich descriptions keep the markup authored in content.json — the global
   reset zeroes margins, so the blocks inside need their own spacing. */
.map-gig-card__description--rich p {
  margin-bottom: var(--space-sm);
}

.map-gig-card__description--rich p:last-child {
  margin-bottom: 0;
}

.map-gig-card__description--rich ul,
.map-gig-card__description--rich ol {
  margin: 0 0 var(--space-sm) var(--space-sm);
  padding-left: var(--space-md);
}

.map-gig-card__description--rich li {
  margin-bottom: var(--space-xs);
}

.map-gig-card__description--rich h3,
.map-gig-card__description--rich h4 {
  font-size: var(--text-base);
  margin: var(--space-sm) 0 var(--space-xs);
}

.map-gig-card__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-fast);
}

.map-gig-card__link:hover,
.map-gig-card__link:focus-visible {
  color: var(--color-accent-secondary);
  text-decoration: underline;
}

.map-gig-card__link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Leaflet popup content ───────────────────────────────── */

.map-popup strong {
  display: block;
  font-family: var(--font-heading);
  font-size: var(--text-base);
  color: var(--color-text);
  margin-bottom: 2px;
}

.map-popup__city {
  font-size: var(--text-sm);
  color: var(--color-accent);
  margin-bottom: var(--space-xs);
}

.map-popup__gigs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-popup__gigs li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 6px;
  border-top: 1px solid var(--color-bg-alt);
}

.map-popup__date {
  font-size: 0.75rem;
  opacity: 0.65;
}

.map-popup__link {
  font-size: var(--text-sm);
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
}

.map-popup__link:hover {
  text-decoration: underline;
}

/* ── Leaflet overrides ───────────────────────────────────── */

.leaflet-container {
  font-family: var(--font-body);
  background: var(--color-bg-alt);
}

/* Custom marker pin */
.map-marker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-marker-icon svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  transition: transform var(--transition-fast);
}

.map-marker-icon:hover svg,
.map-marker-icon--active svg {
  transform: scale(1.25);
}

/* Cluster bubble colours to match accent */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(22, 56, 176, 0.18);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(22, 56, 176, 0.75);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.8rem;
}

/* ── Year filter control ─────────────────────────────────── */

.map-filter {
  background: var(--color-bg);
  border: 1px solid var(--color-accent);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  padding: var(--space-sm);
  min-width: 236px;
  font-family: var(--font-body);
  color: var(--color-text);
}

.map-filter__row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.map-filter__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--color-accent);
}

.map-filter__select {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-bg-alt);
  border-radius: var(--border-radius);
  padding: 4px 6px;
  cursor: pointer;
}

.map-filter__select:focus-visible,
.map-filter__step:focus-visible,
.map-filter__journey:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.map-filter__step {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-accent);
  background: var(--color-bg-alt);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.map-filter__step:hover:not(:disabled) {
  background: var(--color-accent);
  color: var(--color-bg);
}

.map-filter__step:disabled {
  opacity: 0.3;
  cursor: default;
}

.map-filter__summary {
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.75;
}

.map-filter__journey {
  margin-top: var(--space-sm);
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-bg);
  background: var(--color-accent);
  border: none;
  border-radius: var(--border-radius);
  padding: 6px 10px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.map-filter__journey:hover:not(:disabled) {
  background: var(--color-accent-secondary);
}

.map-filter__journey[hidden] {
  display: none;
}

/* ── Journey animation ──────────────────────── */

.map-journey-vehicle {
  --journey-vehicle-color: var(--color-accent);
  background: none;
  border: none;
}

.map-journey-vehicle__art {
  display: block;
  /* Rotated about its own centre so the vehicle pivots on the route line
     rather than swinging around a corner of its box. */
  transform-origin: 50% 50%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  will-change: transform;
}

.map-journey__caption {
  position: absolute;
  left: 50%;
  bottom: var(--space-md);
  transform: translateX(-50%);
  z-index: 500; /* above Leaflet panes, below its controls */
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: min(720px, calc(100% - 2 * var(--space-md)));
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-accent);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  font-family: var(--font-body);
  color: var(--color-text);
}

.map-journey__caption[hidden] {
  display: none;
}

.map-journey__text {
  font-size: var(--text-sm);
  line-height: 1.4;
  margin: 0;
}

.map-journey__controls {
  flex-shrink: 0;
  display: flex;
  gap: var(--space-xs);
}

.map-journey__speed {
  min-width: 34px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-accent);
  background: var(--color-bg-alt);
  border: none;
  border-radius: var(--border-radius);
  padding: 3px 6px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.map-journey__speed:hover {
  background: var(--color-accent);
  color: var(--color-bg);
}

.map-journey__speed:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.map-journey__speed[hidden] {
  display: none;
}

/* ── Gig card disclosure ────────────────────── */

.map-gig-card__summary {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
  border-radius: var(--border-radius);
  /* Replace the default triangle with our own chevron. */
  list-style: none;
}

.map-gig-card__summary::-webkit-details-marker {
  display: none;
}

.map-gig-card__summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.map-gig-card__heading {
  flex: 1;
  min-width: 0;
}

/* The heading's last line shouldn't push space above the fold when shut. */
.map-gig-card__heading > :last-child {
  margin-bottom: 0;
}

.map-gig-card__chevron {
  flex-shrink: 0;
  line-height: 0;
  margin-top: 2px;
  color: var(--color-accent);
  transition: transform var(--transition-fast);
}

.map-gig-card__chevron svg {
  width: 16px;
  height: 16px;
}

.map-gig-card__disclosure[open] .map-gig-card__chevron {
  transform: rotate(180deg);
}

.map-gig-card__detail {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-bg);
}

.map-gig-card__detail > :last-child {
  margin-bottom: 0;
}

/* ── Journey panel cards ────────────────────── */

.map-gig-card__venue {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: var(--space-xs);
}

/* Each arrival fades in as it's appended, so the list visibly builds rather
   than silently growing while the reader is watching the map. */
.map-gig-card--journey {
  animation: map-journey-card-in var(--transition-normal) ease-out both;
}

@keyframes map-journey-card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .map-layout {
    flex-direction: column;
  }

  /* Map fills all space when panel is hidden; shares when panel is open */
  .map-container {
    flex: 1;
    min-height: 0;
  }

  .map-panel {
    width: 100%;
    flex-shrink: 0;
    border-left: none;
    border-top: 1px solid var(--color-accent);
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  :root {
    --map-panel-width: 100%;
  }

  .map-journey__caption {
    left: var(--space-xs);
    right: var(--space-xs);
    bottom: var(--space-xs);
    max-width: none;
    transform: none;
  }

  /* Keep the control from crowding the map on small screens */
  .map-filter {
    min-width: 0;
    max-width: calc(100vw - 96px);
    padding: var(--space-xs);
  }

  .map-filter__label {
    display: none;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .map-marker-icon svg,
  .map-panel,
  .map-gig-card,
  .map-filter__step,
  .map-filter__journey,
  .map-journey__speed {
    transition: none;
  }

  .map-gig-card--journey {
    animation: none;
  }

  .map-gig-card__chevron {
    transition: none;
  }

  .map-journey-vehicle__art {
    will-change: auto;
  }
}
