/* contexel docs — one type scale, one color system, one spacing rhythm.
   Brand sampled from the logo: blue #2563EB → violet #6D5AE6, navy ink.
   Default is the bright theme; dark stays legible via prefers-color-scheme. */

:root {
  --bg: #F7F9FE;
  --surface: #FFFFFF;
  --surface-2: #EEF3FC;
  --ink: #0F1B33;
  --ink-soft: #45536E;
  --line: #D9E2F2;
  --blue: #2563EB;
  --violet: #6D5AE6;
  --grad: linear-gradient(135deg, #2563EB 0%, #6D5AE6 100%);
  --accent-soft: #E4EBFD;
  --good: #0E7A4D;
  --warn: #B3541E;
  --code-bg: #0F1B33;
  --code-ink: #E8EEFB;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 51, .06), 0 8px 24px rgba(37, 99, 235, .07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1424;
    --surface: #16203A;
    --surface-2: #1C2946;
    --ink: #E8EEFB;
    --ink-soft: #A8B6D4;
    --line: #2A3A5E;
    --blue: #7CA7FF;      /* lightened for AA contrast on dark surfaces */
    --violet: #A99CFF;
    --good: #3DD68C;
    --warn: #F0A464;
    --accent-soft: #22315A;
    --code-bg: #0A101F;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
img { max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 2rem; margin: 0 0 .5rem; }
h2 { font-size: 1.4rem; margin: 2.2rem 0 .6rem; }
h3 { font-size: 1.1rem; margin: 1.6rem 0 .4rem; }
p, li { color: var(--ink); }
.lead { font-size: 1.12rem; color: var(--ink-soft); max-width: 62ch; }

code {
  font: .88em/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--surface-2);
  padding: .12em .38em;
  border-radius: 6px;
}
pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}
pre code { background: none; padding: 0; color: inherit; }

/* ---- header / shell / sidebar (wiki layout) ---- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.2rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top img { height: 30px; width: auto; }
.top .spacer { flex: 1; }
.top a.btn { font-weight: 600; }

.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 2rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.6rem 1.2rem 4rem;
}
.side {
  position: sticky; top: 64px;
  align-self: start;
  font-size: .95rem;
}
.side .group { margin: 0 0 1.1rem; }
.side .group > span {
  display: block; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); margin-bottom: .3rem;
}
.side a {
  display: block; color: var(--ink); padding: .28rem .6rem;
  border-radius: 8px; border-left: 2px solid transparent;
}
.side a:hover { background: var(--accent-soft); text-decoration: none; }
.side a.here {
  background: var(--accent-soft);
  border-left: 2px solid var(--blue);
  font-weight: 600;
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; display: flex; flex-wrap: wrap; gap: .3rem; }
  .side .group > span { display: none; }
}

/* ---- components ---- */
.hero { text-align: center; padding: 2.5rem 0 1rem; }
.hero img { width: min(360px, 80%); }
.hero h1 { font-size: 2.3rem; }
.hero .tag {
  font-size: 1.2rem; color: var(--ink-soft); max-width: 46ch; margin: .4rem auto 1.2rem;
}
.cta { display: inline-block; padding: .6rem 1.3rem; border-radius: 999px;
  background: var(--grad); color: #fff; font-weight: 650; box-shadow: var(--shadow); }
.cta:hover { text-decoration: none; filter: brightness(1.07); }
.cta.ghost { background: var(--surface); color: var(--blue);
  border: 1px solid var(--line); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem; margin: 1.4rem 0; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.card h3 { margin: .1rem 0 .35rem; font-size: 1rem; }
.card p { margin: 0; font-size: .93rem; color: var(--ink-soft); }
.card .k { display: inline-block; font-size: .74rem; font-weight: 700;
  color: var(--violet); text-transform: uppercase; letter-spacing: .07em; }

table { border-collapse: collapse; width: 100%; margin: 1rem 0;
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); font-size: .92rem; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-size: .8rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
tr:last-child td { border-bottom: none; }
td.best { color: var(--good); font-weight: 700; }
td.poor { color: var(--warn); font-weight: 600; }
.scroll { overflow-x: auto; }

.note {
  border-left: 3px solid var(--violet);
  background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0;
  padding: .7rem 1rem; margin: 1rem 0; box-shadow: var(--shadow);
  font-size: .95rem;
}

/* ---- interactive pipeline ---- */
.pipe { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
  margin: 1.3rem 0; }
.pipe .node {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: .5rem .8rem; cursor: pointer;
  font: 600 .92rem/1 ui-monospace, Consolas, monospace;
  color: var(--ink); box-shadow: var(--shadow); transition: all .15s;
}
.pipe .node:hover { transform: translateY(-2px); border-color: var(--blue); }
.pipe .node.on { background: var(--grad); color: #fff; border-color: transparent; }
.pipe .arrow { color: var(--ink-soft); font-weight: 700; }
.pipe .cap { border-style: dashed; cursor: default; font-weight: 500;
  color: var(--ink-soft); }
.stagebox {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow);
  min-height: 7.5rem;
}
.stagebox h3 { margin: 0 0 .3rem; }
.stagebox .sig { color: var(--violet); font-weight: 600; }

/* ---- budget demo ---- */
.demo { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.demo input[type=range] { width: 100%; accent-color: var(--blue); }
.demo .meterline { display: flex; justify-content: space-between;
  font-size: .9rem; color: var(--ink-soft); }
.demo .recs { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .7rem; }
.demo .rec { font: .78rem/1.1 ui-monospace, Consolas, monospace;
  border: 1px solid var(--line); border-radius: 7px; padding: .3rem .5rem;
  transition: all .2s; }
.demo .rec.kept { background: var(--accent-soft); border-color: var(--blue); }
.demo .rec.cut { opacity: .32; text-decoration: line-through; }
.demo .rec.dup { border-style: dashed; }

footer {
  border-top: 1px solid var(--line); padding: 1.4rem;
  text-align: center; color: var(--ink-soft); font-size: .9rem;
}
