/* CASCADE site styles.
 *
 * Accessibility constraints honored:
 *   - WCAG 2.1 AA color contrast (≥ 4.5:1 body, ≥ 3:1 large text and UI).
 *   - Visible focus indicators on all interactive elements (no outline: none).
 *   - System font stack — no external font downloads (CSP-friendly, fast,
 *     respects user font-size).
 *   - Honors prefers-color-scheme (light/dark) and prefers-reduced-motion.
 *   - Relative units (rem, em, ch) so the user's browser font-size scales.
 *   - Min 44×44 px touch targets for interactive elements.
 */

/* ---------- color tokens (light theme default) ---------- */
:root {
  /* On a light surface, gray-900 text on white = 19.5:1 (AAA) */
  --bg:        #ffffff;
  --bg-soft:   #f6f7f9;
  --bg-code:   #f1f3f5;
  --fg:        #1a1f2c;       /* near-black */
  --fg-muted:  #4a5160;       /* mid-gray, 7.3:1 on white = AAA */
  --link:      #0a4a91;       /* deep blue, 8.6:1 on white = AAA */
  --link-hov:  #062f5c;
  --rule:      #d6d9de;
  --accent:    #0f6d3d;       /* deep green for status pass */
  --warn:      #8a4b00;       /* deep amber, 5.4:1 on white = AA */
  --fail:      #a50e1a;       /* deep red, 6.2:1 on white = AA */
  --code-num:  #1a4380;
  --code-key:  #5a1078;
  --code-str:  #a04600;
  --focus:     #0066ff;
  --focus-bg:  #ffe066;       /* high-vis yellow band behind focused text */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e1218;
    --bg-soft:   #161b24;
    --bg-code:   #1c2230;
    --fg:        #e6e9ef;     /* 17:1 on bg = AAA */
    --fg-muted:  #aeb6c4;     /* 9.7:1 on bg = AAA */
    --link:      #7ab7ff;     /* 9.9:1 on bg = AAA */
    --link-hov:  #b6d9ff;
    --rule:      #2a313e;
    --accent:    #66d39c;
    --warn:      #f0c47a;
    --fail:      #f7888d;
    --code-num:  #9ec3ff;
    --code-key:  #d8a7ff;
    --code-str:  #f0c181;
    --focus:     #ffe066;
    --focus-bg:  #2c2400;
  }
}

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

html {
  font-size: 100%;
  /* Smooth scroll only when user hasn't requested reduced motion. */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;       /* 17px base, large enough for low-vision users */
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

/* ---------- skip link (a11y) ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--bg);
  color: var(--link);
  padding: 0.75rem 1rem;
  text-decoration: underline;
  font-weight: 600;
  z-index: 1000;
  border: 2px solid var(--focus);
}
.skip-link:focus {
  top: 0;
}

/* ---------- focus ---------- */
:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  background-color: var(--focus-bg);
  border-radius: 2px;
}

/* ---------- layout ---------- */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg-soft);
}
.site-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.site-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}
.site-title a {
  color: var(--fg);
  text-decoration: none;
}
.site-title a:hover { color: var(--link); text-decoration: underline; }

.primary-nav {
  margin-left: auto;
}
.primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.primary-nav a {
  display: inline-block;
  padding: 0.625rem 0.875rem;
  color: var(--fg);
  text-decoration: none;
  border-radius: 4px;
  min-height: 44px;
  line-height: 1.4;
}
.primary-nav a:hover { background: var(--bg); color: var(--link); text-decoration: underline; }
.primary-nav a[aria-current="page"] {
  font-weight: 700;
  color: var(--link);
  background: var(--bg);
  text-decoration: underline;
  text-underline-offset: 4px;
}

main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ---------- typography ---------- */
h1, h2, h3, h4 { line-height: 1.25; margin-top: 2rem; }
h1 { font-size: 2.0rem; margin-top: 1rem; }
h2 { font-size: 1.5rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }
p, ul, ol { margin: 1em 0; }
li { margin: 0.25em 0; }
.lead { font-size: 1.1875rem; color: var(--fg-muted); }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover { color: var(--link-hov); text-decoration-thickness: 2px; }

strong { font-weight: 700; }
em { font-style: italic; }

/* External link indicator (uses CSS only, no images — screen-reader text below) */
a[rel~="external"]::after {
  content: " \2197"; /* north-east arrow */
  font-size: 0.85em;
}

abbr[title] { text-decoration: underline dotted; cursor: help; }

/* ---------- code ---------- */
code, pre, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
  font-size: 0.9375em;
}
p code, li code {
  background: var(--bg-code);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
pre {
  background: var(--bg-code);
  color: var(--fg);
  padding: 1rem 1.125rem;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

/* ---------- tables ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.25rem 0;
  font-size: 0.9375rem;
}
caption {
  text-align: left;
  font-style: italic;
  color: var(--fg-muted);
  padding-bottom: 0.5em;
}
th, td {
  text-align: left;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-weight: 700;
  background: var(--bg-soft);
  border-bottom: 2px solid var(--rule);
}
tbody tr:hover { background: var(--bg-soft); }

/* ---------- callouts ---------- */
.callout {
  border-left: 4px solid var(--link);
  background: var(--bg-soft);
  padding: 1rem 1.125rem;
  margin: 1.25rem 0;
  border-radius: 0 4px 4px 0;
}
.callout-title {
  font-weight: 700;
  margin: 0 0 0.5em;
}
.callout-warn { border-left-color: var(--warn); }
.callout-pass { border-left-color: var(--accent); }

/* ---------- status pills (used in tables and inline) ---------- */
.pill {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  border: 1px solid currentColor;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.pill-pass { color: var(--accent); }
.pill-pending { color: var(--warn); }
.pill-fail { color: var(--fail); }
.pill-info { color: var(--link); }

/* Use icons + text together; never color alone, per WCAG 1.4.1. */
.pill::before {
  display: inline-block;
  margin-right: 0.35em;
  font-weight: 700;
}
.pill-pass::before    { content: "\2713";   /* check  */ }
.pill-pending::before { content: "\22EF";   /* horizontal ellipsis */ }
.pill-fail::before    { content: "\2715";   /* cross  */ }
.pill-info::before    { content: "\2139";   /* info i */ }

/* ---------- definition-style key/value lists ---------- */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.25rem;
  margin: 1rem 0;
  font-size: 0.9375rem;
}
.kv dt { font-weight: 600; color: var(--fg-muted); }
.kv dd { margin: 0; }

/* ---------- hero on landing ---------- */
.hero {
  text-align: left;
  margin: 1.5rem 0 2.5rem;
}
.hero h1 { font-size: 2.25rem; margin: 0 0 0.5rem; }
.hero .tagline {
  font-size: 1.25rem;
  color: var(--fg-muted);
  margin: 0 0 1.25rem;
  max-width: 50ch;
}
.hero .codename {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  padding: 0.15em 0.5em;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--bg-soft);
  margin-top: 4rem;
}
.site-footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: baseline;
  justify-content: space-between;
}
.site-footer a { color: var(--fg-muted); }
.site-footer a:hover { color: var(--link); }

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

/* ---------- responsive tweaks ---------- */
@media (max-width: 40rem) {
  .site-header-inner { gap: 0.5rem; }
  .primary-nav { margin-left: 0; width: 100%; }
  .primary-nav ul { gap: 0; }
  .primary-nav a { padding: 0.625rem 0.75rem; }
  h1 { font-size: 1.75rem; }
  .hero h1 { font-size: 1.875rem; }
  main { padding: 1.25rem 1rem 3rem; }
}

/* Hide noisy decorations for print */
@media print {
  .site-header, .site-footer, .skip-link { display: none; }
  a { color: black; text-decoration: underline; }
  pre { white-space: pre-wrap; }
}
