/* ==========================================================================
   Resilience Group — Base Styles
   Version 1.0
   
   Reset, global defaults, heading/paragraph rules, accessibility.
   Loaded after tokens.css. No component styles here.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

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

/* --------------------------------------------------------------------------
   Document
   -------------------------------------------------------------------------- */

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  /* In-page anchors compensate for the sticky site-header (Sprint H). */
  scroll-padding-top: var(--header-h, 56px);
  /* NEVER overflow-x: hidden — breaks sticky. Use clip. */
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100dvh;
  /* Belt-and-braces overflow-x: clip on body (Sprint H — VP-002). */
  overflow-x: clip;
}

/* In-page anchored sections compensate for the sticky header height (Sprint H). */
[id] {
  scroll-margin-top: calc(var(--header-h, 56px) + var(--space-3));
}

/* Form inputs (Sprint H): ensure font-size >= 16px on mobile to prevent iOS
   focus-zoom (VP-007). Page-level inputs without their own class inherit this. */
input, textarea, select {
  font-size: max(16px, var(--text-base));
  font-family: var(--font-body);
}

/* --------------------------------------------------------------------------
   Selection
   -------------------------------------------------------------------------- */

::selection {
  background-color: var(--color-primary-highlight);
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Focus
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

/* Remove focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */

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

/* --------------------------------------------------------------------------
   Typography — Display (Zodiak: --text-xl and above)
   -------------------------------------------------------------------------- */

h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  text-wrap: balance;
}

h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  text-wrap: balance;
}

/* --------------------------------------------------------------------------
   Typography — Body (Satoshi: --text-lg and below)
   -------------------------------------------------------------------------- */

h3 {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-subhead);
  color: var(--color-text);
  text-wrap: balance;
}

h4 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: var(--leading-subhead);
  color: var(--color-text);
  text-wrap: balance;
}

p {
  max-width: 72ch;
  text-wrap: pretty;
}

li {
  text-wrap: pretty;
}

figcaption {
  max-width: 72ch;
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   Vertical Rhythm — Headings
   -------------------------------------------------------------------------- */

h1 + * { margin-top: var(--space-6); }
h2 + * { margin-top: var(--space-4); }
h3 + * { margin-top: var(--space-3); }
h4 + * { margin-top: var(--space-2); }

/* Space before headings (when they follow other content) */
* + h1 { margin-top: var(--space-16); }
* + h2 { margin-top: var(--space-12); }
* + h3 { margin-top: var(--space-8); }
* + h4 { margin-top: var(--space-6); }

/* --------------------------------------------------------------------------
   Vertical Rhythm — Block Elements
   -------------------------------------------------------------------------- */

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

ul, ol {
  padding-left: var(--space-6);
}

li + li {
  margin-top: var(--space-2);
}

blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--space-6);
  color: var(--color-text-muted);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--color-divider);
  margin: var(--space-12) 0;
}

/* --------------------------------------------------------------------------
   Links
   -------------------------------------------------------------------------- */

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
  transition: color var(--transition-interactive);
}

a:hover {
  color: var(--color-primary-hover);
}

a:active {
  color: var(--color-primary-active);
}

/* --------------------------------------------------------------------------
   Images & Media
   -------------------------------------------------------------------------- */

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

img {
  font-style: italic; /* Alt text styling */
}

/* --------------------------------------------------------------------------
   Tables (base — component tables in components.css)
   -------------------------------------------------------------------------- */

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

/* --------------------------------------------------------------------------
   Code
   -------------------------------------------------------------------------- */

code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  font-size: 0.9em;
  background-color: var(--color-surface-offset);
  padding: 0.15em 0.35em;
  border-radius: var(--radius-sm);
}

pre {
  background-color: var(--color-surface-offset);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Skip Link (accessibility)
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  z-index: 9999;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-4);
}

/* --------------------------------------------------------------------------
   Utility: Screen Reader Only
   -------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
