/* ─── theme tokens ──────────────────────────────────────────────────
   Esmeralda County Fire District palette + typography. Token names
   match session0's originals so the form-builder, admin, and built-in
   sections still resolve correctly. See docs/theming.md. */

:root {
  /* Brand */
  --color-primary:    #1d2f47;          /* deep navy — header, headings */
  --color-primary-fg: #ffffff;

  --color-accent:     #9a2a35;          /* maroon — CTAs */
  --color-accent-fg:  #ffffff;
  --color-accent-hover:#b03441;

  /* Surfaces */
  --color-bg:         #f5f3ee;          /* warm off-white page bg */
  --color-surface:    #eceae3;          /* card / strip surface */
  --color-border:     #d8d3c6;

  /* Text */
  --color-text:       #1f2330;
  --color-muted:      #6b6960;
  --color-heading:    #1d2f47;

  /* Status */
  --color-success:    #38a169;
  --color-warning:    #d69e2e;
  --color-danger:     #c0392b;

  /* District-specific bands */
  --color-events-band:   #5b576b;       /* purple-gray for upcoming events */
  --color-events-fg:     #f5f3ee;
  --color-emergency:     #1d2f47;
  --color-emergency-fg:  #ffffff;
  --color-footer-bg:     #11192a;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --space-xl: 64px;
  --space-2xl: 96px;

  /* Type */
  --font-display: 'Oswald', 'Arial Narrow', 'Impact', sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-xs:  12px;
  --font-sm:  14px;
  --font-md:  16px;
  --font-lg:  20px;
  --font-xl:  28px;
  --font-2xl: 40px;
  --font-3xl: 56px;
  --line-tight:  1.05;
  --line-normal: 1.5;
  --line-loose:  1.7;

  /* Layout */
  --radius:    2px;
  --radius-lg: 4px;
  --max-width: 1180px;
  --shadow:    0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.16);
}

/* ─── reset ─────────────────────────────────────────────────────────── */

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

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-md);
  line-height: var(--line-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-md);
  font-family: var(--font-display);
  color: var(--color-heading);
  line-height: var(--line-tight);
  font-weight: 600;
  letter-spacing: 0.02em;
}

h1 { font-size: var(--font-3xl); text-transform: uppercase; }
h2 { font-size: var(--font-2xl); text-transform: uppercase; }
h3 { font-size: var(--font-xl); }

p  { margin: 0 0 var(--space-md); }

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img, svg, video { max-width: 100%; display: block; }

button { font: inherit; cursor: pointer; }

/* ─── reusable button utilities ─────────────────────────────────────
   Composable across sections. The header CTAs and section CTAs all
   reach for these so the visual language stays consistent. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: var(--font-sm);
  font-weight: 600;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-fg);
}
.btn--primary:hover { background: var(--color-accent-hover); }

.btn--secondary {
  background: var(--color-primary);
  color: var(--color-primary-fg);
}
.btn--secondary:hover { background: #2a3f5d; }

.btn--outline {
  background: transparent;
  color: var(--color-primary-fg);
  border-color: var(--color-primary-fg);
}
.btn--outline:hover {
  background: var(--color-primary-fg);
  color: var(--color-primary);
}

.btn--outline-dark {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--outline-dark:hover {
  background: var(--color-primary);
  color: var(--color-primary-fg);
}

/* ─── page-load fade ────────────────────────────────────────────────
   Public pages render asynchronously (fetch sections, then innerHTML).
   page.html starts with .page-loading; page-runtime.js removes it
   once the first paint is ready. Prevents a content flash. */

body.page-loading { opacity: 0; }
body { opacity: 1; transition: opacity 200ms ease-out; }

/* ─── emergency bar ─────────────────────────────────────────────────
   Persistent strip above the header. Text is settings-driven so the
   district can update it during incidents without a deploy. */

.emergency-bar {
  background: #000;
  color: var(--color-emergency-fg);
  font-family: var(--font-display);
  font-size: var(--font-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px var(--space-md);
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.emergency-bar [data-setting] { font-weight: 600; }

/* ─── site header ───────────────────────────────────────────────────
   Desktop (>980px): five cells —
     [logo] [primary menu] [Controlled Burn] [Donate] [hamburger (hidden)]
   Mobile  (≤980px): three cells —
     [logo] [spacer] [hamburger]
   At the mobile breakpoint the inline nav and CTAs are display:none and
   the same content lives inside the .site-drawer opened by the hamburger. */

.site-header {
  background: var(--color-primary);
  color: var(--color-primary-fg);
  padding: var(--space-sm) var(--space-md);
  border: none;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: var(--space-md);
}

.header-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.site-logo {
  height: 72px;
  width: auto;
}
.site-logo-fallback {
  font-family: var(--font-display);
  font-size: var(--font-md);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary-fg);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid currentColor;
  border-radius: 50%;
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
/* Hide the fallback once the logo image is loaded. page-runtime.js
   removes the [hidden] attribute on the <img> when settings.logo is set. */
.site-logo:not([hidden]) ~ .site-logo-fallback { display: none; }

/* ─── inline nav (desktop only) ──────────────────────────────────── */

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-nav .menu-item {
  color: var(--color-primary-fg);
  font-size: var(--font-sm);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}
.site-nav .menu-item:hover {
  color: #d6cea8;
  text-decoration: none;
}
.site-nav .menu-icon { display: inline-flex; width: 16px; height: 16px; }
.site-nav .menu-icon svg { width: 16px; height: 16px; }

/* ─── hamburger toggle ───────────────────────────────────────────── */

.site-header-toggle {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: transparent;
  border: 2px solid var(--color-primary-fg);
  border-radius: var(--radius);
  color: var(--color-primary-fg);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.site-header-toggle:hover {
  background: var(--color-primary-fg);
  color: var(--color-primary);
}
.site-header-toggle-bars {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}
.site-header-toggle-bars span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

/* ─── slide-out drawer ───────────────────────────────────────────── */

.site-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 90;
}
body.drawer-open .site-drawer-backdrop { opacity: 1; }

.site-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: clamp(280px, 80vw, 420px);
  background: var(--color-primary);
  color: var(--color-primary-fg);
  transform: translateX(100%);
  transition: transform 240ms ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}
body.drawer-open .site-drawer { transform: translateX(0); }

.site-drawer-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-md);
}
.site-drawer-close {
  width: 40px;
  height: 40px;
  font-size: 28px;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--color-primary-fg);
  cursor: pointer;
  border-radius: var(--radius);
}
.site-drawer-close:hover { background: rgba(255, 255, 255, 0.08); }

.site-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-lg);
}
.site-drawer-nav .menu-item {
  color: var(--color-primary-fg);
  font-size: var(--font-lg);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.site-drawer-nav .menu-item:hover {
  color: #d6cea8;
  text-decoration: none;
}
.site-drawer-nav .menu-icon { display: inline-flex; width: 18px; height: 18px; }
.site-drawer-nav .menu-icon svg { width: 18px; height: 18px; }

.site-drawer-ctas {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: auto;
}

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 10px 20px;
  font-family: var(--font-display);
  font-size: var(--font-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-weight: 600;
  white-space: nowrap;
}
.header-cta--filled {
  background: var(--color-accent);
  color: var(--color-accent-fg);
}
.header-cta--filled:hover { background: var(--color-accent-hover); text-decoration: none; }
.header-cta--outline {
  border-color: var(--color-primary-fg);
  color: var(--color-primary-fg);
}
.header-cta--outline:hover {
  background: var(--color-primary-fg);
  color: var(--color-primary);
  text-decoration: none;
}

/* Inside the drawer, CTAs use a larger block-style sizing. */
.site-drawer-ctas .header-cta {
  padding: 14px 20px;
  font-size: var(--font-md);
}

body.drawer-open { overflow: hidden; }

/* ─── responsive: collapse to hamburger at ≤980px ─────────────────── */

@media (max-width: 980px) {
  .site-header-inner {
    grid-template-columns: auto 1fr auto;
  }
  .site-header-inner .site-nav,
  .site-header-inner .site-header-inline {
    display: none;
  }
}

@media (min-width: 981px) {
  .site-header-toggle { display: none; }
}

/* ─── main + section default ────────────────────────────────────── */

.page-main { min-height: 60vh; background: var(--color-bg); }

.section {
  padding: var(--space-xl) var(--space-md);
}

/* Tighter spacing for the built-in (session0 core) sections only.
   Custom per-site sections (homepage_hero, latest_news, newsfeed,
   etc.) ship their own padding and shouldn't be retroactively
   re-spaced from base. The .section--core class is injected by
   renderSectionList for any type whose category is 'generic'.

   Higher specificity (.section.section--core, two classes) than the
   per-type .section-hero / .section-text rules (one class), so it
   wins on padding-bottom and overall padding for built-ins
   regardless of file order. */
.section.section--core { padding: var(--space-lg) var(--space-md); }

/* Adjacent built-in sections shouldn't double up on vertical
   breathing room. Drop padding-bottom on every core section that
   isn't the last child; the next section's padding-top alone provides
   the gap. The final section keeps its full padding so the page
   doesn't end flush against the footer. */
.section.section--core:not(:last-child) { padding-bottom: 0; }

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Eyebrow: small uppercase label above section content with a hairline
   underline. Used by latest_news and similar. */
.section-eyebrow {
  font-family: var(--font-display);
  font-size: var(--font-md);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-heading);
  margin: 0 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

/* ─── footer ────────────────────────────────────────────────────── */

.site-footer {
  background: var(--color-footer-bg);
  color: #cbd1de;
  padding: var(--space-xl) var(--space-md) var(--space-2xl);
  margin-top: 0;
  text-align: center;
  font-size: var(--font-sm);
  border: none;
}
.site-footer .footer-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-lg);
}
.site-footer .footer-badge img {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
}
.site-footer p { margin: 0 0 var(--space-sm); color: #9aa3b3; }
.site-footer .site-footer-admin {
  margin-top: var(--space-md);
  font-size: var(--font-xs, 12px);
  opacity: 0.6;
}
.site-footer .site-footer-admin a {
  color: inherit;
  text-decoration: underline;
}
.site-footer .site-footer-admin a:hover { opacity: 1; }

/* Footer nav — populated when settings.footerMenu names a menu.
   Hidden by page-runtime when no setting is configured. */
.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-md) var(--space-lg);
  margin: 0 auto var(--space-lg);
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: var(--font-sm);
}
.site-footer-nav .menu-item {
  color: #cbd1de;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}
.site-footer-nav .menu-item:hover { color: #fff; }
.site-footer-nav .menu-icon { display: inline-flex; width: 14px; height: 14px; }
.site-footer-nav .menu-icon svg { width: 14px; height: 14px; }

/* Loading + empty states for collection-backed sections (latest_news,
   upcoming_events). Both render a skeleton then swap in real markup. */
.collection-loading,
.collection-empty {
  margin: 0;
  padding: var(--space-lg) 0;
  color: var(--color-muted);
  font-style: italic;
  text-align: center;
}

/* Built-in section styles live in public/css/sections.css; the shell's
   own styles are above. Catalog and per-site sections @import their own
   files inside sections.css. */
