/* ==========================================================================
   Langsplain — shared design system
   Warm paper, full-palette toy shop. See DESIGN.md.
   ========================================================================== */

:root {
  /* Surfaces & ink */
  --paper: oklch(0.97 0.008 85);
  --paper-deep: oklch(0.94 0.012 85);
  --ink: oklch(0.24 0.015 75);
  --ink-soft: oklch(0.45 0.015 75);
  --ink-faint: oklch(0.62 0.012 75);
  --line: oklch(0.86 0.015 80);

  /* Palette roles — consistent meaning across every demo:
     cobalt = input/query · coral = weight/attention · mint = output/prediction
     marigold = the thing under your finger */
  --coral: oklch(0.66 0.19 25);
  --cobalt: oklch(0.52 0.19 262);
  --marigold: oklch(0.8 0.16 80);
  --mint: oklch(0.72 0.13 165);

  /* Tints for chips and demo surfaces */
  --coral-tint: oklch(0.93 0.04 25);
  --cobalt-tint: oklch(0.93 0.035 262);
  --marigold-tint: oklch(0.95 0.05 85);
  --mint-tint: oklch(0.94 0.04 165);

  /* Darker variants for text-on-tint (AA) */
  --coral-deep: oklch(0.5 0.18 25);
  --cobalt-deep: oklch(0.42 0.17 262);
  --marigold-deep: oklch(0.55 0.13 80);
  --mint-deep: oklch(0.47 0.11 165);

  /* Type */
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 180ms;
  --t-med: 320ms;
  --t-slow: 560ms;

  /* Shape */
  --r-chip: 10px;
  --r-stage: 20px;
  --border-toy: 2px solid var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Typography ---------- */

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); font-weight: 800; }
h2 { font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 750; }
h3 { font-size: clamp(1.15rem, 2.4vw, 1.4rem); font-weight: 700; }

p { max-width: 68ch; }
a { color: var(--cobalt-deep); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--coral); }
strong { font-weight: 700; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

::selection { background: var(--marigold); color: var(--ink); }

:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Page scaffold ---------- */

.wrap { width: min(100% - 3rem, 72rem); margin-inline: auto; }
.prose { width: min(100% - 3rem, 42rem); margin-inline: auto; }
.prose p + p { margin-top: 1em; }

/* Top nav */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
}
.site-nav .brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.site-nav .brand .dot { color: var(--coral); }
.site-nav .nav-links { display: flex; gap: 1.25rem; font-size: 0.95rem; }
.site-nav .nav-links a { color: var(--ink-soft); text-decoration: none; font-weight: 600; }
.site-nav .nav-links a:hover { color: var(--ink); }

/* Chapter header */
.chapter-head { padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(1.5rem, 4vw, 2.5rem); }
.chapter-head .kicker {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 0.9rem;
}
.chapter-head .kicker b { color: var(--coral); font-weight: 600; }
.chapter-head .lede {
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  color: var(--ink-soft);
  margin-top: 1.1rem;
  max-width: 46ch;
}

/* Section rhythm */
.section { padding-block: clamp(2rem, 6vw, 4rem); }
.section + .section { border-top: 1px solid var(--line); }

/* ---------- Demo stage ---------- */

.stage {
  background: oklch(0.985 0.006 85);
  border: var(--border-toy);
  border-radius: var(--r-stage);
  overflow: hidden;
  margin-block: clamp(1.5rem, 4vw, 2.5rem);
}
.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-deep);
}
.stage-bar .stage-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}
.stage-body { padding: clamp(1rem, 3vw, 2rem); }
.stage-body.flush { padding: 0; }

/* ---------- Controls ---------- */

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
  border: var(--border-toy);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.btn:hover { background: var(--marigold-tint); transform: translateY(-1px); box-shadow: 0 3px 0 var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--coral); color: oklch(0.98 0.01 25); }
.btn.primary:hover { background: var(--coral-deep); }
.btn.small { font-size: 0.82rem; padding: 0.3rem 0.85rem; }

/* Chunky slider */
.knob { display: grid; gap: 0.35rem; min-width: 0; }
.knob-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.88rem;
  font-weight: 700;
}
.knob-label .value { font-family: var(--font-mono); font-weight: 500; color: var(--ink-soft); }
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--paper-deep);
  border: 2px solid var(--ink);
  cursor: grab;
}
input[type="range"]:active { cursor: grabbing; }
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--marigold);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  transition: transform var(--t-fast) var(--ease-out);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--marigold);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}

/* Segmented control */
.seg { display: inline-flex; border: var(--border-toy); border-radius: 999px; overflow: hidden; background: var(--paper); }
.seg button {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.35rem 0.95rem;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.seg button + button { border-left: 2px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- Token chip: the atomic unit ---------- */

.token {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 0.3rem 0.6rem;
  border: var(--border-toy);
  border-radius: var(--r-chip);
  background: var(--paper);
  white-space: pre;
  transition: background var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.token.input { background: var(--cobalt-tint); }
.token.weight { background: var(--coral-tint); }
.token.output { background: var(--mint-tint); }
.token.active { background: var(--marigold); box-shadow: 0 3px 0 var(--ink); transform: translateY(-2px); }
button.token { cursor: pointer; }
button.token:hover { background: var(--marigold-tint); }

.token-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ---------- Footer / chapter pager ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: clamp(2rem, 5vw, 3.5rem);
  border-top: 2px solid var(--ink);
  margin-top: clamp(2rem, 6vw, 4rem);
}
.pager a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  display: grid;
  gap: 0.2rem;
}
.pager a .dir { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 500; color: var(--ink-soft); }
.pager a:hover { color: var(--coral); }
.pager .next { text-align: right; margin-left: auto; }

.site-footer {
  padding: 1.5rem 0 2.5rem;
  color: var(--ink-faint);
  font-size: 0.88rem;
}
.site-footer a { color: var(--ink-soft); }

/* ---------- Utilities ---------- */

.controls-row { display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; align-items: end; margin-top: 1.25rem; }
.controls-row .knob { flex: 1 1 200px; max-width: 320px; }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
.legend .swatch {
  display: inline-block;
  width: 0.75em; height: 0.75em;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  margin-right: 0.4em;
  vertical-align: baseline;
}

.hint { font-size: 0.88rem; color: var(--ink-soft); }
.hint::before { content: "↳ "; color: var(--coral); }

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