/* NOESIS site styles
 *
 * Accessibility targets:
 *  - WCAG AA contrast (>= 4.5:1 normal text, >= 3:1 large text and UI components).
 *  - Visible keyboard focus indicators on all interactive elements.
 *  - Respects prefers-reduced-motion.
 *  - Respects prefers-color-scheme.
 *  - Skip-to-main link visible on focus.
 *  - All interactive controls reachable by Tab.
 */

:root {
  /* Light theme. */
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-code: #f3f3f5;
  --fg: #1a1a1f;            /* 16.4:1 on --bg */
  --fg-muted: #4d4d56;      /* 8.2:1 on --bg */
  --fg-faint: #6b6b75;      /* 5.4:1 on --bg, still AA for normal text */
  --accent: #5b21b6;        /* purple, 7.1:1 on --bg */
  --accent-fg: #ffffff;
  --border: #d4d4d8;
  --border-strong: #a1a1aa;
  --focus-ring: #2563eb;    /* 4.7:1 on --bg, contrast ring */
  --ok: #15803d;
  --warn: #a16207;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 4px rgba(0, 0, 0, 0.04);

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
               Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono",
               "SF Mono", Menlo, Consolas, monospace;

  --content-max: 72ch;
  --wide-max: 96ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d10;
    --bg-elevated: #16161b;
    --bg-code: #1c1c22;
    --fg: #ececf0;            /* 16.7:1 on --bg */
    --fg-muted: #b4b4be;      /* 9.6:1 */
    --fg-faint: #8c8c98;      /* 5.5:1 */
    --accent: #a78bfa;        /* 9.0:1 on dark bg */
    --accent-fg: #1a0033;
    --border: #2a2a32;
    --border-strong: #404049;
    --focus-ring: #93c5fd;    /* 9.6:1 on dark bg */
    --ok: #4ade80;
    --warn: #fbbf24;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Skip link: visually hidden until focused. */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-fg);
  z-index: 100;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Focus styles — visible everywhere. */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* Page chrome. */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header__inner {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--fg);
  font-weight: 700;
}
.brand__mark {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.brand__name {
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.site-nav a {
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
}
.site-nav a:hover {
  color: var(--fg);
  background: var(--bg-code);
}
.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--bg-code);
}

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}
main.wide {
  max-width: var(--wide-max);
}

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-top: 2.5rem;
  margin-bottom: 0.875rem;
}
h1 { font-size: clamp(2rem, 4vw, 2.75rem); margin-top: 0; }
h2 { font-size: 1.5rem; margin-top: 3rem; }
h3 { font-size: 1.125rem; margin-top: 2rem; }
h4 { font-size: 1rem; margin-top: 1.5rem; }

p, ul, ol {
  margin: 0 0 1rem 0;
}

ul, ol { padding-left: 1.5rem; }
li + li { margin-top: 0.25rem; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-code);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-size: 0.875rem;
  line-height: 1.55;
}
pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* Hero. */
.hero {
  padding: 3.5rem 0 1rem;
}
.hero__eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
}
.hero__title {
  font-size: clamp(2.25rem, 5.5vw, 3.5rem);
  margin: 0 0 1rem;
}
.hero__tagline {
  font-size: 1.25rem;
  color: var(--fg-muted);
  margin: 0 0 2rem;
  max-width: 60ch;
}
.hero__cta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 80ms ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn--ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn--ghost:hover {
  background: var(--bg-code);
}

/* Card grid. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--accent);
}
.card p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--fg-muted);
}

/* Stat banner. */
.stat-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat {
  display: flex;
  flex-direction: column;
  min-width: 140px;
}
.stat__value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.stat__label {
  font-size: 0.8125rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.125rem;
}

/* Status pill. */
.pill {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}
.pill--ok    { color: var(--ok); }
.pill--warn  { color: var(--warn); }
.pill--info  { color: var(--accent); }

/* Tables. */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9375rem;
}
th, td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th {
  font-weight: 600;
  background: var(--bg-elevated);
  border-bottom-color: var(--border-strong);
}
tbody tr:hover { background: var(--bg-elevated); }

/* Component diagram (architecture page). */
.diagram {
  display: grid;
  gap: 0.75rem;
  margin: 2rem 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}
.diagram__row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}
.diagram__box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.75rem 1.125rem;
  min-width: 180px;
  text-align: center;
}
.diagram__box--accent {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.diagram__arrow {
  text-align: center;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  margin: 0.25rem 0;
}

footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  margin-top: 4rem;
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.875rem;
}
footer a { color: var(--fg-muted); }

/* Utility. */
.muted { color: var(--fg-muted); }
.lead { font-size: 1.125rem; color: var(--fg-muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
