/* =========================================================
   DSI Design System — Foundations
   Colors, Type, Spacing, Radii, Shadows, Motion
   ========================================================= */

/* ---- Fonts (Google Fonts — UW brand fonts + JetBrains Mono) ---- */
@import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@400;500;700;900&family=Red+Hat+Text:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ---------------------------------------------------------
     COLORS
     --------------------------------------------------------- */

  /* ---------------------------------------------------------
     UW–Madison canonical palette (preserved exactly).
     These are the source-of-truth names used in audits + brand
     compliance. All other red/black/gray tokens alias to these.
     --------------------------------------------------------- */
  --uw-red:       #C5050C;   /* Badger Red — primary action, accents */
  --uw-red-dark:  #9B0000;   /* Crimson — hover, focus rings on red */
  --uw-gray:      #E1E5E7;   /* UW neutral gray */
  --uw-black:     #121212;   /* UW black */
  --uw-white:     #FFFFFF;

  /* Aliases (DSI vocabulary → UW canonical) */
  --badger-red: var(--uw-red);
  --crimson:    var(--uw-red-dark);

  /* DSI neutrals — warm, paper-leaning.
     NOTE: --ink-soft and --ink-mute were darkened from earlier
     drafts to clear WCAG 2.1 AA (4.5:1) on bone AND cream.
     Verified with WebAIM contrast checker. */
  --ink:        #1C1A19;   /* primary text · 14.9:1 on bone */
  --ink-soft:   #3D3A37;   /* secondary text · 8.7:1 on bone, 8.0:1 on cream */
  --ink-mute:   #5E5852;   /* tertiary text · 5.4:1 on bone, 4.9:1 on cream — meets AA */
  --bone:       #F7F3EC;   /* default page background */
  --cream:      #EFE7D6;   /* sections, sub-brand fills */
  --mist:       #D7D1C4;   /* borders, dividers */
  --paper:      #FBF9F4;   /* slightly lifted bone */
  --white:      #FFFFFF;   /* card surfaces */

  /* DSI accents — restrained */
  --slate:      #2E4756;   /* cool counterweight, links on light */
  --slate-soft: #5C7785;   /* hover state for slate */
  --wheat:      #C9A227;   /* single warm highlight */
  --moss:       #59833A;   /* UW secondary green — used for env/sustainability tags only */

  /* Semantic */
  --fg-1:       var(--ink);
  --fg-2:       var(--ink-soft);
  --fg-3:       var(--ink-mute);
  --fg-on-red:  var(--white);
  --bg:         var(--bone);
  --bg-elev:    var(--white);
  --bg-section: var(--cream);
  --border:     var(--mist);
  --border-strong: #B8B0A0;
  --link:       var(--slate);
  --link-hover: var(--ink);
  --accent:     var(--badger-red);
  --accent-hover: var(--crimson);
  --success:    var(--moss);
  --warning:    #B07700;
  --danger:     var(--badger-red);
  --info:       var(--slate);

  /* ---------------------------------------------------------
     TYPOGRAPHY
     --------------------------------------------------------- */
  --font-display: 'Red Hat Display', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:    'Red Hat Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Type scale — modular ratio 1.25 (major third), base 18 */
  --fs-12: 0.75rem;     /* 12px — eyebrow, micro */
  --fs-14: 0.875rem;    /* 14px — captions, tags */
  --fs-16: 1rem;        /* 16px — small body */
  --fs-18: 1.125rem;    /* 18px — body */
  --fs-20: 1.25rem;     /* 20px — lead, large body */
  --fs-24: 1.5rem;      /* 24px — h4 */
  --fs-30: 1.875rem;    /* 30px — h3 */
  --fs-36: 2.25rem;     /* 36px — h2 */
  --fs-48: 3rem;        /* 48px — h1 */
  --fs-60: 3.75rem;     /* 60px — display sm */
  --fs-72: 4.5rem;      /* 72px — display md */
  --fs-96: 6rem;        /* 96px — display lg, hero */

  /* Line heights */
  --lh-tight:   1.05;
  --lh-snug:    1.15;
  --lh-normal:  1.4;
  --lh-relaxed: 1.55;
  --lh-loose:   1.65;

  /* Letter-spacing */
  --tracking-tight:  -0.02em;
  --tracking-normal:  0;
  --tracking-wide:    0.02em;
  --tracking-eyebrow: 0.12em;

  /* ---------------------------------------------------------
     SPACING — 8px base unit
     --------------------------------------------------------- */
  --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;

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

  /* ---------------------------------------------------------
     SHADOWS
     --------------------------------------------------------- */
  --shadow-sm: 0 1px 2px rgba(28, 26, 25, 0.06);
  --shadow-md: 0 4px 16px rgba(28, 26, 25, 0.08), 0 1px 2px rgba(28, 26, 25, 0.04);
  --shadow-lg: 0 12px 32px rgba(28, 26, 25, 0.10), 0 2px 6px rgba(28, 26, 25, 0.05);

  /* ---------------------------------------------------------
     MOTION
     --------------------------------------------------------- */
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 280ms;

  /* ---------------------------------------------------------
     LAYOUT
     --------------------------------------------------------- */
  --container: 1200px;
  --gutter: 32px;
  --gutter-sm: 20px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
  }
}

/* =========================================================
   BASE / RESET
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-18);
  line-height: var(--lh-loose);
  color: var(--fg-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* =========================================================
   TYPOGRAPHY ELEMENTS
   ========================================================= */
.display-lg, .display-md, .display-sm,
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--fg-1);
  margin: 0;
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

.display-lg { font-size: clamp(3.5rem, 7vw, var(--fs-96)); font-weight: 900; }
.display-md { font-size: clamp(3rem, 6vw, var(--fs-72)); font-weight: 900; }
.display-sm { font-size: clamp(2.5rem, 5vw, var(--fs-60)); }

h1 { font-size: var(--fs-48); }
h2 { font-size: var(--fs-36); line-height: var(--lh-snug); }
h3 { font-size: var(--fs-30); line-height: var(--lh-snug); letter-spacing: -0.01em; }
h4 { font-size: var(--fs-24); line-height: var(--lh-snug); letter-spacing: 0; font-weight: 500; }
h5 { font-size: var(--fs-20); line-height: var(--lh-normal); letter-spacing: 0; font-weight: 500; }
h6 { font-size: var(--fs-16); line-height: var(--lh-normal); letter-spacing: var(--tracking-wide); font-weight: 700; text-transform: uppercase; }

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

.eyebrow {
  font-family: var(--font-display);
  font-size: var(--fs-12);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--fg-2);
}

.lead {
  font-size: var(--fs-20);
  line-height: var(--lh-relaxed);
  color: var(--fg-2);
}

.caption {
  font-size: var(--fs-14);
  color: var(--fg-3);
  line-height: var(--lh-normal);
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}
code { background: var(--cream); padding: 2px 6px; border-radius: var(--radius-sm); color: var(--ink); }
pre { background: var(--cream); padding: var(--space-5); border-radius: var(--radius-md); overflow-x: auto; }
pre code { background: transparent; padding: 0; }

/* Links — always underlined in flowing text (axe link-in-text-block) */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-thickness var(--dur-base) var(--ease-out);
}
a:hover { text-decoration-thickness: 2px; color: var(--link-hover); }

/* =========================================================
   FOCUS RINGS — UW red, 2px solid, 2px offset.
   Every interactive element gets one. On red surfaces the ring
   uses --uw-red-dark for separation.
   ========================================================= */
:focus-visible {
  outline: 2px solid var(--uw-red);
  outline-offset: 2px;
  border-radius: 2px;
}
.on-red :focus-visible,
[data-on-red] :focus-visible,
.btn-primary:focus-visible {
  outline-color: var(--uw-red-dark);
}

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

/* Tabular numerals for data */
.tabular { font-variant-numeric: tabular-nums; }

/* =========================================================
   ACCESSIBILITY HELPERS
   ========================================================= */

/* Skip-to-content link — visually hidden until focused.
   Required on every page. Targets <main id="main" tabindex="-1">. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 10000;
  background: var(--uw-red);
  color: var(--uw-white);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { left: 16px; outline: 2px solid var(--uw-red-dark); outline-offset: 2px; }

/* Visually hidden but available to screen readers */
.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Disabled state — see rule 4 + 13: keep focusable for aria-describedby */
[disabled], [aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Required-field marker */
.required-mark { color: var(--uw-red); margin-left: 2px; }

/* Validation error message */
[role="alert"].field-error {
  display: block;
  margin-top: var(--space-2);
  color: var(--uw-red-dark);
  font-size: var(--fs-14);
  font-weight: 500;
}
[aria-invalid="true"] {
  border-color: var(--uw-red) !important;
  box-shadow: 0 0 0 1px var(--uw-red);
}

/* =========================================================
   UTILITY: container
   ========================================================= */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
@media (max-width: 768px) {
  .container { padding: 0 var(--gutter-sm); }
}
