:root {
  /* App chrome (header, timeline): a calm slate, so the event colours on the map
     stand out. The brand red stays in the app icon only. */
  --accent: #3d4852;
  --accent-dark: #262e35;
  --bar-h: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
body { display: flex; flex-direction: column; }
.app-bar {
  height: var(--bar-h);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.3), 0 6px 16px rgba(0,0,0,.18);
  position: relative; /* keeps the bar (and its shadow) above the map */
  z-index: 1000;
}
.app-bar h1 { margin: 0; font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.app-logo { height: 30px; width: 30px; }
#map { flex: 1; }

/* Event popups */
/* Leaflet's popup frame: no inner padding, so the coloured header runs edge to edge */
.event-popup-wrap .leaflet-popup-content-wrapper { padding: 0; overflow: hidden; border-radius: 12px; }
.event-popup-wrap .leaflet-popup-content { margin: 0; line-height: 1.4; }
.event-popup-wrap a.leaflet-popup-close-button { color: #fff; opacity: .85; top: 6px; right: 6px; }
.event-popup-wrap a.leaflet-popup-close-button:hover { color: #fff; opacity: 1; }

.event-popup { --event-color: #555; font-size: 13px; color: #222; }
.event-popup .popup-header {
  background: var(--event-color); color: #fff;
  padding: 12px 34px 10px 14px;
}
.event-popup .popup-title { font-size: 15px; font-weight: 700; line-height: 1.25; }
.event-popup .popup-sport {
  margin-top: 3px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; opacity: .9;
}
.event-popup .popup-body { padding: 10px 14px 12px; }
.event-popup .popup-location {
  display: flex; align-items: center; gap: 5px; color: #555;
}
.event-popup .popup-location svg { flex: none; color: var(--event-color); }
.event-popup .popup-heading {
  margin: 12px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #888;
}
/* Austragungen: a year badge next to the name, rows separated by hairlines */
.event-popup .popup-editions { list-style: none; margin: 0; padding: 0; }
.event-popup .popup-editions li {
  display: flex; align-items: flex-start; gap: 10px; padding: 6px 0;
  border-top: 1px solid #eee;
}
.event-popup .popup-editions li:first-child { border-top: 0; padding-top: 0; }
.event-popup .popup-year {
  flex: none; min-width: 44px; padding: 2px 6px; border-radius: 10px; text-align: center;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--event-color) 14%, #fff);
  color: color-mix(in srgb, var(--event-color) 75%, #000);
}
.event-popup .popup-edition { display: flex; flex-direction: column; min-width: 0; }
.event-popup .popup-edition-name { font-weight: 500; }
.event-popup .popup-edition-date { color: #777; font-size: 12px; }
/* Photo carousel: one photo at a time */
.event-popup .carousel { margin-top: 12px; }
.event-popup .popup-photo { margin: 0; }
.event-popup .popup-photo[hidden] { display: none; }
.event-popup .carousel-nav {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px;
}
.event-popup .carousel-nav[hidden] { display: none; }
.event-popup .carousel-btn {
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--event-color) 14%, #fff);
  color: color-mix(in srgb, var(--event-color) 75%, #000);
  font-size: 20px; line-height: 28px; cursor: pointer;
}
.event-popup .carousel-btn:hover { background: color-mix(in srgb, var(--event-color) 24%, #fff); }
.event-popup .carousel-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.event-popup .carousel-count { color: #777; font-size: 0.85em; min-width: 3.5em; text-align: center; }
.event-popup .popup-photo img {
  /* whole image visible; black bars where it does not fit the frame */
  display: block; width: 100%; height: 160px; object-fit: contain;
  border-radius: 8px; background: #000;
}
/* Under each photo/video: Legende (biggest), then photographer, then credits (smallest) */
.event-popup .popup-photo figcaption { font-size: 14px; font-weight: 500; line-height: 1.4; color: #222; margin-top: 8px; }
.event-popup .popup-author { color: #555; font-size: 12px; margin-top: 4px; }
.event-popup .popup-credits { color: #888; font-size: 11px; margin-top: 2px; }
.event-pin { background: none; border: none; }
.event-pin svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }

/* "Mehr zum Event" link at the bottom of a popup */
.event-popup .popup-more {
  display: block; padding: 7px 10px; border-radius: 8px; text-align: center;
  font-weight: 600; text-decoration: none;
  background: color-mix(in srgb, var(--event-color) 14%, #fff);
  color: color-mix(in srgb, var(--event-color) 75%, #000);
}
.event-popup .popup-more:hover { background: color-mix(in srgb, var(--event-color) 24%, #fff); }
.event-popup .popup-description p { margin: 0 0 10px; line-height: 1.6; }
.event-popup .popup-description p:last-child { margin-bottom: 0; }

/* Event page (event.html): header stays on top, the content scrolls */
.app-bar a { color: #fff; text-decoration: none; }
.app-bar h1 a { display: flex; align-items: center; gap: 8px; }
.app-bar-back { margin-left: auto; font-size: .95rem; font-weight: 600; opacity: .9; }
.app-bar-back:hover { opacity: 1; text-decoration: underline; }
/* No card on the pages: content sits directly on the page, the coloured
   header runs as a full-width band under the app bar. */
body.page { background: #fff; }
.page-main { --page-top: 24px; flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--page-top) 16px 40px; }
.event-page { max-width: 760px; margin: 0 auto; }
.page-message { color: #555; }
.event-page > a { color: var(--accent); font-weight: 600; }
.event-page .event-popup { font-size: 15px; }
.event-page .popup-header {
  /* stretch to the edges of the page; text stays aligned with the content column */
  margin: calc(-1 * var(--page-top)) calc(50% - 50vw) 0;
  padding: 28px calc(50vw - 50%) 22px;
}
.event-page .popup-title { font-size: 28px; }
.event-page .popup-sport { font-size: 12px; margin-top: 6px; }
.event-page .popup-body { padding: 20px 0 8px; }
.event-page .popup-heading { margin-top: 22px; font-size: 12px; }
.event-page .carousel { margin-top: 18px; }
.event-page .popup-photo img { height: min(420px, 60vw); min-height: 200px; object-fit: contain; background: #e8e7e3; }
.event-page .popup-photo figcaption { font-size: 17px; }
.event-page .popup-author { font-size: 14px; }
.event-page .popup-credits { font-size: 12px; }
.event-page .popup-edition-date, .event-page .popup-year { font-size: 13px; }
.event-page .popup-description { font-size: 15px; color: #333; }
@media (max-width: 520px) {
  .page-main { --page-top: 0px; padding: 0 16px 32px; }
  .event-page .popup-header { padding-top: 20px; padding-bottom: 16px; }
  .event-page .popup-title { font-size: 22px; }
  .app-bar-back { font-size: .85rem; }
}

/* Clickable Austragungen (popups and event page) */
.event-popup .popup-editions li { padding: 0; }
.event-popup .popup-editions li > a { flex: 1; min-width: 0; }
.event-popup .popup-edition-link {
  display: flex; align-items: flex-start; gap: 10px; padding: 6px 4px; margin: 0 -4px;
  border-radius: 6px; color: inherit; text-decoration: none;
}
.event-popup .popup-editions li:first-child .popup-edition-link { padding-top: 4px; }
.event-popup .popup-edition-link:hover { background: color-mix(in srgb, var(--event-color) 8%, #fff); }
.event-popup .popup-edition-link:hover .popup-edition-name { text-decoration: underline; }
.event-popup .popup-edition-link:focus-visible { outline: 2px solid var(--event-color); outline-offset: 1px; }
.event-popup .popup-edition-chevron {
  margin-left: auto; align-self: center; padding-left: 6px;
  font-size: 18px; line-height: 1; color: color-mix(in srgb, var(--event-color) 75%, #000);
}

/* Austragung page: link to the event in the header, key facts, Rangliste text */
.event-popup .popup-sport a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.event-popup .facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; margin: 0;
}
.event-popup .facts div {
  padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--event-color) 8%, #fff);
}
.event-popup .facts dt {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #777;
}
.event-popup .facts dd { margin: 2px 0 0; font-weight: 600; }
.event-popup .ranking-text p { margin: 0 0 6px; line-height: 1.55; }
.event-popup .ranking-text p:last-child { margin-bottom: 0; }
.event-popup .page-empty { color: #777; font-style: italic; margin: 0; }

/* Austragung page: newspaper articles, one link card each */
.event-popup .press-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.event-popup .press-list + .popup-more, .event-popup .mini-map + .popup-more { margin-top: 24px; } /* breathing room before the button */
.event-popup .press-card {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: inherit; text-decoration: none;
  background: color-mix(in srgb, var(--event-color) 8%, #fff);
}
.event-popup .press-card:hover { background: color-mix(in srgb, var(--event-color) 14%, #fff); }
.event-popup .press-card:hover .press-open { text-decoration: underline; }
.event-popup .press-card:focus-visible { outline: 2px solid var(--event-color); outline-offset: 1px; }
.event-popup .press-icon { flex: none; margin-top: 2px; color: color-mix(in srgb, var(--event-color) 75%, #000); }
.event-popup .press-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.event-popup .press-source { font-size: 12px; color: #555; } /* author · date, like the photographer line */
.event-popup .press-title { font-weight: 700; font-family: Georgia, "Times New Roman", serif; font-size: 1.05em; line-height: 1.35; } /* the Legende */
.event-popup .press-open {
  margin-top: 2px; font-size: 12px; font-weight: 600;
  color: color-mix(in srgb, var(--event-color) 75%, #000);
}

/* Videos in the media carousel: the source's player in a 16:9 frame */
.event-popup .media-frame {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 8px; overflow: hidden; background: #111;
}
.event-popup .media-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; overflow: hidden; }
.event-popup .media-frame-4x3 { aspect-ratio: 4 / 3; }
/* On the pages, keep tall 4:3 players from taking over the screen */
.event-page .media-frame-4x3 { max-height: 520px; }
.event-popup .media-placeholder {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; text-decoration: none;
}

/* Timeline under the map: the whole period fits the width. A thin axis with
   decade ticks and labels, a dot per Austragung, and the selected range as a
   slate block with a handle on each end (see js/timeline.js). */
.timeline {
  flex: none; display: flex; align-items: center;
  height: calc(52px + env(safe-area-inset-bottom));
  padding: 0 22px env(safe-area-inset-bottom);
  background: #f7f6f3; border-top: 1px solid #dcdad5;
  box-shadow: 0 -2px 8px rgba(0,0,0,.12);
  position: relative; z-index: 1000;
  user-select: none; -webkit-user-select: none;
}
.timeline:empty { display: none; }
.tl-track { position: relative; flex: 1; min-width: 0; height: 100%; cursor: pointer; touch-action: none; }
.tl-axis { position: absolute; left: 0; right: 0; top: 24px; height: 2px; background: #cfccc6; border-radius: 1px; }
.tl-tick { position: absolute; top: 21px; height: 8px; width: 1px; background: #cfccc6; }
.tl-tick-major { top: 16px; height: 18px; background: #b3afa8; }
.tl-decade {
  position: absolute; bottom: 4px; transform: translateX(-50%); z-index: 2;
  font-size: 11px; color: #8a867f; font-variant-numeric: tabular-nums; pointer-events: none;
}
.tl-decade[hidden] { display: none; }
.tl-decade.in-range { color: #fff; }
/* Austragungen: dots stacked above the axis at their year */
.tl-dots {
  position: absolute; bottom: 30px; transform: translateX(-50%); z-index: 3;
  display: flex; flex-direction: column-reverse; gap: 1px; pointer-events: none;
}
.tl-dots i { width: 6px; height: 6px; border-radius: 50%; box-shadow: 0 0 0 1px #f7f6f3; }
.tl-dots.in-range i { box-shadow: 0 0 0 1.5px #fff; }
/* Hover preview of the decade a click selects */
.tl-ghost {
  position: absolute; top: 4px; bottom: 4px; border-radius: 4px; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent);
}
.tl-ghost[hidden], .tl-range[hidden] { display: none; }
.tl-range {
  position: absolute; top: 4px; bottom: 4px; z-index: 1; cursor: grab;
  background: color-mix(in srgb, var(--accent) 82%, #fff);
}
.tl-range.is-dragging { background: var(--accent); cursor: grabbing; }
.tl-handle {
  position: absolute; top: 0; bottom: 0; width: 8px; z-index: 4;
  background: var(--accent-dark); cursor: ew-resize; touch-action: none;
}
/* Bigger invisible grab area for fingers */
.tl-handle::before { content: ""; position: absolute; top: -4px; bottom: -4px; width: 22px; }
.tl-handle-from::before { right: 0; }
.tl-handle-to::before { left: 0; }
.tl-handle::after {
  content: ""; position: absolute; top: 50%; margin-top: -4px;
  border: 4px solid transparent;
}
.tl-handle-from { left: -8px; border-radius: 3px 0 0 3px; }
.tl-handle-from::after { right: 2px; border-right-color: #fff; border-left-width: 0; }
.tl-handle-to { right: -8px; border-radius: 0 3px 3px 0; }
.tl-handle-to::after { left: 2px; border-left-color: #fff; border-right-width: 0; }
.tl-handle:focus-visible { outline: 2px solid #222; outline-offset: 1px; }

/* Map popups never get taller than the map: header and "Mehr zum Event" stay
   put, the part in between scrolls. map.js sets --popup-max-h from the map height. */
.event-popup-wrap .event-popup {
  display: flex; flex-direction: column; max-height: var(--popup-max-h, none);
}
.event-popup-wrap .popup-header, .event-popup-wrap .popup-footer { flex: none; }
.event-popup-wrap .popup-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y; /* the map blocks native touch scrolling; allow it here */
}
.event-popup-wrap .popup-footer {
  padding: 8px 14px 12px;
  border-top: 1px solid #eee;
}
/* Smaller photo in popups, even smaller on short screens */
.event-popup-wrap .popup-photo img { height: 130px; }
@media (max-height: 640px) {
  .event-popup-wrap .popup-photo img { height: 100px; }
}

/* Mini map on the Austragung page */
.event-popup .mini-map {
  height: 300px; margin-top: 16px; border-radius: 10px; overflow: hidden;
  background: #e8e7e3; z-index: 0; /* keep Leaflet's panes below the app bar */
}
@media (max-width: 520px) { .event-popup .mini-map { height: 240px; } }

/* Winners on the Austragung page: portrait, name (linked to Wikidata), country */
.event-popup .winners { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.event-popup .winner {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; border-radius: 12px;
  background: color-mix(in srgb, var(--event-color) 8%, #fff);
}
.event-popup .winner-photo {
  position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  background: color-mix(in srgb, var(--event-color) 20%, #fff);
}
.event-popup .winner-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }
.event-popup .winner-photo-missing::after {
  content: attr(data-initial); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: color-mix(in srgb, var(--event-color) 75%, #000);
}
.event-popup .winner-text { display: flex; flex-direction: column; }
.event-popup .winner-name { font-weight: 700; }
.event-popup .winner-name a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--event-color) 50%, transparent); text-underline-offset: 2px; }
.event-popup .winner-land { color: #666; font-size: 0.9em; }

/* QR-Code button in the header and its large popup */
.qr-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 14px; padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.45); border-radius: 8px; background: transparent;
  color: #fff; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.app-bar h1 + .qr-btn { margin-left: auto; } /* map page: no back link, push to the right */
.qr-btn:hover { background: rgba(255,255,255,.12); }
.qr-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 520px) { .qr-btn-text { display: none; } .qr-btn { padding: 6px; margin-left: 10px; } }
.qr-dialog {
  border: 0; border-radius: 20px; padding: 24px 24px 16px; background: #fff; color: #222;
  max-width: 95vw; max-height: 95vh; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.qr-dialog::backdrop { background: rgba(20, 24, 28, .75); }
.qr-image { display: block; width: min(86vw, 100vh - 190px, 1000px); height: auto; aspect-ratio: 1; margin: 0 auto; }
.qr-caption { margin: 14px 0 2px; font-size: clamp(18px, 2.4vw, 28px); font-weight: 700; }
.qr-url { margin: 0; font-size: clamp(14px, 1.8vw, 20px); color: #555; }
.qr-url a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.qr-url a:hover { color: #000; }
.qr-close {
  position: absolute; top: 8px; right: 12px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; font-size: 30px; line-height: 1; color: #555; cursor: pointer;
}
.qr-close:hover { background: #eee; color: #000; }
