:root {
  color-scheme: light dark;

  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #1e1b16;
  --muted: #6b6459;
  --accent: #8a1f1f;      /* Pontian flag red */
  --line: #e3ded3;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 6px 20px rgba(0, 0, 0, .05);

  --chip-paid-bg: #f0e6e6;
  --chip-paid-fg: var(--accent);
  --chip-free-bg: #e4efe4;
  --chip-free-fg: #2f6b30;
  --badge-neutral-bg: #ece9e3;
  --map-filter: none;
  --logo-src: url("../img/logo.png");
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a1f1f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* dark palette - auto (OS) unless the user forced light... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f;
    --surface: #211d17;
    --ink: #ece7de;
    --muted: #a89e8d;
    --accent: #e0685f;
    --line: #38322a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .4);
    --chip-paid-bg: rgba(224, 104, 95, .16);
    --chip-paid-fg: #eb8981;
    --chip-free-bg: rgba(96, 176, 110, .16);
    --chip-free-fg: #86cf94;
    --badge-neutral-bg: rgba(255, 255, 255, .09);
    --map-filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9) saturate(.85);
    --logo-src: url("../img/logo-dark.png");
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a89e8d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
/* ...and the explicit toggle wins in both directions */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17140f;
  --surface: #211d17;
  --ink: #ece7de;
  --muted: #a89e8d;
  --accent: #e0685f;
  --line: #38322a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .4);
  --chip-paid-bg: rgba(224, 104, 95, .16);
  --chip-paid-fg: #eb8981;
  --chip-free-bg: rgba(96, 176, 110, .16);
  --chip-free-fg: #86cf94;
  --badge-neutral-bg: rgba(255, 255, 255, .09);
  --map-filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9) saturate(.85);
  --logo-src: url("../img/logo-dark.png");
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a89e8d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
body.modal-open { overflow: hidden; }

/* ---- top bar ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}
.topbar__brand { margin: 0; font-size: 0; line-height: 0; }
.topbar__brand a { display: inline-block; }
.topbar__logo {
  display: block;
  height: 88px;
  width: auto;
  max-width: 100%;
  /* dark mode swaps in a version whose lettering is white - see --logo-src */
  content: var(--logo-src, url("../img/logo.png"));
}

.viewswitch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.viewswitch button { border: 0; background: var(--surface); padding: 8px 16px; font: inherit; cursor: pointer; color: var(--muted); }
.viewswitch button.is-active { background: var(--accent); color: #fff; }

.topbar__tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: auto; }

.langswitch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.langswitch button {
  border: 0; background: var(--surface); padding: 8px 12px;
  font: 600 13px inherit; cursor: pointer; color: var(--muted); letter-spacing: .3px;
}
.langswitch button + button { border-left: 1px solid var(--line); }
.langswitch button.is-active { background: var(--accent); color: #fff; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-size: 17px; line-height: 1; cursor: pointer;
}
.iconbtn:hover { border-color: var(--accent); }

/* ---- filter bar ---- */
.filters {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: end;
}
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.filters input, .filters select {
  font: 14px/1.3 inherit;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* custom-styled dropdowns to match the site (native arrow removed) */
.filters select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.filters select::-ms-expand { display: none; }
.filters select option { background: var(--surface); color: var(--ink); }

.filters__search input { min-width: 220px; }

/* Νομός / Τραγουδιστής: pick more than one - each pick becomes a removable
   chip, so festivals matching ANY of them show up (see app.js visible()).
   The suggestion list is our own dropdown (.multiselect__menu), not the
   browser's <datalist>. */
.multiselect {
  position: relative;
  width: 150px;                /* empty: just wide enough for the short hint */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 5px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.multiselect:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.multiselect__chips { display: contents; }
.multiselect input {
  flex: 1 1 70px;
  min-width: 50px;
  border: 0 !important;
  background: none !important;
  padding: 3px 5px !important;
}
.multiselect input:focus { outline: none; }

/* With chips picked the box stops filling the row. .has-chips / .has-many
   are toggled from renderChips(). */
.multiselect.has-chips { width: auto; max-width: 100%; align-self: flex-start; }
/* the visible content stays on one line - the chip ellipsizes in a narrow
   cell rather than pushing the type-slot / "+N" onto a second row */
.multiselect.has-chips:not(:focus-within) { flex-wrap: nowrap; }

/* One pick: show it with its × plus a short slot so it still reads as a
   field you can type another into. */
.multiselect.has-chips:not(.has-many):not(:focus-within) input {
  flex: 0 0 2.5ch;
  width: 2.5ch;
  min-width: 0;
  padding-left: 2px !important;
  padding-right: 2px !important;
}

/* Several picks: collapse to "first pick +N" so the filter bar stays tight.
   The whole box is a button (container mousedown handler in app.js) that
   expands to the full editable list. */
.multiselect.has-many:not(:focus-within) { cursor: pointer; }
.multiselect.has-many:not(:focus-within) .chip ~ .chip { display: none; }
.multiselect.has-many:not(:focus-within) .chip .chip__remove { display: none; }
.multiselect.has-many:not(:focus-within) .chip { padding-right: 8px; cursor: pointer; }
/* input is out of the way but still focusable, so a click on the box (which
   calls input.focus()) expands the field - display:none would block that */
.multiselect.has-many:not(:focus-within) input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.multiselect__more {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 3px;
}
.multiselect.has-many:not(:focus-within) .multiselect__more { display: inline-flex; }

/* Expanded (being edited): every chip shows with its remove button, and the
   input drops to its own full-width line to type the next one on. Capped so
   a few chips wrap into a tidy block instead of stretching the filter bar. */
.multiselect.has-chips:focus-within { width: auto; max-width: 280px; }
.multiselect.has-chips:focus-within .multiselect__more { display: none; }
.multiselect.has-chips:focus-within input {
  position: static;
  flex: 1 1 100%;
  width: 100%;
  height: auto;
  opacity: 1;
  pointer-events: auto;
  padding: 3px 5px !important;
}

.multiselect__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: -1px;
  right: -1px;
  z-index: 600;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
}
.multiselect__option {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multiselect__option.is-active { background: var(--bg); }
.multiselect__empty { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  max-width: 100%;
  min-width: 0;
  background: var(--surface);
  /* an inset ring instead of a real border: same look, but it adds no
     layout width, so the chip's text lines up with the field's placeholder
     (and the labels above) instead of sitting a notch to the right */
  box-shadow: inset 0 0 0 1px var(--line);
  border-radius: 999px;
  padding: 3px 6px;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
}
.chip__label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chip__remove {
  border: 0; background: none; padding: 0 3px; margin: 0; cursor: pointer;
  color: var(--muted); font-size: 15px; line-height: 1;
}
.chip__remove:hover { color: var(--accent); }
.filters__clear, .filters__near {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 13px inherit;
  line-height: 1.15;               /* keeps the 📍 from making it taller than the fields */
  padding: 7px 12px;              /* match .filters input / select */
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.filters__near.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filters__near:disabled { opacity: .5; cursor: default; }
.filters select:disabled, .filters input:disabled { opacity: .5; }
#f-radius { width: 92px; }

/* shown only on narrow screens (see the media query below), where the
   filter bar starts collapsed so the map/list is visible right away */
.filters-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 10px 14px 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px inherit;
  cursor: pointer;
}
.filters-toggle__badge {
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  border-radius: 999px; min-width: 20px; height: 20px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
}
.filters-toggle__chevron { margin-left: auto; color: var(--muted); transition: transform .15s; }
.filters-toggle[aria-expanded="true"] .filters-toggle__chevron { transform: rotate(180deg); }

main { position: relative; flex: 1; min-height: 0; }
.view { display: none; position: absolute; inset: 0; }
.view.is-active { display: block; }
#map { z-index: 0; }

#list {
  overflow-y: auto;
  padding: 28px clamp(16px, 4vw, 40px);
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 28px;
  align-content: start;
}
#list.is-active { display: grid; }

/* ---- list cards ---- */
.card {
  /* NOT overflow:hidden - a grid item with overflow != visible gets an
     automatic min-height of 0 instead of one based on its content, which
     collapses the whole card to a couple of px. Corners are rounded on
     .card__poster/.card__body instead. */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.1), 0 16px 36px rgba(0,0,0,.08); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card__poster {
  width: 100%; height: 260px; object-fit: cover; background: var(--line); display: block;
  border-radius: 16px 16px 0 0;
}
.card__body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; }
.card__title { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 700; }
.card__date { margin: 0; font-weight: 600; font-size: 15px; color: var(--accent); }
.card__km { font-weight: 400; color: var(--muted); }
.card__loc { margin: 0; font-size: 14.5px; line-height: 1.4; }
.card__meta { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.card__fee {
  align-self: start;
  margin-top: 6px;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--chip-paid-bg);
  color: var(--chip-paid-fg);
  font-weight: 600;
}
.card__fee--free { background: var(--chip-free-bg); color: var(--chip-free-fg); }
.card__more { margin: 10px 0 0; font-size: 14px; color: var(--accent); font-weight: 700; }

/* ---- status badge (over / happening now) ---- */
.badge {
  align-self: start;
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: .2px;
}
.badge--over { background: var(--badge-neutral-bg); color: var(--muted); }
.badge--today { background: var(--chip-free-bg); color: var(--chip-free-fg); }
.card--over { opacity: .68; }
.card--over:hover { opacity: 1; }
.detail__main .badge { margin: -4px 0 12px; }
.popup .badge { margin: 2px 0 4px; }

.status {
  position: absolute; left: 12px; bottom: 12px; margin: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 12px; font-size: 13px; color: var(--muted); box-shadow: var(--shadow); z-index: 500;
}
.empty { color: var(--muted); }

/* ---- Leaflet popup ---- */
.popup { max-width: 240px; }
.popup__poster { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; }
.popup h3 { margin: 8px 0 2px; font-size: 15px; }
.popup__date { margin: 0 0 4px; font-weight: 600; color: var(--accent); }
.popup p { margin: 2px 0; font-size: 13px; }
.popup__km { color: var(--muted); }
.popup__actions { margin-top: 8px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.popup__more {
  border: 0; background: none; padding: 0;
  color: var(--accent); font: 600 13px inherit; cursor: pointer;
}

/* ---- Leaflet in dark mode ---- */
.leaflet-tile-pane { filter: var(--map-filter); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow);
}
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--surface); color: var(--ink); border-color: var(--line);
}
.leaflet-container .leaflet-control-attribution {
  background: var(--surface);
  color: var(--muted);
}
.leaflet-container .leaflet-control-attribution a { color: var(--accent); }

/* "you are here" dot */
.user-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: #2456b8; border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(36, 86, 184, .4);
}

/* ---- detail modal ---- */
.detail { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.detail__backdrop { position: absolute; inset: 0; background: rgba(20, 16, 12, .55); }
.detail__panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
}
.detail__body {
  display: grid;
  grid-template-columns: 260px 1fr;
}
.detail__close {
  position: absolute; top: 8px; right: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 20px; line-height: 1; cursor: pointer; z-index: 2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.detail__poster-link { display: block; background: var(--line); align-self: start; position: sticky; top: 0; }
.detail__poster { width: 100%; max-height: calc(100vh - 40px); object-fit: contain; display: block; }
.detail__main { padding: 20px 22px; }
.detail__title { margin: 0 0 2px; font-size: 20px; }
.detail__date { margin: 0 0 12px; font-weight: 600; color: var(--accent); }
.detail__meta { display: grid; gap: 6px; margin-bottom: 4px; }
.detail__row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; font-size: 14px; }
.detail__label { color: var(--muted); }
.detail__h3 { margin: 16px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.detail__performers { margin: 0; padding-left: 18px; font-size: 14px; }
.detail__desc { margin: 0; font-size: 14px; }
.detail__actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  font: 14px inherit; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer; text-decoration: none; display: inline-block;
}
.btn--ghost { background: transparent; color: var(--accent); }

/* ---- footer / credits ---- */
.sitefoot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px 4px;
  padding: 7px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.sitefoot span + span::before { content: "·"; margin-right: 4px; opacity: .55; }
.sitefoot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.sitefoot a:hover { color: var(--accent); }

@media (max-width: 620px) {
  .topbar { padding: 10px 14px; }
  .topbar__brand { flex-basis: 100%; }        /* logo on its own row... */
  .topbar__tools { margin-left: 0; }          /* ...tools left-aligned below it */
  .topbar__logo { height: 64px; }
  .viewswitch button { padding: 10px 16px; }   /* a bit taller: easier to tap */

  /* the credits stack, one line each - no dangling "·" at the start of a line.
     Kept deliberately faint here: it's fine print, not part of the UI. */
  .sitefoot {
    flex-direction: column;
    gap: 1px;
    padding: 7px 14px 9px;
    font-size: 10px;
    line-height: 1.4;
    opacity: .6;
    border-top-color: color-mix(in srgb, var(--line) 55%, transparent);
  }
  .sitefoot span + span::before { content: none; }

  /* Filters start collapsed so the map/list shows right away instead of
     being pushed off screen below a dozen stacked fields; the toggle
     button (hidden on wider screens - see .filters-toggle above) opens
     them as a compact 2-column panel instead of one field per row. */
  .filters-toggle { display: inline-flex; margin: 10px 14px 12px; }
  /* when open, the toggle sits flush on the panel - flat bottom, no gap, no seam */
  .filters-toggle[aria-expanded="true"] {
    margin-bottom: 0;
    border-radius: 8px 8px 0 0;
    border-bottom: 0;
  }
  .filters {
    display: none;
    grid-template-columns: 1fr 1fr;
    padding: 14px;
    gap: 12px 10px;
    /* one rounded card with the toggle, inset from the screen edges, with a
       clean bottom edge instead of running full-bleed into the map */
    margin: 0 14px 14px;
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    /* no overflow clip here - it would cut off the suggestion dropdown;
       an open filter panel pushing the map down on a phone is fine */
  }
  .filters.is-open { display: grid; }
  /* a grid item's default min-width is its content's natural (unwrapped)
     size, not its column's - long chips/labels were forcing the grid
     wider than the screen instead of wrapping within their column */
  .filters > label { min-width: 0; }
  .filters__search { grid-column: 1 / -1; }
  .filters__search input, .filters input, .filters select { width: 100%; }
  #f-radius { width: 100%; }
  .multiselect { width: 100%; min-width: 0; }
  .multiselect input { width: auto; }   /* overrides the width:100% above */
  /* a collapsed chip field is small - let it sit in the 2-col grid; when
     tapped to edit it takes the full row so there's room for the list */
  .multiselect.has-chips:not(:focus-within) { width: auto; }
  .filters__multi:focus-within { grid-column: 1 / -1; }
  .multiselect.has-chips:focus-within { width: 100%; max-width: none; }
  /* one pick, narrow cell: the type-slot fills whatever space is left after
     the chip and just disappears if the name is long, instead of wrapping */
  .multiselect.has-chips:not(.has-many) { width: 100%; }
  .multiselect.has-chips:not(.has-many):not(:focus-within) input {
    flex: 1 1 0;
    width: auto;
  }
  .filters__near, .filters__clear { padding: 8px 12px; justify-content: center; }

  #list { padding: 16px; gap: 18px; grid-template-columns: 1fr; }
  .card__poster { height: 210px; }

  /* full-screen sheet instead of a centered card - there's no room to
     spare for margins around it on a phone */
  .detail { padding: 0; }
  .detail__panel { width: 100%; max-height: 100vh; border-radius: 0; }
  .detail__body { grid-template-columns: 1fr; }
  .detail__poster { height: 220px; }
  .detail__main { padding: 18px 16px; }
  .detail__actions .btn { flex: 1 1 auto; text-align: center; }

  /* pin the close button to the viewport corner - absolute-positioned it
     scrolled up out of reach once the event page got long, and it could
     sit behind the sticky poster */
  .detail__close {
    position: fixed;
    top: 10px; right: 10px;
    width: 38px; height: 38px;
    font-size: 22px;
    z-index: 3;
  }
}
