/* ==========================================================================
   base.css — Design tokens + reset for measuredstrength.com/gear
   Art direction: warm editorial, evidence-forward, physical/scientific
   Palette: aged paper cream + iron blue accent + oxblood highlight
   ========================================================================== */

:root,
[data-theme='light'] {
  /* Type scale — fluid, clamped */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Spacing — 4px system */
  --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;
  --space-32: 8rem;

  /* Surfaces — warm cream, aged-paper feel */
  --color-bg: #f5f1e8;
  --color-surface: #faf6ec;
  --color-surface-2: #fdfaf1;
  --color-surface-offset: #ede7d7;
  --color-surface-offset-2: #e4dcc7;
  --color-divider: #d9d0b8;
  --color-border: #c9bfa4;

  /* Text — deep warm charcoal */
  --color-text: #1f1a12;
  --color-text-muted: #6b6353;
  --color-text-faint: #a89e88;
  --color-text-inverse: #faf6ec;

  /* Primary accent — iron blue, evidence/instrument tone */
  --color-primary: #2b4a6f;
  --color-primary-hover: #1e3654;
  --color-primary-active: #14243b;
  --color-primary-highlight: #d3dae6;

  /* Highlight accent — oxblood, used sparingly for emphasis */
  --color-accent: #7a2e1f;
  --color-accent-hover: #601f13;
  --color-accent-highlight: #e8d0c9;

  /* Success — restrained forest, for the recommended-pick tags */
  --color-success: #3d6a3a;
  --color-success-highlight: #d4dfd0;

  /* Radii */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows — warm-toned to match surfaces */
  --shadow-sm: 0 1px 2px oklch(0.2 0.03 60 / 0.08);
  --shadow-md: 0 4px 14px oklch(0.2 0.03 60 / 0.1);
  --shadow-lg: 0 16px 40px oklch(0.2 0.03 60 / 0.14);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1180px;

  /* Fonts */
  --font-display: 'Fraunces', 'Georgia', 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

/* Dark mode */
[data-theme='dark'] {
  --color-bg: #12100c;
  --color-surface: #1a1712;
  --color-surface-2: #1f1c16;
  --color-surface-offset: #24201a;
  --color-surface-offset-2: #2a2620;
  --color-divider: #2d2924;
  --color-border: #3d3830;
  --color-text: #ebe3d0;
  --color-text-muted: #948a75;
  --color-text-faint: #5d5648;
  --color-text-inverse: #1a1712;
  --color-primary: #7fa4c9;
  --color-primary-hover: #a4bfd9;
  --color-primary-active: #bcd0e2;
  --color-primary-highlight: #2a3648;
  --color-accent: #c66a54;
  --color-accent-hover: #d88872;
  --color-accent-highlight: #4a2a20;
  --color-success: #7aa274;
  --color-success-highlight: #2b3a2a;
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 14px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.5);
}

/* System-preference fallback (before user toggles) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #12100c;
    --color-surface: #1a1712;
    --color-surface-2: #1f1c16;
    --color-surface-offset: #24201a;
    --color-surface-offset-2: #2a2620;
    --color-divider: #2d2924;
    --color-border: #3d3830;
    --color-text: #ebe3d0;
    --color-text-muted: #948a75;
    --color-text-faint: #5d5648;
    --color-text-inverse: #1a1712;
    --color-primary: #7fa4c9;
    --color-primary-hover: #a4bfd9;
    --color-primary-active: #bcd0e2;
    --color-primary-highlight: #2a3648;
    --color-accent: #c66a54;
    --color-accent-hover: #d88872;
    --color-accent-highlight: #4a2a20;
    --color-success: #7aa274;
    --color-success-highlight: #2b3a2a;
  }
}

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

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

ul[role='list'],
ol[role='list'] {
  list-style: none;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
  line-height: 1.1;
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--color-text);
}

p,
li,
figcaption,
dd {
  text-wrap: pretty;
}

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

::selection {
  background: oklch(from var(--color-primary) l c h / 0.22);
  color: var(--color-text);
}

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

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a,
button,
[role='button'],
input,
textarea,
select {
  transition:
    color var(--transition-interactive),
    background var(--transition-interactive),
    border-color var(--transition-interactive),
    box-shadow var(--transition-interactive),
    transform var(--transition-interactive);
}

/* 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-width: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-5);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-md) 0;
}

.skip-link:focus {
  left: 0;
  color: var(--color-text-inverse);
}

/* Anchor offset target for scroll-to-section from sticky header */
.anchor-target {
  position: relative;
  top: calc(-1 * var(--space-16));
}
