/* "Field guide" look, from the Amesbury Event Calendar Figma file, pared back: no banners or rules,
   soft fills instead of borders, spacing to separate things. 1rem = the design's 15px body text,
   nothing smaller than .8rem, and the Text size buttons scale everything. Light only. */
:root {
  /* City of Amesbury brand colors, plus the school's red */
  --navy: #092745;      /* city navy */
  --blue: #1d8bcb;      /* city sky blue */
  --gold: #faa61a;      /* city sun gold */
  --green: #1aa565;     /* city green */
  --orange: #e75925;    /* city orange */
  --red: #fe0002;       /* Amesbury mascot red (text uses a darker mix of it) */
  /* text-safe shades of the accents (4.5:1 or better on cream) */
  --orange-text: #b23f14;
  --green-text: #0f6b42;
  --blue-text: #0b5e95;
  /* neutrals */
  --ink: #0e2236;
  --cream: #f8f6f0;
  --paper: #ffffff;
  --sand: #ebeef1;
  --sand-2: #dde3e9;
  --muted: #4d5966;
  --display: "Oswald", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --banner-h: 2.6rem;   /* the sticky feedback banner; other sticky things sit below it */
  color-scheme: light;
}
html { font-size: 18px; scroll-padding-top: calc(var(--banner-h) + 12px); }
html[data-size="2"] { font-size: 20px; }
html[data-size="3"] { font-size: 23px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 1rem/1.55 var(--body); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
a { color: var(--navy); }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--navy); padding: 8px 14px; border-radius: 6px; z-index: 20; font-weight: 700; }
.skip:focus { left: 16px; }

/* ---------- Feedback banner, stuck to the top ---------- */
.feedback-banner {
  position: sticky; top: 0; z-index: 8; min-height: var(--banner-h); display: flex; align-items: center; justify-content: center;
  padding: 6px 16px; background: var(--navy); color: #fff; text-align: center; font-size: .85rem;
}
.feedback-banner p { margin: 0; }
.feedback-banner a {
  display: inline-block; margin-left: .5rem; padding: 3px 12px; border-radius: 6px;
  background: var(--gold); color: var(--navy); font-weight: 700; text-decoration: none;
}
.feedback-banner a:hover { background: #ffbe4d; }
.feedback-banner a:focus-visible { outline-color: #fff; }
@media (max-width: 600px) { .feedback-banner .lead { display: none; } .feedback-banner a { margin-left: 0; } }

.dot { display: inline-block; width: .75rem; height: .75rem; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Top: logo, then navigation, views and text size ---------- */
.page { max-width: 1400px; margin: 0 auto; padding: 1rem clamp(16px, 4vw, 64px) 2rem; }
.masthead { display: flex; align-items: center; gap: 1rem 2rem; margin-bottom: 1rem; }
.logo { flex: none; display: block; border-radius: 8px; }
.logo img { display: block; height: 6.6rem; width: auto; }
.toolbar { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-group button { min-height: 46px; min-width: 46px; padding: 6px 16px; border-radius: 6px; font-weight: 600; background: var(--sand); color: var(--navy); }
.nav-group button:hover { background: var(--sand-2); }
#prev, #next { font-size: 1.5rem; line-height: 1; padding: 2px 12px; }
#today { background: var(--navy); color: #fff; }
.nav-group h1 { margin: 0 0 0 10px; font: 400 1.6rem/1.2 var(--display); color: var(--navy); text-transform: uppercase; }
.view-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.views, .text-size { display: flex; gap: 2px; padding: 3px; background: var(--sand); border-radius: 8px; }
.views button, .text-size button { min-height: 44px; border-radius: 6px; background: transparent; color: var(--navy); font-weight: 600; }
.views button { padding: 6px 14px; font-size: .9rem; }
.text-size button { min-width: 44px; font-weight: 700; }
.views button:hover, .text-size button:hover { background: var(--sand-2); }
.views button.active { background: var(--navy); color: #fff; }
.text-size button[aria-pressed="true"] { background: var(--gold); color: var(--navy); }

/* ---------- Search + filters ---------- */
.filters { margin-bottom: 1.6rem; }
.search {
  display: flex; align-items: center; gap: 10px; max-width: 24rem; min-height: 46px; padding: 0 14px; margin-bottom: 10px;
  background: var(--sand); border-radius: 6px; color: var(--muted);
}
.search:focus-within { outline: 3px solid var(--orange-text); outline-offset: 2px; background: var(--paper); }
.search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: .95rem; color: var(--ink); padding: 10px 0; }
.search input:focus { outline: none; }
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-list { display: contents; }
.filter {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px;
  border-radius: 6px; font-size: .85rem; font-weight: 600; color: var(--navy); background: var(--sand);
}
.filter .dot { width: .7rem; height: .7rem; }
.filter:hover { background: var(--sand-2); }
.filter[aria-pressed="true"] { background: var(--gold); }
.free-only { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px; font-size: .85rem; font-weight: 600; color: var(--navy); cursor: pointer; }
.free-only input { width: 1.15rem; height: 1.15rem; accent-color: var(--navy); }
.filter-clear { min-height: 40px; padding: 4px 10px; border-radius: 6px; background: none; color: var(--orange-text); font-size: .85rem; font-weight: 700; text-decoration: underline; }
.filter-status { margin: 8px 0 0; font-size: .9rem; font-weight: 600; color: var(--orange-text); }
.filter-status:empty { display: none; }
.unused { display: none !important; } /* hooks app.js expects that this page doesn't show */

/* ---------- Layout: events + month ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 2.4rem; align-items: start; }
#cal:focus { outline: none; }
.side { position: sticky; top: calc(var(--banner-h) + 16px); }

/* ---------- Day list: date stamp beside each day's events ---------- */
.day-view { padding-bottom: 96px; }
.agenda-day { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 0 1.2rem; }
.agenda-day + .agenda-day { margin-top: 1.8rem; }
.agenda-day h3 { margin: 0; position: sticky; top: calc(var(--banner-h) + 12px); align-self: start; display: flex; flex-direction: column; gap: 4px; }
.agenda-day h3:focus { outline: none; }
.agenda-day h3:focus-visible { outline: 3px solid var(--orange-text); outline-offset: 4px; }
.stamp { display: flex; flex-direction: column; line-height: 1.1; }
.stamp-mon { color: var(--orange-text); font-size: .8rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.stamp-day { font: 400 2.4rem/1.1 var(--display); color: var(--navy); }
.stamp-dow { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; }
.day-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } /* read aloud, not shown */
.agenda-day h3 .badge { display: none; }
.agenda-day:has(.badge) .stamp-day { background: var(--gold); border-radius: 4px; padding: 0 6px; align-self: flex-start; }
.agenda-day h3 .muted { display: none; }

.list { display: flex; flex-direction: column; gap: 4px; }
.ev { border-radius: 8px; }
.ev[open] { background: var(--paper); }
/* label (+ Free) / title / time · place, with the chevron on the right */
.ev summary {
  list-style: none; cursor: pointer; padding: .55rem 2.6rem .55rem .8rem; border-radius: 8px; position: relative;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
}
.ev summary:hover { background: var(--paper); }
.ev summary::-webkit-details-marker { display: none; }
.ev summary::after { content: "\203A"; position: absolute; right: .9rem; top: 50%; translate: 0 -50%; font-size: 1.8rem; line-height: 1; color: var(--muted); transition: rotate .15s; }
.ev[open] summary::after { rotate: 90deg; }
.ev .cat {
  order: 1; display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 3px; font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  background: color-mix(in srgb, var(--c) 14%, var(--cream)); color: color-mix(in srgb, var(--c) 55%, #000); /* 4.5:1+ for every filter color */
}
.ev .cat .dot { display: none; }
.ev .flag { order: 2; font-size: .85rem; color: var(--green-text); font-weight: 600; }
.ev .title { order: 3; flex: 1 0 100%; font: 500 1.35rem/1.2 var(--display); color: var(--navy); }
.ev .when { order: 4; font-weight: 600; white-space: nowrap; }
.ev .where { order: 5; min-width: 0; color: var(--muted); }
.ev .where::before { content: "\00b7"; margin-right: 10px; }
.ev .body { padding: 0 .8rem 1rem; }
.ev .body p { margin: .6rem 0 0; white-space: pre-line; }
.ev .meta { color: var(--muted); font-size: .9rem; }
.ev .tags { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal !important; }
.ev .tags span { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; padding: 2px 8px; border-radius: 3px; background: var(--sand); color: var(--navy); }
.ev .links { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; margin-top: .8rem; }
.ev .links a, .ev .links button { min-height: 44px; display: inline-flex; align-items: center; padding: 0; background: none; color: var(--navy); font-size: .9rem; font-weight: 600; }
.ev .links a:first-child { padding: 0 16px; border-radius: 6px; background: var(--navy); color: #fff; text-decoration: none; }
.ev.city { background: color-mix(in srgb, var(--red) 7%, var(--cream)); box-shadow: inset 4px 0 0 var(--red); }
.empty { margin: 0; padding: .55rem .8rem; color: var(--muted); }

.next-day {
  display: flex; align-items: baseline; gap: 10px; width: 100%; margin-top: 1.8rem; padding: 14px 18px; min-height: 56px;
  border-radius: 8px; background: var(--sand); color: var(--navy); font: 500 1.15rem/1.2 var(--display); text-transform: uppercase; text-align: left;
}
.next-day::before { content: "+"; }
.next-day .muted { margin-left: auto; font: 600 .85rem var(--body); text-transform: none; }
.next-day:hover { background: var(--sand-2); }

/* ---------- Week / weekend ---------- */
.cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; }
.col { background: var(--sand); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.col.today { box-shadow: inset 0 0 0 3px var(--gold); }
.col.alert { box-shadow: inset 0 4px 0 var(--red); }
.col.today.alert { box-shadow: inset 0 4px 0 var(--red), inset 0 0 0 3px var(--gold); }
.col-head { background: none; padding: 10px 10px 4px; text-align: left; color: var(--navy); }
.col-head span { display: block; font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--orange-text); }
.col-head b { font: 400 1.5rem/1.1 var(--display); }
.chips { display: flex; flex-direction: column; gap: 4px; padding: 6px; }
.chip {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  width: 100%; text-align: left; border-left: 5px solid var(--c); border-radius: 3px;
  background: var(--paper); padding: 6px 8px; font-size: .85rem; line-height: 1.35; color: var(--navy);
}
.chip time { font-weight: 700; }
.more { background: none; color: var(--navy); font-weight: 700; text-align: left; padding: 4px 10px 10px; min-height: 44px; text-decoration: underline; }
.none { margin: 4px; font-size: .85rem; color: var(--muted); }

/* ---------- Month ---------- */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month .dow { padding: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); text-align: center; text-transform: uppercase; }
.cell { background: var(--sand); border-radius: 6px; min-height: 6rem; padding: 8px; text-align: left; display: flex; flex-direction: column; gap: 8px; position: relative; color: var(--navy); }
.cell:hover { background: var(--sand-2); }
.cell.out { background: transparent; color: var(--muted); }
.cell.today { background: var(--gold); }
.cell.alert { box-shadow: inset 0 4px 0 var(--red); }
.num { font-weight: 700; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; }
.dots .dot { width: .9rem; height: .9rem; }
.count { position: absolute; top: 8px; right: 10px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.cell.today .count { color: var(--navy); }
.cell.today .dot { box-shadow: 0 0 0 2px var(--paper); } /* keeps a gold dot visible on the gold "today" square */

/* ---------- Mini month ---------- */
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.mini-head h2 { margin: 0; font: 400 1.35rem/1.2 var(--display); color: var(--navy); text-transform: uppercase; }
.mini-head button { min-width: 40px; min-height: 40px; background: none; color: var(--navy); font-size: 1.5rem; line-height: 1; border-radius: 6px; }
.mini-head button:hover { background: var(--sand); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.mini-dow { font-size: .75rem; color: var(--muted); }
.mini-day { min-height: 2.1rem; border-radius: 4px; background: none; color: var(--muted); font-size: .85rem; padding: 0; }
.mini-day:hover { background: var(--sand); }
.mini-day.has { color: var(--navy); font-weight: 800; }
.mini-day.shown { background: var(--sand); }
.mini-day.today { background: var(--gold); color: var(--navy); }
.mini-note { display: none; }

/* ---------- Fine print ---------- */
.fine-print { margin: 2.4rem 0 0; font-size: .8rem; color: var(--muted); }
.fine-print a { color: var(--muted); }

/* ---------- Floating calendar / list toggle ---------- */
.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 9;
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: var(--gold); box-shadow: 0 6px 20px rgba(20, 46, 69, .3);
}
.fab:focus-visible { outline: 3px solid var(--orange-text); outline-offset: 3px; }

/* ---------- Day panel ---------- */
#scrim { position: fixed; inset: 0; background: rgba(20, 46, 69, .45); z-index: 10; }
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100%); z-index: 11;
  background: var(--cream); box-shadow: -10px 0 30px rgba(20, 46, 69, .2); display: flex; flex-direction: column;
  transform: translateX(105%); transition: transform .2s ease, visibility 0s .2s; visibility: hidden;
}
#panel.open { transform: none; visibility: visible; transition: transform .2s ease; }
#panel > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 18px 20px 8px; }
#panel h2 { margin: 0; font: 400 1.6rem/1.2 var(--display); color: var(--navy); text-transform: uppercase; }
#panel-close { background: var(--sand); color: var(--navy); border-radius: 6px; font-size: 1.8rem; line-height: 1; min-width: 48px; min-height: 48px; }
#panel-list { overflow-y: auto; padding: 4px 12px 24px; flex: 1; }
.summary { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: .85rem; color: var(--muted); }
.summary span { display: flex; align-items: center; gap: 6px; }

/* ---------- Narrower screens ---------- */
@media (max-width: 1000px) {
  .masthead { align-items: flex-start; }
  .logo img { height: 5.8rem; }
  .layout { grid-template-columns: 1fr; }
  .side { display: none; } /* the Month view and floating button cover this */
}
@media (max-width: 760px) {
  .masthead { flex-direction: column; align-items: stretch; gap: .6rem; }
  .logo { align-self: center; }
  .logo img { height: 5rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .view-controls { justify-content: flex-end; }
  .views { flex: 1 1 100%; }
  .views button { flex: 1; }
  .nav-group h1 { font-size: 1.25rem; }
  .views button { flex: 1; padding: 6px 4px; }
  .search { max-width: none; }
  /* filters become one swipeable row so the events start near the top */
  .filter-row {
    flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 8px;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
  .filter, .free-only { flex: none; white-space: nowrap; }
  .agenda-day { grid-template-columns: 3.4rem minmax(0, 1fr); gap: 0 .6rem; }
  .stamp-day { font-size: 1.9rem; }
  .ev summary { padding: .5rem 2.2rem .5rem .6rem; }
  .ev .where { flex: 1 0 100%; }
  .ev .where::before { display: none; }
  .cols { grid-template-columns: 1fr; }
  .cell { min-height: 4.4rem; padding: 4px; gap: 4px; }
  .num { font-size: .9rem; }
  .dots .dot { width: .65rem; height: .65rem; }
  .count { display: none; }
  #panel { top: auto; height: 88vh; width: 100%; border-radius: 14px 14px 0 0; transform: translateY(105%); }
}

/* ---------- Stars + "can't save" popup ---------- */
.ev-wrap { position: relative; }
.ev-wrap .ev summary { padding-right: 5.6rem; }
.ev-wrap .ev summary::after { right: 3.6rem; }
.star {
  position: absolute; top: 50%; translate: 0 -50%; right: .6rem; z-index: 1; width: 48px; height: 48px;
  display: grid; place-items: center; border-radius: 8px; background: none;
  font-size: 1.6rem; line-height: 1; color: var(--muted);
}
.ev-wrap:has(.ev[open]) .star { top: 1.6rem; translate: none; }
.star:hover { background: var(--sand); }
.star[aria-pressed="true"] { color: #d98a00; }
.notice-dialog {
  max-width: min(30rem, calc(100vw - 32px)); padding: 1.5rem 1.6rem; border: 0; border-radius: 12px;
  background: var(--paper); color: var(--ink); box-shadow: 0 12px 40px rgba(9, 39, 69, .3);
}
.notice-dialog::backdrop { background: rgba(9, 39, 69, .5); }
.notice-dialog h2 { margin: 0 0 .7rem; font: 500 1.5rem/1.2 var(--display); color: var(--navy); }
.notice-dialog h2 span { color: var(--gold); }
.notice-dialog p { margin: 0 0 .7rem; }
.notice-dialog form { display: flex; justify-content: flex-end; margin-top: 1.1rem; }
.notice-dialog button { min-width: 7rem; min-height: 48px; border-radius: 6px; background: var(--navy); color: #fff; font-weight: 700; }
@media (max-width: 760px) {
  .ev-wrap .ev summary { padding-right: 4.8rem; }
  .ev-wrap .ev summary::after { right: 3.1rem; }
  .star { right: .2rem; }
}
