:root {
  --dp-red: #aa1e22;
  --dp-white: #ffffff;
  --serif: 'ivypresto-text', 'Lora', 'Times', serif;   /* years */
  --georgia: Georgia, 'Times New Roman', serif;          /* addresses + titles */
}

html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
  overscroll-behavior: none;          /* no pull-to-refresh / bounce on mobile */
  -webkit-text-size-adjust: 100%;     /* stop iOS auto-enlarging text on rotate */
}

#map {
  position: absolute;
  inset: 0;
}

/* ---------- Time slider panel ---------- */
.timeline {
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  box-sizing: border-box;
  padding: 16px 20px 14px;
  background: var(--dp-white);
  border-top: 4px solid var(--dp-red);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  z-index: 5;
}

.date-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.nav-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.nav-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1.5px solid var(--dp-red);
  border-radius: 50%;
  background: var(--dp-white);
  color: var(--dp-red);
  display: grid;
  place-items: center;
  box-sizing: border-box;
  cursor: pointer;
}
.nav-btn svg { display: block; }
@media (hover: hover) {
  .nav-btn:hover:not(:disabled) { background: var(--dp-red); color: var(--dp-white); }
}
.nav-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.nav-btn:focus-visible { outline: 2px solid var(--dp-red); outline-offset: 2px; }
.nav-btn:disabled { opacity: 0.35; cursor: default; }

.year {
  font-family: var(--serif);
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1;
  color: var(--dp-red);
  text-box: trim-both cap alphabetic;
}

#slider {
  width: 100%;
  touch-action: pan-x;
  accent-color: var(--dp-red);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--serif);
  font-size: 0.8rem;
  color: #777;
}

.events {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 22vh;
  overflow-y: auto;
  font-family: var(--georgia);
}

.events:empty { display: none; }

.events li {
  padding: 8px 0;
  border-top: 1px solid #e6e6e6;
  cursor: default;
}
.events li.has-location { cursor: pointer; }
.events li.has-location:hover .ev-title { color: var(--dp-red); }

.ev-address {
  font-family: var(--georgia);
  font-size: 0.8rem;
  color: #777;
}
.ev-title {
  font-family: var(--georgia);
  font-size: 1rem;
  font-weight: bold;
  color: #222;
}

/* ---------- Centered text popup (no-location rows) ---------- */
.center-note {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 48px));
  box-sizing: border-box;
  padding: 18px 22px;
  background: var(--dp-white);
  border-top: 4px solid var(--dp-red);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-family: var(--georgia);
  text-align: center;
  z-index: 4;
  pointer-events: none;
}
.center-note[hidden] { display: none; }
.center-note .note + .note { margin-top: 14px; padding-top: 14px; border-top: 1px solid #e6e6e6; }
.center-note .note-title { font-weight: bold; font-size: 1.1rem; margin-bottom: 4px; }
.center-note .note-desc { font-size: 0.95rem; line-height: 1.45; color: #333; }

/* ---------- Map marker popups ---------- */
.maplibregl-popup-content {
  font-family: var(--georgia);
  padding: 12px 16px;
}
.popup-address { font-size: 0.8rem; color: #777; margin-bottom: 2px; }
.popup-title { font-weight: bold; font-size: 1rem; margin-bottom: 4px; }
.popup-desc { font-size: 0.9rem; line-height: 1.4; color: #333; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  /* Timeline becomes a bottom sheet that sits flush with the screen edge */
  .timeline {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right));
    border-radius: 12px 12px 0 0;
  }

  .date-row { gap: 12px; margin-bottom: 8px; }

  /* Bigger tap targets (~44px is the recommended minimum) */
  .nav-btn { width: 44px; height: 44px; }

  .year { font-size: 1.75rem; }

  #slider { height: 32px; margin: 0; }

  /* Keep the no-location note above the bottom sheet */
  .center-note {
    top: 38%;
    width: calc(100% - 32px);
    padding: 14px 16px;
  }

  /* Pinch-to-zoom replaces the +/- buttons on phones */
  .maplibregl-ctrl-top-right .maplibregl-ctrl-group { display: none; }

  .maplibregl-popup-content { padding: 10px 14px; }
  .maplibregl-popup-close-button { width: 32px; height: 32px; font-size: 20px; }
  .popup-desc { font-size: 0.85rem; max-height: 30vh; overflow-y: auto; }
}

/* Short landscape phones: tighten the sheet so the map stays visible */
@media (max-height: 480px) and (orientation: landscape) {
  .timeline { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .year { font-size: 1.5rem; }
  .range-labels { display: none; }
}
