/*
 * All events at /events. The palette comes from css/app.css and the parts
 * (page head, chips, segmented buttons, buttons) from css/ui.css. This file
 * adds what only the event directory needs: the search and filter bar, the
 * section headers with counts, and the event cards and list rows that
 * js/all-events-page.js renders. <html data-events-view="card|list"> picks
 * the layout.
 */

.events-page .page-head { margin-bottom: 18px; }

/* ---------- search and filters ---------- */
.event-filter-panel { margin: 0 0 14px; }
.event-filter-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.event-filter-search-row { display: flex; gap: 8px; align-items: stretch; }
.event-search { position: relative; flex: 1; min-width: 0; }
.event-search svg {
  position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.event-search input {
  width: 100%; height: 46px; padding: 0 12px 0 40px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--ink);
  font: inherit; font-size: 16px;
}
.event-search input::placeholder { color: var(--muted); opacity: 1; }
.event-filter-toggle {
  flex: none; display: none; align-items: center; gap: 6px;
  height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--panel-2);
  font-size: 14px; font-weight: 600;
}
.event-filter-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.event-filter-toggle[aria-expanded="true"] { background: var(--ink); color: var(--app); border-color: var(--ink); }

.event-filter-body { display: flex; flex-direction: column; gap: 10px; }
.event-filter-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
/* A select with its label on top, drawn as one box. */
.event-filter-field {
  position: relative; min-width: 0;
  border-radius: 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.event-filter-field:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.event-filter-field label {
  position: absolute; left: 12px; top: 7px; pointer-events: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.event-filter-field select {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 52px; padding: 18px 30px 0 12px; margin: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; text-overflow: ellipsis; cursor: pointer;
}
.event-filter-field select:focus-visible { outline: none; }
.event-filter-field option { background: var(--panel-2); color: var(--ink); }
.event-filter-field::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}

.event-filter-checks { display: flex; flex-wrap: wrap; gap: 6px; }
/* A checkbox that looks like a chip: filled when it is on. */
.event-filter-check {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 17px;
  border: 1px solid var(--line-strong); background: var(--panel-2);
  font-size: 13px; font-weight: 600; cursor: pointer; user-select: none;
}
.event-filter-check:hover { background: var(--chip); }
.event-filter-check input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer;
}
.event-filter-check:has(input:checked) { background: var(--ink); color: var(--app); border-color: var(--ink); }
.event-filter-check:has(input:checked)::before { content: "✓"; font-size: 12px; line-height: 1; }
.event-filter-check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.event-filter-active { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; }
.active-filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.active-filter-chip {
  display: inline-flex; align-items: center; min-height: 26px; padding: 3px 10px; border-radius: 13px;
  background: var(--chip); color: var(--ink); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere;
}
.event-filter-reset { color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: none; }
.event-filter-reset:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- result count and layout switch ---------- */
.results-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  margin: 0 0 6px; padding-top: 12px; border-top: 1px solid var(--line-strong);
}
.results-count { margin: 0; min-width: 0; color: var(--muted); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.events-view-toggle { flex: none; }
.events-view-button { display: inline-flex; align-items: center; gap: 6px; }
.events-view-button svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sections ---------- */
.events-section { margin-top: 26px; }
.section-row { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.section-row .section-title { margin: 0; }
.section-count {
  min-width: 26px; height: 22px; padding: 0 8px; border-radius: 11px;
  display: inline-grid; place-items: center;
  background: var(--chip); color: var(--ink); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.section-archive-link { margin: -4px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.section-archive-link a { color: var(--accent); font-weight: 600; text-decoration: none; }
.section-archive-link a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- empty states ---------- */
.empty-state {
  padding: 22px 18px; border-radius: 14px; border: 1px dashed var(--line-strong);
  color: var(--muted); text-align: center; line-height: 1.5;
}
#all-events-empty { margin-top: 22px; }
.empty-state strong { display: block; color: var(--ink); font-size: 15px; font-weight: 700; }
.empty-state p { max-width: 52ch; margin: 4px auto 0; font-size: 13.5px; }
.empty-state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.empty-state-action {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 16px;
  border: 1px solid var(--line-strong); color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: none;
}
.empty-state-action:hover { background: var(--chip); }
.events-grid > .section-empty { grid-column: 1 / -1; }

/* ---------- event cards (the card view) ---------- */
.events-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.event-card {
  position: relative; min-width: 0;
  display: flex; flex-direction: column;
  border-radius: 14px; overflow: hidden;
  background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.event-card-media {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--chip); color: inherit; text-decoration: none;
}
.event-card-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.event-card-media-fallback {
  position: absolute; inset: 0; display: none; place-items: center; padding: 12px;
  color: var(--muted); text-align: center;
  font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1; text-transform: uppercase;
  overflow-wrap: anywhere;
}
.event-card-media.is-fallback .event-card-image { display: none; }
.event-card-media.is-fallback .event-card-media-fallback { display: grid; }
a.event-card-media:focus-visible { outline-offset: -3px; }

.event-card-favorite {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.event-card-favorite:hover { color: var(--accent); }
.event-card-favorite svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linejoin: round; }
.event-card-favorite[aria-pressed="true"] { color: var(--accent); }
.event-card-favorite[aria-pressed="true"] svg { fill: currentColor; }

.event-card-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px 14px 14px; }
.event-card-head { min-width: 0; }
.event-card-topline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-bottom: 4px; }
.event-card-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.event-card-status, .event-card-theme-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 6px;
  background: var(--chip); color: var(--ink); font-size: 11px; font-weight: 700; line-height: 1.5;
}
.event-card-status[data-tone="now"] { background: var(--ink); color: var(--app); }
.event-card-theme-badge svg { width: 12px; height: 12px; stroke: var(--warn); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.event-card-title {
  margin: 0; font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1.05;
  text-transform: uppercase; overflow-wrap: anywhere;
}
.event-card-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }

.event-card-facts { display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.4; }
.event-card-facts p { margin: 0; min-width: 0; }
.event-card-date { color: var(--ink); }
.event-card-date-main { font-weight: 600; }
.event-card-date-hint { color: var(--muted); }
.event-card-date-hint::before { content: "·"; margin: 0 6px; }
.event-card-location { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); }
.event-card-location-text { min-width: 0; overflow-wrap: anywhere; }
.event-card-country-flag-wrap { flex: none; display: inline-flex; align-items: center; height: 18px; }
.event-card-country-flag {
  display: block; width: 18px; height: 13px; border-radius: 2px; object-fit: cover;
  box-shadow: 0 0 0 1px var(--line-strong);
}
.event-card-country-code { display: none; font-size: 11px; font-weight: 700; color: var(--ink); }
.event-card-country-flag-wrap.is-missing .event-card-country-flag { display: none; }
.event-card-country-flag-wrap.is-missing .event-card-country-code { display: inline; }
.event-card-editions { color: var(--muted); }

.event-card-signals { display: flex; flex-wrap: wrap; gap: 4px; }
.event-card-signal {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--chip); color: var(--ink); font-size: 11.5px; font-weight: 600; line-height: 1.45;
}
.event-card-signal::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.event-card-signal-live::before, .event-card-signal-friends::before { background: var(--accent); }
.event-card-signal-pending::before { background: var(--warn); }

.event-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.event-action, .event-ticket-action {
  display: inline-flex; align-items: center; justify-content: center; max-width: 100%;
  min-height: 34px; padding: 6px 14px; border-radius: 17px;
  font-size: 13px; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  overflow-wrap: anywhere;
}
.event-action { background: var(--accent); color: var(--accent-ink); }
.event-action:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
.event-ticket-action { box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink); }
.event-ticket-action:hover { background: var(--chip); }
.event-action-disabled, .event-ticket-action-disabled,
.event-action-disabled:hover, .event-ticket-action-disabled:hover {
  background: var(--chip); color: var(--muted); box-shadow: none; cursor: default;
}
.event-card-updated { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.4; }

/* ---------- the list view ---------- */
html[data-events-view="list"] .events-grid {
  display: flex; flex-direction: column; gap: 0;
  border-radius: 14px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong); overflow: hidden;
}
html[data-events-view="list"] .events-grid > .section-empty { border: 0; border-radius: 0; }
html[data-events-view="list"] .event-card {
  display: grid; align-items: start; column-gap: 12px; row-gap: 6px;
  grid-template-columns: 88px minmax(0, 1fr) 36px;
  grid-template-areas:
    "media head fav"
    "media facts facts"
    "signals signals signals"
    "actions actions actions"
    "updated updated updated";
  padding: 12px 14px; border-radius: 0; overflow: visible; background: none; box-shadow: none;
}
html[data-events-view="list"] .event-card + .event-card { border-top: 1px solid var(--line-strong); }
html[data-events-view="list"] .event-card-body { display: contents; }
html[data-events-view="list"] .event-card-media { grid-area: media; border-radius: 8px; }
html[data-events-view="list"] .event-card-media-fallback { padding: 4px; font-size: 11px; }
html[data-events-view="list"] .event-card-favorite { grid-area: fav; position: static; justify-self: end; }
html[data-events-view="list"] .event-card-head { grid-area: head; }
html[data-events-view="list"] .event-card-title { font-size: 19px; }
html[data-events-view="list"] .event-card-facts { grid-area: facts; }
html[data-events-view="list"] .event-card-signals { grid-area: signals; }
html[data-events-view="list"] .event-card-actions { grid-area: actions; margin: 0; padding: 0; }
html[data-events-view="list"] .event-card-updated { grid-area: updated; }

/* ---------- wider screens ---------- */
@media (max-width: 700px) {
  .event-filter-toggle { display: inline-flex; }
  .event-filter-panel:not(.is-filter-open) .event-filter-body { display: none; }
  .event-filter-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-filter-field select { font-size: 16px; }
}
@media (max-width: 359px) {
  .event-filter-options { grid-template-columns: minmax(0, 1fr); }
  .event-filter-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .event-filter-toggle { padding: 0 13px; }
}
@media (min-width: 701px) and (max-width: 959px) {
  .event-filter-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 701px) {
  html[data-events-view="list"] .event-card {
    grid-template-columns: 112px minmax(0, 1fr) minmax(0, max-content) 36px;
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "media head actions fav"
      "media facts actions fav"
      "media signals actions fav"
      "media updated actions fav";
    column-gap: 16px; row-gap: 4px; padding: 12px 16px;
  }
  html[data-events-view="list"] .event-card-actions {
    align-self: center; justify-content: flex-end; max-width: 250px;
  }
  html[data-events-view="list"] .event-card-favorite { align-self: center; }
  html[data-events-view="list"] .event-card-updated { align-self: end; }
}
@media (min-width: 1000px) {
  html[data-events-view="list"] .event-card { grid-template-columns: 128px minmax(0, 1fr) minmax(0, max-content) 36px; }
  html[data-events-view="list"] .event-card-actions { max-width: 340px; }
}
