/* ───────── Tokens ───────── */
:root {
  --bg-l: #fff8f1;        --bg-d: #170f14;
  --surface-l: #ffffff;   --surface-d: #22171e;
  --sunken-l: #fbeee4;    --sunken-d: #2f222a;
  --text-l: #2a1620;      --text-d: #fbf0f3;
  --muted-l: #75606a;     --muted-d: #bba7b1;
  --border-l: #f0dfd4;    --border-d: #3f2f38;
  --accent-l: #e0411b;    --accent-d: #ff8a5c;
  --on-accent-l: #ffffff; --on-accent-d: #2b0c02;
  --shadow-l: 110 50 30;  --shadow-d: 0 0 0;
  --blob-a-l: #ffd0b8;    --blob-a-d: #5c2112;
  --blob-b-l: #ffc6e4;    --blob-b-d: #4d1840;
  --blob-c-l: #fff0a8;    --blob-c-d: #4a3a0c;

  --bg: var(--bg-l); --surface: var(--surface-l); --sunken: var(--sunken-l);
  --text: var(--text-l); --muted: var(--muted-l); --border: var(--border-l);
  --accent: var(--accent-l); --on-accent: var(--on-accent-l); --shadow: var(--shadow-l);
  --blob-a: var(--blob-a-l); --blob-b: var(--blob-b-l); --blob-c: var(--blob-c-l);
  --tone: 0;

  @media (prefers-color-scheme: dark) {
    --bg: var(--bg-d); --surface: var(--surface-d); --sunken: var(--sunken-d);
    --text: var(--text-d); --muted: var(--muted-d); --border: var(--border-d);
    --accent: var(--accent-d); --on-accent: var(--on-accent-d); --shadow: var(--shadow-d);
    --blob-a: var(--blob-a-d); --blob-b: var(--blob-b-d); --blob-c: var(--blob-c-d);
    --tone: 1;
  }

  /* The scheme picker writes the <meta>; map it back so the cascade follows it. */
  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
    --bg: var(--bg-d); --surface: var(--surface-d); --sunken: var(--sunken-d);
    --text: var(--text-d); --muted: var(--muted-d); --border: var(--border-d);
    --accent: var(--accent-d); --on-accent: var(--on-accent-d); --shadow: var(--shadow-d);
    --blob-a: var(--blob-a-d); --blob-b: var(--blob-b-d); --blob-c: var(--blob-c-d);
    --tone: 1;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
    --bg: var(--bg-l); --surface: var(--surface-l); --sunken: var(--sunken-l);
    --text: var(--text-l); --muted: var(--muted-l); --border: var(--border-l);
    --accent: var(--accent-l); --on-accent: var(--on-accent-l); --shadow: var(--shadow-l);
    --blob-a: var(--blob-a-l); --blob-b: var(--blob-b-l); --blob-c: var(--blob-c-l);
    --tone: 0;
  }

  /* Strip colours */
  --sold: var(--accent);
  --open: color-mix(in srgb, #1c9a6c calc(100% - var(--tone) * 10%), var(--surface));
  --book: #1c9a6c;

  --radius: 18px;
  --radius-lg: 26px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  color-scheme: light dark;
  accent-color: var(--accent);
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-block-size: 100dvh;
  font: 1rem/1.5 var(--font); color: var(--text); background: var(--bg);
  overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { text-wrap: balance; line-height: 1.2; margin: 0; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { inline-size: 1.4em; block-size: 1.4em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--accent); }
.help { color: var(--muted); font-size: 0.88rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blobs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.7; animation: drift 26s ease-in-out infinite alternate; }
.blobs i:nth-child(1) { inline-size: 42rem; block-size: 32rem; inset: -14rem -12rem auto auto; background: var(--blob-a); }
.blobs i:nth-child(2) { inline-size: 36rem; block-size: 30rem; inset: auto auto -14rem -14rem; background: var(--blob-b); animation-duration: 32s; animation-direction: alternate-reverse; }
.blobs i:nth-child(3) { inline-size: 24rem; block-size: 20rem; inset: 40% auto auto 55%; background: var(--blob-c); opacity: 0.45; animation-duration: 38s; }
@keyframes drift { to { translate: -4rem 3rem; scale: 1.08; } }

/* ───────── Header ───────── */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: max(0.6rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) 0.6rem max(1rem, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.brand-wrap { display: grid; justify-items: start; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 750; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.logo { inline-size: 1.9rem; block-size: 1.9rem; stroke: none; }
.logo-ticket { fill: var(--accent-l); }
.logo-flame { fill: #ffe08a; }
.credit { margin: 0; padding-inline-start: 2.45rem; font-size: 0.75rem; font-weight: 500; line-height: 1.3; color: var(--muted); }
.credit a { color: var(--accent); font-weight: 600; text-decoration: none; }
.credit a:hover { text-decoration: underline; }
.apps-link { display: block; inline-size: fit-content; margin-block-start: 0.15rem; white-space: nowrap; }
.apps-link svg { display: inline; inline-size: 1.05em; block-size: 1.05em; margin-inline-end: 0.25em; vertical-align: -0.18em; stroke-width: 2.2; }

.header-actions { display: flex; gap: 0.5rem; }
.icon-btn { display: inline-grid; place-items: center; inline-size: 44px; block-size: 44px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); transition: background-color 0.15s, scale 0.15s; }
.icon-btn:hover { background: var(--sunken); }
.icon-btn:active { scale: 0.94; }

main {
  inline-size: min(100%, 62rem); margin-inline: auto;
  padding: 1rem max(1rem, env(safe-area-inset-right, 0px)) max(2rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
}

/* ───────── Hero ───────── */
.hero { display: grid; gap: 0.6rem; padding-block: clamp(0.5rem, 3vw, 2rem) 1.25rem; text-align: center; justify-items: center; }
.hero h1 { font-size: clamp(2rem, 1.3rem + 3.6vw, 3.3rem); letter-spacing: -0.035em; line-height: 1.05; max-inline-size: 17ch; }
.hot { font-family: var(--serif); font-style: italic; font-weight: 600; color: var(--accent); }
.tagline { max-inline-size: 38rem; color: var(--muted); font-size: clamp(0.98rem, 0.9rem + 0.35vw, 1.1rem); text-wrap: balance; }

/* ───────── Preferences ───────── */
.panel {
  display: grid; gap: 1.1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.06), 0 24px 48px -28px rgb(var(--shadow) / 0.35);
}
fieldset { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.panel legend, .label { display: block; padding: 0; margin-block-end: 0.5rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip { --c: oklch(calc(0.62 + var(--tone) * 0.12) 0.16 var(--h)); position: relative; display: grid; }
.chip input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-block-size: 40px; padding: 0.3rem 0.95rem 0.3rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--border)); border-radius: 999px;
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  font-weight: 600; font-size: 0.92rem; white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, scale 0.15s, box-shadow 0.15s;
}
.chip span::before { content: ""; inline-size: 0.6rem; block-size: 0.6rem; border-radius: 50%; background: var(--c); }
.chip small { font-weight: 500; opacity: 0.7; }
.chip:hover span { background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.chip input:checked + span { background: var(--c); border-color: var(--c); color: #fff; box-shadow: 0 8px 18px -10px var(--c); }
.chip input:checked + span::before { background: #fff; }
.chip input:active + span { scale: 0.96; }
.chip input:focus-visible + span { outline: 3px solid var(--c); outline-offset: 2px; }

.row { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem 1.25rem; }
.grow { flex: 1 1 16rem; min-inline-size: 0; }
.dates { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.dates label { display: flex; align-items: center; gap: 0.45rem; font-weight: 600; font-size: 0.92rem; }
input[type="date"], select {
  min-block-size: 44px; padding: 0.35rem 0.7rem;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
}
.search-box {
  display: flex; align-items: center; gap: 0.5rem; padding-inline: 0.9rem 0.4rem;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
}
.search-box:focus-within, input[type="date"]:focus, select:focus { border-color: var(--accent); outline: none; }
.search-box svg { color: var(--muted); }
.search-box input { flex: 1; min-inline-size: 0; min-block-size: 40px; border: 0; background: none; outline: none; }
.tools { align-items: center; gap: 0.6rem 1.4rem; font-size: 0.92rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; min-block-size: 32px; cursor: pointer; }
.check input { inline-size: 1.1rem; block-size: 1.1rem; margin: 0; }
.sort { display: inline-flex; align-items: center; gap: 0.5rem; margin-inline-start: auto; font-weight: 600; }

/* ───────── As-of slider ───────── */
.asof {
  display: grid; gap: 0.5rem; margin-block-start: 1rem;
  padding: 1rem clamp(1rem, 3vw, 1.5rem);
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.asof-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.demo-badge { padding: 0.1rem 0.6rem; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.asof input[type="range"] { inline-size: 100%; min-block-size: 32px; }

/* ───────── Results ───────── */
.results { display: grid; gap: 0.9rem; margin-block-start: 1.4rem; }
.summary { color: var(--muted); font-weight: 600; }
.summary strong { color: var(--text); }
.cards { display: grid; gap: 0.85rem; }
.card {
  display: grid; grid-template-columns: auto 1fr; gap: 1rem;
  padding: 1rem 1.1rem 1.05rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.05), 0 14px 30px -24px rgb(var(--shadow) / 0.4);
}
.heat {
  --heat-c: oklch(calc(0.66 + var(--tone) * 0.06) calc(0.04 + var(--heat) * 0.0016) calc(95 - var(--heat) * 0.6));
  display: grid; place-content: center; justify-items: center;
  inline-size: 3.6rem; block-size: 3.6rem; border-radius: 16px;
  background: color-mix(in srgb, var(--heat-c) 16%, var(--surface));
  border: 2px solid var(--heat-c);
  color: color-mix(in srgb, var(--heat-c) 70%, var(--text));
}
.heat-n { font-size: 1.35rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.heat-l { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; }
.card-body { display: grid; gap: 0.3rem; min-inline-size: 0; }
.card-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem; }
.genre { --c: oklch(calc(0.58 + var(--tone) * 0.14) 0.15 var(--h)); color: var(--c); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.verdict { padding: 0.15rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; background: var(--sunken); color: var(--muted); }
.verdict[data-v="book"] { background: var(--book); color: #fff; }
.verdict[data-v="gone"] { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.verdict[data-v="open"] { background: color-mix(in srgb, var(--book) 12%, var(--surface)); color: color-mix(in srgb, var(--book) 75%, var(--text)); }
.title { font-size: 1.12rem; letter-spacing: -0.01em; }
.title a { color: var(--text); text-decoration: none; }
.title a:hover { color: var(--accent); text-decoration: underline; }
.byline, .where { color: var(--muted); font-size: 0.88rem; }
.teaser { font-size: 0.93rem; }
.reasons { font-size: 0.88rem; font-weight: 600; }
.reasons span:not(:last-child)::after { content: " · "; color: var(--muted); font-weight: 400; }

/* The run: one cell per festival day */
.strip { --days: 25; display: grid; grid-template-columns: repeat(var(--days), 1fr); gap: 2px; margin-block: 0.35rem 0.45rem; max-inline-size: 34rem; }
.strip i { position: relative; block-size: 14px; border-radius: 3px; background: color-mix(in srgb, var(--border) 45%, transparent); }
.strip i.trip::before { content: ""; position: absolute; inset: auto -1px -6px; block-size: 3px; background: var(--text); }
.strip i.trip + i.trip::before { inset-inline-start: -3px; }
.strip i.open { background: color-mix(in srgb, var(--open) 30%, var(--surface)); border: 1.5px solid var(--open); }
.strip i.sold { background: var(--sold); }
.strip i.past { opacity: 0.35; }
.strip i.added::after { content: ""; position: absolute; inset: -4px -1px auto auto; inline-size: 6px; block-size: 6px; border-radius: 50%; background: #f5b400; border: 1px solid var(--surface); }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; color: var(--muted); font-size: 0.8rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { display: inline-block; inline-size: 12px; block-size: 12px; border-radius: 3px; }
.legend .sold { background: var(--sold); }
.legend .open { background: color-mix(in srgb, var(--open) 30%, var(--surface)); border: 1.5px solid var(--open); }
.legend .trip { background: none; border-block-end: 3px solid var(--text); border-radius: 0; block-size: 8px; }
.legend .added { inline-size: 7px; block-size: 7px; border-radius: 50%; background: #f5b400; }

.empty { padding: 1.5rem; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.more { justify-self: center; }

/* ───────── Dialogs ───────── */
dialog {
  inline-size: min(100vw - 1.5rem, 34rem); max-block-size: min(100dvh - 2rem, 46rem);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.5);
}
dialog[open] { display: flex; flex-direction: column; animation: dialog-in 0.22s ease-out; }
dialog::backdrop { background: rgb(25 8 15 / 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes dialog-in { from { opacity: 0; translate: 0 16px; scale: 0.98; } }
.dialog-head { padding: 1.2rem 1.25rem 0.4rem; }
.dialog-head h2 { font-size: 1.3rem; }
.dialog-body { display: grid; gap: 1.2rem; padding: 0.8rem 1.25rem 1.2rem; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; padding: 0.9rem 1.25rem max(0.9rem, env(safe-area-inset-bottom, 0px)); border-block-start: 1px solid var(--border); }
.field { display: grid; gap: 0.5rem; }
.field > legend { margin-block-end: 0.5rem; font-weight: 700; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--sunken); }
.segmented label { position: relative; display: grid; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented input:disabled { cursor: not-allowed; }
.segmented input:disabled + span { opacity: 0.45; }
.segmented span { display: grid; place-items: center; min-block-size: 40px; border-radius: 10px; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.primary-btn { min-block-size: 2.75rem; padding: 0.4rem 1.3rem; border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.primary-btn:hover { filter: brightness(1.07); }
.soft-btn { min-block-size: 44px; padding: 0.4rem 1.1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--sunken); font-weight: 600; font-size: 0.92rem; }
.soft-btn:hover { background: color-mix(in srgb, var(--accent) 12%, var(--sunken)); }
.about { gap: 1.15rem; line-height: 1.55; }
.about h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.about ul { display: grid; gap: 0.4rem; padding-inline-start: 1.25rem; list-style: disc; }
.about li::marker { color: var(--accent); }
.about p + p { margin-block-start: 0.5rem; }

.copyright { display: grid; gap: 0.3rem; margin: 0; padding: 3rem 1rem 0; text-align: center; font-size: 0.8rem; color: var(--muted); }

@media (max-width: 560px) {
  .card { grid-template-columns: 1fr; gap: 0.6rem; }
  .heat { grid-auto-flow: column; align-items: baseline; gap: 0.35rem; inline-size: auto; block-size: auto; justify-self: start; padding: 0.25rem 0.7rem; border-radius: 999px; }
  .sort { margin-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .blobs i, dialog[open] { animation: none; }
}
