/* Base: reset, typography, layout primitives, focus, motion. No raw colours here. */

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

html {
  background: var(--color-background);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: var(--leading-normal);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(60rem 40rem at 20% -10%, var(--tint-active), transparent 60%),
    var(--color-background);
  overflow-x: hidden;
}

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

svg.icon {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  vertical-align: -0.15em;
}

/* ---- typography --------------------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  line-height: var(--leading-tight);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p,
ul,
ol,
dl,
pre,
table {
  margin: 0 0 var(--space-4);
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--color-border-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

a:hover {
  color: var(--color-accent-active);
  text-decoration-color: currentcolor;
}

code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

pre {
  padding: var(--space-4);
  overflow-x: auto;
  background: var(--color-background-deep);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  line-height: 1.5;
}

code:not(pre code) {
  padding: 0.1em 0.35em;
  background: var(--tint-muted);
  border-radius: var(--radius-sm);
}

kbd {
  padding: 0.05em 0.4em;
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th,
td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}

th {
  color: var(--color-text-secondary);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.eyebrow--active { color: var(--color-accent-active); }

.muted { color: var(--color-text-muted); }
.secondary { color: var(--color-text-secondary); }
.measure { max-width: var(--measure); }
.small { font-size: var(--text-sm); }
.nowrap { white-space: nowrap; }

/* ---- rendered markdown ----------------------------------------------------------- */

.prose {
  max-width: var(--measure);
  color: var(--color-text-secondary);
}

.prose p,
.prose li { font-size: var(--text-base); }
.prose strong { color: var(--color-text-primary); font-weight: 600; }
.prose h3 { margin-top: var(--space-5); }
.prose ul { padding-left: 1.2em; }
.prose li + li { margin-top: var(--space-2); }
.prose table { display: block; overflow-x: auto; }
.prose pre { font-size: var(--text-sm); }

/* ---- layout primitives ---------------------------------------------------------- */

.container {
  width: min(100% - 2 * var(--space-4), var(--container));
  margin-inline: auto;
}

.stack > * + * { margin-top: var(--stack-gap, var(--space-4)); }
.stack-lg { --stack-gap: var(--space-6); }
.stack-sm { --stack-gap: var(--space-2); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cluster-gap, var(--space-2));
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min, 18rem), 100%), 1fr));
  gap: var(--grid-gap, var(--space-4));
}

.scroll-x {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.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;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-palette);
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent-active);
  color: var(--color-text-inverse);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

/* ---- focus ---------------------------------------------------------------------- */

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

/* ---- motion --------------------------------------------------------------------- */

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes trace {
  to { stroke-dashoffset: 0; }
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes pulse-evidence {
  0%, 100% { box-shadow: 0 0 0 0 var(--tint-active); }
  50% { box-shadow: 0 0 0 6px var(--tint-active); }
}

.reveal { animation: reveal var(--dur-slow) var(--ease-out) both; }
.reveal--1 { animation-delay: 60ms; }
.reveal--2 { animation-delay: 120ms; }
.reveal--3 { animation-delay: 180ms; }
.reveal--4 { animation-delay: 240ms; }
.slide-in { animation: slide-in var(--dur-base) var(--ease-out) both; }
.fade { animation: fade var(--dur-base) var(--ease) both; }

.trace {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: trace var(--dur-trace) var(--ease-out) forwards;
}

.cursor::after {
  content: "\2588";
  margin-left: 0.15em;
  color: var(--color-accent-active);
  animation: blink 1s steps(1) infinite;
}

.evidence-highlight { animation: pulse-evidence 1.6s var(--ease) 2; }

@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;
  }

  .trace { stroke-dashoffset: 0; }
  .cursor::after { animation: none; }
}
