/* GainesvilleEvents.com — design system ported from the original directory page. */

:root {
  --cream: #F4F7FB;
  --cream-dark: #E5EBF4;
  --white: #FFFFFF;
  --green-deep: #1A3358;
  --green-mid: #2C5F9E;
  --green-light: #E4EDF8;
  --amber: #B8860B;
  --amber-light: #FBF5E0;
  --terracotta: #8B6500;
  --brown-dark: #0F1C2E;
  --brown-mid: #4A607A;
  --brown-light: #D8E3F0;
  --border: #C8D6E8;
  --text: #0F1E30;
  --text-muted: #5A708A;
  --shadow-sm: 0 1px 3px rgba(26, 51, 88, 0.10);
  --shadow-md: 0 4px 16px rgba(26, 51, 88, 0.12);
  --radius: 8px;
  --radius-lg: 14px;

  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --wrap: 1080px;
}

/* Self-hosted latin-subset variable fonts (no third-party requests at runtime). */
@font-face {
  font-family: 'Playfair Display';
  src: url('/fonts/playfair-display.woff2') format('woff2-variations');
  font-weight: 600 700;
  font-display: swap;
}
@font-face {
  font-family: 'Source Sans 3';
  src: url('/fonts/source-sans-3.woff2') format('woff2-variations');
  font-weight: 400 600;
  font-display: swap;
}

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

/* The [hidden] attribute must always win — otherwise a display rule (e.g. .event's
   `display: grid`) overrides it and JS-hidden events keep rendering. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); color: var(--green-deep); line-height: 1.2; }

a { color: var(--green-mid); }
a:hover { color: var(--green-deep); }

/* Focus is never removed — only restyled. */
:focus-visible {
  outline: 3px solid var(--green-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--green-deep);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  z-index: 100;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
  color: var(--white);
}

/* ---------- header ---------- */

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--green-deep);
  text-decoration: none;
}
.brand:hover { color: var(--green-deep); }
.brand .dot { color: var(--amber); }

.site-nav { display: flex; gap: 1.25rem; }
.site-nav a {
  color: var(--brown-mid);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--green-deep); border-bottom-color: var(--border); }
.site-nav a[aria-current='page'] { color: var(--green-deep); border-bottom-color: var(--amber); }

/* ---------- page intro ---------- */

.intro { padding: 2.25rem 0 1.25rem; }
.intro h1 { margin: 0 0 0.4rem; font-size: clamp(1.9rem, 4.5vw, 2.6rem); }
.intro p { margin: 0; color: var(--text-muted); max-width: 60ch; }
.intro p.intro-support { margin-top: 0.6rem; font-size: 0.85rem; }
.intro-support a { font-weight: 600; }

/* ---------- filters ---------- */

.filters {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
  margin-bottom: 1.5rem;
}
.filters .wrap { display: grid; gap: 0.7rem; }

.filter-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

.chip {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown-mid);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  min-height: 44px;
  cursor: pointer;
}
.chip:hover { border-color: var(--green-mid); color: var(--green-deep); }
.chip[aria-pressed='true'] {
  background: var(--green-deep);
  border-color: var(--green-deep);
  color: var(--white);
}

/* Gators toggle: UF orange/blue accent when active. */
.chip-gators[aria-pressed='true'] {
  background: #0021A5; /* UF blue */
  border-color: #FA4616; /* UF orange */
  color: var(--white);
}

.search-field { position: relative; flex: 1 1 16rem; min-width: 12rem; }
.search-field input {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
}
.search-field input::placeholder { color: var(--text-muted); }

.result-count {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- agenda ---------- */

.day-group { margin-bottom: 2.25rem; }
.day-heading {
  font-size: 1.15rem;
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--cream-dark);
}
.day-heading .day-count { font-family: var(--font-body); font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }

.event {
  display: grid;
  grid-template-columns: 4.25rem 1fr;
  gap: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}
.event:hover { box-shadow: var(--shadow-md); border-color: var(--green-mid); }

@media (prefers-reduced-motion: no-preference) {
  .event { transition: box-shadow 140ms ease, border-color 140ms ease; }
  .chip { transition: background 120ms ease, color 120ms ease, border-color 120ms ease; }
}

/* Decorative: the full date is always in the meta line for screen readers. */
.event-date {
  text-align: center;
  background: var(--green-light);
  border-radius: var(--radius);
  padding: 0.45rem 0.25rem;
  align-self: start;
}
/* Darker than --terracotta so the small uppercase label clears 4.5:1 on --green-light. */
.event-date .m { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #6B4E00; }
.event-date .d { display: block; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--green-deep); line-height: 1.1; }
.event-date .w { display: block; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; color: var(--brown-mid); }

.event-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; margin: 0 0 0.3rem; }
.event-title a { color: var(--green-deep); text-decoration: none; }
.event-title a:hover { text-decoration: underline; }

.event-meta { margin: 0; font-size: 0.93rem; color: var(--text-muted); }
.event-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }

.tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--cream-dark);
  color: var(--brown-mid);
}
.tag-free { background: var(--amber-light); color: var(--terracotta); }
.tag-source { background: transparent; color: var(--text-muted); text-transform: none; letter-spacing: 0; font-weight: 600; padding-left: 0; }

.empty {
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- featured (paid) strip ---------- */
/* Sits between the filters and #agenda. Set apart from organic listings with the
   site's amber highlight token (never the blue/green of normal cards). Rendered
   outside #agenda and not class="event", so client.js filters never hide a paid slot. */

.featured { margin: 0 0 1.75rem; }

.featured-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--terracotta);
  margin: 0 0 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--amber-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.featured-eyebrow::before { content: ""; width: 16px; height: 2px; background: var(--amber); }

.featured-list { display: grid; gap: 0.7rem; }
@media (min-width: 720px) { .featured-list { grid-template-columns: 1fr 1fr; } }

.fcard {
  display: grid;
  gap: 1rem;
  background: var(--amber-light);
  border: 1px solid rgba(184, 134, 11, 0.30);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
}
.fcard--img { grid-template-columns: 88px 1fr; }
.fthumb { width: 88px; height: 88px; object-fit: cover; border-radius: var(--radius); align-self: start; }

.feyebrow {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--terracotta);
  margin: 0 0 0.2rem;
}
.ftitle { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; margin: 0 0 0.25rem; line-height: 1.2; }
.ftitle a { color: var(--green-deep); text-decoration: none; }
.ftitle a:hover { text-decoration: underline; }
.fmeta { margin: 0; font-size: 0.92rem; color: var(--text-muted); }
.ftags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.55rem 0; }
.flink { font-weight: 700; font-size: 0.92rem; color: var(--green-mid); text-decoration: none; }
.flink:hover { color: var(--green-deep); text-decoration: underline; }

/* Tags read against the amber card, not the grey they use on white cards. */
.fcard .tag { background: var(--white); }
.fcard .tag-free { background: var(--white); color: var(--terracotta); border: 1px solid rgba(184, 134, 11, 0.35); }

/* ---------- event detail ---------- */

.detail { padding: 2rem 0 3rem; max-width: 44rem; }
.detail h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 0.75rem; }
.detail-when { font-size: 1.05rem; font-weight: 600; color: var(--green-deep); margin: 0 0 0.25rem; }
.detail-where { color: var(--text-muted); margin: 0 0 1.25rem; }
.detail img { width: 100%; height: auto; border-radius: var(--radius-lg); margin-bottom: 1.5rem; }
.detail-body { margin-bottom: 1.75rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 2rem; }
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--green-deep);
}
.btn:hover { border-color: var(--green-mid); }
.btn-primary { background: var(--green-deep); border-color: var(--green-deep); color: var(--white); }
.btn-primary:hover { background: var(--brown-dark); color: var(--white); }

.back-link { display: inline-block; margin-top: 1rem; font-weight: 600; }

/* ---------- sources / about / status ---------- */

.prose { padding: 2rem 0 3rem; max-width: 44rem; }
.prose h2 { margin-top: 2rem; }
.prose li { margin-bottom: 0.4rem; }

.source-grid { list-style: none; padding: 0; margin: 0 0 2rem; display: grid; gap: 0.7rem; }
@media (min-width: 720px) { .source-grid { grid-template-columns: 1fr 1fr; } }

.source-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}
.source-card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.source-card p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }

.status-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.status-table caption { text-align: left; color: var(--text-muted); padding-bottom: 0.75rem; }
.status-table th, .status-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.status-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--brown-mid); }
.badge { font-weight: 700; font-size: 0.8rem; padding: 0.15rem 0.5rem; border-radius: 999px; }
.badge-ok { background: var(--green-light); color: var(--green-deep); }
.badge-warn { background: var(--amber-light); color: var(--terracotta); }
.badge-fail { background: #FBE4E4; color: #8B2020; }
.table-scroll { overflow-x: auto; }

/* ---------- footer ---------- */

.site-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.site-footer a { font-weight: 600; }
.site-footer p { margin: 0 0 0.5rem; }

/* Shorter filter area on phones: each chip GROUP row becomes one swipeable line
   instead of wrapping to ~4 lines, so the featured strip and events sit higher.
   Only the date/category groups scroll (they carry role="group"); the search row
   still wraps. The mask fades chips into the bar at the right edge to hint scroll. */
@media (max-width: 640px) {
  .filters { padding: 0.6rem 0; }
  .filter-row[role="group"] {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, #000 90%, transparent);
    mask-image: linear-gradient(to right, #000 90%, transparent);
  }
  .filter-row[role="group"]::-webkit-scrollbar { display: none; }
  .filter-row[role="group"] > .chip { flex: 0 0 auto; }
}

@media (max-width: 480px) {
  .event { grid-template-columns: 3.5rem 1fr; gap: 0.8rem; padding: 0.9rem; }
  .event-date .d { font-size: 1.3rem; }
  .fcard--img { grid-template-columns: 68px 1fr; }
  .fthumb { width: 68px; height: 68px; }
}

/* ---------- dark mode ---------- */
/* Auto, no toggle: follows the visitor's OS setting. The whole design is driven by
   the custom properties in :root, so dark mode is almost entirely a re-definition of
   those tokens. A few tokens are dual-role (e.g. --white is a card surface in most
   places but light text on the primary button; --green-deep is heading text but also
   the primary-button/pressed-chip fill), so after the token overrides we re-specify
   just those solid-fill components to guarantee contrast. Every pairing here was
   checked to clear WCAG 2.2 AA (4.5:1 text / 3:1 large). */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --cream: #0E1A2C;         /* page background */
    --cream-dark: #233247;    /* day-heading rule, plain tag background */
    --white: #16273F;         /* raised card/input surface (lifts off the page) */
    --green-deep: #E6EEFA;    /* headings, titles, high-emphasis text */
    --green-mid: #7FB2F0;     /* links + the primary-action fill */
    --green-light: #213B5E;   /* date chip / "OK" badge background */
    --amber: #E0A93A;         /* accent dot & hairline rules */
    --amber-light: #3A2E12;   /* featured card / free tag / "warn" badge background */
    --terracotta: #F0C066;    /* amber-family text on --amber-light */
    --brown-mid: #A6BAD4;     /* nav + secondary labels */
    --brown-light: #2A3A52;
    --brown-dark: #0A121E;
    --border: #3A4F6B;
    --text: #E7EEF8;
    --text-muted: #A2B5CE;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.55);
  }

  /* Primary actions: bright-blue fill with dark text (the light theme's deep-navy
     fill would vanish against the dark page). :not(.chip-gators) so the UF-colored
     Gators toggle below keeps its own brand fill. */
  .btn-primary,
  .chip[aria-pressed='true']:not(.chip-gators) {
    background: var(--green-mid);
    border-color: var(--green-mid);
    color: #0B1626;
  }
  .btn-primary:hover { background: #A6CDF6; border-color: #A6CDF6; color: #0B1626; }

  /* Pressed Gators chip keeps its dark UF-blue fill (excluded from the bright-fill
     rule above), so it needs LIGHT text — the base rule's var(--white) is a dark
     surface token in dark mode, which would leave dark-on-dark. */
  .chip-gators[aria-pressed='true'] { color: #FFFFFF; }

  /* Skip link stays a bright, obvious target when focused. */
  .skip-link,
  .skip-link:focus { background: var(--green-mid); color: #0B1626; }

  /* Date chip month label: a touch brighter to clear 4.5:1 on the dark-blue chip. */
  .event-date .m { color: #E0B968; }

  /* Failing-source badge: dark-red chip instead of the light-mode pale pink. */
  .badge-fail { background: #3A1A1A; color: #F3B4B4; }
}
