/* ============================================================================
   FranklinWhat — homepage layout
   ============================================================================ */

/* ---- Lede / editorial hero (LCP-light: type only, no hero image) ---- */
.lede { padding-block: var(--s-7) var(--s-5); }
.lede__date { font-family: var(--font-mono); font-size: var(--t-sm); letter-spacing: 0.04em; color: var(--color-text-3); margin-bottom: var(--s-3); }
.lede__h { font-size: var(--t-4xl); font-weight: 500; line-height: 1.0; max-width: 16ch; }
.lede__h em { font-style: italic; color: var(--color-primary); }
.lede__count { margin-top: var(--s-4); font-size: var(--t-md); color: var(--color-text-2); }
.lede__count b { color: var(--color-text); font-weight: 700; }
.lede__family-shortcut {
  color: var(--river-600);
  border-bottom: 1.5px dotted color-mix(in srgb, var(--river-500) 50%, transparent);
  font-weight: 600;
  white-space: nowrap;
}
.lede__family-shortcut:hover {
  color: var(--river-500);
  border-bottom-style: solid;
  text-decoration: none;
}
html[data-theme="dark"] .lede__family-shortcut { color: var(--river-500); }

/* ---- Sticky controls ---- */
.controls {
  position: sticky; top: 67px; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-block: 1.5px solid var(--color-border);
  padding-block: var(--s-3);
}
.controls__row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

/* lenses (date) — segmented */
.lenses { display: inline-flex; background: var(--paper-sunk); border: 1.5px solid var(--color-border); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.lens {
  font-size: var(--t-sm); font-weight: 600; color: var(--color-text-2);
  padding: 0.4rem 0.85rem; border-radius: var(--r-pill); white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.lens[aria-pressed="true"] { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--sh-xs); }

/* value filter chips */
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--t-sm); font-weight: 600; color: var(--color-text-2);
  padding: 0.42rem 0.8rem; border-radius: var(--r-pill);
  background: var(--color-surface); border: 1.5px solid var(--color-border);
  transition: all var(--dur) var(--ease);
}
.chip svg { width: 15px; height: 15px; }
.chip:hover { border-color: var(--color-border-2); }
.chip.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.chip--childcare.is-active { background: var(--clay-500); border-color: var(--clay-600); }

/* Kid-friendly chip gets a quiet emphasis so families notice it first.
 * Visual approach: a soft river-blue tint at rest (matches the family-
 * marker palette), unchanged on active so it doesn't fight the rest of
 * the segmented control.  Same size, same height. */
.chip--family-prominent {
  background: color-mix(in srgb, var(--river-100) 60%, var(--color-surface));
  border-color: color-mix(in srgb, var(--river-500) 40%, var(--color-border));
  color: var(--river-600);
}
.chip--family-prominent:hover {
  border-color: var(--river-500);
}
.chip--family-prominent.is-active {
  background: var(--river-500);
  border-color: var(--river-600);
  color: #fff;
}
html[data-theme="dark"] .chip--family-prominent {
  background: color-mix(in srgb, var(--river-500) 15%, var(--color-surface));
  color: var(--river-500);
}

/* ============================================================================
 * "Tonight" panel — events starting in the next 6 hours, pinned at the top
 * of the feed. Quiet clay accent so it reads as editorial, not promotional.
 * ========================================================================== */
.tonight-panel {
  padding: var(--s-5) var(--s-5);
  margin-bottom: var(--s-6);
  background: linear-gradient(0deg, var(--clay-50), var(--color-surface) 70%);
  border: 1.5px solid color-mix(in srgb, var(--clay-500) 35%, var(--color-border));
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
html[data-theme="dark"] .tonight-panel {
  background: linear-gradient(0deg, color-mix(in srgb, var(--clay-500) 10%, var(--color-surface)), var(--color-surface) 70%);
}
.tonight-panel__head { margin-bottom: var(--s-4); }
.tonight-panel__eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clay-700);
  margin-bottom: 0.4rem;
}
html[data-theme="dark"] .tonight-panel__eyebrow { color: var(--clay-500); }
.tonight-panel__title {
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  font-weight: 600;
  line-height: 1.1;
  color: var(--color-text);
}
.tonight-panel__list { display: grid; gap: var(--s-3); }
.tonight-panel.hidden { display: none; }

.controls__spacer { flex: 1; }

/* search */
.search { position: relative; min-width: 200px; }
.search svg { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--color-text-3); }
.search input {
  width: 100%; padding: 0.5rem 0.8rem 0.5rem 2.2rem; border-radius: var(--r-md);
  border: 1.5px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  font-size: var(--t-sm);
}
.search input:focus-visible { border-color: var(--color-primary); box-shadow: var(--ring); }
@media (max-width: 640px){ .search { width: 100%; order: 5; } .controls__spacer { display: none; } }

/* ---- Section spacing ---- */
.section { padding-block: var(--s-7); }
.section--tight { padding-block: var(--s-6); }

/* ---- Featured grid ---- */
.featured-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
@media (max-width: 900px){ .featured-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 520px){ .featured-grid { grid-template-columns: 1fr; } }

/* ---- Feed layout ---- */
.feed-wrap { display: grid; grid-template-columns: 1fr 300px; gap: var(--s-7); align-items: start; }
@media (max-width: 920px){ .feed-wrap { grid-template-columns: 1fr; } }
#feedSummary { font-family: var(--font-mono); font-size: var(--t-sm); color: var(--color-text-3); margin-bottom: var(--s-4); }
/* Reserve vertical space for JS-rendered feed/featured/regional sections
 * so cards appearing after the data fetch don't cause CLS. Once content
 * is injected the min-height becomes a floor that doesn't affect layout. */
#feed:empty { min-height: 1100px; }
@media (max-width: 920px) { #feed:empty { min-height: 1500px; } }
#featuredGrid:empty { min-height: 380px; }
@media (max-width: 520px) { #featuredGrid:empty { min-height: 600px; } }
#regionalRow:empty { min-height: 200px; }

/* sidebar */
.aside { position: sticky; top: 130px; display: grid; gap: var(--s-5); }
@media (max-width: 920px){ .aside { position: static; } }
.panel { background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: var(--r-lg); padding: var(--s-5); }
.panel__h { font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-3); margin-bottom: var(--s-4); }

/* regional buttons */
#regional { display: grid; gap: 0.5rem; }
.region {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label range" "towns count";
  gap: 0.15rem 0.5rem; text-align: left; padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--color-border); border-radius: var(--r-md); background: var(--surface-2);
  transition: all var(--dur) var(--ease); width: 100%;
}
.region:hover { border-color: var(--color-border-2); }
.region.is-active { border-color: var(--color-primary); background: var(--emerald-50); }
html[data-theme="dark"] .region.is-active { background: color-mix(in srgb, var(--emerald-500) 12%, var(--surface)); }
.region__label { grid-area: label; font-weight: 700; font-size: var(--t-sm); color: var(--color-text); }
.region__range { grid-area: range; font-size: 0.68rem; color: var(--color-text-3); align-self: center; }
.region__count { grid-area: count; font-family: var(--font-mono); font-size: 0.68rem; color: var(--color-primary); align-self: center; text-align: right; white-space: nowrap; }
.region__towns { grid-area: towns; font-size: 0.7rem; color: var(--color-text-2); }
#bandNote { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--color-primary); min-height: 1em; margin-top: var(--s-2); }

/* deals */
#deals { display: grid; gap: 0.6rem; }
.deal { display: grid; gap: 0.1rem; padding-bottom: 0.6rem; border-bottom: 1px dashed var(--color-border); }
.deal:last-child { border-bottom: 0; padding-bottom: 0; }
.deal__what { font-weight: 700; font-size: var(--t-sm); color: var(--clay-600); }
html[data-theme="dark"] .deal__what { color: var(--clay-500); }
.deal__who { font-size: var(--t-sm); color: var(--color-text); }
.deal__note { font-size: 0.68rem; color: var(--color-text-3); }

/* empty state */
.empty { text-align: center; padding: var(--s-8) var(--s-4); border: 1.5px dashed var(--color-border); border-radius: var(--r-lg); }
.empty__title { font-family: var(--font-display); font-size: var(--t-xl); margin-bottom: var(--s-2); }
.empty__text { color: var(--color-text-2); max-width: 40ch; margin: 0 auto var(--s-4); }

/* ---- Partners ---- */
.partners-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--s-4); }
@media (max-width: 720px){ .partners-grid { grid-template-columns: 1fr; } }
.partner { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4); border: 1.5px solid var(--color-border); border-radius: var(--r-lg); background: var(--color-surface); }
.partner__logo { width: 52px; height: 52px; border-radius: var(--r-md); background: var(--paper-sunk); display: grid; place-items: center; flex-shrink: 0; font-family: var(--font-display); font-weight: 600; color: var(--color-primary); }
.partner__name { font-weight: 700; }
.partner__detail { font-size: var(--t-sm); color: var(--color-text-2); }
.partner__link { font-family: var(--font-mono); font-size: 0.7rem; color: var(--color-primary); }

/* ---- About strip ---- */
.about { background: var(--surface-2); border-block: 1.5px solid var(--color-border); }
.about__grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: var(--s-7); align-items: center; }
@media (max-width: 720px){ .about__grid { grid-template-columns: 1fr; gap: var(--s-5); } }
.about__lead { font-family: var(--font-display); font-size: var(--t-xl); line-height: 1.4; }
.about__lead b { color: var(--color-primary); font-style: italic; font-weight: 500; }
.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--s-4); }
.stat__n { font-family: var(--font-display); font-size: var(--t-2xl); font-weight: 600; color: var(--color-primary); }
.stat__l { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-3); }

/* ============================================================================
 * Post-integration polish — WCAG AA + Cumulative Layout Shift.
 * Audit failures fixed: small emerald body text needed a slightly darker
 * shade to clear 4.5:1 on warm paper, and async-rendered modules need
 * pre-allocated height so the page doesn't reflow when data lands.
 * ========================================================================== */

/* Small emerald text → use the darker --color-primary-text token. The
 * brand emerald (#059669) is held for surfaces / large headings. */
.lens[aria-pressed="true"] { color: var(--color-primary-text); }
.daygroup--today .daygroup__dow { color: var(--color-primary-text); }
.region__count,
#bandNote,
.section-head__link:hover,
.partner__link { color: var(--color-primary-text); }

/* CLS reservations — page-load shouldn't jolt these regions. Without
 * these, JS-rendered modules (feed, featured, regional, lede count)
 * pop in and shove the page down by ~600px.  Hard min-heights kill
 * that shift without locking layout once content arrives (content
 * just grows the container past the min).  See Lighthouse CLS. */
#feed { min-height: 60vh; }
#featured, .featured-grid { min-height: 280px; }
#featuredSection { min-height: 360px; }
#regional { min-height: 320px; }
#deals { min-height: 60px; }
.lede { min-height: 280px; }
.lede__count { min-height: 1.6em; }
#feedSummary { min-height: 1.2em; }
#ledeCount, #ledeDate { display: block; }

/* Font-loading CLS: while web fonts arrive, the system-font fallbacks
 * should occupy similar metrics.  This 'size-adjust' shim trims the
 * fallback metrics so headings don't snap when Newsreader swaps in. */
@font-face {
  font-family: "Newsreader Fallback";
  src: local("Georgia"), local("Times New Roman");
  size-adjust: 105%;
  ascent-override: 90%;
}
@font-face {
  font-family: "Hanken Fallback";
  src: local("system-ui"), local("Segoe UI");
  size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .freshness__dot::after { display: none; }
}
