/* Hyperbolic PolyStep: shared style for the hub and every explainer in this folder.
   The palette and components follow the Galactic Lensing manuals so the folder reads as one family. */
:root {
    --bg: #020617;
    --panel: #0b1222;
    --line: rgba(34, 211, 238, 0.16);
    --line-strong: rgba(34, 211, 238, 0.38);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --faint: #64748b;
    --cyan: #22d3ee;
    --fuchsia: #e879f9;
    --amber: #fbbf24;
    --rose: #fb7185;
    --emerald: #34d399;
    --sky: #38bdf8;
    --purple: #c084fc;
    --gold: #f5c542;
    /* the three channels (branches 0, 1, 2 at 0°, 120°, 240°), as on the tri-engine pages */
    --chA: #ff0055; --chB: #00f2ff; --chC: #ffd700;
    /* system-map node kinds */
    --k-source: #f5c542; --k-math: #c084fc; --k-comp: #22d3ee; --k-artifact: #34d399; --k-existing: #94a3b8;
    --mono: 'Fira Code', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(139, 92, 246, 0.12), transparent 60%),
        radial-gradient(900px 600px at -10% 20%, rgba(34, 211, 238, 0.07), transparent 60%);
}
a { color: var(--cyan); text-decoration-color: rgba(34, 211, 238, 0.4); text-underline-offset: 3px; }
a:hover { color: #67e8f9; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.88em; }
code { background: rgba(15, 23, 42, 0.9); border: 1px solid rgba(51, 65, 85, 0.7); border-radius: 5px; padding: 0.05em 0.35em; color: #a5f3fc; overflow-wrap: anywhere; }
strong { color: #f8fafc; }
h1, h2, h3, h4 { line-height: 1.25; color: #f8fafc; }
h2 { font-size: 1.75rem; margin: 0 0 0.4rem; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; margin: 2rem 0 0.5rem; color: #cffafe; }
h4 { font-size: 1rem; margin: 1.4rem 0 0.4rem; color: #e0f2fe; }
p { margin: 0.7rem 0; }
ul, ol { padding-left: 1.4rem; }
li { margin: 0.25rem 0; }

.hero { padding: 92px 20px 40px; text-align: center; border-bottom: 1px solid var(--line); }
.eyebrow { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); margin: 0.6rem auto 0.8rem; max-width: 980px; letter-spacing: -0.02em;
    background: linear-gradient(90deg, #ff0055, #00f2ff 50%, #ffd700); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lede { max-width: 780px; margin: 0 auto; color: #cbd5e1; font-size: 1.08rem; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 1.6rem; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; font-weight: 600; text-decoration: none; border: 1px solid transparent; cursor: pointer; font-size: 0.95rem; }
.btn-primary { background: linear-gradient(90deg, #9f1239, #0e7490 55%, #a16207); color: #fff; }
.btn-primary:hover { color: #fff; filter: brightness(1.1); }
.btn-ghost { border-color: var(--line-strong); color: #cffafe; background: rgba(8, 47, 73, 0.35); }
.btn-ghost:hover { background: rgba(8, 47, 73, 0.6); color: #fff; }
.hero-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 1.8rem; }
.stat { font-family: var(--mono); font-size: 0.8rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(15, 23, 42, 0.7); color: #cbd5e1; }
.stat b { color: var(--gold); }

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; max-width: 1240px; margin: 0 auto; padding: 32px 20px 80px; }
.layout.wide { grid-template-columns: minmax(0, 1fr); max-width: 1180px; }
.toc { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 90px); overflow-y: auto; padding-right: 6px; font-size: 0.88rem; }
.toc-title { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 5px 10px; border-left: 2px solid rgba(51, 65, 85, 0.6); color: var(--muted); text-decoration: none; }
.toc a:hover { color: #e2e8f0; border-left-color: #475569; }
.toc a.active { color: var(--gold); border-left-color: var(--gold); background: rgba(120, 53, 15, 0.25); }
.toc .part { margin: 14px 0 4px 10px; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fuchsia); }
.toc-mobile { display: none; }
main { min-width: 0; max-width: 900px; }
.layout.wide main { max-width: none; }

section.chapter { padding: 8px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 36px; }
section.chapter:last-of-type { border-bottom: 0; }
.chapter-num { font-family: var(--mono); font-size: 0.78rem; color: var(--fuchsia); letter-spacing: 0.1em; }
.chapter-intro { color: #cbd5e1; font-size: 1.04rem; }

.callout { border: 1px solid; border-radius: 12px; padding: 14px 16px; margin: 1.2rem 0; background: rgba(15, 23, 42, 0.75); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout .label { display: inline-block; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 4px; }
.plain { border-color: rgba(52, 211, 153, 0.4); } .plain .label { color: var(--emerald); }
.tryit { border-color: rgba(34, 211, 238, 0.45); background: rgba(8, 47, 73, 0.3); } .tryit .label { color: var(--cyan); }
.note { border-color: rgba(251, 191, 36, 0.45); } .note .label { color: var(--amber); }
.deep { border-color: rgba(192, 132, 252, 0.45); } .deep .label { color: var(--purple); }
.limit { border-color: rgba(251, 113, 133, 0.45); } .limit .label { color: var(--rose); }

.table-wrap { position: relative; overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid rgba(51, 65, 85, 0.5); vertical-align: top; }
th { background: rgba(15, 23, 42, 0.95); color: #a5f3fc; font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.mono { font-family: var(--mono); font-size: 0.84rem; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: rgba(15, 23, 42, 0.7); }
.card h4 { margin-top: 0; }
.card p { margin: 0.3rem 0 0; font-size: 0.93rem; color: #cbd5e1; }
a.card { display: block; text-decoration: none; color: inherit; transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.card.planned { border-style: dashed; opacity: 0.85; }
.card .meta { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); margin-top: 8px; }
figure { margin: 1.4rem 0; }
figure svg, figure canvas { display: block; width: 100%; height: auto; }
figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 8px; text-align: center; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding: 4px 0 10px 46px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 4px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    font-family: var(--mono); font-weight: 600; font-size: 0.85rem; color: #020617; background: linear-gradient(135deg, #ff0055, #00f2ff); }

/* Epistemic tags, as in the papers */
.tag { font-family: var(--mono); font-size: 0.72rem; padding: 1px 7px; border-radius: 5px; border: 1px solid; white-space: nowrap; vertical-align: 1px; }
.t-PROVEN { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.55); }
.t-ESTABLISHED { color: #93c5fd; border-color: rgba(96, 165, 250, 0.55); }
.t-DEFINITION { color: #cbd5e1; border-color: rgba(148, 163, 184, 0.55); }
.t-COMPUTED { color: #67e8f9; border-color: rgba(34, 211, 238, 0.55); }
.t-EMPIRICAL { color: #fdba74; border-color: rgba(251, 146, 60, 0.55); }
.t-HEURISTIC { color: #fcd34d; border-color: rgba(245, 158, 11, 0.55); }
.t-CONJECTURAL { color: #fca5a5; border-color: rgba(248, 113, 113, 0.55); }
.t-OPEN { color: #f8fafc; border-color: rgba(248, 250, 252, 0.55); }
.t-SUPPORTED { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.55); background: rgba(6, 78, 59, 0.25); }
.t-REFUTED { color: #fca5a5; border-color: rgba(248, 113, 113, 0.55); background: rgba(127, 29, 29, 0.25); }
.t-MIXED { color: #fde68a; border-color: rgba(251, 191, 36, 0.55); background: rgba(120, 53, 15, 0.25); }
.t-DESIGN { color: #f0abfc; border-color: rgba(232, 121, 249, 0.55); }
.status { font-family: var(--mono); font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.s-done { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.55); background: rgba(6, 78, 59, 0.3); }
.s-next { color: #fde68a; border-color: rgba(251, 191, 36, 0.55); background: rgba(120, 53, 15, 0.3); }
.s-planned { color: var(--muted); border-color: rgba(148, 163, 184, 0.45); }
.s-existing { color: #cbd5e1; border-color: rgba(148, 163, 184, 0.6); background: rgba(30, 41, 59, 0.6); }

/* Labs (live diagrams) */
.lab { border: 1px solid var(--line-strong); border-radius: 14px; background: linear-gradient(180deg, rgba(8, 47, 73, 0.35), rgba(15, 23, 42, 0.8)); padding: 16px; margin: 1.4rem 0; }
.lab-title { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan); margin-bottom: 8px; }
.lab-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 8px 0; }
.lab-row label { font-size: 0.85rem; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
.lab-row input[type="range"] { width: 130px; accent-color: var(--cyan); }
.chip { font: 0.8rem var(--mono); padding: 4px 10px; border-radius: 999px; border: 1px solid #334155; background: #0f172a; color: #cbd5e1; cursor: pointer; }
.chip:hover { border-color: var(--cyan); color: #fff; }
.chip.on { border-color: var(--gold); color: #fff; background: rgba(120, 53, 15, 0.35); }
.out { font-family: var(--mono); font-size: 0.84rem; background: #020617; border: 1px solid #1e293b; border-radius: 10px; padding: 10px 12px; overflow-wrap: anywhere; }
.out .k { color: var(--muted); }
.out .good { color: var(--emerald); }
.out .bad { color: var(--rose); }
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.duo .pane { border: 1px solid #1e293b; border-radius: 10px; background: #020617; padding: 6px; min-width: 0; }
.duo canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.duo .pane h5 { margin: 2px 4px 4px; font: 600 0.78rem var(--mono); color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* Interconnection charts (assets/hp-map.js) */
.map-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: rgba(2, 6, 23, 0.85); padding: 8px; }
.map-wrap svg { display: block; width: 100%; min-width: 760px; height: auto; }
.map-wrap.mini svg { min-width: 560px; }
.map-node { cursor: pointer; }
.map-node rect { transition: opacity 0.15s, stroke-width 0.15s; }
.map-node text { pointer-events: none; }
.map-node:focus { outline: none; }
.map-node:focus rect, .map-node.sel rect { stroke-width: 2.6; }
.map-edge { fill: none; stroke-width: 1.4; transition: opacity 0.15s, stroke-width 0.15s; }
svg.dim .map-node:not(.lit) { opacity: 0.25; }
svg.dim .map-edge:not(.lit) { opacity: 0.08; }
svg.dim .map-edge.lit { stroke-width: 2.4; }
.map-detail { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(15, 23, 42, 0.8); min-height: 5.5em; }
.map-detail h4 { margin: 0 0 4px; }
.map-detail p { margin: 0.3rem 0; font-size: 0.93rem; color: #cbd5e1; }
.map-detail .links { font-size: 0.86rem; color: var(--muted); }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--muted); margin: 8px 2px 0; }
.map-legend span::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--c); }
.map-legend span.dashed::before { border-style: dashed; }

.gloss { display: grid; grid-template-columns: 220px 1fr; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gloss dt, .gloss dd { margin: 0; padding: 9px 12px; border-bottom: 1px solid rgba(51, 65, 85, 0.45); }
.gloss dt { font-weight: 600; color: #a5f3fc; background: rgba(15, 23, 42, 0.9); }
.gloss dd { color: #cbd5e1; font-size: 0.93rem; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 2rem; }
footer { text-align: center; color: var(--faint); font-size: 0.85rem; padding: 30px 20px 60px; border-top: 1px solid var(--line); }

@media (max-width: 1023px) {
    .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 20px; }
    .toc { display: none; }
    .toc-mobile { display: block; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: rgba(15, 23, 42, 0.8); }
    .toc-mobile summary { cursor: pointer; font-weight: 600; }
    .toc-mobile ol { margin: 8px 0 0; padding-left: 1.2rem; columns: 2; column-gap: 20px; font-size: 0.9rem; }
}
@media (max-width: 640px) {
    body { font-size: 15px; }
    .grid-2, .grid-3, .duo { grid-template-columns: minmax(0, 1fr); }
    .gloss { grid-template-columns: minmax(0, 1fr); }
    .gloss dt { border-bottom: 0; padding-bottom: 2px; }
    .toc-mobile ol { columns: 1; }
    h2 { font-size: 1.45rem; }
    .hero { padding-top: 76px; }
}
