/* ==========================================================================
   COPECHECK DATA — Dark theme, data dashboard energy
   Colours: Navy #0a0e27, Teal #2a9d8f, Red #e63946, Cream #c8cad0
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy: #0a0e27;
    --navy-light: #121631;
    --navy-mid: #1a1f3d;
    --red: #e63946;
    --red-dark: #b82d38;
    --white: #f1faee;
    --cream: #c8cad0;
    --grey: #8a8d96;
    --grey-dark: #3a3d4a;
    --teal: #2a9d8f;
    --teal-dark: #1f7a6f;
    --amber: #f4a261;
    --purple: #9b59b6;
    --orange: #e76f51;
    --green: #4ade80;

    --font-mono: 'DM Mono', 'Fira Code', monospace;
    --font-serif: 'Playfair Display', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --max-width: 1200px;
    --radius: 6px;
    --radius-lg: 10px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font-sans);
    background: var(--navy);
    color: var(--cream);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Geometry Overlay --- */
.geo-grid { position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.geo-line { position: absolute; background: var(--teal); opacity: 0.03; }
.geo-h { top: 50%; left: 0; right: 0; height: 2px; }
.geo-v { left: 50%; top: 0; bottom: 0; width: 2px; }
.geo-dot { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--teal); opacity: 0.06; }
.geo-dot-1 { top: 25%; left: 25%; }
.geo-dot-2 { bottom: 25%; right: 25%; }

/* --- Skip Link --- */
.skip-link {
    position: absolute; top: -100px; left: 0; padding: 8px 16px;
    background: var(--teal); color: var(--navy); z-index: 9999;
    font-size: 0.85rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { top: 0; }

/* --- Header --- */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(10, 14, 39, 0.95); backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.header-inner {
    max-width: var(--max-width); margin: 0 auto;
    padding: 0.8rem 1.5rem; display: flex; align-items: center; gap: 2rem;
}
.logo { display: flex; gap: 2px; font-family: var(--font-mono); font-size: 0.95rem; font-weight: 500; text-decoration: none !important; }
.logo-data { color: var(--green); }
.logo-cope { color: var(--red); }
.logo-check { color: var(--cream); opacity: 0.6; }

.main-nav { display: flex; gap: 0.3rem; margin-left: auto; }
.nav-link {
    padding: 6px 14px; border-radius: var(--radius); font-size: 0.85rem;
    color: var(--grey); transition: all 0.2s;
}
.nav-link:hover, .nav-link.active { color: var(--cream); background: rgba(255,255,255,0.06); text-decoration: none; }

.nav-toggle {
    display: none; background: none; border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius); padding: 8px; cursor: pointer;
    flex-direction: column; gap: 4px; margin-left: auto;
}
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--cream); border-radius: 2px; }

/* --- Main --- */
.main-wrap { position: relative; z-index: 1; max-width: var(--max-width); margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* --- Section Titles --- */
.section-title { font-family: var(--font-serif); font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.section-subtitle { color: var(--grey); font-size: 1rem; margin-bottom: 2rem; max-width: 700px; }
.page-hero { margin-bottom: 2rem; }

/* --- Stat Cards --- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 2rem 0; }
.stat-card {
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 1.5rem; text-align: center;
}
.stat-num { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; color: var(--teal); }
.stat-label { font-size: 0.8rem; color: var(--grey); margin-top: 0.3rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- Chart Sections --- */
.chart-section { margin-bottom: 3rem; }
.chart-title { font-family: var(--font-mono); font-size: 1rem; color: var(--cream); margin-bottom: 1rem; font-weight: 500; }
.chart-container {
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 1.5rem; height: 350px; position: relative;
}
.chart-container.chart-tall { height: 450px; }
.chart-link { display: inline-block; margin-top: 0.75rem; font-size: 0.85rem; color: var(--teal); font-family: var(--font-mono); }

/* --- Country Filter Buttons --- */
.country-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.filter-btn {
    padding: 5px 12px; border-radius: var(--radius); font-size: 0.8rem;
    background: var(--navy-mid); border: 1px solid rgba(255,255,255,0.08);
    color: var(--grey); cursor: pointer; transition: all 0.2s; font-family: var(--font-mono);
}
.filter-btn:hover { border-color: var(--teal); color: var(--cream); }
.filter-btn.active { background: var(--teal); color: var(--navy); border-color: var(--teal); }

/* --- Data Tables --- */
.data-table-section { margin-bottom: 3rem; }
.data-table-wrap { overflow-x: auto; }
.data-table {
    width: 100%; border-collapse: collapse; font-size: 0.9rem;
    background: var(--navy-light); border-radius: var(--radius-lg); overflow: hidden;
}
.data-table th {
    padding: 0.75rem 1rem; text-align: left; font-family: var(--font-mono);
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--grey); border-bottom: 1px solid rgba(255,255,255,0.08);
    background: var(--navy-mid);
}
.data-table td {
    padding: 0.65rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--cream);
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* --- Severity / Trend Badges --- */
.severity-badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.severity-badge.critical { background: rgba(230,57,70,0.15); color: var(--red); }
.severity-badge.high { background: rgba(244,162,97,0.15); color: var(--amber); }
.severity-badge.moderate { background: rgba(155,89,182,0.15); color: var(--purple); }
.severity-badge.low { background: rgba(42,157,143,0.15); color: var(--teal); }

/* --- Indicator Cards (Country page) --- */
.indicator-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.indicator-card {
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 1.2rem;
}
.indicator-name { font-size: 0.75rem; color: var(--grey); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem; }
.indicator-value { font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700; color: var(--white); }
.indicator-meta { font-size: 0.8rem; color: var(--grey); margin-top: 0.3rem; }
.change-up { color: var(--red); }
.change-down { color: var(--green); }
.change-flat { color: var(--grey); }

/* --- Cope Badges --- */
.cope-badge {
    display: inline-block; min-width: 36px; padding: 3px 10px; border-radius: 12px;
    font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600;
    text-align: center;
}
.cope-badge.pure-cope { background: rgba(230,57,70,0.2); color: var(--red); }
.cope-badge.heavy-cope { background: rgba(244,162,97,0.2); color: var(--amber); }
.cope-badge.partial-cope { background: rgba(155,89,182,0.2); color: var(--purple); }
.cope-badge.somewhat-lucid { background: rgba(42,157,143,0.2); color: var(--teal); }
.cope-badge.reality { background: rgba(74,222,128,0.2); color: var(--green); }
.cope-badge.unscored { background: rgba(255,255,255,0.06); color: var(--grey); }

/* --- Commentary / Comment Cards --- */
.commentary-section { margin-bottom: 3rem; }
.comment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.comment-card {
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 1.2rem;
}
.comment-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.comment-series { font-family: var(--font-mono); font-size: 0.75rem; color: var(--teal); }
.comment-country { font-size: 0.8rem; color: var(--grey); }
.comment-headline { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--white); }
.comment-excerpt { font-size: 0.85rem; color: var(--grey); line-height: 1.5; }
.comment-meta { font-size: 0.7rem; color: var(--grey-dark); margin-top: 0.6rem; font-family: var(--font-mono); }

/* --- Feed --- */
.feed-filters { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 0.5rem; }
.filter-group label { font-size: 0.8rem; color: var(--grey); font-family: var(--font-mono); }
.filter-group select {
    padding: 6px 12px; border-radius: var(--radius); font-size: 0.85rem;
    background: var(--navy-mid); border: 1px solid rgba(255,255,255,0.1);
    color: var(--cream); cursor: pointer;
}

.feed-list { display: flex; flex-direction: column; gap: 1.5rem; }
.feed-card {
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 1.5rem;
}
.feed-card-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.feed-card-meta { display: flex; gap: 0.75rem; flex: 1; }
.feed-series { font-family: var(--font-mono); font-size: 0.8rem; color: var(--teal); }
.feed-country { font-size: 0.85rem; color: var(--grey); }
.feed-date { font-size: 0.75rem; color: var(--grey-dark); font-family: var(--font-mono); }
.feed-headline { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--white); }
.feed-body { font-size: 0.9rem; color: var(--cream); line-height: 1.6; }
.feed-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid rgba(255,255,255,0.04); }
.cope-type-label {
    font-family: var(--font-mono); font-size: 0.75rem; padding: 3px 10px;
    border-radius: 12px; font-weight: 600;
}
.cope-type-label.pure-cope { background: rgba(230,57,70,0.15); color: var(--red); }
.cope-type-label.heavy-cope { background: rgba(244,162,97,0.15); color: var(--amber); }
.cope-type-label.partial-cope { background: rgba(155,89,182,0.15); color: var(--purple); }
.cope-type-label.somewhat-lucid { background: rgba(42,157,143,0.15); color: var(--teal); }
.cope-type-label.reality { background: rgba(74,222,128,0.15); color: var(--green); }
.cope-type-label.unscored { background: rgba(255,255,255,0.06); color: var(--grey); }
.feed-model { font-size: 0.7rem; color: var(--grey-dark); font-family: var(--font-mono); }

/* --- Pagination --- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 1.5rem; margin-top: 2rem; }
.page-link { font-family: var(--font-mono); font-size: 0.85rem; color: var(--teal); padding: 6px 16px; border-radius: var(--radius); border: 1px solid var(--teal); }
.page-link:hover { background: var(--teal); color: var(--navy); text-decoration: none; }
.page-info { font-size: 0.85rem; color: var(--grey); }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--grey); }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* --- Country Grid --- */
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 2rem; }
.country-card {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem;
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius); transition: all 0.2s;
}
.country-card:hover { border-color: var(--teal); text-decoration: none; background: var(--navy-mid); }
.country-flag { font-size: 1.4rem; }
.country-name { font-size: 0.9rem; color: var(--cream); }
.countries-grid-section { margin-bottom: 3rem; }

/* --- About Page --- */
.about-section { max-width: 800px; }
.about-content h2 { font-family: var(--font-serif); font-size: 1.3rem; margin: 2rem 0 0.75rem; color: var(--white); }
.about-content p { margin-bottom: 1rem; color: var(--cream); }

.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin: 1rem 0; }
.source-card {
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg); padding: 1.2rem;
}
.source-card h3 { font-family: var(--font-mono); font-size: 0.9rem; color: var(--teal); margin-bottom: 0.5rem; }
.source-card p { font-size: 0.85rem; color: var(--grey); margin: 0; }

.scoring-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0; }
.scoring-item {
    background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius); padding: 1rem;
}
.scoring-name { font-family: var(--font-mono); font-size: 0.85rem; color: var(--teal); font-weight: 500; }
.scoring-weight { font-size: 0.75rem; color: var(--amber); margin: 0.3rem 0; }
.scoring-desc { font-size: 0.8rem; color: var(--grey); }

.verdict-key { line-height: 2.2; margin: 1rem 0; }
.network-list { list-style: none; padding: 0; margin: 1rem 0; }
.network-list li { padding: 0.3rem 0; font-size: 0.9rem; }

.stats-box {
    display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 2rem;
    padding: 1.5rem; background: var(--navy-light); border-radius: var(--radius-lg);
    border: 1px solid rgba(255,255,255,0.06);
}
.stat-item { text-align: center; }
.stat-item .stat-num { font-family: var(--font-mono); font-size: 1.5rem; color: var(--teal); display: block; }

/* --- Error Pages --- */
.error-section { text-align: center; padding: 6rem 2rem; }
.error-code { font-family: var(--font-mono); font-size: 6rem; color: var(--red); opacity: 0.5; }
.error-msg { font-size: 1.1rem; color: var(--grey); margin: 1rem 0 2rem; }
.btn-primary {
    display: inline-block; padding: 10px 24px; background: var(--teal);
    color: var(--navy); border-radius: var(--radius); font-weight: 600;
    font-size: 0.9rem; transition: all 0.2s;
}
.btn-primary:hover { background: var(--teal-dark); text-decoration: none; }

/* --- Footer --- */
.site-footer {
    border-top: 1px solid rgba(255,255,255,0.06); margin-top: 4rem;
    padding: 2rem 0;
}
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }
.footer-brand { margin-bottom: 1.5rem; }
.footer-tagline { font-size: 0.85rem; color: var(--grey); margin-top: 0.5rem; }
.footer-network { margin-bottom: 1.5rem; }
.network-title { font-family: var(--font-mono); font-size: 0.75rem; color: var(--grey); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.network-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: 0.85rem; justify-content: center; }
.network-links strong { color: var(--cream); }
.footer-copy { font-size: 0.75rem; color: var(--grey-dark); }

/* --- Responsive --- */
@media (max-width: 768px) {
    .nav-toggle { display: flex; }
    .main-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--navy-light); flex-direction: column; padding: 1rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
    .main-nav.open { display: flex; }
    .section-title { font-size: 1.5rem; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .chart-container { height: 280px; }
    .chart-container.chart-tall { height: 350px; }
    .comment-grid { grid-template-columns: 1fr; }
    .header-inner { gap: 1rem; }
    .indicator-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Expandable comment cards */
.comment-card.expandable { cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.comment-card.expandable:hover { border-color: rgba(255,255,255,0.15); background: rgba(255,255,255,0.03); }
.comment-card.expanded { border-color: var(--teal); }
.expand-icon { margin-left: auto; font-size: 0.7rem; color: var(--grey); transition: transform 0.2s; }
.comment-full { font-size: 0.85rem; color: var(--grey); line-height: 1.6; margin-top: 0.5rem; white-space: pre-wrap; word-wrap: break-word; }
.comment-full br { display: block; margin-bottom: 0.3rem; }

/* --- Source/Freshness Labels --- */
.chart-source-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--grey);
    margin-top: 0.5rem;
    opacity: 0.7;
}
.chart-source-label span { color: var(--grey); }

/* --- Method Notes Panel --- */
.method-notes {
    margin: 3rem 0 1rem;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    background: var(--navy-light);
    overflow: hidden;
}
.method-notes-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    color: var(--cream);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}
.method-notes-toggle:hover { background: rgba(255,255,255,0.03); }
.method-notes-toggle .chevron {
    font-size: 0.75rem;
    transition: transform 0.3s;
    color: var(--grey);
}
.method-notes-toggle[aria-expanded='true'] .chevron { transform: rotate(180deg); }
.method-notes-body {
    display: none;
    padding: 0 1.25rem 1.25rem;
    font-size: 0.85rem;
    color: var(--grey);
    line-height: 1.7;
}
.method-notes-body.open { display: block; }
.method-notes-body h3 {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--cream);
    margin: 1.25rem 0 0.4rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.method-notes-body h3:first-child { margin-top: 0; }
.method-notes-body p { margin-bottom: 0.6rem; }
.method-notes-body ul {
    margin: 0.4rem 0 0.8rem 1.2rem;
    list-style: disc;
}
.method-notes-body li { margin-bottom: 0.3rem; }
