/* ─── Token Definitions: Raw values (single source of truth) ─ */
:root {
  /* Light palette */
  --light-bg: #f5f2ec;
  --light-surface: #edeae3;
  --light-surface-2: #e4e0d8;
  --light-border: rgba(0, 0, 0, 0.09);
  --light-border-strong: rgba(0, 0, 0, 0.18);
  --light-text-primary: #1a1814;
  --light-text-muted: #5a5550;
  --light-text-dim: #7a7570;
  --light-accent: #7d5820;
  --light-accent-soft: rgba(125, 88, 32, 0.12);
  --light-tile-filter: grayscale(100%) brightness(1.08) contrast(0.92);
  --light-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);

  /* Dark palette */
  --dark-bg: #0e0e10;
  --dark-surface: #17171a;
  --dark-surface-2: #1f1f24;
  --dark-border: rgba(255, 255, 255, 0.08);
  --dark-border-strong: rgba(255, 255, 255, 0.16);
  --dark-text-primary: #f0ece4;
  --dark-text-muted: #9e9a94;
  --dark-text-dim: #6e6a65;
  --dark-accent: #c8a96e;
  --dark-accent-soft: rgba(200, 169, 110, 0.15);
  --dark-tile-filter: grayscale(100%) brightness(0.28) contrast(1.1);
  --dark-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);

  /* Non-themeable tokens */
  --font-display: "Playfair Display", Georgia, serif;
  --font-mono: "DM Mono", "Courier New", monospace;
  --radius: 6px;
}

/* ─── Active Theme: default = light ─────────────────────── */
:root {
  --bg: var(--light-bg);
  --surface: var(--light-surface);
  --surface-2: var(--light-surface-2);
  --border: var(--light-border);
  --border-strong: var(--light-border-strong);
  --text-primary: var(--light-text-primary);
  --text-muted: var(--light-text-muted);
  --text-dim: var(--light-text-dim);
  --accent: var(--light-accent);
  --accent-soft: var(--light-accent-soft);
  --tile-filter: var(--light-tile-filter);
  --shadow: var(--light-shadow);
}

/* System dark → dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--dark-bg);
    --surface: var(--dark-surface);
    --surface-2: var(--dark-surface-2);
    --border: var(--dark-border);
    --border-strong: var(--dark-border-strong);
    --text-primary: var(--dark-text-primary);
    --text-muted: var(--dark-text-muted);
    --text-dim: var(--dark-text-dim);
    --accent: var(--dark-accent);
    --accent-soft: var(--dark-accent-soft);
    --tile-filter: var(--dark-tile-filter);
    --shadow: var(--dark-shadow);
  }
}

/* Manual toggle: checkbox checked = force dark (when system is light) */
body:has(.theme-checkbox:checked) {
  --bg: var(--dark-bg);
  --surface: var(--dark-surface);
  --surface-2: var(--dark-surface-2);
  --border: var(--dark-border);
  --border-strong: var(--dark-border-strong);
  --text-primary: var(--dark-text-primary);
  --text-muted: var(--dark-text-muted);
  --text-dim: var(--dark-text-dim);
  --accent: var(--dark-accent);
  --accent-soft: var(--dark-accent-soft);
  --tile-filter: var(--dark-tile-filter);
  --shadow: var(--dark-shadow);
}

/* System dark + checkbox checked = force light */
@media (prefers-color-scheme: dark) {
  body:has(.theme-checkbox:checked) {
    --bg: var(--light-bg);
    --surface: var(--light-surface);
    --surface-2: var(--light-surface-2);
    --border: var(--light-border);
    --border-strong: var(--light-border-strong);
    --text-primary: var(--light-text-primary);
    --text-muted: var(--light-text-muted);
    --text-dim: var(--light-text-dim);
    --accent: var(--light-accent);
    --accent-soft: var(--light-accent-soft);
    --tile-filter: var(--light-tile-filter);
    --shadow: var(--light-shadow);
  }
}

/* ─── Reset / Base ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

/* playfair-display-regular - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/playfair-display-v40-latin-regular.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* playfair-display-700 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 700;
  src: url("../fonts/playfair-display-v40-latin-700.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* dm-mono-300 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 300;
  src: url("../fonts/dm-mono-v16-latin-300.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* dm-mono-regular - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/dm-mono-v16-latin-regular.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

html {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  /* No font-size override — respects browser/system setting (like prefers-color-scheme).
     JS sets an explicit px value only when the user picks small (15px) or large (20px). */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Hide the actual checkboxes */
.theme-checkbox,
.about-checkbox,
.timeline-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* ─── Icon Buttons (shared base) ────────────────────────── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1;
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
  flex-shrink: 0;
  user-select: none;
  cursor: pointer;
}
.icon-btn:focus-visible,
.info-panel-btn:focus-visible,
.fontsize-btn:focus-visible,
.timeline-search-input:focus-visible,
.ctrl-select:focus-visible,
.search-clear-btn:focus-visible,
.ctrl-fav-label:focus-visible,
.about-impressum a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}
@media (hover: hover) {
  .icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

/* Per-button overrides */
.about-label {
  margin-left: auto;
  font-weight: 400;
}
.about-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 1.2rem;
}
.timeline-close {
  font-size: 1.2rem;
}
.timeline-open-label {
  font-size: 1.1rem;
}

/* ─── Header ────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.5rem;
  flex-shrink: 0;
}

/* Compact header in landscape to save vertical space */
@media (orientation: landscape) and (max-height: 500px) {
  .site-header {
    padding: 0.4rem 1rem;
  }
  .site-title {
    font-size: 1.1rem;
  }
  .header-date {
    font-size: 0.65rem;
  }
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.header-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  margin: 0.125rem 0;
}

.title-city {
  color: var(--accent);
  font-style: italic;
}

/* Show/hide moon vs sun icon.
   Default (light mode): show moon (to switch to dark).
   Dark mode active: show sun (to switch to light).    */
.theme-icon {
  line-height: 1;
}
.theme-icon--light {
  display: block;
} /* moon = switch to dark */
.theme-icon--dark {
  display: none;
} /* sun  = switch to light */

/* System dark or toggle-forced dark: show sun */
@media (prefers-color-scheme: dark) {
  .theme-icon--light {
    display: none;
  }
  .theme-icon--dark {
    display: block;
  }
  body:has(.theme-checkbox:checked) .theme-icon--light {
    display: block;
  }
  body:has(.theme-checkbox:checked) .theme-icon--dark {
    display: none;
  }
}
body:has(.theme-checkbox:checked) .theme-icon--light {
  display: none;
}
body:has(.theme-checkbox:checked) .theme-icon--dark {
  display: block;
}

/* ─── Layout ────────────────────────────────────────────── */
.container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--border);
  gap: 1px;
  min-height: 0;
}

.map-section {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
  flex: 1;
}

.section-header {
  display: flex;
  flex-direction: column;
  padding: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-header-row--title {
  padding: 0.35rem 0.6rem 0.35rem 1rem;
}

.section-header-row--controls {
  padding: 0.3rem 0.6rem;
  border-top: 1px solid var(--border);
  justify-content: center;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.6rem 1rem 0.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-header .section-label,
.timeline-dialog-header .section-label {
  padding: 0.25rem 0;
  border-bottom: none;
  flex: 1;
}

@media (orientation: landscape) and (max-height: 500px) {
  .section-header-row--title {
    padding: 0.2rem 0.4rem 0.2rem 0.6rem;
  }
  .section-header-row--controls {
    padding: 0.15rem 0.4rem;
  }
  .section-header .section-label,
  .timeline-dialog-header .section-label {
    font-size: 0.72rem;
  }
  .ctrl-select {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
  }
  .ctrl-fav-label {
    width: 1.6rem;
    height: 1.6rem;
  }
  .timeline-search-input {
    width: 5rem;
    font-size: 16px;
    padding: 0.15rem 0.3rem;
  }
}

/* ─── Timeline Controls ─────────────────────────────────── */
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.ctrl-select {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.ctrl-select:focus {
  outline: 1px solid var(--accent);
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.timeline-search-input {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 0.25rem 0.5rem;
  width: 8rem;
  flex: 1;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
}
.timeline-search-input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.timeline-search-input::placeholder {
  color: var(--text-muted);
}
.timeline-search-input:focus {
  border-color: var(--accent);
}

.search-wrapper:has(.search-clear-btn:not([hidden])) .timeline-search-input {
  padding-right: 1.6rem;
}

.search-clear-btn {
  position: absolute;
  right: 0.3rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  border-radius: var(--radius);
}
@media (hover: hover) {
  .search-clear-btn:hover {
    color: var(--text-primary);
  }
}

.ctrl-fav-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
  user-select: none;
  color: var(--text-dim);
}
.ctrl-fav-label:has(:not(:disabled)) {
  cursor: pointer;
}
.ctrl-fav-label:has(:disabled) {
  opacity: 0.35;
  cursor: not-allowed;
}
.ctrl-fav-label:has(:checked) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
@media (hover: hover) {
  .ctrl-fav-label:not(:has(:disabled)):hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

/* Timeline dialog fav label: references #fav-toggle via for= (doesn't wrap the input),
   so :has() can't see the input state — drive styles from body :has() instead */
body:has(#fav-toggle:checked) #fav-toggle-timeline-label {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
body:has(#fav-toggle:disabled) #fav-toggle-timeline-label {
  opacity: 0.35;
  cursor: not-allowed;
}
body:not(:has(#fav-toggle:disabled)) #fav-toggle-timeline-label {
  cursor: pointer;
}
@media (hover: hover) {
  body:not(:has(#fav-toggle:disabled)) #fav-toggle-timeline-label:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

.fav-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ctrl-fav-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ─── Favorites ─────────────────────────────────────────── */
.bar-fav-star {
  pointer-events: none;
}

.markers circle.marker-dot.favorited {
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(
    0 0 4px color-mix(in srgb, var(--accent) 60%, transparent)
  );
}

.markers .marker-hidden {
  display: none;
}
.markers .search-dimmed {
  opacity: 0.12;
  pointer-events: none;
}

@keyframes fav-burst {
  0% {
    transform: scale(14);
    opacity: 1;
    stroke-width: 6;
    fill: var(--accent);
    fill-opacity: 0.45;
  }
  20% {
    stroke-width: 4;
    opacity: 1;
  }
  65% {
    transform: scale(128);
    opacity: 0.7;
    fill-opacity: 0.35;
    stroke-width: 2.5;
  }
  85% {
    transform: scale(128);
    opacity: 0.5;
    fill-opacity: 0.3;
    stroke-width: 1.5;
  }
  100% {
    transform: scale(128);
    opacity: 0;
    stroke-width: 1.5;
    fill-opacity: 0;
  }
}

@keyframes unfav-burst {
  0% {
    transform: scale(128);
    opacity: 0.6;
    stroke-width: 2;
    fill-opacity: 0.2;
  }
  60% {
    transform: scale(18);
    opacity: 0.8;
    stroke-width: 4;
    fill-opacity: 0.1;
  }
  100% {
    transform: scale(14);
    opacity: 0;
    stroke-width: 6;
    fill-opacity: 0;
  }
}

.markers circle.marker-fav-burst {
  pointer-events: none;
  fill: none;
  stroke: var(--accent);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  vector-effect: non-scaling-stroke;
}

.markers circle.marker-fav-burst.bursting {
  animation: fav-burst 0.85s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

.markers circle.marker-fav-burst.unfaving {
  stroke: var(--text-muted);
  animation: unfav-burst 0.6s cubic-bezier(0.4, 0, 0.8, 0.6) forwards;
}

/* ─── Map ───────────────────────────────────────────────── */
.map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  -webkit-user-select: none;
  user-select: none;
}

#theMap {
  display: block;
  width: 100%;
  height: 100%;
}

/* Tile filter is applied via SVG <filter> in JS for WebKit/iOS compatibility.
   CSS filter on SVG <image> elements is not supported on Safari/iOS. */

/* OSM attribution — required by ODbL / Tile Usage Policy */
.map-attribution {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: auto;
  line-height: 1.6;
  z-index: 10;
}
.map-attribution a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}
@media (hover: hover) {
  .map-attribution a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
}


.markers circle.marker-dot {
  transition:
    opacity 0.2s ease,
    filter 0.2s ease;
  cursor: pointer;
}

.markers circle.marker-dot.highlighted {
  /* drop-shadow via CSS filter is unsupported on SVG elements in iOS Safari (same issue as
     tile grayscale filter — ADR 005). The actual glow filter is applied via SVG <filter> in
     map.ts (buildSvgFilters), referenced as filter="url(#marker-highlight)" by JS. */
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.35);
}

/* Cross-highlight: triggered from the other view. Slightly less intense than local selection. */
.markers circle.marker-dot.cross-highlighted {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.25);
}

@media (hover: hover) {
  .markers circle.marker-dot.cross-highlighted:hover {
    transform: scale(1.4);
  }
}

.markers circle.marker-dot.dimmed {
  opacity: 0.25;
}


/* ─── User Location Marker ──────────────────────────────── */
.user-location-dot {
  fill: #3b82f6;
  stroke: #fff;
  stroke-width: 2;
  pointer-events: none;
}

.icon-btn.locate-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ─── Timeline Wrapper ──────────────────────────────────── */
.timeline-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  min-height: 0;
  touch-action: none; /* d3-zoom controls both axes; browser must not consume any touch events */
  -webkit-user-select: none;
  user-select: none;
}

#theTimeline {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Axis text (colours set via JS/SVG attr for D3 compat) */
.x-axis .domain,
.y-axis .domain {
  display: none;
}

/* Vertical grid lines */
.grid-lines line {
  stroke: var(--border);
  stroke-width: 1;
}
.grid-lines .domain {
  display: none;
}

/* Hour tick marks on x-axis */
.x-axis .tick line {
  stroke: var(--border-strong);
  stroke-width: 1;
}

/* Bars */
.bar {
  cursor: pointer;
  transition:
    opacity 0.25s ease,
    filter 0.25s ease,
    transform 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
  transform-box: fill-box;
  transform-origin: center;
}

.bar.highlighted {
  /* filter set via JS with bar's own color for the glow */
  opacity: 1;
}

/* Cross-highlight: triggered from map selection. Filter applied via JS. */
.bar.cross-highlighted {
  opacity: 1;
}

.bar.dimmed {
  opacity: 0.22;
  filter: saturate(0.4);
}

/* Bar selection burst overlay */
.bar-select-burst {
  pointer-events: none;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes bar-burst {
  0% {
    opacity: var(--burst-opacity, 0.7);
    transform: scaleX(1) scaleY(1);
  }
  40% {
    opacity: calc(var(--burst-opacity, 0.7) * 0.71);
    transform: scaleX(1.06) scaleY(1.1);
  }
  100% {
    opacity: 0;
    transform: scaleX(1.12) scaleY(1.2);
  }
}

.bar-select-burst.bursting {
  animation: bar-burst 0.4s cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
}

/* Fav-add burst: bar flashes outward with accent colour */
@keyframes bar-fav-burst {
  0% {
    opacity: 0.7;
    transform: scaleX(1) scaleY(1);
    fill: var(--accent);
  }
  40% {
    opacity: 0.55;
    transform: scaleX(1.07) scaleY(1.12);
  }
  100% {
    opacity: 0;
    transform: scaleX(1.14) scaleY(1.22);
  }
}

/* Fav-remove burst: bar collapses inward and fades */
@keyframes bar-unfav-burst {
  0% {
    opacity: 0.6;
    transform: scaleX(1) scaleY(1);
    fill: var(--text-muted);
  }
  50% {
    opacity: 0.45;
    transform: scaleX(0.92) scaleY(0.7);
  }
  100% {
    opacity: 0;
    transform: scaleX(0.88) scaleY(0);
  }
}

.bar-fav-burst {
  pointer-events: none;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.bar-fav-burst.fav-bursting {
  animation: bar-fav-burst 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

.bar-fav-burst.unfav-bursting {
  animation: bar-unfav-burst 0.5s cubic-bezier(0.4, 0, 0.7, 0.5) forwards;
}

/* Row bands */
.row-band {
  pointer-events: none;
}

/* ─── Info Panel ─────────────────────────────────────────── */
.info-resizer {
  height: 8px;
  flex-shrink: 0;
  cursor: ns-resize;
  background: color-mix(in srgb, var(--accent) 50%, transparent);
  position: relative;
  touch-action: none;
  user-select: none;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Three dot drag indicator, centered */
.info-resizer::before {
  content: "...";
  position: absolute;
  font-size: 1rem;
  font-weight: 700;
  line-height: 0.1rem;
  height: 0.5rem;
  vertical-align: middle;
  color: var(--text-primary);
  pointer-events: none;
}
.info-resizer::after {
  content: "";
  position: absolute;
  inset: -6px 0;
}
.info-panel {
  height: 5.33rem; /* ~80px at 15px base */
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.info-panel-placeholder {
  color: var(--text-dim);
  font-style: italic;
  line-height: 2.5;
}
.info-panel-location {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  white-space: pre-line;
}
.info-panel-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.info-panel-row td {
  vertical-align: middle;
  padding: 0.15rem 0.25rem 0.15rem 0;
  white-space: nowrap;
}
.info-panel-event-name {
  color: var(--text-primary);
  width: 100%; /* expands to fill remaining space */
  max-width: 0; /* forces truncation in table-layout: auto */
  overflow: hidden;
  text-overflow: ellipsis;
}
.info-panel-time {
  color: var(--accent);
  font-size: 0.8rem;
  padding-left: 0.5rem;
  text-align: right;
}

/* Action buttons (★ / ⓘ) inside info-panel event rows */
.info-panel-actions {
  display: inline-flex;
  gap: 0.3rem;
  padding-left: 0.3rem;
  flex-shrink: 0;
  vertical-align: middle;
  justify-content: flex-end;
}
.info-panel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
}
.info-panel-btn--fav.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
@media (hover: hover) {
  .info-panel-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

/* ─── Dialogs (shared base) ─────────────────────────────── */

/* Prevent body scroll while any dialog is open */
body:has(.about-checkbox:checked),
body:has(.timeline-checkbox:checked) {
  overflow: hidden;
}

/* Backdrop: full-screen label that toggles the checkbox on click */
.about-backdrop,
.timeline-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  cursor: default;
}

body:has(.about-checkbox:checked) .about-backdrop,
body:has(.timeline-checkbox:checked) .timeline-backdrop {
  display: block;
}

/* Overlay: positions the dialog box above the backdrop */
.about-overlay,
.timeline-overlay {
  display: none;
  position: fixed;
  z-index: 201;
  pointer-events: none;
}

body:has(.about-checkbox:checked) .about-overlay,
body:has(.timeline-checkbox:checked) .timeline-overlay {
  display: flex;
}

/* ─── About Dialog ──────────────────────────────────────── */
.about-overlay {
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.about-dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--accent);
  border-radius: calc(var(--radius) * 2);
  box-shadow: var(--shadow);
  padding: 3.5rem 2rem 2.5rem;
  max-width: 520px;
  width: 100%;
  pointer-events: auto;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

@media (min-width: 400px) {
  .about-dialog {
    padding: 4rem 2.75rem 3rem;
  }
}

.about-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

/* Primary headline — large display type, centred */
.about-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 2rem 0;
}

/* Secondary line — accent-coloured subheadline, centred */
.about-subline {
  font-family: var(--font-display);
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 400;
  color: var(--accent);
  line-height: 1.3;
  margin-bottom: 1.5rem;
}

/* Heart icons in about dialog */
.about-heart {
  font-style: normal;
  color: var(--accent);
}
.about-heart--accent {
  font-size: 0.9em;
}

/* How-to section */
.about-howto {
  width: 100%;
  text-align: left;
  margin-bottom: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.about-howto-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.about-howto-list {
  list-style: none;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.about-howto-list li {
  display: contents;
}

.about-howto-list li strong {
  color: var(--text-primary);
  font-weight: 400;
}

.about-howto-icon {
  color: var(--accent);
  font-size: 1em;
  white-space: nowrap;
  padding-top: 0.05em;
}

.about-howto-icon strong {
  color: var(--text-primary);
  font-weight: 400;
  font-size: 0.82rem;
}

/* Font size selector in about dialog */
.about-fontsize {
  width: 100%;
  text-align: left;
  margin-bottom: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.about-fontsize-btns {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.fontsize-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  padding: 0.3rem 0.8rem;
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
  line-height: 1;
}

.fontsize-btn:nth-child(1) {
  font-size: 0.78rem;
}
.fontsize-btn:nth-child(2) {
  font-size: 1rem;
}
.fontsize-btn:nth-child(3) {
  font-size: 1.25rem;
}

@media (hover: hover) {
  .fontsize-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

.fontsize-btn--active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* PWA install hint in about dialog */
.about-install {
  width: 100%;
  text-align: left;
  margin-bottom: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.about-install-list {
  list-style: none;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.75rem;
}

.about-install-list li {
  display: contents;
}

.about-install-list li strong {
  color: var(--text-primary);
  font-weight: 400;
  white-space: nowrap;
}

/* Divider before impressum */
.about-impressum {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  width: 100%;
}

.about-impressum a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  transition:
    border-color 0.2s,
    color 0.2s;
}
@media (hover: hover) {
  .about-impressum a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
}

/* ─── Timeline Dialog ───────────────────────────────────── */
.timeline-overlay {
  inset: 2vh 2vw;
}

.timeline-dialog {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--accent);
  border-radius: calc(var(--radius) * 2);
  box-shadow: var(--shadow);
  width: 100%;
  height: 100%;
  pointer-events: auto;
  overflow: hidden;
}

.timeline-dialog-header {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── Category Legend ────────────────────────────────────── */
/* Colour values mirror CATEGORY_COLORS in constants.ts */
:root {
  --cat-musik:         #A0237A;
  --cat-darstellend:   #CF872E;
  --cat-kunst:         #A6AD3C;
  --cat-film:          #1e8393;
  --cat-kinder:        #F0CE4E;
  --cat-literatur:     #8A211D;
}

.category-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
  padding: 0.45rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Cat-chip: uses --cat-col (category colour) and --cat-on (text on filled bg).
   We avoid using `color` as a proxy for the category colour, because:
   - `border: 1px solid currentColor` and `background: currentColor` (::before dot)
     both read from `color` — mixing text-colour and fill-colour on the same property
     causes conflicts when .active needs a different text colour.
   Solution: store the category colour in --cat-col; derive border/dot from it explicitly;
   use `color` only for text. */
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.15em 0.6em 0.15em 0.4em;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.4;
  background: transparent;
  border: 1px solid var(--cat-col);
  color: var(--cat-text, var(--cat-col));
  opacity: 0.85;
  white-space: nowrap;
}

.cat-chip::before {
  content: '';
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--cat-col);
}

/* Per-chip: set --cat-col (fill/border) and --cat-on (text when active).
   --cat-text overrides text colour when the raw category colour is too light to read
   on the page background (e.g. Kinderprogramm gold on light bg). */
.cat-chip[data-cat="Musik"]                        { --cat-col: var(--cat-musik);    --cat-on: #f0ece4; }
.cat-chip[data-cat="Literatur"]                    { --cat-col: var(--cat-literatur); --cat-on: #f0ece4; }
.cat-chip[data-cat="Film / Medien"]                { --cat-col: var(--cat-film);     --cat-on: #f0ece4; }
.cat-chip[data-cat="Bildende Kunst / Installation"] { --cat-col: var(--cat-kunst);   --cat-on: #1a1814; }
.cat-chip[data-cat="Kinderprogramm"]               { --cat-col: var(--cat-kinder);   --cat-on: #1a1814; --cat-text: #a08a00; }
.cat-chip[data-cat="Darstellende Kunst"]           { --cat-col: var(--cat-darstellend); --cat-on: #1a1814; }

.cat-chip[role="button"] { cursor: pointer; }

.cat-chip.active {
  opacity: 1;
  background: var(--cat-col);
  color: var(--cat-on);
}

.cat-chip.active::before {
  background: var(--cat-on);
}

@media (hover: hover) {
  .cat-chip[role="button"]:not(.active):hover {
    opacity: 1;
    background: color-mix(in srgb, var(--cat-col) 12%, transparent);
  }
}

/* ─── Detail Dialog (JS-driven) ──────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.detail-overlay[hidden] {
  display: none;
}
.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: default;
}
.detail-dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--accent);
  border-radius: calc(var(--radius) * 2);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem 2rem;
  max-width: 420px;
  width: 100%;
  pointer-events: auto;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.detail-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 1.2rem;
}
.detail-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.detail-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.detail-location {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-line;
  line-height: 1.5;
}
.detail-time {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 700;
}
.detail-bereich {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.detail-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.detail-category {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  line-height: 1.4;
  white-space: nowrap;
}
.detail-description {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  white-space: pre-line;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 2px;
}
