/* ------------------------------------------------------------------
   clustertrial.app — static content layer
   Palette is taken from the calculator's own semantics: slate = control,
   emerald = intervention, blue = action. The design grid is the signature.
   ------------------------------------------------------------------ */

:root {
  --ink:        #0f172a;
  --ink-soft:   #334155;
  --muted:      #64748b;
  --faint:      #94a3b8;
  --rule:       #e2e8f0;
  --surface:    #f8fafc;
  --paper:      #ffffff;

  --control:      #e2e8f0;
  --control-line: #cbd5e1;
  --arm:          #d1fae5;
  --arm-line:     #34d399;
  --arm-ink:      #065f46;
  --off:          #fbfcfd;
  --off-line:     #eef2f6;

  --accent:      #2563eb;
  --accent-dark: #1d4ed8;
  --warn:        #b45309;

  --display: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --body:    "Inter", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  --measure: 68ch;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-soft);
  background: var(--paper);
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
}

/* ---------- nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.nav__mark {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.nav__mark::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 0.5rem;
  border-radius: 2px;
  background: var(--arm);
  border: 1.5px solid var(--arm-line);
  vertical-align: baseline;
}

.nav__links { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: center; }

.nav__links a {
  font-size: 0.86rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 1.5px solid transparent;
}
.nav__links a:hover { color: var(--ink); border-bottom-color: var(--arm-line); }
.nav__links a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--arm-line); }

.nav__cta {
  margin-left: auto;
  font-family: var(--body);
  font-size: 0.84rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  padding: 0.4rem 0.9rem;
  border-radius: 7px;
  text-decoration: none;
  white-space: nowrap;
}
.nav__cta:hover { background: var(--accent-dark); }

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1.5rem; }

.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  padding: 3.5rem 0 5rem;
}

@media (min-width: 1000px) {
  .page.page--railed { grid-template-columns: 200px minmax(0, 1fr); }
}

.rail { display: none; }
@media (min-width: 1000px) {
  .rail {
    display: block;
    position: sticky;
    top: 5rem;
    align-self: start;
    font-size: 0.83rem;
    line-height: 1.5;
  }
}
.rail__title {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  margin: 0 0 0.85rem;
}
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail li { margin-bottom: 0.55rem; }
.rail a {
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid var(--rule);
  padding-left: 0.7rem;
  display: block;
}
.rail a:hover { color: var(--ink); border-left-color: var(--arm-line); }

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

/* ---------- type ---------- */

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--faint);
  margin: 0 0 0.9rem;
}

h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2rem, 4.2vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.018em;
  color: var(--ink);
  margin: 0 0 1.1rem;
}

h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 3rem 0 1rem;
  scroll-margin-top: 5rem;
}

h3 {
  font-family: var(--body);
  font-weight: 600;
  font-size: 1.03rem;
  color: var(--ink);
  margin: 2rem 0 0.6rem;
  scroll-margin-top: 5rem;
}

.lede {
  font-size: 1.16rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 2rem;
}

p { margin: 0 0 1.1rem; }

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

ul, ol { margin: 0 0 1.2rem; padding-left: 1.3rem; }
li { margin-bottom: 0.5rem; }

code, .param {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.08em 0.34em;
  color: var(--ink);
}

strong { color: var(--ink); font-weight: 600; }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

/* ---------- signature: the allocation grid ---------- */

.grid-fig {
  margin: 0 0 2rem;
  padding: 1.4rem 1.5rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.grid-fig svg { display: block; max-width: 100%; height: auto; }
.grid-fig figcaption {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 1rem;
  line-height: 1.5;
}

.cell-c { fill: var(--control);  stroke: var(--control-line); }
.cell-i { fill: var(--arm);      stroke: var(--arm-line); }
.cell-o { fill: var(--off);      stroke: var(--off-line); }
.cell-c, .cell-i, .cell-o { stroke-width: 1.5; rx: 5; }

.axis-label {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--faint);
}
.cell-glyph { font-family: var(--mono); font-size: 10px; fill: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .grid-fig--animate .cell-c,
  .grid-fig--animate .cell-i,
  .grid-fig--animate .cell-o {
    opacity: 0;
    animation: cellIn 0.42s ease-out forwards;
  }
  .grid-fig--animate rect:nth-of-type(5n+1) { animation-delay: 0.02s; }
  .grid-fig--animate rect:nth-of-type(5n+2) { animation-delay: 0.08s; }
  .grid-fig--animate rect:nth-of-type(5n+3) { animation-delay: 0.14s; }
  .grid-fig--animate rect:nth-of-type(5n+4) { animation-delay: 0.20s; }
  .grid-fig--animate rect:nth-of-type(5n+5) { animation-delay: 0.26s; }
}
@keyframes cellIn { to { opacity: 1; } }

.legend {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.9rem;
}
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i {
  width: 11px; height: 11px; border-radius: 3px;
  display: inline-block; border: 1.5px solid;
}
.legend .k-c { background: var(--control); border-color: var(--control-line); }
.legend .k-i { background: var(--arm);     border-color: var(--arm-line); }
.legend .k-o { background: var(--off);     border-color: var(--off-line); }

/* ---------- hero ---------- */

.hero { padding: 4rem 0 2.5rem; }
@media (min-width: 900px) {
  .hero__inner { display: grid; grid-template-columns: 1fr 1fr; gap: 3.5rem; align-items: center; }
}
.hero p.lede { max-width: 34rem; }

.hero__actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1.6rem; }
.btn {
  display: inline-block;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid transparent;
}
.btn--solid { background: var(--accent); color: #fff; }
.btn--solid:hover { background: var(--accent-dark); color: #fff; }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { border-color: var(--faint); color: var(--ink); }

/* ---------- cards ---------- */

.cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  margin: 2rem 0;
  padding: 0;
  list-style: none;
}
.card {
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1.25rem 1.3rem;
  background: var(--paper);
  margin: 0;
}
.card h3 { margin: 0 0 0.4rem; font-size: 0.98rem; }
.card p { font-size: 0.89rem; color: var(--muted); margin: 0; line-height: 1.55; }
.card a { text-decoration: none; }
.card a:hover { text-decoration: underline; }

/* ---------- feature blocks ---------- */

.feature { border-top: 1px solid var(--rule); padding-top: 1.6rem; margin-top: 2.6rem; }
.feature__tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
}
.feature h2 { margin-top: 0.35rem; }

/* ---------- callouts / tables ---------- */

.note {
  border-left: 3px solid var(--arm-line);
  background: var(--surface);
  padding: 1rem 1.2rem;
  border-radius: 0 8px 8px 0;
  margin: 1.8rem 0;
  font-size: 0.93rem;
}
.note--warn { border-left-color: #f59e0b; background: #fffbeb; }
.note p:last-child { margin-bottom: 0; }
.note strong { display: block; margin-bottom: 0.3rem; }

.tbl-scroll { overflow-x: auto; margin: 1.8rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.62rem 0.85rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--control-line);
  white-space: nowrap;
}
td code { background: none; border: none; padding: 0; }

/* ---------- steps ---------- */

.steps { list-style: none; padding: 0; counter-reset: step; margin: 2rem 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.6rem;
  margin-bottom: 1.8rem;
}
.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0; top: 0.12rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--arm-ink);
  background: var(--arm);
  border: 1px solid var(--arm-line);
  border-radius: 5px;
  padding: 0.1rem 0.38rem;
}
.steps h3 { margin-top: 0; }

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--rule);
  background: var(--surface);
  padding: 2.8rem 0 3rem;
  margin-top: 4rem;
}
.footer__cols {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.footer h4 {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  margin: 0 0 0.8rem;
  font-weight: 500;
}
.footer ul { list-style: none; padding: 0; margin: 0; font-size: 0.88rem; }
.footer li { margin-bottom: 0.45rem; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--ink); text-decoration: underline; }
.footer__base {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--faint);
}
.footer__base code { font-size: 0.8rem; }

/* ---------- maths ---------- */

.katex-display { margin: 1.4rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0; }
.katex { font-size: 1.03em; }

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