/* Mobile-first, no framework. Palette: Alentejo fields (whitewash, wheat, clay, cork oak). */
/* Surfaces, on --bg: 1 cards and controls · 2 emphasis (today's cards, event facts)
   · 3 inset bits that sit on 1 or 2 (chips, placeholders), so they must differ from both
   · 4 floating (menus, with shadow and scrim). Text on 3 and 4 is --text only:
   muted and accent drop below 4.5:1 there. */
:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --surface-1: #fffdf8;
  --surface-2: #f1e6cc;
  --surface-3: #e0cea3;
  --surface-4: #ffffff;
  --scrim: rgb(46 42 34 / 25%);
  --text: #2e2a22;
  --muted: #6f6754;
  --line: #e4d9c3;
  --accent: #ad4f28;
  --accent-2: #5b6b3a;
  --on-accent: #ffffff;
  --radius: 14px;
  /* Header to first title, shared by the list and the text pages so nothing jumps between them. */
  --content-top: 20px;
}
/* Dark tokens twice on purpose: light-dark() would say it once, but Safari only
   has it from 17.5 and iOS 16 visitors get broken colours. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b1d16;
    --surface-1: #24271d;
    --surface-2: #343b24;
    --surface-3: #464d34;
    --surface-4: #4b5138;
    --scrim: rgb(0 0 0 / 45%);
    --text: #efe8d8;
    --muted: #a9a28c;
    --line: #363a2b;
    --accent: #d98a4e;
    --accent-2: #9fae76;
    --on-accent: #1b1d16;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1d16;
  --surface-1: #24271d;
  --surface-2: #343b24;
  --surface-3: #464d34;
  --surface-4: #4b5138;
  --scrim: rgb(0 0 0 / 45%);
  --text: #efe8d8;
  --muted: #a9a28c;
  --line: #363a2b;
  --accent: #d98a4e;
  --accent-2: #9fae76;
  --on-accent: #1b1d16;
}

* { box-sizing: border-box; }
/* Short pages have no scrollbar: without the reserved gutter the centred header jumps sideways. */
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  /* 100%, not px: respects the visitor's own default text size. */
  font: 100%/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }
img { max-width: 100%; display: block; }

.container { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px;
  padding: 12px 16px;
  background: var(--accent);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--on-accent); font-weight: 800; font-size: 1.15rem; text-decoration: none;
}
/* The icon's clay tile matches the light header: a thin ring keeps its edge visible. */
.brand__icon { border-radius: 7px; box-shadow: 0 0 0 1.5px var(--on-accent); }
/* margin-left: auto keeps the actions right-aligned when large text wraps them onto a second line. */
.site-header__actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
/* Inverted pill so it reads as the one call to action in the bar; 44px tap area via ::before. */
.support-link {
  position: relative;
  /* Outlined, with the logo tile's corner radius rather than a pill. */
  padding: 4px 12px; border: 1.5px solid var(--on-accent); border-radius: 8px;
  color: var(--on-accent);
  font-size: .85rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.support-link::before { content: ""; position: absolute; inset: -7px 0; }
.theme-toggle {
  min-width: 44px; min-height: 44px; margin: -10px -10px -10px 0;
  display: grid; place-items: center;
  border: 0; background: none; cursor: pointer;
  color: var(--on-accent);
}

/* Wrapped, not scrolled: a hidden scrollbar can't be dragged on desktop
   and resets on every navigation, hiding the active pill. */
.headline { margin: var(--content-top) 0 0; font-size: 1.5rem; line-height: 1.2; font-weight: 800; }
/* Named so only this phrase animates when the period changes (Turbo view transitions). */
.headline__when { display: block; color: var(--accent); view-transition-name: headline-when; }
/* Same line once the longest phrase fits (~480px); below that it stays on its
   own line so the headline height doesn't jump between periods. */
@media (min-width: 520px) { .headline__when { display: inline-block; } }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
/* No size morph and no stretching: "hoje?" and the long phrases differ a lot in
   width, so the default group animation would squash the text. */
::view-transition-group(headline-when) { animation: none; }
::view-transition-old(headline-when), ::view-transition-new(headline-when) {
  width: auto; height: 100%; object-fit: none; object-position: left top;
}
::view-transition-old(headline-when) { animation: headline-out 160ms ease-in both; }
::view-transition-new(headline-when) { animation: headline-in 240ms ease-out both; }
@keyframes headline-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes headline-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: 0.01ms; }
}

.pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 0 4px; }
/* Tap target ≥ 44px without making the pills look bigger. */
.pill { position: relative; }
.pill::before { content: ""; position: absolute; inset: -5px 0; }
.pill {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-1);
  text-decoration: none;
  font-size: .9rem;
  white-space: nowrap;
}
/* Kinds read as a second, lighter row under the periods: outlined, filled with the accent when picked.
   One scrolling row on phones (swiped, and kinds_controller.js brings the active one into view);
   wrapped on desktop, where a scrollbar can't be dragged. */
/* A rule between filter groups; on phones it runs edge to edge like the swiped row. */
.pills--kinds, .filters { border-top: 1px solid var(--line); margin: 12px -16px 0; }
.pills--kinds {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  padding: 12px 16px 4px; scroll-padding-inline: 16px;
}
.pills--kinds::-webkit-scrollbar { display: none; }
.pill--kind { background: transparent; }
.pill.pill--kind.is-active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 6px 16px 0; }
/* The venue is a quiet text button: the native picker, without the boxed look. */
.place { position: relative; display: inline-flex; align-items: center; max-width: 100%; }
.select.select--quiet {
  width: auto; padding: 0 22px 0 0; border: 0; border-radius: 0;
  appearance: none; -webkit-appearance: none;
  background: transparent; font-weight: 600; text-overflow: ellipsis;
}
.place__arrow { position: absolute; right: 2px; pointer-events: none; }
.clear-filters { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font-size: .9rem; }
.select {
  width: 100%; min-width: 0;
  min-height: 44px; padding: 0 28px 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-1); color: var(--text);
  font: inherit; font-size: 1rem;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.pill.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }

.day h2 { font-size: 1rem; margin: 24px 0 10px; color: var(--muted); }
.day--today h2 { color: var(--accent); }

.card {
  display: flex; gap: 12px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-1);
  border: 1px solid var(--line);
  text-decoration: none;
}
.card--now { background: var(--surface-2); }

.series { margin-bottom: 10px; }
.series > summary { margin-bottom: 0; cursor: pointer; list-style: none; }
.series > summary::-webkit-details-marker { display: none; }
.series__toggle span { display: inline-block; transition: transform .15s; }
.series[open] .series__toggle span { transform: rotate(180deg); }
.series[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.series__sessions {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px;
  margin: 0; padding: 4px 0; list-style: none;
  border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface-1);
}
.series__session {
  display: grid; gap: 0 10px; grid-template-columns: auto 1fr; align-items: baseline;
  min-height: 44px; padding: 8px 12px; text-decoration: none;
}
.series__sessions > li { grid-column: 1 / -1; }
/* Subgrid lines every title up behind the widest date; without it each row sizes its own. */
@supports (grid-template-columns: subgrid) {
  .series__sessions > li { display: grid; grid-template-columns: subgrid; }
  .series__session { grid-column: 1 / -1; grid-template-columns: subgrid; }
}
.series__session:hover .series__what { text-decoration: underline; }
/* Date and time break apart rather than overflow at 320px with large text. */
.series__when { color: var(--accent-2); font-size: .85rem; font-weight: 600; }
.series__unit { white-space: nowrap; }
.series__what { font-weight: 600; }
.series__today {
  display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: middle;
  border-radius: 50%; background: var(--accent);
}
/* Muted, not faded: opacity would drop the text below 4.5:1. */
.series__session--started .series__when, .series__session--started .series__what { color: var(--muted); font-weight: 400; }
.series__where { grid-column: 2; color: var(--muted); font-size: .8rem; }
@media (prefers-reduced-motion: reduce) { .series__toggle span { transition-duration: 0.01ms; } }
.card-wrap { position: relative; }
.card-wrap .card__body { padding-right: 32px; }
.card__img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; flex: none; }
.card__media { position: relative; flex: none; display: grid; place-items: center; align-self: start; }
/* Cancelled: the photo goes grey under a stamp; the text keeps full contrast so it still reads. */
.card--cancelled .card__img, .event--cancelled .event__img { filter: grayscale(1); opacity: .45; }
.stamp {
  position: absolute;
  padding: 2px 5px; border-radius: 4px;
  background: var(--text); color: var(--bg);
  font-size: .625rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase;
  transform: rotate(-8deg);
}
.notice {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--text); color: var(--bg);
}
.placeholder { display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.placeholder svg { width: 45%; height: 45%; }
.event__img.placeholder { width: 100%; aspect-ratio: 4 / 3; max-height: min(45vh, 360px); }
.event__img.placeholder svg { width: 20%; height: 20%; }
.card__body { min-width: 0; }
.card__meta { margin: 0; font-size: .85rem; color: var(--accent-2); font-weight: 600; }
/* Two lines at most in the list (the event page shows the full title). A visual
   cut only: screen readers and search engines still get the whole title. */
.card__title {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  margin: 2px 0 6px; overflow: hidden; overflow-wrap: anywhere;
  font-size: 1rem; line-height: 1.3;
}
.tag { font-size: .75rem; color: var(--muted); }
.card__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.card__foot .chips { margin: 0; }
.card__price { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 6px; padding: 0; list-style: none; }
.chip {
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--text);
  font-size: .75rem; font-weight: 600; line-height: 1.5;
}
.event .chips { margin: -4px 0 14px; }

.event { padding: 16px 0 32px; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; }
/* Whole photo, never cropped: shrinks to the height cap keeping its ratio,
   on a full-width surface that fills the sides of portraits. */
.event__media {
  display: flex; justify-content: center;
  margin-bottom: 16px; overflow: hidden;
  border-radius: var(--radius); background: var(--surface-2);
}
.event__img { width: auto; height: auto; max-width: 100%; max-height: min(45vh, 360px); }
.event__zoom { display: flex; justify-content: center; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }

.lightbox {
  max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; margin: 0; padding: 16px;
  border: 0; background: none; place-items: center;
  /* Pinch and drag move the photo (lightbox_controller.js), not the page. */
  touch-action: none; overflow: hidden;
}
.lightbox[open] { display: grid; }
.lightbox::backdrop { background: rgb(0 0 0 / 85%); }
.lightbox__img {
  max-width: 100%; max-height: calc(100vh - 96px); object-fit: contain; border-radius: 6px;
  user-select: none; -webkit-user-drag: none; cursor: zoom-in;
}
.lightbox__close {
  position: fixed; top: 12px; right: 12px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 999px; background: #fffdf8; color: #2e2a22;
  font: inherit; font-weight: 700; cursor: pointer;
}
.event h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 12px; }
.event__facts {
  display: grid; gap: 14px;
  margin: 0 0 16px; padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-2);
}
.event__facts dt { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.event__facts dd { margin: 2px 0 0; font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.event__facts .fact__sub { font-size: .9rem; font-weight: 400; color: var(--muted); }
.event__facts .fact__sub a { display: inline-block; padding: 12px 0; margin: -12px 0; }
.event__facts-wrap { position: relative; }
.event__facts-wrap .event__facts { padding-right: 48px; }
.menu { position: absolute; top: 2px; right: 2px; z-index: 2; }
/* Above the sticky header too; the scrim swallows the tap that closes it, so it never opens the card below. */
.menu[open] { z-index: 20; }
.menu[open]::before { content: ""; position: fixed; inset: 0; background: var(--scrim); }
.menu__toggle {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 10px; color: var(--muted); cursor: pointer; list-style: none;
}
.menu__toggle::-webkit-details-marker { display: none; }
.menu__toggle:hover, .menu[open] .menu__toggle { color: var(--text); }
.menu__list {
  position: absolute; top: 100%; right: 0; width: max-content; max-width: min(280px, calc(100vw - 48px)); margin: 4px 0 0; padding: 6px 0;
  list-style: none; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-4); box-shadow: 0 8px 28px rgb(0 0 0 / 30%);
}
.menu__item {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 10px 16px; line-height: 1.3;
  border: 0; background: none; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.menu__item:hover { background: var(--surface-2); }
.menu__item[hidden] { display: none; }
.event__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.button {
  padding: 10px 16px; border: 1px solid transparent; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); text-decoration: none;
  font: inherit; font-weight: 600; cursor: pointer;
}
.button--ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.event__description { overflow-wrap: anywhere; }

.empty, .sync { color: var(--muted); }
.sync { font-size: .8rem; margin: 24px 0 0; }
.site-footer { padding: 24px 16px 40px; font-size: .8rem; color: var(--muted); }
.site-footer p { margin: 0; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 0 16px; margin-top: 4px; }
.site-footer__links a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; }

.page { padding: var(--content-top) 0 40px; max-width: 65ch; font-size: 1.0625rem; }
.page h1 { font-size: 2rem; line-height: 1.15; font-weight: 800; margin: 0 0 12px; }
.page > h1 + p:not(.updated) { font-size: 1.2rem; line-height: 1.5; }
/* A rule above each section: long prose reads as separate blocks at a glance. */
.page h2 {
  font-size: 1.25rem; line-height: 1.3; font-weight: 800;
  margin: 36px 0 10px; padding-top: 24px; border-top: 1px solid var(--line);
}
.page p, .page li { line-height: 1.65; }
.page p { margin: 0 0 14px; }
.page ul { padding-left: 1.25rem; margin: 0 0 14px; }
.page li + li { margin-top: 10px; }
.page .updated { color: var(--muted); font-size: .875rem; margin-bottom: 0; }

/* Keyboard focus: a clear ring everywhere, light on the clay header. */
:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.site-header :focus-visible { outline-color: var(--on-accent); }
main:focus { outline: none; }

.skip-link {
  position: absolute; top: -100px; left: 16px; z-index: 20;
  padding: 10px 14px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Forced colours (Windows high contrast etc.) drop backgrounds: keep states visible. */
@media (forced-colors: active) {
  .pill.is-active { outline: 2px solid CanvasText; outline-offset: 2px; }
  .card--now { border: 2px solid CanvasText; }
  .chip, .support-link { border: 1px solid CanvasText; }
}

/* Wide screens: a real desktop layout instead of the phone column stretched. */
@media (min-width: 1024px) {
  :root { --filters-width: 340px; --filters-gap: 40px; }
  .container { max-width: 1180px; }
  /* Header content lines up with the page container below it. */
  .site-header { padding-inline: max(16px, calc((100% - 1180px) / 2 + 16px)); }

  .list-layout { display: grid; grid-template-columns: var(--filters-width) minmax(0, 1fr); gap: var(--filters-gap); align-items: start; }
  /* On the list, the footer lines up with the events column, not the filters.
     (No :has() in older browsers: the footer just stays full width there.) */
  body:has(.list-layout) .site-footer { padding-left: calc(16px + var(--filters-width) + var(--filters-gap)); }
  /* Sticky 30px below the 54px header even unscrolled: the text pages start that much lower to match. */
  .list-layout__filters { position: sticky; top: 84px; padding-bottom: 24px; }
  .page { padding-top: calc(var(--content-top) + 30px); }
  .list-layout__filters .headline__when { display: block; }
  .pills--kinds { flex-wrap: wrap; overflow-x: visible; }
  .pills--kinds, .filters { margin-inline: 0; padding-inline: 0; }
  /* The first day heading lines up with the headline, which the sticky column holds 30px down. */
  .list-layout__results { padding-top: 30px; }
  .list-layout__results > .day:first-child h2 { margin-top: var(--content-top); }
  .day__cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
  /* Cards in a row share one height; an open series takes a row of its own. */
  /* Not the summary of an open series: stretched, it pushed the session list over the next row. */
  .day__cards .card-wrap, .day__cards .card-wrap > .card,
  .day__cards .series:not([open]), .day__cards .series:not([open]) > summary { height: 100%; }
  .day__cards .card, .day__cards .series { margin-bottom: 0; }
  .day__cards .series[open] { grid-column: 1 / -1; }

  /* The photo takes the summary's height rather than setting it, so a wide photo
     leaves no gap below. Shown whole (posters carry the details), on the media surface. */
  .event__top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
  .event__media { position: relative; min-height: 320px; margin-bottom: 0; }
  .event__zoom, .event__media > .event__img { position: absolute; inset: 0; }
  .event__media .event__img { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; object-fit: contain; }
  .event__actions, .event__facts-wrap:last-child .event__facts { margin-bottom: 0; }
  .event__description { max-width: 70ch; margin-top: 24px; }

}

