/* Climate Curves — Static Site Styles */

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

body {
    background-color: #111827;
    color: #f9fafb;
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: #3b82f6; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Container ─────────────────────────────────────────────────────── */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.main-header {
    text-align: center;
    margin-bottom: 20px;
}
.main-header h1 {
    font-size: 2.2rem;
    margin-bottom: 5px;
    color: #f9fafb;
}
.main-header .subtitle {
    color: #9ca3af;
    font-size: 1.1rem;
    margin-bottom: 3px;
}
.main-header .description {
    color: #6b7280;
    font-size: 0.85rem;
}

/* ── Stat Cards ────────────────────────────────────────────────────────── */
.stat-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.stat-card {
    background-color: #1f2937;
    border-radius: 12px;
    padding: 15px 18px;
    flex: 1 1 160px;
    min-width: 0;
    max-width: 260px;
}
.stat-card .card-title {
    color: #9ca3af;
    font-size: 0.85rem;
    margin: 0;
}
.stat-card .card-value {
    color: #f9fafb;
    font-size: 1.4rem;
    font-weight: bold;
    margin: 5px 0;
}
.stat-card .card-subtitle {
    color: #6b7280;
    font-size: 0.82rem;
    margin: 0;
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #111827;
    padding: 8px 20px 0;
    border-bottom: 1px solid #374151;
    transition: box-shadow 0.2s ease;
}
.tabs-wrapper.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.tab-bar {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.tab-btn {
    background: #1f2937;
    color: #9ca3af;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 20px;
    font-size: 0.95rem;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    min-height: 44px;
    font-family: inherit;
}
.tab-btn:hover {
    color: #d1d5db;
}
.tab-btn.active {
    color: #f9fafb;
    border-bottom-color: #3b82f6;
    background-color: #111827;
}
.tab-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ── Tab Content ───────────────────────────────────────────────────────── */
.tab-content {
    display: none;
    padding: 20px;
}
.tab-content.active {
    display: block;
}

/* ── Section Notes ─────────────────────────────────────────────────────── */
.section-note {
    color: #9ca3af;
    font-size: 0.85rem;
    font-style: italic;
    margin: 0 0 15px 5px;
    line-height: 1.5;
}
.section-note.warning {
    color: #f59e0b;
}

/* ── Grid Layouts ──────────────────────────────────────────────────────── */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.full-width {
    margin-bottom: 20px;
}
.full-width.section-gap {
    margin-top: 40px;
    margin-bottom: 40px;
    padding-top: 20px;
    border-top: 1px solid #1e3a5f;
}

/* ── Insight Cards (autoresearch findings) ────────────────────────────── */
.insight-card {
    border-left: 3px solid #a855f7;
    background: rgba(30,30,46,0.7);
    padding: 12px 16px;
    margin: 8px 0 16px;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.6;
}
.insight-card strong { color: #e2e8f0; }
.insight-card .finding-tag {
    display: inline-block;
    background: rgba(168,85,247,0.2);
    color: #c4b5fd;
    font-size: 0.75rem;
    padding: 1px 6px;
    border-radius: 3px;
    margin-right: 6px;
}

/* ── Chart Containers ──────────────────────────────────────────────────── */
.chart-container {
    width: 100%;
    min-height: 400px;
    position: relative;
    z-index: 1;
}
/* Lock map containers to a fixed height so dropdown changes never resize */
#chart-precip-map,
#chart-drought-map,
#chart-snow-map {
    height: 450px;
    min-height: 450px;
}
.chart-container .chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 0.9rem;
}
.chart-container .chart-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #374151;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dropdowns ─────────────────────────────────────────────────────────── */
.dropdown-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding-left: 10px;
    flex-wrap: wrap;
    position: relative;
    z-index: 5;
}
.dropdown-pair {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 200px;
    flex-wrap: wrap;
}
.dropdown-pair label {
    color: #d1d5db;
    font-size: 0.95rem;
    white-space: nowrap;
}
.dropdown-pair select,
.map-dropdown {
    flex: 1;
    min-width: 120px;
    max-width: 300px;
    padding: 8px 12px;
    background-color: #1f2937;
    color: #f9fafb;
    border: 1px solid #374151;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    appearance: auto;
}
.map-dropdown:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* ── Slider (ENSO impact months) ───────────────────────────────────────── */
.slider-container {
    padding: 0 10px;
    margin-bottom: 10px;
    position: relative;
    z-index: 5;
}
.slider-container label {
    color: #d1d5db;
    font-size: 0.95rem;
    margin-right: 10px;
}
.slider-container input[type="range"] {
    width: 100%;
    margin-top: 6px;
    accent-color: #3b82f6;
}
.slider-marks {
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
    margin-top: 4px;
}
.slider-marks span {
    font-size: 0.75rem;
    cursor: pointer;
}
.slider-marks .green { color: #22c55e; }
.slider-marks .yellow { color: #eab308; }
.slider-marks .red { color: #ef4444; }

/* ── Info Panels ───────────────────────────────────────────────────────── */
.info-panel {
    background-color: #1e293b;
    border-radius: 8px;
    padding: 14px 20px;
    margin-bottom: 20px;
}
.info-panel h3, .info-panel h4 {
    margin: 0 0 8px;
}
.info-panel p, .info-panel li {
    color: #d1d5db;
    font-size: 0.88rem;
    line-height: 1.6;
}

.bordered-section {
    background-color: #111827;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #1e3a5f;
}

.disclaimer {
    background-color: #1e293b;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}
.disclaimer h3 { color: #f59e0b; font-size: 1rem; margin: 0 0 8px; }
.disclaimer p { color: #d1d5db; font-size: 0.85rem; line-height: 1.5; margin: 0 0 6px; }
.disclaimer .ipcc { color: #9ca3af; font-size: 0.8rem; font-style: italic; }

/* ── Teleconnection Controls ───────────────────────────────────────────── */
.telecon-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    position: relative;
    z-index: 5;
}
.telecon-controls label {
    color: #d1d5db;
    font-size: 0.95rem;
}
.telecon-controls select {
    width: 100px;
    min-width: 80px;
    font-size: 0.9rem;
}
.nav-btn {
    background-color: #374151;
    color: #d1d5db;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}
.nav-btn:hover { background-color: #4b5563; }
.telecon-jumps {
    display: flex;
    gap: 6px;
    margin-left: auto;
}
.jump-btn {
    background-color: #1e293b;
    color: #9ca3af;
    border: 1px solid #374151;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
}
.jump-btn:hover { background-color: #374151; color: #f9fafb; }

.regime-summary {
    background-color: #1e293b;
    border-radius: 8px;
    padding: 14px 18px;
    margin-top: 10px;
    min-height: 30px;
}

/* ── ENSO Status Card ──────────────────────────────────────────────────── */
.enso-status-card {
    background-color: #1f2937;
    border-radius: 12px;
    padding: 18px 24px;
    margin-bottom: 20px;
}

/* ── Glossary ──────────────────────────────────────────────────────────── */
.glossary {
    background-color: #1e293b;
    border-radius: 8px;
    padding: 12px 18px;
    margin-bottom: 20px;
}
.glossary summary {
    color: #f9fafb;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
}
.glossary summary:hover { color: #fbbf24; }
.glossary-content {
    margin-top: 10px;
    columns: 2;
    column-gap: 30px;
}
.glossary-content .term {
    margin-bottom: 10px;
    break-inside: avoid;
}
.glossary-content strong { color: #fbbf24; font-size: 0.9rem; }
.glossary-content span { color: #d1d5db; font-size: 0.85rem; }

/* ── Data Health Table ─────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.data-table th {
    background-color: #1e293b;
    color: #9ca3af;
    padding: 8px 12px;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
    border-bottom: 1px solid #374151;
}
.data-table td {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: #d1d5db;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
}
.data-table tbody tr:hover { background-color: rgba(55, 65, 81, 0.3); }

.status-fresh { color: #22c55e; }
.status-stale { color: #f59e0b; }
.status-missing { color: #ef4444; }

/* ── Key Findings / Education ──────────────────────────────────────────── */
.findings-panel {
    background-color: #1e293b;
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 10px;
}
.findings-panel h4 { color: #a855f7; margin: 0 0 10px; font-size: 1rem; }
.findings-panel li {
    color: #d1d5db;
    font-size: 0.88rem;
    line-height: 1.7;
    margin-bottom: 4px;
}

.education-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.education-grid h4 { margin: 0 0 6px; font-size: 0.95rem; }
.education-grid p { color: #9ca3af; font-size: 0.85rem; line-height: 1.5; }

/* ── Weather Map ───────────────────────────────────────────────────────── */
#weather-map {
    width: 100%;
    height: 600px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.footer {
    text-align: center;
    color: #6b7280;
    padding: 20px;
    border-top: 1px solid #374151;
    margin-top: 20px;
    font-size: 0.85rem;
}
.footer p { margin: 4px 0; }

/* ── Build Info ────────────────────────────────────────────────────────── */
.build-info {
    text-align: center;
    color: #4b5563;
    font-size: 0.75rem;
    margin-top: 8px;
}

/* ── Responsive: Tablet (<=1024px) ─────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-2col { grid-template-columns: 1fr; }
    .grid-2-1 { grid-template-columns: 1fr; }
    .education-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Responsive: Mobile (<=768px) ──────────────────────────────────────── */
@media (max-width: 768px) {
    .app-container { padding: 10px; overflow-x: hidden; }
    .main-header h1 { font-size: 1.5rem; }
    .main-header .subtitle { font-size: 0.85rem; }

    .stat-cards {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .stat-card { max-width: 100%; }

    .tab-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .grid-2col, .grid-2-1 { display: block; }
    .grid-2col > *, .grid-2-1 > * { margin-bottom: 15px; }

    .dropdown-row { flex-direction: column; align-items: stretch; gap: 8px; padding: 0 5px; }
    .dropdown-pair { flex-direction: column; align-items: stretch; flex: 1 1 100%; gap: 4px; }
    .dropdown-pair select, .map-dropdown { width: 100%; max-width: 100%; }

    .telecon-controls { flex-direction: column; align-items: stretch; gap: 10px; }
    .telecon-jumps { flex-wrap: wrap; margin-left: 0; gap: 6px; }
    .jump-btn { flex: 1 1 auto; padding: 6px 10px; }

    .glossary-content { columns: 1; }

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

    .chart-container { min-height: 300px; }
}

/* ── Responsive: Small Phone (<=480px) ─────────────────────────────────── */
@media (max-width: 480px) {
    .app-container { padding: 6px; }
    .main-header h1 { font-size: 1.3rem; }
    .stat-card .card-value { font-size: 1.1rem; }
    .stat-card .card-subtitle { font-size: 0.8rem; }
    .tab-btn { padding: 8px 8px; font-size: 0.78rem; }

    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        margin-bottom: 10px;
        padding: 10px;
        background-color: #1e293b;
        border-radius: 8px;
    }
    .data-table tbody td {
        display: block;
        text-align: left;
        padding: 3px 0;
        font-size: 0.85rem;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #9ca3af;
        margin-right: 8px;
    }
}

/* ── Print ─────────────────────────────────────────────────────────────── */
@media print {
    .tabs-wrapper, .tab-bar, select, .telecon-controls, .glossary { display: none !important; }
    .app-container { background: white !important; color: black !important; padding: 0; }
    .tab-content { display: block !important; }
    .stat-cards { flex-direction: row; }
    .grid-2col { display: grid; grid-template-columns: 1fr 1fr; }
}

/* ── Focus & Accessibility ─────────────────────────────────────────────── */
:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
