/* ═══════════════════════════════════════════════════════════════
   EconGE — editorial design system
   "Statistical bureau" aesthetic: ink on paper, hairline rules,
   serif display (Fraunces) + institutional sans (Public Sans),
   tabular figures everywhere numbers appear.
   Loaded only on /sites/econge/* pages via {% block extra_head %}.
   ═══════════════════════════════════════════════════════════════ */

:root {
    --eg-paper: #FAF7F2;        /* warm off-white, never pure #fff */
    --eg-shade: #F2EDE2;        /* deeper cream for insets & hover */
    --eg-ink: #1F1B16;          /* warm near-black, never pure #000 */
    --eg-body: #3A342A;         /* running text */
    --eg-mute: #6E6656;         /* secondary text, ≥4.5:1 on paper */
    --eg-faint: #8D8471;        /* large/decorative text only */
    --eg-rule: #DFD8CA;         /* hairline rules */
    --eg-accent: #E88B00;       /* orange — marks & rules, spent wisely */
    --eg-accent-ink: #9C5A00;   /* orange dark enough for small text */
    --eg-navy: #0f172a;         /* shared chrome */
    --eg-serif: 'Fraunces', 'Georgia', serif;
    --eg-sans: 'Public Sans', 'Inter', system-ui, sans-serif;
}

/* ─── Page base ─────────────────────────────────────────────── */

body.econge {
    background-color: var(--eg-paper);
    color: var(--eg-body);
    font-family: var(--eg-sans);
}

/* The portfolio navbar is transparent over dark heroes; portal pages
   are paper-light, so pin it solid navy from the start. */
body.econge #navbar {
    background-color: rgba(15, 23, 42, 0.97);
}

body.econge ::selection {
    background-color: rgba(232, 139, 0, 0.22);
}

body.econge a:focus-visible,
body.econge button:focus-visible,
body.econge input:focus-visible {
    outline: 2px solid var(--eg-accent-ink);
    outline-offset: 2px;
}

/* ─── Typography ────────────────────────────────────────────── */

.eg-serif {
    font-family: var(--eg-serif);
    font-optical-sizing: auto;
}

.eg-headline {
    font-family: var(--eg-serif);
    font-optical-sizing: auto;
    font-weight: 600;
    font-size: clamp(1.75rem, 1.1rem + 2.4vw, 3rem);
    line-height: 1.08;
    letter-spacing: -0.015em;
    color: var(--eg-ink);
    text-wrap: balance;
}

.eg-display {
    font-family: var(--eg-serif);
    font-optical-sizing: auto;
    font-weight: 600;
    font-size: clamp(3rem, 1.6rem + 6vw, 6.5rem);
    line-height: 0.98;
    letter-spacing: -0.02em;
    color: var(--eg-ink);
}

.eg-section-title {
    font-family: var(--eg-serif);
    font-weight: 600;
    font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem);
    line-height: 1.12;
    letter-spacing: -0.01em;
    color: var(--eg-ink);
    text-wrap: balance;
}

.eg-kicker {
    font-family: var(--eg-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--eg-mute);
}

.eg-kicker a { color: inherit; }
.eg-kicker a:hover { color: var(--eg-ink); }

.eg-kicker .eg-kicker-mark { color: var(--eg-accent-ink); }

.eg-num {
    font-variant-numeric: tabular-nums lining-nums;
}

.eg-prose {
    max-width: 62ch;
    line-height: 1.75;
    color: var(--eg-body);
}
.eg-prose p + p { margin-top: 1.1em; }

.eg-dropcap::first-letter {
    font-family: var(--eg-serif);
    font-weight: 600;
    font-size: 3.6em;
    line-height: 0.82;
    float: left;
    padding: 0.06em 0.1em 0 0;
    color: var(--eg-ink);
}

/* ─── Rules ─────────────────────────────────────────────────── */

/* Classic newspaper masthead rule: thick over thin */
.eg-rule-double {
    height: 7px;
    border-top: 3px solid var(--eg-ink);
    border-bottom: 1px solid var(--eg-ink);
}

.eg-rule-strong { border-top: 2px solid var(--eg-ink); }
.eg-hairline    { border-top: 1px solid var(--eg-rule); }

/* ─── Links & buttons ───────────────────────────────────────── */

.eg-link {
    color: var(--eg-accent-ink);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(156, 90, 0, 0.4);
    text-underline-offset: 3px;
    transition: color 0.15s ease-out, text-decoration-color 0.15s ease-out;
}
.eg-link:hover {
    color: var(--eg-ink);
    text-decoration-color: var(--eg-ink);
}

.eg-link-quiet {
    color: var(--eg-ink);
    text-decoration: none;
    transition: color 0.15s ease-out;
}
.eg-link-quiet:hover { color: var(--eg-accent-ink); }

.eg-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--eg-ink);
    color: var(--eg-paper);
    font-family: var(--eg-sans);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.8rem 1.6rem;
    border-radius: 2px;
    transition: background-color 0.15s ease-out;
}
.eg-btn:hover { background-color: #3A342A; }

.eg-btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--eg-ink);
    color: var(--eg-ink);
    font-family: var(--eg-sans);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: calc(0.8rem - 1px) 1.6rem;
    border-radius: 2px;
    transition: background-color 0.15s ease-out;
}
.eg-btn-ghost:hover { background-color: var(--eg-shade); }

/* ─── Chips (small-caps metadata tags) ──────────────────────── */

.eg-chip {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--eg-mute);
    border: 1px solid var(--eg-rule);
    border-radius: 2px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

.eg-chip-accent {
    color: var(--eg-accent-ink);
    border-color: rgba(156, 90, 0, 0.35);
}

/* ─── Forms ─────────────────────────────────────────────────── */

.eg-input {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--eg-ink);
    border-radius: 0;
    font-family: var(--eg-sans);
    font-size: 0.9rem;
    color: var(--eg-ink);
    padding: 0.45rem 0.1rem;
    transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
.eg-input::placeholder { color: var(--eg-faint); }
.eg-input:focus {
    outline: none;
    border-bottom-color: var(--eg-accent-ink);
    box-shadow: 0 1px 0 var(--eg-accent-ink);
}

.eg-search-btn {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--eg-ink);
    border-bottom: 1px solid var(--eg-ink);
    padding: 0.45rem 0.1rem;
    transition: color 0.15s ease-out;
}
.eg-search-btn:hover { color: var(--eg-accent-ink); }

/* ─── Tables ────────────────────────────────────────────────── */

.eg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.eg-table thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--eg-mute);
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--eg-ink);
    background-color: var(--eg-paper);
}
.eg-table tbody td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--eg-rule);
    vertical-align: top;
    font-variant-numeric: tabular-nums;
}
.eg-table tbody tr { transition: background-color 0.12s ease-out; }
.eg-table tbody tr:hover { background-color: var(--eg-shade); }

/* ─── Ledger (ruled index rows, the anti-card) ──────────────── */

.eg-ledger { border-top: 2px solid var(--eg-ink); }

.eg-ledger-row {
    display: block;
    border-bottom: 1px solid var(--eg-rule);
    padding: 1.15rem 0.35rem;
    transition: background-color 0.12s ease-out;
}
a.eg-ledger-row:hover { background-color: var(--eg-shade); }

.eg-ledger-row .eg-ledger-name {
    font-family: var(--eg-serif);
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--eg-ink);
    transition: color 0.12s ease-out;
}
a.eg-ledger-row:hover .eg-ledger-name { color: var(--eg-accent-ink); }

/* ─── Stats ─────────────────────────────────────────────────── */

.eg-stat {
    font-family: var(--eg-serif);
    font-weight: 600;
    font-size: clamp(1.9rem, 1.4rem + 1.8vw, 3rem);
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--eg-ink);
    font-variant-numeric: tabular-nums lining-nums;
}

.eg-stat-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--eg-mute);
    margin-top: 0.55rem;
}

.eg-stat-block {
    border-top: 1px solid var(--eg-ink);
    padding-top: 0.9rem;
    position: relative;
}
.eg-stat-block::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    width: 2rem;
    border-top: 3px solid var(--eg-accent);
}

/* ─── Figures (charts, diagrams) ────────────────────────────── */

.eg-figure {
    border-top: 2px solid var(--eg-ink);
    border-bottom: 1px solid var(--eg-rule);
    padding: 0.9rem 0 1.1rem;
}

.eg-figcaption {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--eg-mute);
}
.eg-figcaption .eg-fig-no { color: var(--eg-accent-ink); }

/* ─── Code (API docs) ───────────────────────────────────────── */

.eg-code {
    background-color: var(--eg-shade);
    border: 1px solid var(--eg-rule);
    border-radius: 2px;
    color: var(--eg-ink);
    font-size: 0.8125rem;
    line-height: 1.7;
    padding: 1rem 1.25rem;
    overflow-x: auto;
}

.eg-code-inline {
    background-color: var(--eg-shade);
    border: 1px solid var(--eg-rule);
    border-radius: 2px;
    font-size: 0.8125em;
    padding: 0.08em 0.35em;
    color: var(--eg-ink);
    white-space: nowrap;
}

/* ─── Breadcrumbs ───────────────────────────────────────────── */

.eg-crumbs {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--eg-faint);
}
.eg-crumbs a { color: var(--eg-mute); transition: color 0.12s ease-out; }
.eg-crumbs a:hover { color: var(--eg-accent-ink); }
.eg-crumbs .eg-crumb-here { color: var(--eg-ink); }

/* ─── Facets (catalog sidebar) ──────────────────────────────── */

.eg-facet-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--eg-mute);
    border-bottom: 1px solid var(--eg-ink);
    padding-bottom: 0.4rem;
    margin-bottom: 0.35rem;
}

.eg-facet {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--eg-body);
    padding: 0.3rem 0.35rem;
    border-bottom: 1px solid var(--eg-rule);
    transition: background-color 0.12s ease-out;
}
.eg-facet:hover { background-color: var(--eg-shade); }
.eg-facet .eg-facet-n {
    color: var(--eg-faint);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
}
.eg-facet-on {
    color: var(--eg-ink);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--eg-accent);
    background-color: var(--eg-shade);
}

/* ─── Sort pills ────────────────────────────────────────────── */

.eg-sort {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--eg-mute);
    padding: 0.3rem 0.55rem;
    border-radius: 2px;
    transition: color 0.12s ease-out;
}
.eg-sort:hover { color: var(--eg-ink); }
.eg-sort-on {
    color: var(--eg-paper);
    background-color: var(--eg-ink);
}
.eg-sort-on:hover { color: var(--eg-paper); }

/* ─── Bulk-download toolbar ─────────────────────────────────── */

.bulk-col { width: 36px; text-align: center; }
@media (max-width: 640px) { .bulk-col { display: none; } }

.bulk-toolbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--eg-ink);
    color: var(--eg-paper);
    padding: 12px 24px;
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    box-shadow: 0 -1px 0 var(--eg-accent);
    z-index: 50;
}
.bulk-toolbar.visible { display: flex; }
.bulk-toolbar .count { flex: 1; font-variant-numeric: tabular-nums; }
.bulk-toolbar a, .bulk-toolbar button {
    background: var(--eg-paper);
    color: var(--eg-ink);
    padding: 8px 14px;
    border: none;
    border-radius: 2px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8125rem;
}
.bulk-toolbar a[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

/* ─── Motion ────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    body.econge * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
