/* ── Climate Diagnostics — Static Site Styles ──────────────────────── */

/* ── CSS Custom Properties ─────────────────────────────────────────── */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21242f;
    --bg-sidebar: #161921;
    --text-primary: #e4e6ed;
    --text-secondary: #9ca0ae;
    --text-muted: #6b7085;
    --accent: #5b8af5;
    --accent-hover: #7ba4ff;
    --accent-dim: rgba(91, 138, 245, 0.12);
    --tier1: #5ba0f5;
    --tier2: #f5a623;
    --tier3: #b967f5;
    --border: #2a2d3a;
    --border-light: #353849;
    --success: #4ade80;
    --warning: #fbbf24;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 280px;
    --transition: 0.2s ease;

    /* Confidence badge colors */
    --confidence-high: #4ade80;
    --confidence-medium: #fbbf24;
    --confidence-low: #f87171;
}

/* ── Reset & Base ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

/* ── Layout: Sidebar + Main ────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 1.5rem 0;
    z-index: 100;
}

.sidebar-header {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.sidebar-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--tier3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.sidebar-header .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.sidebar-nav {
    padding: 0 0.75rem;
}

.tier-group {
    margin-bottom: 1rem;
}

.tier-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.4rem 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link:hover {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

/* ── Main Content ──────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1400px;
}

/* ── Page Header ───────────────────────────────────────────────────── */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.page-header .meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Tier Badges ───────────────────────────────────────────────────── */
.tier-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    line-height: 1;
}

.tier-badge--1 {
    background: rgba(91, 160, 245, 0.15);
    color: var(--tier1);
}

.tier-badge--2 {
    background: rgba(245, 166, 35, 0.15);
    color: var(--tier2);
}

.tier-badge--3 {
    background: rgba(185, 103, 245, 0.15);
    color: var(--tier3);
}

/* ── Card Grid (Index) ─────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
}

.card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-thumb {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 1rem 1.25rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-headline {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    padding: 0.6rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* ── Diagnostic Page ───────────────────────────────────────────────── */
.synthesis-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
}

.synthesis-box h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.synthesis-headline {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--accent);
    background: var(--accent-dim);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.synthesis-narrative {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-line;
}

/* ── Figure Section ────────────────────────────────────────────────── */
.figure-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.figure-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.figure-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.figure-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.figure-image {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.figure-image img {
    width: 100%;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.figure-details {
    padding: 1.25rem;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    max-height: 600px;
}

/* ── Metadata Table ────────────────────────────────────────────────── */
.meta-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.meta-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.35rem 0.6rem;
    white-space: nowrap;
    width: 35%;
    border-bottom: 1px solid var(--border);
}

.meta-table td {
    color: var(--text-secondary);
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--border);
}

/* ── Analysis Panel ────────────────────────────────────────────────── */
.analysis-panel h4 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 1rem 0 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analysis-panel h4:first-child {
    margin-top: 0;
}

.analysis-panel p,
.analysis-panel li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.analysis-panel ul {
    list-style: none;
    padding: 0;
}

.analysis-panel ul li {
    padding: 0.25rem 0 0.25rem 1rem;
    position: relative;
}

.analysis-panel ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* ── Confidence Badge ──────────────────────────────────────────────── */
.confidence-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.confidence-badge--high {
    background: rgba(74, 222, 128, 0.15);
    color: var(--confidence-high);
}

.confidence-badge--medium {
    background: rgba(251, 191, 36, 0.15);
    color: var(--confidence-medium);
}

.confidence-badge--low {
    background: rgba(248, 113, 113, 0.15);
    color: var(--confidence-low);
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .figure-content {
        grid-template-columns: 1fr;
    }

    .figure-details {
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem 1rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Lightbox ───────────────────────────────────────────────────────── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    cursor: zoom-out;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.lightbox.active {
    display: flex;
    animation: lightbox-fade-in 0.2s ease;
}

.lightbox img {
    max-width: 95vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

@keyframes lightbox-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Utility ───────────────────────────────────────────────────────── */
.no-analysis-notice {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.5rem 0;
}