/*
 * Combined Intelligence -- shared site chrome ("refined dark").
 *
 * One stylesheet for every Combined Intelligence page: the design tokens, the
 * header, the full-screen Contents menu and the footer. Page layout stays in
 * the page. Behaviour (the menu) is ci-site.js.
 *
 * Dark is the default ground; the Insights library keeps its light reading
 * panel (insights/library.css, loaded AFTER this file so its .ci-paper rules
 * win ties). Orange is the human side of the brand -- the dot on the logo's i
 * -- and marks emphasis and primary actions; cyan is the machine side, used for
 * labels and links. No glows, glass or particle canvas: hairlines carry structure.
 *
 * Markup contract -- copy the blocks from index.html (home) or
 * insights/index.html (any page below the root, links root-absolute):
 *   <aside class="side-menu" id="side-menu" role="dialog" ... hidden>  Contents
 *   <header class="site-header"> ... <div class="nav-links"> ... #menuToggle
 *   <footer id="contact" class="site-footer">
 * test_insights_library.py reads .nav-links and .side-menu for the Insights link.
 *
 * Pages written in the earlier glass style (cards, badges, section titles with
 * an orange rule) opt into the translation layer at the bottom with
 * <body class="ci-lib">, which re-points that vocabulary at these tokens.
 */

:root {
    --ci-bg: #0A141E;
    --ci-bg-raised: #101D2A;
    --ci-bg-deep: #070F17;
    --ci-line: #1F3246;
    --ci-line-strong: #2A4058;
    --ci-text: #ECE8DF;
    --ci-text-soft: #A7B2BD;
    --ci-text-mute: #8593A1;
    --ci-human: #F7943D;
    --ci-machine: #29B6F6;
    --ci-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --ci-sans: 'Space Grotesk', system-ui, sans-serif;
    --ci-header-h: 76px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
    margin: 0;
    font-family: var(--ci-sans);
    background: var(--ci-bg);
    color: var(--ci-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body.nav-open { overflow: hidden; }

a { color: var(--ci-machine); }
a:hover { color: var(--ci-human); }
:focus-visible { outline: 2px solid var(--ci-machine); outline-offset: 3px; }

.skip-link {
    position: absolute; left: 16px; top: -60px; z-index: 4000;
    background: var(--ci-text); color: var(--ci-bg);
    padding: 10px 16px; border-radius: 999px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 40px; }

section { scroll-margin-top: calc(var(--ci-header-h) + 16px); }

.dot {
    display: inline-block; width: 0.2em; height: 0.2em;
    border-radius: 50%; background: var(--ci-human); margin-left: 0.05em;
}
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ci-human); }
.human { font-style: italic; color: var(--ci-human); }
.machine { color: var(--ci-machine); }

.label {
    font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--ci-text-mute); display: flex; gap: 10px; align-items: center; margin: 0;
}
.kind { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ci-machine); }

.btn {
    display: inline-flex; align-items: center; gap: 10px; min-height: 48px;
    padding: 0 24px; border-radius: 999px; text-decoration: none;
    font-weight: 500; font-size: 15px; font-family: var(--ci-sans);
}
.btn-solid { background: var(--ci-human); color: var(--ci-bg); }
.btn-solid:hover { background: var(--ci-machine); color: var(--ci-bg); }

/* ---------------------------------------------------------------- header */

.site-header {
    position: sticky; top: 0; z-index: 2000;
    background: var(--ci-bg); border-bottom: 1px solid var(--ci-line);
}
.site-header nav { display: flex; align-items: center; gap: 28px; height: var(--ci-header-h); }

.logo {
    display: flex; align-items: center; gap: 12px; text-decoration: none;
    color: var(--ci-text); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap;
}
.logo:hover { color: var(--ci-text); }
.logo img { width: 34px; height: 30px; object-fit: contain; }
/* The combined wordmark (mark + name in one image, white on transparent, drawn
 * for the dark ground) replaces the mark + text span in the header and the
 * Contents bar. width/height on the <img> keep its 2048x570 ratio reserved. */
.logo img.logo-wordmark { width: auto; height: 38px; }

.nav-links { display: flex; gap: 28px; margin-left: auto; }
.nav-links a {
    color: var(--ci-text); text-decoration: none; font-size: 15px;
    padding: 4px 0; border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: var(--ci-human); }
.nav-links a[aria-current="page"] { border-bottom-color: var(--ci-human); }

.nav-toggle {
    display: none; align-items: center; justify-content: center;
    width: 44px; height: 44px; margin-left: auto; border: 0; border-radius: 999px;
    background: var(--ci-text); color: var(--ci-bg); font-size: 18px; cursor: pointer;
}
.nav-toggle:hover { background: var(--ci-machine); }

.nav-cta {
    display: flex; align-items: center; height: 44px; padding: 0 18px; border-radius: 999px;
    background: var(--ci-text); color: var(--ci-bg); text-decoration: none;
    font-size: 14px; font-weight: 500; white-space: nowrap;
}
.nav-cta:hover { background: var(--ci-machine); color: var(--ci-bg); }

/* ---------------------------------------------------------------- contents menu
 * Full-screen table of contents. Hovering or focusing a chapter shows what is
 * in it; on a phone the preview is dropped and the chapters are the menu. A
 * page with its own sections lists them under "On this page". */

.side-menu {
    position: fixed; inset: 0; z-index: 3000; overflow: auto;
    background: var(--ci-bg-deep); color: var(--ci-text);
}
.sm-bar { display: flex; align-items: center; gap: 24px; height: var(--ci-header-h); border-bottom: 1px solid var(--ci-line); }
.sm-talk {
    margin-left: auto; font-size: 14px; color: var(--ci-text); text-decoration: none;
    border-bottom: 1px solid var(--ci-human); padding-bottom: 2px;
}
.sm-close {
    display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 18px;
    border: 0; border-radius: 999px; background: var(--ci-text); color: var(--ci-bg);
    font-family: var(--ci-sans); font-size: 14px; font-weight: 500; cursor: pointer;
}
.sm-close:hover { background: var(--ci-machine); }
.sm-grid {
    display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 0.75fr);
    gap: 56px; padding-top: 48px; padding-bottom: 64px;
}
.sm-kick {
    font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--ci-text-mute); margin: 0 0 18px; display: flex; align-items: center; gap: 10px;
}
.sm-chaps { list-style: none; margin: 0; padding: 0; counter-reset: chap; }
.sm-chaps li { counter-increment: chap; border-top: 1px solid var(--ci-line); }
.sm-chaps a {
    display: flex; align-items: baseline; gap: 22px; padding: 12px 0;
    color: #6F7F8F; text-decoration: none;
    font-family: var(--ci-serif); font-weight: 300; font-size: 46px; line-height: 1.05; letter-spacing: -0.02em;
}
.sm-chaps a::before {
    content: counter(chap, decimal-leading-zero);
    font-family: var(--ci-sans); font-size: 13px; letter-spacing: 0; min-width: 30px;
}
.sm-chaps a:hover, .sm-chaps a:focus-visible, .sm-chaps a.is-active { color: var(--ci-text); }
.sm-chaps a.is-active::before { color: var(--ci-human); }
.sm-preview { border-left: 1px solid var(--ci-line); padding-left: 40px; }
.sm-panel h3 {
    font-family: var(--ci-serif); font-weight: 400; font-size: 22px; line-height: 1.45;
    color: var(--ci-text-soft); margin: 0 0 28px;
}
.sm-panel a, .sm-onpage a {
    display: block; padding: 16px 0; border-top: 1px solid var(--ci-line);
    text-decoration: none; color: var(--ci-text);
}
.sm-panel a span { display: block; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ci-text-mute); }
.sm-panel a strong { display: block; font-weight: 400; font-size: 19px; margin-top: 4px; }
.sm-panel a:hover strong, .sm-onpage a:hover { color: var(--ci-machine); }
.sm-onpage { list-style: none; margin: 0 0 36px; padding: 0; }
.sm-onpage a { padding: 12px 0; font-size: 17px; }
.sm-card {
    display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: 20px;
    background: var(--ci-bg-raised); border: 1px solid var(--ci-line); text-decoration: none;
}
.sm-card strong { font-family: var(--ci-serif); font-weight: 400; font-size: 22px; line-height: 1.25; color: var(--ci-text); }
.sm-card span { font-size: 14px; color: var(--ci-text-soft); }
.sm-card:hover strong { color: var(--ci-human); }
.sm-mail { font-size: 15px; color: var(--ci-text); text-decoration: none; border-bottom: 1px solid var(--ci-human); padding-bottom: 3px; }

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

.site-footer { background: var(--ci-bg-deep); padding: 110px 0; scroll-margin-top: var(--ci-header-h); }
.footer-cta {
    font-family: var(--ci-serif); font-weight: 300; font-size: 88px; line-height: 1;
    letter-spacing: -0.03em; margin: 0 0 24px; color: var(--ci-text);
}
.contact-email {
    font-size: 26px; color: var(--ci-text); text-decoration: none;
    border-bottom: 1px solid var(--ci-human); padding-bottom: 4px;
}
.contact-email:hover { color: var(--ci-machine); border-color: var(--ci-machine); }
.footer-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px;
    margin-top: 96px; padding-top: 32px; border-top: 1px solid var(--ci-line);
}
.site-footer .footer-grid h2 {
    font-family: var(--ci-sans); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--ci-text-mute); font-weight: 500; margin: 0 0 14px;
}
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.footer-grid a { color: var(--ci-text); text-decoration: none; font-size: 15px; }
.footer-grid a:hover { color: var(--ci-human); }
.footer-legal {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    margin-top: 56px; font-size: 13px; color: var(--ci-text-mute);
}

/* ---------------------------------------------------------------- responsive (chrome) */

@media (max-width: 1080px) {
    .nav-links { display: none; }
    .nav-toggle { display: flex; }
}
@media (max-width: 960px) {
    .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sm-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
    .sm-preview { display: none; }
    .sm-chaps a { font-size: 38px; }
}
@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .footer-cta { font-size: 52px; }
    .site-footer { padding: 72px 0; }
    .nav-cta, .sm-talk { display: none; }
    .sm-close { margin-left: auto; }
    .logo { font-size: 15px; }
    .logo img.logo-wordmark { height: 30px; }
    .contact-email { font-size: 19px; }
}

/* ---------------------------------------------------------------- translation layer
 * <body class="ci-lib">: library pages were written in the earlier glass
 * vocabulary (--glass-*, .card, .badge-*, .section-title with an orange rule,
 * uppercase buttons). Rather than rewrite each page, re-point it here. The
 * legacy custom properties are redefined on body, so every rule that reads
 * them picks up the new palette. */

body.ci-lib {
    --bg-dark: var(--ci-bg);
    --bg-light: var(--ci-bg);
    --bg-color: var(--ci-bg);
    --text-white: var(--ci-text);
    --text-grey: var(--ci-text-soft);
    --glass-bg: var(--ci-bg-raised);
    --glass-border: var(--ci-line);
    --ci-accent-cyan: var(--ci-machine);
    --ci-accent-orange: var(--ci-human);
    --glow-cyan: none;
    --glow-orange: none;
    background: var(--ci-bg);
    padding-top: 0;
}

.ci-lib h1, .ci-lib h2, .ci-lib h3, .ci-lib h4 {
    font-family: var(--ci-serif);
    font-weight: 400;
    letter-spacing: -0.01em;
    text-shadow: none;
}
.ci-lib h1 { font-weight: 300; letter-spacing: -0.025em; }

.ci-lib .section-title {
    border-left: 0;
    padding-left: 0;
    text-shadow: none;
    font-weight: 300;
    letter-spacing: -0.02em;
}
.ci-lib .section-lead { padding-left: 0; }

.ci-lib .highlight-cyan,
.ci-lib .highlight-orange { text-shadow: none; }
.ci-lib .highlight-orange { font-style: italic; }

.ci-lib .btn {
    border-radius: 999px;
    text-transform: none;
    letter-spacing: 0;
    font-family: var(--ci-sans);
    font-weight: 500;
    font-size: 15px;
    backdrop-filter: none;
    box-shadow: none;
}
.ci-lib .btn:hover { box-shadow: none; }

.ci-lib .card {
    background: var(--ci-bg-raised);
    border-color: var(--ci-line);
    border-radius: 18px;
    backdrop-filter: none;
}
.ci-lib .card::before { display: none; }
.ci-lib .card:hover { transform: none; border-color: var(--ci-line-strong); box-shadow: none; }

.ci-lib .badge-cyan,
.ci-lib .badge-orange {
    background: transparent;
    border-radius: 999px;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.ci-lib .badge-cyan { color: var(--ci-machine); border-color: color-mix(in srgb, var(--ci-machine) 45%, transparent); }
.ci-lib .badge-orange { color: var(--ci-human); border-color: color-mix(in srgb, var(--ci-human) 45%, transparent); }
