/*
 * Out in Simcoe — community events across Simcoe County.
 *
 * The layout came from Civi-Times, but the two sites are not doing the same job: one is a
 * civic record, this one is an invitation. So the bones are shared and the surface is not
 * — warmer paper, a wonky display face, a colour per category and a bunting stripe under
 * the masthead. Every rule here is cosmetic; the markup and the script are Civi-Times'.
 */

/* ---- display face ----
   Fraunces (SIL OFL, see fonts/OFL.txt), self-hosted so the site has no third-party
   request and `npm test` keeps working with no network at all. Variable on four axes:
   SOFT and WONK are what make it playful rather than newspaper-serious. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url(/fonts/fraunces-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url(/fonts/fraunces-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;
  --bg: #fdf7ed;
  --surface: #fffdf8;
  --surface-2: #f5ecdd;
  --ink: #231c13;
  --ink-2: #5d5245;
  --ink-3: #918675;
  --line: #e8dcc8;
  /* --accent fills; --accent-deep is the same hue at text contrast on paper. */
  --accent: #e05a17;
  --accent-deep: #a63f09;
  --accent-ink: #fffaf4;
  --sun: #f4b23c;
  --sun-ink: #6b4708;
  --hl: color-mix(in srgb, var(--sun) 55%, transparent);
  --rel-bg: color-mix(in srgb, var(--sun) 38%, var(--surface));
  --rel-ink: #6b4708;
  --warn: #8a4b12;
  --warn-bg: #fbf1e6;
  --stop: #a3282d;
  --stop-bg: #fbeae9;
  --speak: #1c4f7a;
  --speak-bg: #eaf2f9;
  --free: #2c7a4b;
  --free-bg: #e7f5eb;

  /* One colour per category. Carried by a dot and a stripe, never by body text, so the
     palette can be cheerful without any of it having to pass a contrast check. */
  --cat-arts: #7c3aed;
  --cat-music: #d6336c;
  --cat-family: #e8590c;
  --cat-outdoors: #2f9e44;
  --cat-markets: #dc8a00;
  --cat-sports: #1971c2;
  --cat-community: #0f7b8a;
  --cat-education: #5f3dc4;
  --cat-civic: #6b7280;
  --cat-other: #96825f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(60, 40, 16, .06), 0 6px 20px rgba(60, 40, 16, .07);
  --shadow-lift: 0 2px 4px rgba(60, 40, 16, .08), 0 12px 28px rgba(60, 40, 16, .12);
}

/*
 * Dark, written twice on purpose.
 *
 * The first block is the system preference, which must not win once the reader has
 * explicitly chosen light. The second is that explicit choice, which must win over a
 * light system. There is no way to share one declaration block between the two
 * selectors, so the tokens are repeated; change one, change both.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #14110f;
  --surface: #1e1a17;
  --surface-2: #2a2521;
  --ink: #f4ece1;
  --ink-2: #b9ac9c;
  --ink-3: #887d70;
  --line: #352e28;
  --accent: #ff8a4c;
  --accent-deep: #ffb083;
  --accent-ink: #2c1205;
  --sun: #f6c465;
  --sun-ink: #2c1e05;
  --hl: color-mix(in srgb, var(--accent) 22%, transparent);
  --rel-bg: color-mix(in srgb, var(--sun) 15%, var(--surface));
  --rel-ink: var(--sun);
  --warn: #e0a86a;
  --warn-bg: #2c2318;
  --stop: #f08b86;
  --stop-bg: #2e1a1a;
  --speak: #8ab8e0;
  --speak-bg: #17222e;
  --free: #7fd39b;
  --free-bg: #16281d;

  --cat-arts: #b69cff;
  --cat-music: #ff8fb1;
  --cat-family: #ffa86b;
  --cat-outdoors: #78d98c;
  --cat-markets: #f3c05a;
  --cat-sports: #7ab8ef;
  --cat-community: #6fc9d6;
  --cat-education: #a99aff;
  --cat-civic: #a6adb8;
  --cat-other: #c4b191;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .45), 0 12px 28px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --bg: #14110f;
  --surface: #1e1a17;
  --surface-2: #2a2521;
  --ink: #f4ece1;
  --ink-2: #b9ac9c;
  --ink-3: #887d70;
  --line: #352e28;
  --accent: #ff8a4c;
  --accent-deep: #ffb083;
  --accent-ink: #2c1205;
  --sun: #f6c465;
  --sun-ink: #2c1e05;
  --hl: color-mix(in srgb, var(--accent) 22%, transparent);
  --rel-bg: color-mix(in srgb, var(--sun) 15%, var(--surface));
  --rel-ink: var(--sun);
  --warn: #e0a86a;
  --warn-bg: #2c2318;
  --stop: #f08b86;
  --stop-bg: #2e1a1a;
  --speak: #8ab8e0;
  --speak-bg: #17222e;
  --free: #7fd39b;
  --free-bg: #16281d;

  --cat-arts: #b69cff;
  --cat-music: #ff8fb1;
  --cat-family: #ffa86b;
  --cat-outdoors: #78d98c;
  --cat-markets: #f3c05a;
  --cat-sports: #7ab8ef;
  --cat-community: #6fc9d6;
  --cat-education: #a99aff;
  --cat-civic: #a6adb8;
  --cat-other: #c4b191;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .45), 0 12px 28px rgba(0, 0, 0, .4);
}

/* Form controls, scrollbars and the canvas behind the page follow the choice too. */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

/*
 * The `hidden` attribute must always win.
 *
 * The browser's own `[hidden] { display: none }` is a user-agent rule, so ANY author
 * rule setting `display` on the same element defeats it — no extra specificity needed.
 * Several elements here are flex or grid containers that the script shows and hides via
 * `el.hidden`, and without this the attribute silently becomes a no-op: menus render
 * open and cannot be closed, and search cannot hide the rows it filters out.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* The display face, and the two axes that make it wonky. Applied by name so anything
   that wants the voice can opt in; body copy never does. */
.display, .masthead h1, .monthnav h2, .modal-head h2, .day-head h2, .event h3,
.sheet-inner h2, .event-page h1 {
  font-family: 'Fraunces', ui-serif, Georgia, "Times New Roman", serif;
  font-variation-settings: 'SOFT' 100, 'WONK' 1, 'opsz' 48;
  letter-spacing: -.01em;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 72px; }

/* ---- masthead ---- */
.masthead { position: relative; margin-bottom: 22px; padding: 34px 0 20px; }
/* Bunting: the category palette, in the order the filter menu lists it. A rainbow rule
   instead of a black one is most of the difference in tone between the two sites. */
.masthead::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--cat-arts) 0 10%, var(--cat-music) 10% 22%, var(--cat-family) 22% 36%,
    var(--cat-outdoors) 36% 50%, var(--cat-markets) 50% 63%, var(--cat-sports) 63% 76%,
    var(--cat-community) 76% 88%, var(--cat-education) 88% 100%);
}
.masthead-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.wordmark { display: flex; align-items: center; gap: 16px; min-width: 0; }
/* The mark tracks the wordmark's own clamp so the lockup holds at every width.
   The field takes the ink colour and the sun the accent, so it themes itself. */
.mark {
  width: clamp(34px, 4.8vw, 50px); height: auto; flex: none; color: var(--ink);
  transform-origin: 50% 62%;
}
.masthead h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(31px, 6.2vw, 50px);
  line-height: 1.02;
  font-variation-settings: 'SOFT' 100, 'WONK' 1, 'opsz' 144;
}
/* A marker stroke under the last word, sitting behind the text. */
.masthead h1 .hl {
  color: var(--accent-deep);
  background: linear-gradient(transparent 62%, var(--hl) 62% 92%, transparent 92%);
}
.masthead .tagline { margin: 10px 0 0; color: var(--ink-2); font-size: 15.5px; max-width: 64ch; }
.masthead .stats {
  margin: 14px 0 0; color: var(--ink-2); font-size: 13px;
  display: inline-block; background: var(--surface-2);
  border-radius: 999px; padding: 4px 13px;
}

/* ---- filters ---- */
.filters {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  margin-bottom: 20px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.field { position: relative; }
.field > button {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 6%, transparent);
}
.field > button:hover { border-color: var(--accent); color: var(--accent-deep); }
.field > button[aria-expanded="true"] { border-color: var(--accent); }
.field .count {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700;
  min-width: 18px; text-align: center;
}
.field .count[hidden] { display: none; }
.chev { color: var(--ink-3); font-size: 11px; }

.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  min-width: 282px; max-width: min(360px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lift); padding: 6px;
  /* The search box and bulk actions stay put while only the list scrolls. */
  display: flex; flex-direction: column; max-height: min(420px, 70vh);
}
.menu-search { padding: 2px 2px 6px; flex: none; }
.menu-search input {
  width: 100%; box-sizing: border-box;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font: inherit; font-size: 14px;
}
.menu-search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.menu-search input::placeholder { color: var(--ink-3); }
/* Safari draws its own clear button that clashes with the field styling. */
.menu-search input::-webkit-search-cancel-button { appearance: none; }

.menu-options { overflow-y: auto; flex: 1 1 auto; }

.menu-group {
  padding: 9px 9px 5px; margin-top: 4px;
  border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 11.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
/* No rule above the first section — it would sit directly under the toolbar. */
.menu-options > .menu-group:first-child { border-top: none; margin-top: 0; padding-top: 4px; }

.menu-empty { margin: 0; padding: 16px 9px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.menu label {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
}
.menu label:hover { background: var(--surface-2); }
.menu label input { accent-color: var(--accent); flex: none; }
.menu .tally { margin-left: auto; color: var(--ink-3); font-size: 12px; padding-left: 8px; }
.menu .opt-label { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.menu .opt-note { color: var(--ink-3); font-size: 11.5px; }
.menu .menu-head {
  display: flex; gap: 12px; padding: 2px 9px 8px;
  border-bottom: 1px solid var(--line); margin-bottom: 4px; flex: none;
}
.menu .menu-head button {
  background: none; border: none; color: var(--accent-deep);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;
}

.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.toggle input { accent-color: var(--accent); }

/* The view switch and the two buttons travel together: pushed right when the row has
   room, wrapping as one group rather than stranding a button on its own line. */
.row-end { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff) 0%, var(--accent) 100%);
  color: var(--accent-ink);
  border: 1px solid transparent; border-radius: 999px;
  padding: 8px 17px; font: inherit; font-size: 14px; font-weight: 700;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 60%, #000);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.ghost {
  background: var(--surface); color: var(--ink); border-color: var(--line);
  font-weight: 600; box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 6%, transparent);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-deep); filter: none; }

.active-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--sun) 20%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--sun) 45%, var(--line));
  border-radius: 999px; padding: 4px 8px 4px 11px; font-size: 13px; color: var(--ink);
}
.pill button { background: none; border: none; color: var(--ink-2); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.pill button:hover { color: var(--stop); }
.pill.clear-all {
  cursor: pointer; padding: 4px 11px; font: inherit; font-size: 13px;
  background: var(--surface-2); border-color: var(--line); color: var(--ink-2);
}
.pill.clear-all:hover { border-color: var(--ink-3); color: var(--ink); }

/* ---- view switch ---- */
.viewswitch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.viewswitch button {
  background: none; border: none; border-radius: 999px;
  padding: 6px 15px; font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer;
}
.viewswitch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }

/* ---- theme switch ---- */
.themeswitch { flex: none; margin-top: 5px; display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.themeswitch button {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 999px;
  padding: 5px 11px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.themeswitch button svg { width: 15px; height: 15px; display: block; }
.themeswitch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.themeswitch button:hover { color: var(--ink); }

/* ---- date range menu ---- */
.menu-dates { min-width: 268px; padding: 10px; gap: 12px; }
.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.date-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.date-row input {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 7px 9px; font: inherit; font-size: 13.5px; width: 100%;
}
.date-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.date-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.date-presets button {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.date-presets button:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ---- month navigation ---- */
.monthnav { display: flex; align-items: center; gap: 6px; margin: 0 0 16px; }
.monthnav h2 { margin: 0 4px; min-width: 12ch; font-weight: 800; font-size: 22px; line-height: 1.2; }
.monthnav button {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 50%; width: 34px; height: 34px; font: inherit; font-size: 19px;
  line-height: 1; cursor: pointer; flex: none;
}
.monthnav button:hover { border-color: var(--accent); color: var(--accent-deep); }
.monthnav .today-btn { width: auto; padding: 0 14px; font-size: 13.5px; border-radius: 999px; }
.monthnav .month-count { margin-left: auto; color: var(--ink-3); font-size: 13px; }

/* ---- calendar grid ---- */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.cal-weekday {
  background: var(--surface-2); color: var(--ink-3);
  padding: 7px 6px; text-align: center;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.cal-weekday abbr { text-decoration: none; border: none; }

.cal-day {
  background: var(--surface); border: none; margin: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  min-height: 108px; padding: 6px; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
}
.cal-day:hover { background: var(--surface-2); }
.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day[aria-disabled="true"] { cursor: default; }
.cal-day[aria-disabled="true"]:hover { background: inherit; }
/* The weekend reads as the weekend at a glance, which is when most of this happens. */
.cal-day.is-weekend { background: color-mix(in srgb, var(--sun) 7%, var(--surface)); }
.cal-day.is-outside { background: var(--bg); }
.cal-day.is-outside .cal-daynum { color: var(--ink-3); opacity: .7; }
.cal-day.is-selected { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }

.cal-daynum { font-size: 12.5px; font-weight: 700; color: var(--ink-2); flex: none; }
.cal-day.is-today .cal-daynum {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; width: 23px; height: 23px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sun) 45%, transparent);
}

.cal-chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chip {
  display: flex; gap: 4px; align-items: baseline; min-width: 0;
  background: color-mix(in srgb, var(--cat, var(--cat-other)) 12%, var(--surface));
  border-left: 3px solid var(--cat, var(--cat-other));
  border-radius: 4px; padding: 2px 4px; font-size: 11.5px; line-height: 1.3;
}
.chip-time { color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }
.chip-place { font-weight: 700; flex: none; max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.is-cancelled { border-left-color: var(--stop); opacity: .65; }
.chip.is-cancelled .chip-title { text-decoration: line-through; }
.chip-more { color: var(--ink-3); font-size: 11px; padding-left: 4px; }

/* Dots replace chips where a cell is too narrow for text — see the media query below. */
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; }
.cal-dots .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cat, var(--cat-other)); }
.cal-dots .dot.is-cancelled { background: var(--stop); }

.cal-empty { text-align: center; color: var(--ink-2); padding: 22px 12px; margin: 0; }
.linkish {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--accent-deep); text-decoration: underline; cursor: pointer; font-weight: 600;
}

/* ---- day modal ----
   A <dialog> is display:none until [open], so the display rule is scoped to [open].
   Setting display on the bare class would defeat the closed state entirely. */
.modal {
  padding: 0; border: none; background: none;
  max-width: none; max-height: none; width: 100%; height: 100%;
  overflow: hidden;
}
.modal[open] { display: flex; align-items: center; justify-content: center; }
.modal::backdrop { background: rgba(30, 18, 6, .55); backdrop-filter: blur(2px); }

.modal-inner {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lift);
  width: min(560px, calc(100vw - 32px)); max-height: min(76vh, 720px);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.modal-head h2 { margin: 0; flex: 1 1 auto; font-weight: 800; font-size: 20px; line-height: 1.25; }
.modal-close {
  background: none; border: none; color: var(--ink-3); cursor: pointer;
  font-size: 26px; line-height: 1; padding: 0 4px; flex: none; border-radius: 6px;
}
.modal-close:hover { color: var(--ink); }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.modal-body { padding: 16px 20px 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-body .event { box-shadow: none; }
.modal-body .event:last-child { margin-bottom: 0; }
.modal-body .cal-empty { padding: 12px 0; }

/* ---- share dialog ---- */
.share-modal .modal-inner { width: min(460px, calc(100vw - 32px)); }
.share-what {
  margin: 0 0 14px; font-size: 15px; font-weight: 700; line-height: 1.35; color: var(--ink);
}
.share-link { display: flex; gap: 8px; }
.share-link input {
  flex: 1 1 auto; min-width: 0;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font: inherit; font-size: 13.5px;
}
.share-link input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.share-link .btn { flex: none; }
.share-status { margin: 9px 0 0; min-height: 18px; font-size: 13px; color: var(--accent-deep); }

.share-targets {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px;
  margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--line);
}
.share-target {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; font-size: 13px; background: var(--surface);
}
.share-target:hover { border-color: var(--accent); color: var(--ink); }
.share-target:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-target svg { width: 22px; height: 22px; }

/* The page behind a modal must not scroll under it. */
body.modal-open { overflow: hidden; }

/* ---- day groups ---- */
.day { margin-bottom: 28px; }
.day-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 12px; padding-bottom: 7px;
  border-bottom: 2px dotted var(--line);
}
.day-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
/* "today", "tomorrow", "in 3 days" — small enough to ignore, bright enough to catch. */
.day-head .rel {
  background: var(--rel-bg);
  color: var(--rel-ink);
  border-radius: 999px; padding: 2px 10px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}

/* ---- event cards ---- */
.event {
  display: grid; grid-template-columns: 92px 1fr; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line); border-left: 5px solid var(--cat, var(--cat-other));
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.event:hover { box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--cat, var(--cat-other)) 50%, var(--line)); border-left-color: var(--cat, var(--cat-other)); }
.event .time {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; color: var(--ink);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 7px 4px; text-align: center; align-self: start;
}
.event .time .tbd { display: block; font-weight: 600; font-size: 11.5px; color: var(--ink-3); }
.event h3 { margin: 0 0 5px; font-size: 18px; font-weight: 700; line-height: 1.28; }
.event h3 a { text-decoration: none; }
.event h3 a:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }
.event .meta { color: var(--ink-2); font-size: 13.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.event .meta .jur { font-weight: 700; color: var(--ink); }
/* The category, as a dot in its own colour and a label in ordinary ink. */
.event .meta .cat { display: inline-flex; align-items: center; gap: 6px; }
.cat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cat, var(--cat-other)); flex: none; }
.event .docs { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.event .docs a {
  font-size: 12.5px; text-decoration: none; color: var(--accent-deep);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}
.event .docs a:hover { border-color: var(--accent); }
.event.is-cancelled { opacity: .72; }
.event.is-cancelled h3 { text-decoration: line-through; text-decoration-thickness: 1.5px; }

.tag { border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.tag.cancelled { background: var(--stop-bg); color: var(--stop); }
.tag.moved { background: var(--warn-bg); color: var(--warn); }
.tag.speak { background: var(--speak-bg); color: var(--speak); }
.tag.package { background: var(--surface-2); color: var(--ink-3); }
.tag.free { background: var(--free-bg); color: var(--free); }
.tag.paid { background: var(--surface-2); color: var(--ink-2); }

.more {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 26px 20px 8px; border-top: 1px solid var(--line); margin-top: 18px;
}
.more .btn { padding: 9px 22px; }
.more-count { margin: 0; color: var(--ink-3); font-size: 13px; }

.empty { text-align: center; padding: 64px 20px; color: var(--ink-2); }
.empty p { margin: 0 0 14px; }
.loading { text-align: center; padding: 64px 20px; color: var(--ink-3); }

.sheet {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(30, 18, 6, .5); padding: 20px;
}
.sheet[hidden] { display: none; }
.sheet-inner {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lift);
  padding: 26px; max-width: 520px; width: 100%;
}
.sheet-inner h2 { margin: 0 0 8px; font-size: 21px; font-weight: 800; }
.sheet-inner p { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }
.sheet-inner code {
  display: block; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px; font-size: 12.5px; word-break: break-all; margin-bottom: 14px;
}
.sheet-actions { display: flex; gap: 9px; flex-wrap: wrap; }

footer { margin-top: 44px; padding-top: 18px; border-top: 2px dotted var(--line); color: var(--ink-3); font-size: 13px; }
footer a { color: var(--ink-2); }
.support { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
/* width/height attributes are on the img so the footer does not jump while it loads. */
.support .bmc { display: inline-flex; line-height: 0; border-radius: 8px; }
.support .bmc:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---- single event page ---- */
.event-page { padding: 0 20px 60px; }
.event-page .topbar { max-width: 680px; margin: 0 auto; padding: 22px 0; }
.event-page .home {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink-2); text-decoration: none; font-size: 14px;
}
.event-page .home:hover { color: var(--ink); }
.event-page .home .mark { width: 26px; color: var(--ink); }
.event-page .card {
  max-width: 680px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--line); border-top: 5px solid var(--cat, var(--accent));
  border-radius: var(--radius);
  padding: 30px; box-shadow: var(--shadow);
}
.event-page .eyebrow { margin: 0 0 6px; color: var(--ink-2); font-size: 13.5px; font-weight: 700; }
.event-page h1 { margin: 0 0 10px; font-weight: 800; font-size: 30px; line-height: 1.18; }
.event-page .when { margin: 0 0 3px; font-size: 17px; font-weight: 700; }
.event-page .where { margin: 0 0 16px; color: var(--ink-2); }
.event-page .notice { border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px; margin: 0 0 11px; }
.event-page .notice.cancelled { background: var(--stop-bg); color: var(--stop); font-weight: 700; }
.event-page .notice.moved { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.event-page .notice.speak { background: var(--speak-bg); color: var(--speak); }
.event-page .actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 18px 0 0; }
.event-page .subscribe { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }
.event-page .cost { margin: 4px 0 0; font-weight: 700; }
.event-page .cost.free { color: var(--free); }
.event-page .cost.unknown { color: var(--ink-3); font-weight: 400; }
.event-page .hero { display: block; max-width: 100%; border-radius: var(--radius); margin: 18px 0; }
.event-page .description { margin: 18px 0; line-height: 1.6; color: var(--ink-2); }
.event-page .organizer { color: var(--ink-3); }
.event-page .listed { margin-top: 20px; font-size: 13px; color: var(--ink-3); }

.event .meta .also { color: var(--ink-3); font-style: italic; }
.select-toggle select {
  margin-left: 6px; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit;
}

/* ---- the category palette, bound to the data attribute the script writes ---- */
[data-cat="arts"] { --cat: var(--cat-arts); }
[data-cat="music"] { --cat: var(--cat-music); }
[data-cat="family"] { --cat: var(--cat-family); }
[data-cat="outdoors"] { --cat: var(--cat-outdoors); }
[data-cat="markets"] { --cat: var(--cat-markets); }
[data-cat="sports"] { --cat: var(--cat-sports); }
[data-cat="community"] { --cat: var(--cat-community); }
[data-cat="education"] { --cat: var(--cat-education); }
[data-cat="civic-meeting"] { --cat: var(--cat-civic); }
[data-cat="other"] { --cat: var(--cat-other); }

/* ---- motion, for those who want it ---- */
@media (prefers-reduced-motion: no-preference) {
  .mark { transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); }
  .wordmark:hover .mark { transform: rotate(-9deg) scale(1.06); }
  .event, .field > button, .btn, .cal-day { transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease, background .18s ease; }
  .event:hover { transform: translateY(-2px); }
  .btn:active { transition: none; }
}

@media (max-width: 760px) {
  /* Chips cannot be read in a cell this narrow, so show dots and let tapping a day
     open the full list underneath the grid. */
  .cal-day { min-height: 62px; padding: 5px 3px; align-items: center; gap: 3px; }
  .cal-chips { display: none; }
  .cal-dots { display: flex; justify-content: center; }
  .cal-daynum { font-size: 12px; }
  .monthnav h2 { font-size: 18px; min-width: 0; }
  .monthnav .month-count { display: none; }
}

@media (max-width: 620px) {
  .wordmark { gap: 11px; }
  /* Reversed so the switch reads above the title instead of crowding it. */
  .masthead-top { flex-direction: column-reverse; align-items: stretch; gap: 12px; }
  .masthead-top .themeswitch { align-self: flex-end; margin-top: 0; }
  .masthead { padding-top: 26px; }
  .menu { position: fixed; left: 12px; right: 12px; top: auto; min-width: 0; max-width: none; }
  .modal[open] { align-items: flex-end; }
  .modal-inner {
    width: 100%; max-height: 82vh;
    border-radius: 18px 18px 0 0; border-bottom: none;
  }

  /* Narrow enough that the group has the row to itself and may break inside it. */
  .row-end { flex-wrap: wrap; margin-left: 0; }
  .event { grid-template-columns: 70px 1fr; gap: 12px; padding: 12px 13px; }
  .event .time { font-size: 14px; padding: 6px 3px; }
  .event h3 { font-size: 16.5px; }
  .filters { padding: 10px 0; }
  .event-page .card { padding: 22px 18px; }
}

/* An outbound link says so: the listing lives on the source's own site. */
.ext { font-size: .85em; opacity: .8; }
