/* Shared theme: sober, "occult archive". No gradients, no emoji. Dark is the default; light is :root[data-theme="light"]. */
:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #131314;
  --surface-2: #1b1b1d;
  --border: #2d2d30;
  /* Borders of interactive controls (inputs, chips, buttons): >= 3:1 against the background (WCAG 1.4.11). */
  --control-border: #6b675f;
  --text: #d8d4cb;
  --muted: #8d897f;
  --accent: #b9a77a;
  --danger: #c4604f;
  /* Gold accents: pins, clusters, active chip, badges. */
  --gold: #c9b97a; --gold-hover: #e6d9a3; --gold-edge: #f3e7b5; --gold-glow: rgba(243, 231, 181, 0.7); --on-gold: #0a0a0a;
  /* Secondary greys of the map UI and the artist card. */
  --chip-text: #555555; --chip-border: #222222; --card-meta: #666666; --card-link: #555555; --rule: #1e1e1e;
  --chip-fill: #1a1a1a; --venue-focus: #3a3526;
  /* Feedback, overlays and shadows. */
  --error: #e08a7a; --ok: #6f9a6f; --ok-text: #8fbf8f;
  --overlay: rgba(19, 19, 20, 0.92); --overlay-strong: rgba(11, 11, 12, 0.85); --scrim: rgba(0, 0, 0, 0.75); --pin-shadow: rgba(0, 0, 0, 0.75);
  --radius: 2px;
  --logo-dim: #3a3a3a; /* grey text of the logo */
  --font: Georgia, "Times New Roman", serif;
  --font-ui: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  /* Metadata (city, country, dates, counters, status labels). Generic `monospace` is the final fallback. */
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

/* Light theme: warm paper, same structure. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1ea; --surface: #fbf9f4; --surface-2: #ebe6da; --border: #d8d2c4; --control-border: #8c8576;
  --text: #1f1d19; --muted: #5c574d; --accent: #7a5c10; --danger: #a8402f;
  --gold: #836512; --gold-hover: #6a5010; --gold-edge: #e3c45f; --gold-glow: rgba(227, 196, 95, 0.85); --on-gold: #ffffff;
  --chip-text: #5c574d; --chip-border: #8c8576; --card-meta: #6b665b; --card-link: #6b665b; --rule: #e2dccf;
  --chip-fill: #f4f1ea; --venue-focus: #ebe3c8; --logo-dim: #6b665b;
  --error: #a32f1d; --ok: #3d7a3d; --ok-text: #3d7a3d;
  --overlay: rgba(251, 249, 244, 0.94); --overlay-strong: rgba(251, 249, 244, 0.9); --scrim: rgba(31, 29, 25, 0.55); --pin-shadow: rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }

/* The page canvas takes the theme colour from the first paint, before <body> is parsed. */
html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--text); }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button { font: inherit; }

[hidden] { display: none !important; }

/* Skip link: first focusable element, visible only when focused (keyboard users). */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 3000;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 8px; color: var(--bg); }
[tabindex="-1"]:focus { outline: none; } /* programmatic focus targets (skip link, success message) */

/* Top bar shared by every page */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--font);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  display: inline-block;
  padding: 2px 0; /* keeps the title link at least 24px tall (WCAG 2.5.8) */
}

/* The logo carries the site name. The wrapper is an h1 on the map page and a plain paragraph elsewhere (those pages
   have their own h1). */
.brand-block { margin-right: auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; } /* the map-page counter drops under the logo when there is no room beside it */
.brand-text { min-width: 0; }

/* Logo (inline SVG from server/partials/logo.html). Gold strokes use currentColor (--gold, so they follow the theme);
   the grey text and the pin knock-out use the classes below. Same drawing in the header, About and 404. */
.logo { color: var(--gold); }
.lg-dim { fill: var(--logo-dim); }
.lg-ko { fill: var(--logo-ko, var(--bg)); }
.lg-hair { vector-effect: non-scaling-stroke; stroke-width: 1px; } /* hairlines of the artwork (0.2-0.7 units) vanish when scaled down: keep them at 1px */
.brand-mark { flex: none; display: inline-flex; }
.brand-mark .logo { --logo-ko: var(--surface); display: block; width: auto; height: 88px; }
@media (max-width: 1000px) { .brand-mark .logo { height: 72px; } }
.brand-mark:hover .logo { color: var(--gold-hover); }
.brand-title { margin: 0; font: inherit; }

/* Right side of the header: navigation links. */
.topbar-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }

.topnav { display: flex; flex-wrap: wrap; gap: 0 14px; font-size: 0.9rem; } /* wraps instead of overflowing on narrow screens */
.topnav a { color: var(--muted); text-decoration: none; padding: 6px 0; }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--accent); }

/* Light / dark switch, added to the nav by theme.js: a bordered icon button, so it does not read as a page link.
   The icon shows the mode you would switch to; the text label is visually hidden (it is shown in the mobile menu). */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; align-self: center;
  min-width: 32px; height: 32px; margin-left: 6px; padding: 0;
  background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 0.9rem; cursor: pointer;
}
.theme-toggle-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--control-border); border-radius: var(--radius);
}
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="light"] .theme-toggle .icon-sun,
:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
.theme-toggle:hover { color: var(--accent); }
.theme-toggle:hover .theme-toggle-icon { border-color: var(--accent); }
.theme-toggle-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* "Menu" button: created by nav.js, hidden on wide screens. */
.menu-toggle { display: none; }

@media (max-width: 720px) {
  /* Only when nav.js is active (.has-menu). Logo and counter on the left,
     "Menu" button on the right; the links drop down as a panel over the page. */
  .topbar.has-menu {
    position: relative;
    z-index: 2000; /* above the Leaflet panes and controls (max 1000), below the skip link */
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    align-items: start;
  }
  .topbar.has-menu .brand-block { grid-column: 1; grid-row: 1; }
  .topbar.has-menu .topbar-meta { display: contents; } /* holds only the nav, which becomes the dropdown panel */

  .topbar.has-menu .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    grid-column: 2;
    grid-row: 1;
    min-height: 40px;
    padding: 0 12px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--control-border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
  }
  .menu-toggle::after { /* chevron drawn in CSS */
    content: "";
    width: 6px; height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
  }
  .topbar.menu-open .menu-toggle { border-color: var(--accent); color: var(--accent); }
  .topbar.menu-open .menu-toggle::after { transform: rotate(-135deg) translateY(-2px); }

  .topbar.has-menu .topnav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .topbar.has-menu.menu-open .topnav { display: flex; }
  .topbar.has-menu .topnav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0;
    border-top: 1px solid var(--border);
  }
  .topbar.has-menu .topnav a:first-child { border-top: 0; }
  /* In the panel the switch is a full-width 44px row: the label on the left, the icon button on the right. */
  .topbar.has-menu .theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    height: auto;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--border);
    text-align: left;
  }
  .topbar.has-menu .theme-toggle-label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; }
  .topbar.has-menu .theme-toggle-icon { width: 28px; height: 28px; }
}

/* Logo in the body: top of the About page and the 404 page (decorative). */
.doc-logo { margin: 4px 0 0; }
.doc-logo svg { display: block; width: 100%; max-width: 307px; height: auto; } /* 120px high, shrinks on narrow screens */
.notfound-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.notfound-logo svg { display: block; width: 100%; max-width: 266px; height: auto; } /* 104px high */

/* Static text pages (Rules, Privacy) */
.doc {
  max-width: 42rem;
  margin: 0 auto;
  padding: 24px 16px 64px;
}
.doc h1 { font-family: var(--font); font-weight: normal; letter-spacing: 0.03em; margin-top: 8px; }
.doc h2 { font-family: var(--font); font-weight: normal; font-size: 1.15rem; margin-top: 2rem; color: var(--accent); }
.doc li { margin-bottom: 6px; }
.doc .note { color: var(--muted); font-size: 0.9rem; }

/* 404 page */
.notfound { max-width: 34rem; margin: 0 auto; padding: 18vh 16px 64px; text-align: center; }
.notfound .code { margin: 0; font-family: var(--font); font-size: clamp(4rem, 22vw, 7rem); line-height: 1; letter-spacing: 0.06em; color: var(--accent); }
.notfound h1 { margin: 12px 0 8px; font-family: var(--font); font-weight: normal; font-size: 1.5rem; }
.notfound p { color: var(--muted); }
.notfound .back { display: inline-block; margin-top: 18px; padding: 10px 20px; border: 1px solid var(--control-border); border-radius: var(--radius); text-decoration: none; }
.notfound .back:hover { border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Touch screens: comfortable tap targets (44px) for navigation links. */
@media (pointer: coarse) {
  .topnav a { display: inline-flex; align-items: center; min-height: 44px; padding-top: 0; padding-bottom: 0; }
  .topnav { gap: 8px; }
  .topnav a { padding-left: 6px; padding-right: 6px; }
  .theme-toggle { min-width: 44px; height: 44px; }
}
