/* ==========================================================================
   base.css
   Tokens, reset, and accessibility primitives.
   Palette: Modern Federal Executive (emerald + muted gold on paper canvas).
   ========================================================================== */

:root {
  /* Type scale (fluid, rem based so the A- / A / A+ control scales everything) */
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-base: clamp(1rem, 0.97rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.25rem + 1vw, 2.125rem);
  --text-2xl: clamp(2rem, 1.4rem + 2.2vw, 3.25rem);

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --measure: 68ch;
  --container: 74rem;
  --container-narrow: 52rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --header-h: 4.5rem;
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 220ms;

  /* Fonts */
  --font-display: 'Gambetta', 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: 'Switzer', 'Inter', 'Segoe UI', system-ui, sans-serif;

  /* Text size control multiplier, overridden by [data-textsize] */
  --font-scale: 1;
}

/* Keep the current document visible until the next same-origin page is ready.
   The zero-duration swap removes the browser's blank frame between pages. */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0s;
}

/* ------------------------------------------------------------------ themes */
:root,
[data-theme='light'] {
  --color-canvas: #f4f6f4;
  --color-surface: #ffffff;
  --color-surface-2: #eef1ee;
  --color-text: #152219;
  --color-text-muted: #4b5a50;
  --color-text-faint: #5c6b61;
  --color-accent: #2d6a4f;
  --color-accent-strong: #1f4d39;
  --color-accent-soft: #e4ece7;
  --color-gold: #d4a373;
  --color-gold-text: #8c5e2a;
  --color-gold-line: rgba(212, 163, 115, 0.55);
  --color-rule: rgba(21, 34, 25, 0.14);
  --color-rule-strong: rgba(21, 34, 25, 0.28);
  --color-on-accent: #ffffff;
  --color-error: #8c2f1c;
  --shadow-sm: 0 1px 2px rgba(21, 34, 25, 0.06);
  --shadow-md: 0 8px 24px rgba(21, 34, 25, 0.08);
  --photo-matte: #ffffff;
  color-scheme: light;
}

[data-theme='dark'],
:root:has(#theme-dark-toggle:checked) {
  --color-canvas: #384252;
  --color-surface: #3e495b;
  --color-surface-2: #485365;
  --color-text: #f3f1ec;
  --color-text-muted: #d3cfc5;
  --color-text-faint: #b8b5ad;
  --color-accent: #88bf92;
  --color-accent-strong: #95c69e;
  --color-accent-soft: #485365;
  --color-gold: #d8b86f;
  --color-gold-text: #e4c981;
  --color-gold-line: rgba(216, 184, 111, 0.55);
  --color-rule: rgba(243, 241, 236, 0.18);
  --color-rule-strong: rgba(243, 241, 236, 0.32);
  --color-on-accent: #252c37;
  --color-error: #f4a48f;
  --shadow-sm: 0 1px 2px rgba(19, 24, 32, 0.28);
  --shadow-md: 0 10px 28px rgba(19, 24, 32, 0.34);
  --photo-matte: #e9ece9;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --color-canvas: #384252;
    --color-surface: #3e495b;
    --color-surface-2: #485365;
    --color-text: #f3f1ec;
    --color-text-muted: #d3cfc5;
    --color-text-faint: #b8b5ad;
    --color-accent: #88bf92;
    --color-accent-strong: #95c69e;
    --color-accent-soft: #485365;
    --color-gold: #d8b86f;
    --color-gold-text: #e4c981;
    --color-gold-line: rgba(216, 184, 111, 0.55);
    --color-rule: rgba(243, 241, 236, 0.18);
    --color-rule-strong: rgba(243, 241, 236, 0.32);
    --color-on-accent: #252c37;
    --color-error: #f4a48f;
    --shadow-sm: 0 1px 2px rgba(19, 24, 32, 0.28);
    --shadow-md: 0 10px 28px rgba(19, 24, 32, 0.34);
    --photo-matte: #e9ece9;
    color-scheme: dark;
  }
}

/* --------------------------------------------------- text size preference */
[data-textsize='sm'],
:root:has(#text-size-sm:checked) {
  --font-scale: 0.9;
}
[data-textsize='lg'],
:root:has(#text-size-lg:checked) {
  --font-scale: 1.15;
}

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

/* Do not animate fallback text into its final theme color during navigation. */
html:not(.is-ready) *,
html:not(.is-ready) *::before,
html:not(.is-ready) *::after {
  animation: none !important;
  transition: none !important;
}

html {
  font-size: calc(100% * var(--font-scale));
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-6));
}

body {
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 var(--space-4);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-2xl);
}
h2 {
  font-size: var(--text-xl);
}
h3 {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0;
}
h4 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.01em;
}

p,
li {
  max-width: var(--measure);
}

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

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur) var(--ease);
}

a:hover {
  color: var(--color-accent-strong);
}

img,
svg,
picture {
  max-width: 100%;
  height: auto;
  display: block;
}

/* The user agent [hidden] rule is namespaced to HTML, so SVG needs this. */
svg[hidden],
[hidden] {
  display: none !important;
}

ul,
ol {
  padding-left: 1.15rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-rule);
  margin: var(--space-10) 0;
}

strong {
  font-weight: 600;
}

/* ----------------------------------------------------------- a11y helpers */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-2);
  z-index: 200;
  transform: translateY(-160%);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: transform var(--dur) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

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