/* ==========================================================================
   Events showcase (cards)
   Each event is a ticket: a stripe in its route color across the top, and
   a perforated stub at the bottom that holds what matters at the show
   (booth number, "Happening now", or a short countdown).
   Type and text color are inherited from the theme so the module fits in.
   ========================================================================== */

.evt {
  --evt-rail: color-mix(in srgb, currentColor 22%, transparent);
  --evt-muted: color-mix(in srgb, currentColor 72%, transparent);
  --evt-tint: color-mix(in srgb, currentColor 7%, transparent);
  --evt-surface: color-mix(in srgb, currentColor 5%, transparent);
  --evt-line-default: #d82029;
  --evt-radius: 0.625rem;
  --evt-notch: 8px;    /* whole pixels keep the gradient slices seamless */
  --evt-pad: 1.25rem;

  container: evt / inline-size;
}

@supports not (color: color-mix(in srgb, red 50%, transparent)) {
  .evt {
    --evt-rail: rgba(127, 127, 127, 0.4);
    --evt-muted: currentColor;
    --evt-tint: rgba(127, 127, 127, 0.12);
    --evt-surface: rgba(127, 127, 127, 0.08);
  }
}

.evt [hidden] { display: none !important; }

.evt__notice {
  padding: 1rem;
  border: 1px dashed currentColor;
}

/* ---- Heading ---------------------------------------------------------- */

.evt__title { margin: 0 0 0.5rem; }

.evt__intro {
  margin: 0 0 1.75rem;
  max-width: 40rem;
  color: var(--evt-muted);
}

/* ---- Tabs + filters ----------------------------------------------------- */

.evt__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--evt-rail);
}

.evt:not(.evt--js) .evt__controls { display: none; }

.evt__tabs {
  display: flex;
  gap: 1.75rem;
}

.evt__tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 -1px;
  padding: 0.5rem 0 0.75rem;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--evt-muted);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.evt__tab:hover { color: inherit; }

.evt__tab[aria-selected="true"] {
  color: inherit;
  border-bottom-color: currentColor;
}

.evt__count {
  min-width: 1.6em;
  padding: 0.125rem 0.4rem;
  border-radius: 999px;
  background: var(--evt-tint);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.evt__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
}

.evt__chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--evt-rail);
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.3;
  cursor: pointer;
}

.evt__chip[data-line]::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--evt-line, var(--evt-line-default));
}

.evt__chip:hover { border-color: currentColor; }

.evt__chip[aria-pressed="true"] {
  border-color: currentColor;
  background: var(--evt-tint);
  font-weight: 600;
}

/* ---- Panels ------------------------------------------------------------ */

/* Cards are rendered once into a plain chronological list (what visitors
   without JS see). module.js sorts them into the two tab panels. */
.evt:not(.evt--js) .evt__panel,
.evt--js .evt__all { display: none; }

.evt__panel-title { margin: 0 0 1.25rem; }

/* With JS on, the tabs label the panels; keep the heading for screen readers. */
.evt--js .evt__panel-title,
.evt__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Card grid --------------------------------------------------------- */

.evt__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.evt__card {
  --evt-line: var(--evt-line-default);
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

.evt__card::before { content: none; } /* neutralise theme list markers */

/* Ticket shape. The notches are holes left in the background gradients
   (left edge / middle / right edge), so whatever is behind the card shows
   through on any section color. No CSS mask and no positioning on the top
   half: the event link's ::after must be able to stretch over the whole
   card, including the stub. --evt-fill lets hover/live states recolor. */
.evt__card { isolation: isolate; }

.evt__main {
  --evt-fill-now: var(--evt-fill, var(--evt-surface));
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem var(--evt-pad) 1.25rem;
  border-top: 4px solid var(--evt-line);
  border-radius: var(--evt-radius) var(--evt-radius) 0 0;
  background:
    radial-gradient(circle at 0 100%, transparent var(--evt-notch), var(--evt-fill-now) calc(var(--evt-notch) + 0.5px)) 0 0 / var(--evt-notch) 100% no-repeat,
    radial-gradient(circle at 100% 100%, transparent var(--evt-notch), var(--evt-fill-now) calc(var(--evt-notch) + 0.5px)) 100% 0 / var(--evt-notch) 100% no-repeat,
    linear-gradient(var(--evt-fill-now), var(--evt-fill-now)) var(--evt-notch) 0 / calc(100% - 2 * var(--evt-notch)) 100% no-repeat;
}

/* Ticket stub, with a dashed perforation between the notches. */
.evt__stub {
  --evt-fill-now: var(--evt-fill, var(--evt-surface));
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  min-height: 1.4rem;
  margin-top: -1px; /* overlap the body by a hair so no seam shows */
  padding: 0.85rem var(--evt-pad);
  border-radius: 0 0 var(--evt-radius) var(--evt-radius);
  background:
    radial-gradient(circle at 0 0, transparent var(--evt-notch), var(--evt-fill-now) calc(var(--evt-notch) + 0.5px)) 0 0 / var(--evt-notch) 100% no-repeat,
    radial-gradient(circle at 100% 0, transparent var(--evt-notch), var(--evt-fill-now) calc(var(--evt-notch) + 0.5px)) 100% 0 / var(--evt-notch) 100% no-repeat,
    linear-gradient(var(--evt-fill-now), var(--evt-fill-now)) var(--evt-notch) 0 / calc(100% - 2 * var(--evt-notch)) 100% no-repeat;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.evt__stub::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(var(--evt-notch) + 2px);
  right: calc(var(--evt-notch) + 2px);
  height: 1.5px;
  background: linear-gradient(to right, var(--evt-rail) 55%, transparent 0) 0 0 / 0.5rem 100% repeat-x;
  pointer-events: none;
}

/* Past events, or upcoming ones with nothing for the stub: one solid card. */
.evt__card[data-state="past"] .evt__stub,
.evt__card.no-stub .evt__stub { display: none; }

.evt__card[data-state="past"] .evt__main,
.evt__card.no-stub .evt__main {
  border-radius: var(--evt-radius);
  background: var(--evt-fill-now);
}

/* ---- Card content ------------------------------------------------------ */

.evt__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.evt__date {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.evt__year {
  margin-left: 0.2rem;
  color: var(--evt-muted);
  font-size: 0.875rem;
  font-weight: 400;
}

/* Route bullet, like the line badges on a transit map. */
.evt__bullet {
  flex: none;
  margin-top: 0.2rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.25rem;
  background: var(--evt-line);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
}

.evt__name {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  text-wrap: balance;
}

.evt__name a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--evt-rail);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

/* The whole card is the click target when there's a link. */
.evt__name a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.evt__card:has(.evt__name a:hover) .evt__name a { text-decoration-color: currentColor; }
.evt__card:has(.evt__name a:hover) .evt__main,
.evt__card:has(.evt__name a:hover) .evt__stub {
  --evt-fill: color-mix(in srgb, var(--evt-surface) 93%, currentColor);
}

.evt__loc {
  margin: 0;
  color: var(--evt-muted);
  font-size: 0.9375rem;
}

.evt__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  margin: 0.1rem 0 0;
  color: var(--evt-muted);
  font-size: 0.875rem;
}

/* Team names only make sense before the show. */
.evt__card[data-state="past"] .evt__team { display: none; }
.evt__card[data-state="past"] .evt__facts:not(:has(.evt__audience)) { display: none; }

.evt__details {
  margin: 0.35rem 0 0;
  font-size: 0.9375rem;
}

.evt__booth-label { color: var(--evt-muted); }
.evt__booth strong { font-weight: 700; }

.evt__when {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  font-weight: 600;
}

.evt__when:empty { display: none; }

/* Happening now: the stub picks up the route color and the dot pulses. */
.evt__card[data-state="live"] .evt__stub {
  --evt-fill: color-mix(in srgb, var(--evt-line) 16%, transparent);
}

.evt__card[data-state="live"] .evt__when::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--evt-line);
  animation: evt-pulse 2.4s ease-out infinite;
}

@keyframes evt-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--evt-line) 55%, transparent); }
  70%  { box-shadow: 0 0 0 0.5rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .evt__card[data-state="live"] .evt__when::before {
    animation: none;
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--evt-line) 30%, transparent);
  }
}

/* ---- Empty states + show more ------------------------------------------ */

.evt__empty {
  padding: 1.5rem var(--evt-pad);
  border: 1px dashed var(--evt-rail);
  border-radius: var(--evt-radius);
}

.evt__empty-text {
  margin: 0;
  color: var(--evt-muted);
}

.evt__textbtn {
  appearance: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.evt__more {
  appearance: none;
  display: block;
  margin: 1.75rem auto 0;
  padding: 0.6rem 1.25rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.evt__more:hover { background: var(--evt-tint); }

/* ---- Focus ------------------------------------------------------------- */

.evt button:focus-visible,
.evt a:focus-visible,
.evt__panel:focus-visible,
.evt__card:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 2px;
}

/* Show the focus ring around the whole card that the link covers. */
@supports selector(:has(*)) {
  .evt .evt__name a:focus-visible { outline: none; }
  .evt__card:has(.evt__name a:focus-visible) {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: var(--evt-radius);
  }
}

.evt__chip:focus-visible,
.evt__more:focus-visible { border-radius: 999px; }

/* ---- Narrow columns + phones ------------------------------------------ */

@container evt (max-width: 34rem) {
  .evt__grid,
  .evt__empty { --evt-pad: 1.1rem; }

  .evt__controls {
    flex-direction: column;
    align-items: stretch;
    border-bottom: 0;
  }

  .evt__tabs { border-bottom: 1px solid var(--evt-rail); }
  .evt__filters { padding-bottom: 0; }
}