/* ==========================================================================
   base.css — Reset, Design Tokens, Typography
   Source of truth: Design-System-v1.md. Do not introduce values here that
   aren't already defined in that document — extend it first, then this file.
   ========================================================================== */

/* ---- Design Tokens -------------------------------------------------- */
:root {
  /* Color */
  --color-primary: #0F2A4A;
  --color-secondary: #1B4965;
  --color-accent: #2EC4B6;
  --color-accent-text: #0E7C71;
  --color-background: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-text-primary: #101828;
  --color-text-muted: #475467;
  --color-text-inverse: #F8FAFC;
  --color-success: #1A7F5A;
  --color-warning: #B7791F;
  --color-danger: #B42318;
  --color-info: #1B4965;
  --color-border: #E4E7EC;
  --color-border-strong: #D0D5DD;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --text-display-xl: 3.5rem;
  --text-display-lg: 2.75rem;
  --text-heading-lg: 2.25rem;
  --text-heading-md: 1.75rem;
  --text-heading-sm: 1.375rem;
  --text-body-lg: 1.125rem;
  --text-body-md: 1rem;
  --text-body-sm: 0.875rem;
  --text-label: 0.8125rem;

  /* Spacing */
  --space-1: 4px;  --space-2: 8px;   --space-3: 12px;  --space-4: 16px;
  --space-5: 24px; --space-6: 32px;  --space-7: 48px;  --space-8: 64px;
  --space-9: 96px; --space-10: 128px;

  /* Radius */
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px;
  --radius-xl: 20px; --radius-full: 9999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.05);
  --shadow-sm: 0 1px 3px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.06);
  --shadow-md: 0 4px 8px rgba(16,24,40,0.10);
  --shadow-lg: 0 12px 24px rgba(16,24,40,0.12);
  --shadow-focus: 0 0 0 3px rgba(46,196,182,0.45);

  /* Motion */
  --transition-fast: 150ms ease-out;
  --transition-base: 250ms ease-out;
  --transition-slow: 400ms ease-in-out;

  /* Z-index scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky-header: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;

  /* Container widths */
  --container-max: 1200px;
  --container-narrow: 720px;
}

/* ---- Reset ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

@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;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--text-body-md);
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

a { color: inherit; text-decoration: none; }

ul, ol { list-style: none; padding: 0; }

table { border-collapse: collapse; width: 100%; }

/* ---- Typography --------------------------------------------------------
   Heading hierarchy is a design-system rule, not a per-page choice — see
   Design-System-v1.md §3.3 and §28. Never skip levels for visual effect;
   use the utility classes below (e.g. .text-heading-sm on an <h2>) instead
   of choosing the wrong semantic tag.
   ------------------------------------------------------------------------ */

h1, h2, h3 { font-family: var(--font-display); color: var(--color-text-primary); line-height: 1.2; }
h4, h5, h6 { font-family: var(--font-body); font-weight: 600; color: var(--color-text-primary); }

h1 { font-size: var(--text-display-lg); font-weight: 600; line-height: 1.15; }
h2 { font-size: var(--text-heading-lg); font-weight: 500; }
h3 { font-size: var(--text-heading-md); font-weight: 500; }
h4 { font-size: var(--text-heading-sm); }
h5 { font-size: var(--text-body-lg); font-weight: 600; }
h6 { font-size: var(--text-body-md); font-weight: 600; }

.text-display-xl { font-family: var(--font-display); font-size: var(--text-display-xl); font-weight: 600; line-height: 1.1; }

p { max-width: 75ch; }
p + p { margin-top: var(--space-4); }

.text-lead { font-size: var(--text-body-lg); color: var(--color-text-muted); max-width: 65ch; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--text-body-sm); }
.text-label {
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.text-mono { font-family: var(--font-mono); }
.text-inverse { color: var(--color-text-inverse); }
.text-accent { color: var(--color-accent-text); }

/* ---- Fonts (self-hosted, per performance guidance in Design-System-v1.md §29) --
   Font files are not included in this delivery (binary assets outside
   generation scope) — swap these @font-face src paths for real .woff2 files
   under assets/fonts/ before deployment, or use the Google Fonts <link>
   fallback documented in index.html's <head>.
   ------------------------------------------------------------------------ */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/inter-variable.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('/assets/fonts/fraunces-variable.woff2') format('woff2');
  font-weight: 500 600;
  font-display: swap;
}

/* ---- Accessibility utilities ------------------------------------------ */
.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;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: var(--z-toast);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: var(--space-4);
}

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* ---- Scroll reveal (Design-System-v1.md §23) --------------------------
   Paired with js/main.js's IntersectionObserver. Reduced-motion users get
   the .is-visible state applied immediately with no transition at all —
   handled in JS, not just CSS, so there's no motion to opt out of. */
[data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}
[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}
