/*
 * Combined Intelligence -- Insights library: the shared parts of every library page.
 *
 * Loaded by the hub (insights/index.html) and by every publication page, after
 * the page's own site-chrome styles. It owns only what is the SAME on all of
 * them: the library bar under the site header, the breadcrumb, the light "paper"
 * reading panel, the cards the hub and the related rows draw, and the gate's
 * returning-reader note. Page-specific layout stays in the page.
 *
 * Markup contract
 *   Library bar  <nav class="ci-library-bar" aria-label="Insights library"> ...
 *                one <a> per section; the current one carries aria-current="page".
 *                Copy it from insights/index.html -- test_insights_library.py
 *                checks every library page carries the same links.
 *   Breadcrumb   <nav class="ci-breadcrumb" aria-label="Breadcrumb"> ...
 *   Paper panel  <section class="ci-paper"> around the long-form reading sections.
 *   Related      <div class="ci-related" data-ci-related="<document key>"></div>,
 *                filled by library.js from GET /api/combinedintelligence/library.
 *
 * Colours are the site tokens from ci-site.css (loaded before this file). The site is
 * dark-only; the paper panel is the one light surface, used for reading at length.
 */

:root {
    --ci-paper: #f4f1ea;
    --ci-paper-edge: #ddd5c5;
    --ci-paper-raised: #ffffff;
    --ci-ink: #14202b;
    --ci-ink-soft: #3d4b59;
    --ci-ink-accent: #0b5f8a;
    --ci-ink-warm: #a8470f;
}

/* ---------------------------------------------------------------- library bar */

.ci-library-bar {
    position: relative;
    z-index: 5;
    background: var(--ci-bg-raised, #101D2A);
    border-bottom: 1px solid var(--ci-line, #1F3246);
}

.ci-library-bar .ci-library-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0.7rem 2rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.6rem;
    font-size: 0.92rem;
}

.ci-library-bar .ci-library-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    color: var(--text-white, #fff);
    text-decoration: none;
    margin-right: 0.6rem;
}

.ci-library-bar a {
    color: var(--text-grey, #b8c2cc);
    text-decoration: none;
    padding: 0.35rem 0;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.ci-library-bar a:hover { color: var(--text-white, #fff); }

.ci-library-bar a[aria-current="page"] {
    color: var(--text-white, #fff);
    border-bottom-color: var(--ci-human, #F7943D);
}

.ci-library-bar .ci-library-subscribe {
    margin-left: auto;
    color: var(--ci-accent-orange, #f98a47);
}

@media (max-width: 768px) {
    .ci-library-bar .ci-library-inner {
        padding: 0.6rem 1.25rem;
        gap: 0.2rem 1.1rem;
        font-size: 0.88rem;
    }
    .ci-library-bar .ci-library-name { width: 100%; }
    .ci-library-bar .ci-library-subscribe { margin-left: 0; }
}

/* ---------------------------------------------------------------- breadcrumb */

.ci-breadcrumb {
    font-size: 0.85rem;
    color: var(--text-grey, #b8c2cc);
    margin-bottom: 1.75rem;
}

.ci-breadcrumb ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.ci-breadcrumb li + li::before {
    content: '/';
    margin-right: 0.35rem;
    color: rgba(184, 194, 204, 0.5);
}

.ci-breadcrumb a { color: var(--text-grey, #b8c2cc); text-decoration: none; }
.ci-breadcrumb a:hover { color: var(--ci-accent-cyan, #29b6f6); }
.ci-breadcrumb [aria-current="page"] { color: var(--text-white, #fff); }

/* ---------------------------------------------------------------- paper panel
 * The long-form reading sections sit on a light surface. Everything below
 * re-points the site's dark-on-glass vocabulary (section titles, prose, cards,
 * badges) at ink colours, so a page opts a section in with one class. */

.ci-paper {
    background: var(--ci-paper);
    color: var(--ci-ink);
}

.ci-paper + .ci-paper { padding-top: 0; }

.ci-paper h1, .ci-paper h2, .ci-paper h3, .ci-paper h4 { color: #0f2a3f; }

.ci-paper .section-title { text-shadow: none; }

.ci-paper .section-lead { color: var(--ci-ink-soft); }

.ci-paper .prose p {
    color: var(--ci-ink);
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 1.15rem;
    line-height: 1.75;
}

.ci-paper .prose strong { color: #0f2a3f; }

.ci-paper .card,
.ci-paper .rule,
.ci-paper .schedules,
.ci-paper .questions {
    background: var(--ci-paper-raised);
    border-color: var(--ci-paper-edge);
    backdrop-filter: none;
    box-shadow: none;
}

.ci-paper .card:hover,
.ci-paper .rule:hover {
    border-color: var(--ci-ink-accent);
    box-shadow: 0 8px 24px rgba(15, 42, 63, 0.08);
}

.ci-paper .card::before { display: none; }

.ci-paper .card p,
.ci-paper .rule p,
.ci-paper .schedule-list li,
.ci-paper .questions p,
.ci-paper .questions li,
.ci-paper .part-audience,
.ci-paper .questions .questions-lead { color: var(--ci-ink-soft); }

.ci-paper .part-clauses,
.ci-paper .rule-num { color: var(--ci-ink-accent); }

.ci-paper .badge-orange,
.ci-paper .badge-cyan {
    background: rgba(168, 71, 15, 0.08);
    border-color: rgba(168, 71, 15, 0.3);
    color: var(--ci-ink-warm);
}

.ci-paper .schedule-list svg { color: var(--ci-ink-accent); }

.ci-paper a:not(.btn) { color: var(--ci-ink-accent); }

.ci-paper .btn-ghost {
    border-color: var(--ci-paper-edge);
    color: var(--ci-ink-soft);
}

.ci-paper .btn-ghost:hover {
    border-color: var(--ci-ink-accent);
    color: var(--ci-ink-accent);
}

/* ---------------------------------------------------------------- publication cards
 * Drawn by library.js on the hub and in the related rows. One card for every
 * publication type; the foot line says what opening it asks of the reader. */

.ci-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: 1.5rem;
}

.ci-card {
    display: flex;
    flex-direction: column;
    background: var(--ci-bg-raised, #101D2A);
    border: 1px solid var(--ci-line, #1F3246);
    border-radius: 18px;
    overflow: hidden;
    color: var(--text-white, #fff);
    text-decoration: none;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.ci-card:hover,
.ci-card:focus-visible {
    transform: translateY(-4px);
    border-color: var(--ci-accent-orange, #f98a47);
}

.ci-card-cover {
    height: 180px;
    background: #0f2a3f;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ci-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* A designed stand-in for a publication with no cover image: a paper "page"
 * carrying the title, so the grid still reads as a shelf of documents. */
.ci-card-sheet {
    width: 118px;
    height: 150px;
    background: var(--ci-paper);
    color: #0f2a3f;
    border-radius: 3px;
    padding: 0.8rem 0.7rem;
    box-sizing: border-box;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.72rem;
    line-height: 1.25;
    overflow: hidden;
}

.ci-card-body {
    padding: 1.3rem 1.4rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.ci-card-kind {
    font-size: 0.74rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--ci-accent-cyan, #29b6f6);
    font-weight: 600;
}

.ci-card-title {
    font-family: var(--ci-serif, 'Source Serif 4', Georgia, serif);
    font-weight: 400;
    font-size: 1.4rem;
    line-height: 1.25;
}

.ci-card-authors { font-size: 0.92rem; color: var(--text-grey, #b8c2cc); }

.ci-card-presenter {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: var(--ci-accent-orange, #f98a47);
}

.ci-card-presenter svg { width: 16px; height: 16px; flex-shrink: 0; }

.ci-card-foot {
    margin-top: auto;
    padding-top: 0.8rem;
    border-top: 1px solid var(--ci-line, #1F3246);
    font-size: 0.84rem;
    color: var(--text-grey, #b8c2cc);
}

.ci-related-wrap[hidden] { display: none !important; }

/* ---------------------------------------------------------------- hub filters */

.ci-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.ci-chip {
    font-family: var(--ci-sans, 'Space Grotesk', sans-serif);
    font-size: 0.9rem;
    min-height: 40px;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--ci-line-strong, #2A4058);
    background: transparent;
    color: var(--text-grey, #b8c2cc);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.ci-chip:hover { color: var(--text-white, #fff); border-color: var(--ci-accent-cyan, #29b6f6); }

.ci-chip[aria-pressed="true"] {
    color: var(--ci-bg, #0A141E);
    border-color: var(--ci-text, #ECE8DF);
    background: var(--ci-text, #ECE8DF);
}

.ci-chip-presenter {
    border-color: rgba(249, 138, 71, 0.55);
    color: var(--ci-accent-orange, #f98a47);
}

.ci-chip-presenter[aria-pressed="true"] {
    border-color: var(--ci-accent-orange, #f98a47);
    background: rgba(249, 138, 71, 0.15);
}

/* ---------------------------------------------------------------- gate: a bundle's files */

[data-gate="downloads"] {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

[data-gate="downloads"] .btn { justify-content: center; }

/* ---------------------------------------------------------------- gate: returning reader */

.ci-gate-welcome {
    margin: 0 0 1.1rem;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    background: rgba(41, 182, 246, 0.1);
    font-size: 0.9rem;
    line-height: 1.5;
    color: #d6eefb;
}

.ci-gate-welcome button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--ci-accent-cyan, #29b6f6);
    text-decoration: underline;
    cursor: pointer;
}
