/* ============================================================
   events2 — art-directed event browser
   All per-type variation flows from CSS custom properties set
   by app.js from data/themes.json, plus [data-texture] /
   [data-motion] hooks for generated ornament + animation.
   ============================================================ */

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

:root {
  /* Overwritten per theme at runtime */
  --accent: #0a84ff;
  --accent2: #5e5ce6;
  --wash-a: #f7f8fa;
  --wash-b: #e5e8ee;
  --ink: #1c1c1e;
  --display: system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --tracking: 0.01em;
  --radius: 16px;
  /* Surfaces resolved from wash + mode */
  --bg: var(--wash-a);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #fff;
  --hairline: color-mix(in srgb, var(--ink) 12%, transparent);
  --ink-soft: color-mix(in srgb, var(--ink) 62%, transparent);
  --ink-faint: color-mix(in srgb, var(--ink) 40%, transparent);
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 12px 32px -12px rgba(0,0,0,.22);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.08), 0 28px 60px -20px rgba(0,0,0,.34);

  --body: system-ui, -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --measure: 62ch;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --gutter: clamp(16px, 4vw, 40px);
  /* Height of the sticky topbar: 12px + 11px padding + 19px icon + 1px rule.
     Sticky day headers, popover panels and scroll-margin all key off this. */
  --topbar-h: 55px;
}

html[data-mode="dark"] {
  /* Dark surfaces must be opaque enough to guarantee text contrast over ANY
     background photograph. A near-transparent tint (0.055 white) left the
     card as pure blur, so on a bright or busy image it read as unusable
     glass. These mix the theme wash with black instead, which keeps the
     card tinted per theme while staying a real, readable surface. */
  --surface: color-mix(in srgb, var(--wash-b) 42%, rgba(0, 0, 0, 0.82));
  --surface-solid: color-mix(in srgb, var(--wash-b) 55%, #000);
  --hairline: color-mix(in srgb, var(--ink) 22%, transparent);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 40px -14px rgba(0,0,0,.7);
  --shadow-lift: 0 2px 8px rgba(0,0,0,.5), 0 32px 70px -22px rgba(0,0,0,.85);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
  transition: background-color .7s var(--ease), color .5s var(--ease);
  overflow-x: hidden;
}

/* ---------- Photographic backdrop ---------- */
/* Two stacked layers crossfade between the active theme's images. The
   veil keeps text legible over any photograph regardless of its content. */
.bg-stack { position: fixed; inset: 0; z-index: -4; overflow: hidden; }
.bg-layer {
  position: absolute; inset: -2%;
  background-size: cover; background-position: center;
  opacity: 0;
  transition: opacity 1.6s var(--ease);
  /* A slow drift stops a static photo from feeling like a dead screenshot. */
  animation: kenburns 46s ease-in-out infinite alternate;
  will-change: opacity, transform;
}
.bg-layer.on { opacity: 1; }
@keyframes kenburns {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to   { transform: scale(1.12) translate3d(-1.5%, -1%, 0); }
}
.bg-veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom,
      color-mix(in srgb, var(--wash-a) 78%, transparent) 0%,
      color-mix(in srgb, var(--wash-a) 62%, transparent) 45%,
      color-mix(in srgb, var(--wash-a) 84%, transparent) 100%);
  transition: background 1s var(--ease);
}
html[data-mode="dark"] .bg-veil {
  /* Heavier in dark mode: the wash is near-black, so a bright photograph
     needs more suppression before card text sits comfortably on top. */
  background:
    linear-gradient(to bottom,
      color-mix(in srgb, var(--wash-a) 92%, transparent) 0%,
      color-mix(in srgb, var(--wash-a) 82%, transparent) 45%,
      color-mix(in srgb, var(--wash-a) 95%, transparent) 100%);
}
@media (prefers-reduced-motion: reduce) {
  .bg-layer { animation: none; }
}

/* With photography behind it the gradient wash only needs to tint. */
.stage {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(90% 70% at 100% 8%, color-mix(in srgb, var(--accent) 16%, transparent) 0%, transparent 55%),
    radial-gradient(80% 60% at 50% 100%, color-mix(in srgb, var(--accent2) 12%, transparent) 0%, transparent 60%);
  transition: background 1s var(--ease);
}

/* ---------- Generated textures, one per event type ---------- */
.texture { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5; transition: opacity .8s var(--ease); }

[data-texture="petals"] .texture {
  background-image: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 40%, transparent) 0 2px, transparent 3px);
  background-size: 34px 34px;
  opacity: .28;
}
[data-texture="mirror"] .texture {
  background-image:
    repeating-conic-gradient(from 0deg at 50% 50%, color-mix(in srgb, var(--accent2) 26%, transparent) 0deg 12deg, transparent 12deg 24deg);
  background-size: 120px 120px;
  opacity: .16;
}
[data-texture="smoke"] .texture {
  background-image: radial-gradient(60% 40% at 50% 110%, color-mix(in srgb, var(--accent) 34%, transparent), transparent 70%);
  opacity: .5;
}
[data-texture="rangoli"] .texture {
  background-image:
    radial-gradient(circle, color-mix(in srgb, var(--accent2) 34%, transparent) 0 1.5px, transparent 2px),
    radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, transparent) 0 1.5px, transparent 2px);
  background-size: 26px 26px, 26px 26px;
  background-position: 0 0, 13px 13px;
  opacity: .34;
}
[data-texture="cobweb"] .texture {
  background-image:
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--ink) 12%, transparent) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ink) 12%, transparent) 0 1px, transparent 1px 22px);
  opacity: .3;
}
[data-texture="frost"] .texture {
  background-image:
    repeating-linear-gradient(60deg, color-mix(in srgb, var(--accent2) 16%, transparent) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(-60deg, color-mix(in srgb, var(--accent) 12%, transparent) 0 1px, transparent 1px 16px);
  opacity: .26;
}
[data-texture="grid"] .texture {
  background-image:
    linear-gradient(color-mix(in srgb, var(--ink) 10%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 10%, transparent) 1px, transparent 1px);
  background-size: 48px 48px, 48px 48px;
  opacity: .45;
}
[data-texture="splash"] .texture {
  background-image:
    radial-gradient(circle at 18% 22%, color-mix(in srgb, var(--accent) 42%, transparent) 0 5%, transparent 26%),
    radial-gradient(circle at 82% 30%, color-mix(in srgb, var(--accent2) 40%, transparent) 0 4%, transparent 22%),
    radial-gradient(circle at 66% 78%, color-mix(in srgb, var(--accent) 32%, transparent) 0 6%, transparent 28%);
  filter: blur(2px);
  opacity: .3;
}
[data-texture="bloom"] .texture {
  background-image: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent2) 38%, transparent) 0 3px, transparent 4px);
  background-size: 44px 44px;
  opacity: .26;
}
[data-texture="paper"] .texture {
  background-image:
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--ink) 6%, transparent) 0 1px, transparent 1px 4px);
  opacity: .6;
}
[data-texture="none"] .texture { opacity: 0; }

/* ---------- Floating ornament layer ---------- */
.confetti { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute;
  font-size: var(--sz, 22px);
  opacity: 0;
  will-change: transform, opacity;
  animation: var(--anim, drift) var(--dur, 18s) linear var(--delay, 0s) infinite;
}
@keyframes drift   { 0% { transform: translateY(105vh) rotate(0deg);   opacity: 0 } 12%,88% { opacity: .55 } 100% { transform: translateY(-15vh) rotate(210deg); opacity: 0 } }
@keyframes sway    { 0% { transform: translate(0,105vh) rotate(-18deg) } 25% { transform: translate(4vw,72vh) rotate(18deg) } 50% { transform: translate(-3vw,44vh) rotate(-14deg) } 75% { transform: translate(3vw,20vh) rotate(16deg) } 12%,88% { opacity: .6 } 100% { transform: translate(0,-15vh) rotate(0deg); opacity: 0 } }
@keyframes rise    { 0% { transform: translateY(105vh) scale(.7); opacity: 0 } 20%,70% { opacity: .5 } 100% { transform: translateY(-15vh) scale(1.5); opacity: 0 } }
@keyframes sparkle { 0%,100% { transform: translateY(var(--y,50vh)) scale(.4); opacity: 0 } 50% { transform: translateY(var(--y,50vh)) scale(1.15); opacity: .85 } }
@keyframes flicker { 0%,100% { opacity: 0; transform: translateY(var(--y,40vh)) rotate(-8deg) } 20% { opacity: .75 } 30% { opacity: .2 } 45% { opacity: .8 } 70% { opacity: .3 } }
@keyframes snow    { 0% { transform: translate(0,-12vh) rotate(0deg); opacity: 0 } 10%,90% { opacity: .75 } 100% { transform: translate(6vw,108vh) rotate(180deg); opacity: 0 } }
@keyframes streak  { 0% { transform: translateX(-12vw) skewX(-24deg) scaleX(.6); opacity: 0 } 15%,80% { opacity: .5 } 100% { transform: translateX(112vw) skewX(-24deg) scaleX(1.4); opacity: 0 } }
@keyframes burst   { 0% { transform: translate(0,0) scale(.3); opacity: 0 } 30% { opacity: .8 } 100% { transform: translate(var(--dx,20vw), var(--dy,-30vh)) scale(1.4); opacity: 0 } }

/* ---------- Shell ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }
/* Room for the fixed footer bar so the last row is never covered. */
main.wrap { padding-bottom: 64px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  /* The bar itself spans the full screen so its background and hairline
     reach both edges. An inner track handles the max-width + gutters, so
     the brand aligns with the cards and no icon touches the screen edge. */
  padding: 0;
  background: color-mix(in srgb, var(--wash-a) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
  transition: background-color .7s var(--ease);
}
.topbar-inner {
  display: flex; align-items: center; gap: 10px;
  max-width: 1240px; margin: 0 auto;
  padding: 12px var(--gutter) 11px;
}
html[data-mode="dark"] .topbar { background: color-mix(in srgb, var(--wash-a) 76%, transparent); }

.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; min-width: 0; }
/* Holds either an emoji glyph or the app icon <img>, so it needs a fixed box
   and centring rather than relying on the emoji's own line-height. */
.brand-glyph {
  font-size: 24px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
}
.brand-glyph img {
  width: 28px; height: 28px; display: block;
  /* The source is a rounded-square medallion; matching the app's own radius
     scale keeps it from reading as a pasted-in sticker. */
  border-radius: 7px;
}
.brand-name {
  font-family: var(--display);
  letter-spacing: var(--tracking);
  font-size: clamp(19px, 3.2vw, 27px);
  font-weight: 600; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Icon buttons */
.icon-btn {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--ink); width: 38px; height: 38px; border-radius: 11px;
  display: inline-grid; place-items: center; cursor: pointer; position: relative;
  font-size: 16px; transition: background-color .18s var(--ease), transform .18s var(--ease), border-color .18s var(--ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.icon-btn:active { transform: scale(.93); }
.icon-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: color-mix(in srgb, var(--accent) 78%, var(--ink)); }

/* Monochrome line icon (settings). Stroke inherits currentColor so it
   picks up hover / theme ink automatically. */
.icon-btn svg {
  width: 19px; height: 19px; display: block;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}
.count {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px;
}

/* ---------- Type rail (multi-select) ---------- */
.rail {
  display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 14px;
  scrollbar-width: none; -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}
.rail::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px 8px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: all .2s var(--ease);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.chip:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 24%, transparent); transform: translateY(-1px); }
.chip .g { font-size: 15px; }
.chip .n { font-variant-numeric: tabular-nums; opacity: .55; font-size: 12px; }
.chip[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--chip-a, var(--accent)), var(--chip-b, var(--accent2)));
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px -6px var(--chip-a, var(--accent));
}
.chip[aria-pressed="true"] .n { opacity: .8; }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-bottom: 18px; }
.field {
  display: flex; align-items: center; gap: 8px; flex: 1 1 260px; min-width: 0;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 0 12px; height: 42px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 20%, transparent); }
.field input, .field select {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 14px; width: 100%; min-width: 0; height: 100%; outline: none;
}
.field .ic { color: var(--ink-faint); font-size: 14px; flex: 0 0 auto; }
.field kbd {
  font-family: var(--mono); font-size: 10.5px; padding: 2px 5px; border-radius: 5px;
  border: 1px solid var(--hairline); color: var(--ink-faint); flex: 0 0 auto;
}
.seg {
  display: inline-flex; background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 11px; padding: 3px; gap: 2px; flex: 0 0 auto;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--ink-soft);
  font: inherit; font-size: 13px; font-weight: 500; padding: 6px 13px;
  border-radius: 8px; cursor: pointer; transition: all .18s var(--ease); white-space: nowrap;
}
.seg button[aria-selected="true"] { background: var(--surface-solid); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.14); }

/* ---------- Status line ---------- */
.statusline {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 16px; font-size: 13px; color: var(--ink-faint);
}
.statusline strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pill-clear {
  appearance: none; cursor: pointer; font: inherit; font-size: 12px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ink-soft);
  padding: 3px 10px; border-radius: 999px; transition: all .18s var(--ease);
}
.pill-clear:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Card grid ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 18px 18px 15px;
  box-shadow: var(--shadow); cursor: pointer; overflow: hidden;
  -webkit-backdrop-filter: blur(22px) saturate(160%); backdrop-filter: blur(22px) saturate(160%);
  /* background-color eases too, so switching event type shifts the card
     tint smoothly instead of snapping while the backdrop crossfades. */
  transition: transform .28s var(--ease-out), box-shadow .28s var(--ease-out),
              border-color .28s var(--ease), background-color .7s var(--ease);
  /* `forwards` (not `both`) so a card is never held invisible during its
     stagger delay — it simply animates to its resting state and stays. */
  animation: card-in .45s var(--ease-out) forwards;
  animation-delay: var(--i, 0ms);
}
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.985) } to { opacity: 1; transform: none } }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--c-a, var(--accent)) 45%, transparent); }

/* The card already carries its identity colour in the left stripe, so a
   full accent-coloured ring on top of it read as two competing oranges.
   Selection is expressed by GROWING the stripe the card already has, and
   the ring that remains is a neutral hairline — shape, not more colour. */
.card:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--c-a, var(--accent)) 55%, transparent);
  box-shadow: var(--shadow-lift),
              0 0 0 1px color-mix(in srgb, var(--ink) 22%, transparent),
              0 0 0 4px color-mix(in srgb, var(--c-a, var(--accent)) 12%, transparent);
}

/* Per-card accent stripe uses the event's OWN type colors, so a mixed
   list stays legible as a mosaic rather than one flat palette. */
.card::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(to bottom, var(--c-a, var(--accent)), var(--c-b, var(--accent2)));
  transition: width .24s var(--ease-out), filter .24s var(--ease);
}

/* Open / selected card. `.is-open` is set by openSheet() and cleared by
   closeSheet(), so "selected" is an explicit state rather than a leftover
   focus ring the browser restores when the dialog hands focus back. */
.card.is-open {
  border-color: color-mix(in srgb, var(--c-a, var(--accent)) 50%, transparent);
  box-shadow: var(--shadow-lift),
              0 0 0 1px color-mix(in srgb, var(--c-a, var(--accent)) 34%, transparent);
}
.card.is-open::before { width: 7px; filter: saturate(1.15) brightness(1.06); }

@media (prefers-reduced-motion: reduce) {
  .card::before { transition: none; }
}
/* Past-event dimming is applied to inner content in modern.css, so the
   card's own opacity stays owned solely by the card-in animation. */

.card-top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.card-glyph {
  font-size: 20px; line-height: 1; flex: 0 0 auto;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.2));
}
.card h3 {
  font-family: var(--c-display, var(--display));
  letter-spacing: var(--c-tracking, var(--tracking));
  font-size: 17px; font-weight: 600; line-height: 1.28; margin: 0; flex: 1 1 auto;
  overflow-wrap: anywhere;
}
.fav {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-size: 15px; padding: 2px; line-height: 1; flex: 0 0 auto;
  filter: grayscale(1); opacity: .3;
  transition: all .2s var(--ease);
}
.fav:hover { opacity: .7; transform: scale(1.16); }
.fav[aria-pressed="true"] { filter: none; opacity: 1; }

.meta { display: grid; gap: 6px; font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }
.meta div { display: flex; gap: 8px; align-items: flex-start; }
.meta .ic { flex: 0 0 15px; text-align: center; opacity: .65; font-size: 12px; }
.meta .v { min-width: 0; overflow-wrap: anywhere; }
.when { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.tag {
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 4px;
}
.tag.hot   { background: color-mix(in srgb, #ff9500 22%, transparent); color: color-mix(in srgb, #ff9500 82%, var(--ink)); }
.tag.free  { background: color-mix(in srgb, #34c759 20%, transparent); color: color-mix(in srgb, #34c759 78%, var(--ink)); }
.tag.paid  { background: color-mix(in srgb, var(--accent) 18%, transparent); color: color-mix(in srgb, var(--accent) 82%, var(--ink)); }
.tag.near  { background: color-mix(in srgb, #0a84ff 20%, transparent); color: color-mix(in srgb, #0a84ff 80%, var(--ink)); }
/* Beyond 12 miles: still shown, just not badged as "nearby". */
.tag.far   { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-faint); }
.tag.soon  { background: linear-gradient(135deg, var(--c-a, var(--accent)), var(--c-b, var(--accent2))); color: #fff; }
/* Cancelled. Deliberately the loudest tag on the card and NOT theme-tinted:
   this must read the same on every category, because a themed grey would get
   lost against an art-directed background. Red, solid, uppercase. */
.tag.cancelled {
  background: #d7263d; color: #fff; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
/* "Day 2 of 3" / "12d left" marker on multi-day agenda rows. */
.tag.day {
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink-soft); font-weight: 500; font-variant-numeric: tabular-nums;
}

/* ---------- Inline link row on cards ---------- */
/* Surfaces the event link on the main page, so the primary action
   (tickets/info) never requires opening the detail sheet first. */
.card-actions {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin-top: 13px; padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.lnk {
  appearance: none; font: inherit; font-size: 12.5px; font-weight: 550;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  padding: 8px 12px; border-radius: 9px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 5px;
  /* 44px tap target on touch without inflating the visual box. */
  min-height: 34px;
  transition: background-color .16s var(--ease), color .16s var(--ease),
              border-color .16s var(--ease), transform .16s var(--ease);
}
.lnk:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 28%, transparent); transform: translateY(-1px); }
.lnk:active { transform: translateY(0) scale(.97); }
.lnk.primary {
  background: linear-gradient(135deg, var(--c-a, var(--accent)), var(--c-b, var(--accent2)));
  color: #fff; border-color: transparent; flex: 1 1 auto; justify-content: center;
  box-shadow: 0 5px 14px -6px var(--c-a, var(--accent));
}
.lnk.primary:hover { color: #fff; filter: brightness(1.07); }
.lnk.icon { padding: 5px 9px; min-height: 0; font-size: 13px; }

@media (hover: none) {
  /* Touch devices get a comfortable 44px target per Apple HIG. */
  .lnk { min-height: 44px; padding: 11px 14px; font-size: 13.5px; }
  .lnk.icon { min-height: 38px; min-width: 38px; justify-content: center; }
  .lnk:hover, .card:hover { transform: none; }
}

/* Countdown ribbon */
.ribbon {
  position: absolute; top: 0; right: 0;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 0 var(--radius) 0 10px;
  background: linear-gradient(135deg, var(--c-a, var(--accent)), var(--c-b, var(--accent2)));
  color: #fff;
}
/* Cancelled ribbon overrides the themed gradient with flat red. */
.ribbon-off { background: #d7263d; }

/* A cancelled card stays visible and clickable — people need to find out WHY,
   and the link is the answer — but it must not compete visually with events
   that are actually happening. Desaturate and knock back, don't hide. */
.card.cancelled { filter: saturate(.45); opacity: .72; }
.card.cancelled h3 { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.card.cancelled:hover, .card.cancelled:focus-visible { filter: none; opacity: 1; }

/* Cancellation notice at the top of the detail sheet. */
.notice-off {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, #d7263d 14%, transparent);
  border-left: 3px solid #d7263d;
  color: var(--ink); font-size: 13.5px; line-height: 1.45;
}

/* ---------- Map view ---------- */
/* Basemap tokens. Land/water are derived from the theme wash so the map
   belongs to whichever art direction is active. */
:root {
  --map-land: color-mix(in srgb, var(--wash-b) 55%, var(--surface-solid));
  --map-water: color-mix(in srgb, #0a84ff 16%, var(--map-land));
  --map-shore: color-mix(in srgb, #0a84ff 42%, transparent);
}
html[data-mode="dark"] {
  --map-land: color-mix(in srgb, var(--wash-b) 40%, #000);
  --map-water: color-mix(in srgb, #0a84ff 22%, #000);
  --map-shore: color-mix(in srgb, #58a6ff 45%, transparent);
}
.mapview {
  position: relative; height: min(72vh, 660px);
  border-radius: 18px; overflow: hidden;
  border: 1px solid var(--hairline); background: var(--map-land);
  box-shadow: var(--shadow);
}
.mapview svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.mapview svg:active { cursor: grabbing; }
/* Geography sits behind the pins and must never intercept taps. */
.basemap { pointer-events: none; }
.mapcity circle { fill: color-mix(in srgb, var(--ink) 45%, transparent); }
.mapcity text {
  font-family: var(--body); font-size: 10.5px; font-weight: 500;
  fill: color-mix(in srgb, var(--ink) 62%, transparent);
  paint-order: stroke; stroke: var(--map-land); stroke-width: 2.5px; stroke-linejoin: round;
}
.mapdot { cursor: pointer; transition: r .18s var(--ease); }
.mapdot:hover { r: 11; }
.maplegend {
  position: absolute; left: 12px; bottom: 12px;
  background: color-mix(in srgb, var(--wash-a) 90%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--hairline); border-radius: 11px;
  padding: 9px 12px; font-size: 11.5px; color: var(--ink-soft); max-width: 60%;
  display: flex; flex-wrap: wrap; gap: 4px 12px;
}
.maplegend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.mapzoom { position: absolute; right: 12px; top: 12px; display: grid; gap: 6px; }
.mapzoom button {
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--hairline); background: color-mix(in srgb, var(--wash-a) 92%, transparent);
  color: var(--ink); font-size: 16px; line-height: 1;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.maptip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-solid); border: 1px solid var(--hairline);
  border-radius: 9px; padding: 6px 10px; font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .15s var(--ease);
  white-space: nowrap; transform: translate(-50%, -140%);
}

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 72px 20px; color: var(--ink-faint); }
.empty .g { font-size: 42px; display: block; margin-bottom: 14px; opacity: .5; }
.empty p { max-width: var(--measure); margin: 0 auto 16px; font-size: 14px; line-height: 1.6; }
.skeleton { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%,310px),1fr)); }
.skeleton div {
  height: 172px; border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 30%, color-mix(in srgb, var(--ink) 8%, transparent) 50%, var(--surface) 70%);
  background-size: 220% 100%; animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { to { background-position: -120% 0 } }

/* ---------- Detail sheet ---------- */
/* Backdrop and enter/exit transitions live in modern.css via
   ::backdrop + @starting-style. */
.sheet {
  position: fixed; z-index: 91; right: 0; top: 0; bottom: 0;
  width: min(460px, 100%);
  background: var(--surface-solid);
  border-left: 1px solid var(--hairline);
  box-shadow: -20px 0 70px -20px rgba(0,0,0,.5);
  /* NOTE: no `display` here. Setting display:flex unconditionally would
     beat the UA's `dialog:not([open]){display:none}` and the sheet would
     never actually close. Layout is applied only in the [open] state. */
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet-hero {
  padding: 22px var(--gutter) 18px; position: relative; flex: 0 0 auto;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c-a, var(--accent)) 22%, transparent), color-mix(in srgb, var(--c-b, var(--accent2)) 14%, transparent));
  border-bottom: 1px solid var(--hairline);
}
.sheet-hero .kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--c-a, var(--accent)) 80%, var(--ink)); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.sheet-hero h2 {
  font-family: var(--c-display, var(--display)); letter-spacing: var(--c-tracking, var(--tracking));
  font-size: clamp(21px, 4.6vw, 27px); font-weight: 600; line-height: 1.2; margin: 0 34px 10px 0;
  overflow-wrap: anywhere;
}
.sheet-close { position: absolute; top: 18px; right: 16px; }
.sheet-body { padding: 18px var(--gutter) 24px; overflow-y: auto; flex: 1 1 auto; -webkit-overflow-scrolling: touch; }
.dl { display: grid; gap: 1px; background: var(--hairline); border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.dl > div { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 11px 13px; background: var(--surface-solid); font-size: 13.5px; }
.dl dt { color: var(--ink-faint); font-size: 12px; margin: 0; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.dl dd a { color: var(--accent); text-decoration: none; }
.dl dd a:hover { text-decoration: underline; }
.actions { display: grid; gap: 9px; grid-template-columns: 1fr 1fr; }
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 550;
  padding: 11px 14px; border-radius: 11px; border: 1px solid var(--hairline);
  background: transparent; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: all .18s var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--c-a, var(--accent)), var(--c-b, var(--accent2)));
  color: #fff; border-color: transparent; grid-column: 1 / -1;
  box-shadow: 0 8px 22px -8px var(--c-a, var(--accent));
}
.section-h {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); margin: 22px 0 10px;
}
/* The sheet's "Also near this venue" list was removed — it competed with
   the map for the same job and pushed the real actions below the fold. */

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 120;
  /* Hidden state must clear `bottom` AS WELL AS the toast's own height.
     A percentage-only translate can't: 130% of a ~40px one-line toast is 52px
     of travel against the 26px + 40px needed, so the top ~14px of the pill
     stayed visible above the bottom edge. calc() makes the offset exact at any
     height, and opacity/visibility guarantee it regardless. */
  transform: translate(-50%, calc(100% + 26px));
  opacity: 0; visibility: hidden; pointer-events: none;
  background: var(--surface-solid); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 11px 18px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lift);
  transition: transform .34s var(--ease-out), opacity .2s var(--ease),
              visibility .34s step-end;
  display: flex; align-items: center; gap: 9px; max-width: calc(100vw - 32px);
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: transform .34s var(--ease-out), opacity .2s var(--ease),
              visibility 0s;
}

/* ---------- Command palette ---------- */
.palette {
  position: fixed; z-index: 130; top: 12vh; left: 50%; transform: translate(-50%, -12px);
  width: min(560px, calc(100vw - 32px));
  background: var(--surface-solid); border: 1px solid var(--hairline);
  border-radius: 15px; box-shadow: 0 40px 100px -25px rgba(0,0,0,.6);
  overflow: hidden; opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease-out);
}
.palette.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.palette input {
  width: 100%; border: 0; outline: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; padding: 16px 18px;
  border-bottom: 1px solid var(--hairline);
}
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 46vh; overflow-y: auto; }
.palette li {
  padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
}
.palette li .sub { margin-left: auto; font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }
.palette li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.palette .hintbar { padding: 8px 14px; border-top: 1px solid var(--hairline); font-size: 11px; color: var(--ink-faint); display: flex; gap: 14px; }

/* ---------- Footer ---------- */
/* Thin fixed bar, matching v1: one line, 11px, pinned to the bottom.
   `body` reserves room for it so the last card is never covered. */
.foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  /* Three columns with equal-weight outer tracks, so the middle cell's centre
     is the SCREEN's centre no matter how wide the left/right clusters get.
     A flex row with `margin-left: auto` spacers could not guarantee that. */
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 10px;
  /* Spans the full screen width — the content is no longer held to the card
     track, so ♥ Support lands on the true centre line of the viewport. */
  width: 100%;
  padding: 5px var(--gutter) calc(5px + env(safe-area-inset-bottom));
  font-size: 11px; line-height: 1.5; color: var(--ink-faint);
  white-space: nowrap;
  background: color-mix(in srgb, var(--wash-a) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--hairline);
  box-sizing: border-box;
}
/* Zones. The outer two keep their own internal spacing; `min-width: 0` lets
   them shrink (and #footCount ellipsise) instead of shoving the centre off-axis. */
.foot-l, .foot-c, .foot-r {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
}
.foot-l { justify-content: flex-start; overflow: hidden; }
.foot-c { justify-content: center; }
.foot-r { justify-content: flex-end; }
.foot .c { font-weight: 500; color: var(--ink-soft); }
.foot .dot { opacity: .4; }
.foot #footCount { overflow: hidden; text-overflow: ellipsis; }
.foot a, .foot .linkish {
  color: var(--ink-soft); text-decoration: none;
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; padding: 2px 0;
}
.foot a:hover, .foot .linkish:hover { color: var(--accent); }
.foot .support { font-weight: 600; color: var(--ink-soft); }
.foot .support:hover { color: #e0245e; }

/* Share row: brand-tinted only on hover, so the bar stays quiet. */
.foot .share { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; }
.foot .sh {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12px; line-height: 1;
  width: 22px; height: 22px; border-radius: 6px;
  display: inline-grid; place-items: center;
  color: var(--ink-faint); text-decoration: none;
  transition: color .16s var(--ease), background-color .16s var(--ease);
}
.foot .sh:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.foot .sh.fb:hover { color: #1877f2; }
.foot .sh.tw:hover { color: var(--ink); }
.foot .sh.wa:hover { color: #25d366; }
.foot .sh.lk:hover { color: var(--accent); }

/* ---------- Support QR codes ---------- */
.qr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.qr {
  display: grid; justify-items: center; gap: 6px;
  padding: 9px; border-radius: 10px; text-decoration: none;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  transition: border-color .16s var(--ease), transform .16s var(--ease);
}
.qr:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-2px); }
.qr-label { font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.qr-label.pp { color: #003087; }
.qr-label.vm { color: #008cff; }
html[data-mode="dark"] .qr-label.pp { color: #6b9bd8; }
.qr img { width: 100%; height: auto; max-width: 116px; border-radius: 7px; background: #fff; padding: 4px; display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .brand-sub { display: none; }
  .controls .seg { order: 3; width: 100%; justify-content: space-between; }
  .seg button { flex: 1; }
  .dl > div { grid-template-columns: 82px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .confetti { display: none; }
}

@media print {
  .topbar, .rail, .controls, .confetti, .texture, .stage, .foot, .mapzoom { display: none !important; }
  body { background: #fff; color: #000; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}

/* ---------- Street line on cards ---------- */
/* Venue/street on its own line above the city, so the card answers
   "where exactly" without opening the detail sheet. */
.meta .v .st {
  display: block; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.meta .v .ct { display: block; font-size: 12px; color: var(--ink-faint); }

/* ---------- List view ---------- */
/* Dense, scannable rows. Mobile default: fits ~4x more events per screen
   than cards, and multi-day events stay a single row. */
.listview {
  border: 1px solid var(--hairline); border-radius: 14px;
  background: var(--surface); overflow: hidden;
  -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow);
}
.lrow {
  display: grid;
  /* Every column is a FIXED or fr track — no `auto`. An auto-sized actions
     column collapses in the header row (which has no buttons), so the
     header labels would not line up with the body rows beneath. */
  grid-template-columns:
    84px                /* when  */
    minmax(0, 1.6fr)    /* name  */
    minmax(0, 1.2fr)    /* where */
    62px                /* dist  */
    72px;               /* act   */
  gap: 12px; align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
  transition: background-color .15s var(--ease);
}
.lrow:first-child { border-top: 0; }
.lrow:hover { background: color-mix(in srgb, var(--c-a, var(--accent)) 8%, transparent); }
/* Matches the card treatment: an inset left bar rather than a full ring,
   so the row's identity colour appears once instead of twice. */
.lrow:focus-visible,
.lrow.is-open {
  outline: none;
  background: color-mix(in srgb, var(--c-a, var(--accent)) 10%, transparent);
  box-shadow: inset 3px 0 0 0 var(--c-a, var(--accent));
}

.lhead {
  cursor: default; padding: 7px 14px; align-items: center;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}
.lhead:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
/* Header cells inherit the same justification as the body columns they label. */
.lhead > :nth-child(4) { justify-self: end; }
.lhead > :nth-child(5) { justify-self: end; }

.lwhen { display: grid; gap: 1px; align-content: center; }
.lwhen .dnum { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lwhen .dsub { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }

.lname { display: flex; align-items: center; gap: 7px; min-width: 0; }
.lname .g { flex: 0 0 auto; font-size: 14px; }
.lname .nm {
  font-size: 14px; font-weight: 550; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lname .tag { flex: 0 0 auto; font-size: 10px; padding: 2px 6px; }

.lwhere { display: grid; gap: 1px; min-width: 0; align-content: center; }
.lwhere .st, .lwhere .ct {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lwhere .st { font-size: 12.5px; color: var(--ink-soft); }
.lwhere .ct { font-size: 11px; color: var(--ink-faint); }

.ldist {
  font-size: 12.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--ink-soft); white-space: nowrap;
  /* Right-aligned in both header and body so the numbers form a clean edge. */
  justify-self: end; text-align: right;
}
.ldist .u { font-size: 10px; font-weight: 400; opacity: .6; margin-left: 1px; }

.lact { display: flex; gap: 4px; align-items: center; justify-self: end; }
.lact .lnk.icon { padding: 4px 7px; min-height: 0; }
.lact .trip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--c-a, var(--accent)) 18%, transparent);
  border-color: color-mix(in srgb, var(--c-a, var(--accent)) 48%, transparent);
  color: color-mix(in srgb, var(--c-a, var(--accent)) 82%, var(--ink));
}
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
