/*
 * fws-a11y.css — Birch Run Township design tokens + accessibility primitives
 * WCAG 2.2 AA. Palette derived from the WordBench municipal feel; refine later.
 *
 * Contrast verified (ratio on #FFFFFF unless noted):
 *   --color-text                 #1A1A1A  16.1:1  body text
 *   --color-text-muted           #5A5A5A   6.9:1  secondary text
 *   --color-primary              #1B3A5B  11.6:1  text/links + white-on-primary (header/buttons)
 *   --color-accent-text          #8A5A00   6.0:1  text-safe accent on WHITE
 *   --color-accent               #B8860B   3.1:1  NON-TEXT / large only (borders, icons, >=24px)
 *   --color-accent-on-primary    #FFE499   9.1:1  text-safe accent on NAVY (eyebrow, footer titles)
 *   --color-link                 #1B3A5B  11.6:1  (always also underlined — never color alone)
 *   --color-error                #B00020   7.4:1
 *   --color-success              #1E6B3A   6.5:1
 *   --color-border               #6B7280   4.8:1  (>= 3:1 non-text)
 *   --color-focus                #B8860B   3.1:1 on white, 3.7:1 on primary navy
 */

:root {
  /* Brand / civic palette */
  --color-primary: #1b3a5b;
  --color-primary-dark: #122a43; /* hover/active */
  --color-primary-tint: #eaf1f8; /* section background — NOT for text */
  --color-accent: #b8860b; /* non-text / large only — borders, icons, >=24px */
  --color-accent-text: #8a5a00; /* text-safe accent on WHITE backgrounds */
  --color-accent-on-primary: #ffe499; /* text-safe accent on NAVY (9.1:1) */

  /* Rust-orange used on the home-page "Looking for something specific?" CTA panel.
   * White text on #A0421A measures 6.1:1 — passes AA for normal text. */
  --color-cta: #a0421a;
  --color-cta-dark: #7e3214; /* hover/active */

  /* Neutrals */
  --color-bg: #ffffff;
  --color-bg-subtle: #f5f7fa;
  --color-text: #1a1a1a;
  --color-text-muted: #5a5a5a;
  --color-text-on-primary: #ffffff;
  --color-border: #6b7280;
  --color-border-subtle: #d4d9e0;

  /* Semantic */
  --color-error: #b00020;
  --color-success: #1e6b3a;
  --color-warning-text: #8a5a00;

  /* Links */
  --color-link: #1b3a5b;
  --color-link-hover: #122a43;

  /* Focus */
  --color-focus: #b8860b;
  --focus-ring-width: 3px;
  --focus-ring-offset: 2px;

  /* Typography */
  --font-sans:
    system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'Roboto Mono', monospace;
  /* Browser default 16px. WCAG has no minimum; 16px easily satisfies 1.4.4
   * resize-to-200% and 1.4.12 text spacing modifiers. */
  --font-size-base: 1rem; /* 16px */
  --line-height-base: 1.55; /* supports 1.4.12 text spacing */
  --line-height-heading: 1.2;

  /* Modular type scale (1.25) */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.953rem;
  --text-3xl: 2.441rem;
  --text-4xl: 3.052rem;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Layout */
  --container-max: 75rem; /* 1200px */
  --content-max: 42rem; /* readable measure */
  --radius: 4px;
  --radius-lg: 8px;

  /* Targets — 2.5.8 min 24px; primary controls aim for 44px */
  --tap-target-min: 24px;
  --tap-target: 44px;

  --header-height: 4.5rem;
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
}

/* Headings: single, descriptive per page; structure not styling. */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: var(--line-height-heading);
  color: var(--color-primary);
  margin: 0 0 var(--space-4);
  font-weight: 700;
}
/* Capped responsive heading sizes — keeps display headings from ballooning on
 * wide viewports while still scaling down on narrow ones. */
h1 {
  font-size: clamp(1.5rem, 2.5vw, 2rem); /* 24–32px */
}
h2 {
  font-size: clamp(1.25rem, 1.8vw, 1.5rem); /* 20–24px */
}
h3 {
  font-size: clamp(1.125rem, 1.4vw, 1.25rem); /* 18–20px */
}
h4 {
  font-size: 1.0625rem; /* 17px */
}
h5 {
  font-size: 1rem;
}
h6 {
  font-size: 0.9375rem;
}

p {
  margin: 0 0 var(--space-4);
  max-width: var(--content-max);
}

img {
  max-width: 100%;
  height: auto;
}

/* Links — color is never the sole signal (1.4.1): underline always present. */
a {
  color: var(--color-link);
  text-underline-offset: 0.15em;
}
a:hover {
  color: var(--color-link-hover);
}

/* Visible focus on every interactive element (2.4.7 / approaching 2.4.13 AAA). */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
  border-radius: 2px;
}
/* Remove default ring only where :focus-visible is supported. */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip-to-content link (2.4.1) — visible on focus. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100%;
  z-index: 1000;
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  border-radius: var(--radius);
  text-decoration: underline;
}
.skip-link:focus {
  top: var(--space-4);
}

/* Screen-reader-only utility. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.sr-only-focusable:focus,
.sr-only-focusable:focus-within {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Respect reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
