/**
 * AI SAT Benchmark Visualizations - Dark Theme
 * Matches PhilPapers survey aesthetic
 */

/* ── Visualization Cards ─────────────────────── */

.benchmark-viz {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
}

.viz-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 24px;
    color: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    margin-bottom: 20px;
}

.viz-card h4 {
    margin: 0 0 20px 0;
    font-size: 1.1em;
    font-weight: 600;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.viz-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.viz-row.two-col {
    grid-template-columns: repeat(2, 1fr);
}

.viz-row.four-col {
    grid-template-columns: repeat(4, 1fr);
}

/* ── Bell Curve ──────────────────────────────── */

.bell-curve-container {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 24px;
    margin: 1.5rem 0;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    overflow-x: auto;
}

.bell-curve-container svg text {
    fill: #94a3b8;
}

.bell-curve-container svg .chart-title {
    fill: #e2e8f0;
}

/* ── Bar Chart ───────────────────────────────── */

.bar-chart-container {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 24px;
    margin: 1.5rem 0;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    overflow-x: auto;
}

/* ── Horizontal Bars (model ranking) ─────────── */

.h-bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 55px;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.h-bar-label {
    font-size: 0.8em;
    color: #cbd5e1;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.h-bar-label .flagship-tag {
    display: inline-block;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    color: #78350f;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

.h-bar-label .china-tag {
    display: inline-block;
    background: linear-gradient(90deg, #ef4444, #dc2626);
    color: white;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

.h-bar-track {
    height: 24px;
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
}

.h-bar-fill {
    height: 100%;
    border-radius: 12px;
    animation: barGrow 1s ease-out forwards;
    position: relative;
    box-shadow: 0 0 10px currentColor;
}

.h-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
    border-radius: 12px 12px 0 0;
}

@keyframes barGrow {
    from { width: 0 !important; }
}

.h-bar-value {
    font-size: 0.85em;
    font-weight: 600;
    color: #e2e8f0;
}

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

.stats-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.benchmark-table {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
    font-size: 0.85em;
}

.benchmark-table th {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #1e1e3a 0%, #1a2540 100%);
    color: #c4b5fd;
    font-weight: 600;
    padding: 12px 14px;
    text-align: center;
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
    white-space: nowrap;
    font-size: 0.9em;
}

.benchmark-table td {
    padding: 10px 14px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: #e2e8f0;
    white-space: nowrap;
}

.benchmark-table tbody tr:hover td {
    background: rgba(99, 102, 241, 0.08);
}

.provider-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    color: white;
    font-size: 11px;
    font-weight: 500;
}

.flagship {
    display: inline-block;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    color: #78350f;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
}

.stats-table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.stats-table-wrapper::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.stats-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4);
    border-radius: 4px;
}

/* ── Stat Cards (summary numbers) ────────────── */

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin: 1.5rem 0;
}

.stat-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border: 1px solid rgba(99, 102, 241, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 50px rgba(0,0,0,0.4);
}

.stat-card .value {
    font-size: 2.2rem;
    font-weight: bold;
    background: linear-gradient(90deg, #6366f1, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .label {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Donut Charts ────────────────────────────── */

.donut-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 15px;
}

.donut {
    width: 100%;
    height: 100%;
}

.donut-progress {
    animation: donutFill 1.5s ease-out forwards;
}

@keyframes donutFill {
    from { stroke-dasharray: 0 314; }
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-value {
    display: block;
    font-size: 1.8em;
    font-weight: bold;
    background: linear-gradient(90deg, #6366f1, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.donut-label {
    font-size: 0.7em;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.donut-info {
    text-align: center;
    font-size: 0.85em;
    color: #94a3b8;
}

/* ── Provider Comparison Cards ───────────────── */

.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.provider-card {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    border: 2px solid;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.provider-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.provider-header {
    padding: 12px 16px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.provider-name { font-weight: 600; }
.provider-count { font-size: 0.75em; opacity: 0.9; font-weight: 400; }

.provider-models {
    padding: 12px 16px;
}

.provider-model-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.8em;
}

.provider-model-row:last-child { border-bottom: none; }
.provider-model-name { color: #cbd5e1; }

.provider-model-score {
    color: #e2e8f0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── US vs China Comparison ──────────────────── */

.country-compare {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
}

.country-side {
    text-align: center;
}

.country-flag {
    font-size: 2.5em;
    margin-bottom: 8px;
}

.country-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.country-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.country-stat-label { color: #94a3b8; }
.country-stat-value { color: #e2e8f0; font-weight: 600; }

.country-vs {
    font-size: 1.5em;
    font-weight: bold;
    color: #475569;
}

/* ── Methodology Note ────────────────────────── */

.methodology-note {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin: 1rem 0;
    font-size: 14px;
    color: #cbd5e1;
}

.methodology-note strong {
    color: #c4b5fd;
}

/* ── Consensus Bar ───────────────────────────── */

.consensus-bar-container {
    margin-bottom: 12px;
}

.consensus-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    margin-bottom: 4px;
}

.consensus-bar-question { color: #cbd5e1; font-weight: 500; }
.consensus-bar-pct { color: #a78bfa; font-weight: 600; }

.consensus-bar-track {
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.consensus-bar-fill {
    height: 100%;
    border-radius: 4px;
    animation: barGrow 1s ease-out forwards;
}

/* ── Responsive ──────────────────────────────── */

@media (max-width: 900px) {
    .viz-row, .viz-row.two-col, .viz-row.four-col {
        grid-template-columns: 1fr;
    }

    .h-bar-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .h-bar-label { text-align: left; }

    .provider-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .country-compare {
        grid-template-columns: 1fr;
    }

    .country-vs {
        transform: rotate(90deg);
    }
}

@media (max-width: 600px) {
    .provider-grid {
        grid-template-columns: 1fr;
    }

    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Light Mode Override ─────────────────────── */

@media (prefers-color-scheme: light) {
    .viz-card,
    .bell-curve-container,
    .bar-chart-container,
    .stat-card,
    .methodology-note {
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
        color: #1e293b;
        box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    }

    .stat-card .label,
    .donut-label, .donut-info,
    .h-bar-label, .provider-model-name,
    .country-stat-label, .consensus-bar-question {
        color: #64748b;
    }

    .h-bar-value, .provider-model-score,
    .country-stat-value, .benchmark-table td {
        color: #334155;
    }

    .h-bar-track, .consensus-bar-track {
        background: rgba(0,0,0,0.08);
    }

    .provider-card, .provider-model-row {
        background: rgba(0,0,0,0.03);
        border-bottom-color: rgba(0,0,0,0.05);
    }

    .stats-table-wrapper {
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
        box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    }

    .benchmark-table th {
        background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
        color: #4338ca;
        border-bottom-color: rgba(99, 102, 241, 0.2);
    }

    .benchmark-table td {
        color: #334155;
        border-bottom-color: rgba(0,0,0,0.04);
    }

    .benchmark-table tbody tr:hover td {
        background: rgba(99, 102, 241, 0.06);
    }

    .bell-curve-container svg text,
    .bar-chart-container svg text {
        fill: #475569;
    }

    .methodology-note {
        border-color: rgba(99, 102, 241, 0.15);
    }

    .methodology-note strong {
        color: #4338ca;
    }

    .stat-card {
        border-color: rgba(99, 102, 241, 0.1);
    }
}
