/* ============================================================
   Whitepaper / technical article styles.
   Loaded AFTER ../styles.css — reuses the same variables, fonts,
   top bar, footer, frames, and chips. This file adds the
   long-form reading layout: prose, code blocks, figures, TOC.
   ============================================================ */

/* ---------- article shell ---------- */
.paper {
    max-width: 1180px;
    margin-inline: auto;
    padding-inline: var(--pad);
    padding-block: clamp(2rem, 5vw, 3.5rem);
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: clamp(1.5rem, 5vw, 4rem);
    align-items: start;
}
@media (max-width: 900px) {
    .paper { grid-template-columns: 1fr; }
}

/* ---------- table of contents ---------- */
.toc {
    position: sticky;
    top: 74px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.5;
    align-self: start;
}
.toc__label {
    color: var(--faint);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 0 0 0.9rem;
    font-size: 0.7rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { margin: 0 0 0.15rem; }
.toc a {
    display: block;
    text-decoration: none;
    color: var(--muted);
    padding: 0.32rem 0.6rem;
    border-left: 1px solid var(--line);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.toc a::before {
    counter-increment: toc;
    content: counter(toc, decimal-leading-zero) "  ";
    color: var(--faint);
}
.toc a:hover { color: var(--ink); border-color: var(--line-strong); }
.toc a.is-active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-soft);
}
@media (max-width: 900px) {
    .toc {
        position: static;
        margin-bottom: 2.5rem;
        border: 1px solid var(--line);
        padding: 1.2rem;
    }
}

/* ---------- article body ---------- */
.article { min-width: 0; }

/* back link */
.article__back {
    font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.06em;
    text-decoration: none; color: var(--muted);
    display: inline-block; margin-bottom: 2rem; transition: color 0.2s;
}
.article__back:hover { color: var(--accent); }

/* header block */
.article__head { margin-bottom: 3rem; }
.article__meta {
    font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--faint);
    display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; margin-bottom: 1.4rem;
}
.article__meta .accent { color: var(--accent); }
.article__title {
    font-weight: 900; font-size: clamp(2.2rem, 6vw, 3.6rem);
    line-height: 1; letter-spacing: -0.02em; margin: 0 0 1.3rem;
    text-transform: uppercase;
}
.article__lede {
    font-size: clamp(1.05rem, 2.2vw, 1.3rem);
    line-height: 1.5; color: var(--ink); max-width: 60ch; margin: 0;
}
.article__abstract {
    margin: 1.8rem 0 0; padding: 1.3rem 1.5rem;
    border: 1px solid var(--line); background: var(--panel);
    color: var(--muted); font-size: 0.98rem; max-width: 68ch;
}
.article__abstract .mono-label { margin-top: 0; }

/* prose rhythm */
.article h2 {
    font-weight: 700; font-size: clamp(1.4rem, 3.5vw, 1.9rem);
    letter-spacing: -0.01em; margin: 3.5rem 0 1.2rem;
    padding-top: 1.4rem; border-top: 1px solid var(--line);
    scroll-margin-top: 80px;
}
.article h2 .num {
    font-family: var(--font-mono); font-size: 0.62em; color: var(--accent);
    margin-right: 0.7rem; vertical-align: 0.15em;
}
.article h3 {
    font-weight: 650; font-size: 1.2rem; letter-spacing: -0.01em;
    margin: 2.4rem 0 0.9rem; scroll-margin-top: 80px;
}
.article h4 {
    font-family: var(--font-mono); font-size: 0.82rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--accent);
    margin: 1.8rem 0 0.7rem;
}
.article p { margin: 0 0 1.2rem; color: var(--muted); max-width: 72ch; }
.article strong { color: var(--ink); font-weight: 600; }
.article a:not(.article__back):not(.card__link):not(.cta__link) {
    color: var(--ink); text-decoration: none;
    border-bottom: 1px solid var(--accent); transition: color 0.2s;
}
.article a:not(.article__back):not(.card__link):not(.cta__link):hover { color: var(--accent); }

/* end-of-paper call to action */
.cta {
    margin-top: 3.5rem;
    padding: clamp(1.4rem, 4vw, 2rem);
    border: 1px solid var(--line-strong);
    background: var(--panel);
}
.cta .mono-label { margin-top: 0; }
.cta p { color: var(--muted); max-width: 62ch; }
.cta p:last-of-type { margin-bottom: 0; }
.cta__link {
    display: inline-flex; align-items: center; gap: 0.5rem;
    margin-top: 1.3rem;
    font-family: var(--font-mono); font-size: 1.05rem; letter-spacing: -0.01em;
    text-decoration: none; color: var(--accent);
    border-bottom: 1px solid var(--accent); padding-bottom: 0.2rem;
    transition: color 0.2s, border-color 0.2s;
}
.cta__link span { transition: transform 0.2s ease; }
.cta__link:hover { color: var(--ink); border-color: var(--ink); }
.cta__link:hover span { transform: translateX(4px); }

.article ul, .article ol { margin: 0 0 1.3rem; padding-left: 1.3rem; max-width: 72ch; color: var(--muted); }
.article li { margin: 0 0 0.5rem; }
.article li::marker { color: var(--accent); }

.article blockquote {
    margin: 1.6rem 0; padding: 0.4rem 0 0.4rem 1.3rem;
    border-left: 2px solid var(--accent); color: var(--ink);
    font-style: italic; max-width: 68ch;
}

.article hr { border: 0; border-top: 1px solid var(--line); margin: 2.6rem 0; }

/* inline code */
.article :not(pre) > code {
    font-family: var(--font-mono); font-size: 0.86em;
    background: var(--panel); border: 1px solid var(--line);
    padding: 0.08em 0.4em; color: var(--accent-ink);
    color: #e8b9a6; /* soft rust-tinted for inline tokens */
}

/* code blocks */
.code {
    margin: 1.6rem 0; border: 1px solid var(--line-strong); background: #0b0a09;
    overflow: hidden;
}
.code__bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line);
    font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--faint); background: var(--panel);
}
.code__lang { color: var(--accent); }
.code pre {
    margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto;
    font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.7;
    color: #cdd6cf;
}
.code pre code { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
/* syntax tokens — hand-applied spans, no JS, no deps */
.code .c { color: #6f685c; font-style: italic; }  /* comment */
.code .k { color: #d98a63; }                        /* keyword */
.code .s { color: #9bb48a; }                        /* string */
.code .n { color: #cfa76a; }                        /* number / const */
.code .t { color: #cdbf9d; }                        /* type / enum */
.code .f { color: #e4ddcd; }                        /* function / method */

/* figures / diagrams */
.figure {
    margin: 2rem 0; border: 1px solid var(--line-strong); background: var(--panel);
}
.figure__frame {
    padding: clamp(1rem, 3vw, 2rem); overflow-x: auto;
    display: flex; justify-content: center;
}
.figure img, .figure svg { max-width: 100%; height: auto; }
.figure figcaption {
    padding: 0.7rem 1rem; border-top: 1px solid var(--line);
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.05em;
    color: var(--faint);
}
.figure figcaption .accent { color: var(--accent); }

/* callout / note */
.note {
    margin: 1.6rem 0; padding: 1.1rem 1.3rem;
    border: 1px solid var(--line); border-left: 2px solid var(--accent);
    background: var(--panel); color: var(--muted); font-size: 0.95rem;
}
.note strong { color: var(--accent); }

/* math / formula block */
.formula {
    margin: 1.6rem 0; padding: 1.2rem 1.4rem; text-align: center;
    border: 1px solid var(--line); background: #0b0a09;
    font-family: var(--font-mono); font-size: 1.05rem; color: var(--ink);
    overflow-x: auto;
}
.formula .var { color: var(--accent); font-style: italic; }
.formula .sub { font-size: 0.7em; vertical-align: -0.25em; }
.formula .sup { font-size: 0.7em; vertical-align: 0.5em; }

/* data table */
.article table {
    width: 100%; border-collapse: collapse; margin: 1.6rem 0;
    font-size: 0.9rem;
}
.article th, .article td {
    text-align: left; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.article thead th {
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--accent); border-bottom-color: var(--line-strong);
}
.article tbody td { color: var(--muted); }
.article tbody td:first-child { color: var(--ink); }
.article .table-wrap { overflow-x: auto; }

/* key-figures strip */
.kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px; background: var(--line); border: 1px solid var(--line);
    margin: 2rem 0;
}
.kpis div { background: var(--bg); padding: 1.1rem 1.2rem; }
.kpis dt {
    font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--faint); margin-bottom: 0.4rem;
}
.kpis dd {
    margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em;
}
.kpis dd .unit { font-size: 0.8rem; color: var(--muted); font-weight: 400; }

/* ---------- on-brand diagrams (pure CSS, no deps) ---------- */
.diagram { width: 100%; font-family: var(--font-mono); }

/* layered top-down flow */
.layer { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; }
.layer + .conn, .conn + .layer, .layer + .layer { margin-top: 0.55rem; }

.node {
    border: 1px solid var(--line-strong); background: var(--bg);
    padding: 0.6rem 0.9rem; text-align: center; min-width: 120px;
}
.node .t { display: block; font-size: 0.82rem; color: var(--ink); letter-spacing: 0.02em; }
.node .s { display: block; font-size: 0.64rem; color: var(--faint); margin-top: 0.15rem; letter-spacing: 0.04em; }
.node--accent { border-color: var(--accent); }
.node--accent .t { color: var(--accent); }
.node--store { background: var(--panel); border-style: dashed; }

/* connector glyph between layers */
.conn { text-align: center; color: var(--accent); font-size: 0.9rem; line-height: 1; }
.conn::before { content: "▼"; }
.conn--label { color: var(--faint); font-size: 0.66rem; letter-spacing: 0.06em; }
.conn--label::before { content: "▼\00a0\00a0"; color: var(--accent); }

/* horizontal pipeline stepper — stays on one row; the framed
   figure scrolls horizontally on very narrow screens instead of
   wrapping steps into orphans */
.stepper {
    display: flex; align-items: stretch; flex-wrap: nowrap; gap: 0.45rem;
    justify-content: center;
}
.step {
    border: 1px solid var(--line-strong); background: var(--bg);
    padding: 0.55rem 0.7rem; min-width: 92px; text-align: center;
    display: flex; flex-direction: column; justify-content: center;
    flex: 0 0 auto;
}
.step .t { font-size: 0.78rem; color: var(--ink); }
.step .s { font-size: 0.62rem; color: var(--faint); margin-top: 0.2rem; }
.step--out { border-color: var(--accent); }
.step--out .t { color: var(--accent); }
.arrow { align-self: center; color: var(--accent); font-size: 0.9rem; }
.arrow::before { content: "→"; }
@media (max-width: 620px) {
    .arrow::before { content: "↓"; }
    .stepper { flex-direction: column; align-items: stretch; }
}

/* side-by-side rail (e.g. actor <-> stores) */
.rail { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; align-items: center; }
.rail .bi { color: var(--faint); font-size: 0.8rem; }
.rail .bi::before { content: "◄►"; letter-spacing: -0.1em; }

/* ---------- whitepapers index ---------- */
.papers-list { display: grid; gap: 1rem; margin-top: 2.5rem; }
.paper-card {
    display: block; text-decoration: none; color: inherit;
    padding: 1.6rem 1.8rem; background: var(--panel);
    transition: border-color 0.25s, transform 0.25s, background 0.25s;
}
.paper-card:hover {
    transform: translateY(-3px); border-color: var(--accent);
    background: color-mix(in srgb, var(--panel) 80%, var(--accent-soft));
}
.paper-card__meta {
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--faint);
    display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; margin-bottom: 0.9rem;
}
.paper-card__meta .accent { color: var(--accent); }
.paper-card__title {
    font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.6rem;
}
.paper-card__desc { color: var(--muted); margin: 0 0 1rem; max-width: 70ch; font-size: 0.97rem; }
.paper-card__more {
    font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink);
}
.paper-card:hover .paper-card__more { color: var(--accent); }

/* ---------- CSP-safe utilities (replace former inline styles) ---------- */
.article__abstract > p:last-child { margin-bottom: 0; }
.formula--inline { display: inline; border: 0; padding: 0; background: none; }
.fig-note {
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.03em;
    color: var(--faint); max-width: 70ch;
}
.article__back--end { margin-top: 2.5rem; }
.hero__blurb--wide { max-width: 60ch; }

/* ---------- unified content measure ----------
   text and all block elements (figures, code, notes, tables, etc.)
   share ONE width so their edges line up */
.article { --measure: 44rem; }
.article p,
.article ul,
.article ol,
.article__abstract,
.article blockquote,
.fig-note,
.figure,
.code,
.note,
.formula,
.kpis,
.table-wrap,
.cta { max-width: var(--measure); }

/* keep the widest stepper (6-step pipeline) inside the measure */
.figure__frame { padding: clamp(0.85rem, 2.5vw, 1.15rem); }
.stepper { gap: 0.35rem; }
.step { min-width: 74px; padding: 0.5rem 0.55rem; }
.step .t { font-size: 0.72rem; }
.step .s { font-size: 0.58rem; }
.arrow { font-size: 0.8rem; }

/* section dividers align to the content measure too */
.article h2,
.article hr { max-width: var(--measure); }
