/* ==========================================================================
   base.css
   - CSS custom properties (design tokens): colour, spacing, type, borders
   - A minimal reset
   - Base typography rules

   Colour VALUES live here as light-mode defaults. Dark mode overrides the
   same variable names in themes.css — nothing else needs to change when
   the theme switches.
   ========================================================================== */

:root {
  /* ---- Colour: light mode (default) ----
     Three text tiers: --color-text (primary), --color-text-secondary
     (descriptions, supporting copy), --color-text-muted (least
     prominent — status labels, footer). All three clear 4.5:1 against
     both --color-bg and --color-surface, and --color-accent clears
     4.5:1 as text on white, on the surface, and as a background behind
     white text — so links, buttons, the brand mark and status labels
     all pass WCAG AA. */
  --color-bg: #ffffff;
  --color-surface: #f7f7f8;
  --color-surface-hover: #f0f0f2;
  --color-text: #18181b;
  --color-text-secondary: #71717a;
  --color-text-muted: #6f6f78;
  --color-border: #e4e4e7;
  --color-accent: #4f46e5;
  --color-accent-hover: #4338ca;
  --color-accent-soft: #eef2ff;      /* subtle accent-tinted background */
  --color-accent-contrast: #ffffff;  /* text placed on top of accent */
  --color-danger: #dc2626;           /* validation errors */

  /* ---- Shadow: minimal, used sparingly ---- */
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.06);

  /* ---- Spacing scale (rem-based, 4px root step) ---- */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-7: 3rem;      /* 48px */
  --space-8: 4rem;      /* 64px */

  /* ---- Borders ---- */
  --radius-sm: 3px;
  --radius-md: 6px;
  --border-width: 1px;

  /* ---- Typography ---- */
  --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --text-xs: 0.8125rem;   /* 13px */
  --text-sm: 0.9375rem;   /* 15px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.375rem;    /* 22px */
  --text-2xl: 1.75rem;    /* 28px */
  --text-3xl: 2.25rem;    /* 36px */

  --line-height-tight: 1.25;
  --line-height-normal: 1.55;

  /* ---- Layout ---- */
  --content-max-width: 72rem;   /* 1152px */
  --text-max-width: 42rem;      /* keeps prose readable */
}

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

html,
body {
  margin: 0;
  padding: 0;
}

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

ul,
ol {
  margin: 0;
  padding: 0;
}

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

a {
  color: inherit;
}

/* ---- Base typography ---- */
html {
  /* Respect the OS colour scheme until the user picks one explicitly.
     theme-toggle.js sets data-theme once a choice is made/stored. */
  color-scheme: light dark;
}

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

h1,
h2,
h3 {
  font-weight: 600;
  line-height: var(--line-height-tight);
  margin: 0 0 var(--space-3) 0;
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

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

code,
.mono {
  font-family: var(--font-mono);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Accessible focus state (used everywhere, not just links) ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

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