/* ==========================================================================
   CLIMATE-HEATMAP — visualisation climatologique de France.
   Refonte v2 : table aérée, cellules carrées plus larges, première colonne
   stable mais sans sticky overlay (qui causait du chevauchement). Pure CSS,
   table HTML sémantique (SEO-friendly), responsive avec scroll horizontal
   et indicateur de défilement.
   ========================================================================== */

.climate-heatmap-wrap {
    margin: 8px 0 22px;
    padding: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    /* Indicateur de défilement horizontal subtil */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}
.climate-heatmap-wrap::-webkit-scrollbar { height: 8px; }
.climate-heatmap-wrap::-webkit-scrollbar-track { background: transparent; }
.climate-heatmap-wrap::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.16);
    border-radius: 8px;
}

.climate-heatmap {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
                 "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}

.climate-heatmap--year {
    /* 240px région + 12 colonnes × 64px = 1008px minimum */
    min-width: 1008px;
}

.climate-heatmap--month {
    min-width: 480px;
}

.climate-heatmap thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 12px 4px;
    text-align: center;
    white-space: nowrap;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
    text-transform: uppercase;
    vertical-align: middle;
}

.climate-heatmap__corner {
    text-align: left !important;
    padding-left: 16px !important;
    width: 240px;
    min-width: 240px;
}

.climate-heatmap--year .climate-heatmap__col-header {
    width: 64px;
    min-width: 64px;
}

.climate-heatmap__row-header {
    background: #ffffff;
    color: #1d1d1f;
    text-align: left;
    font-weight: 600;
    padding: 14px 16px;
    width: 240px;
    min-width: 240px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    vertical-align: middle;
}

.climate-heatmap tbody tr:last-child .climate-heatmap__row-header,
.climate-heatmap tbody tr:last-child .climate-heatmap__cell {
    border-bottom: 0;
}

.climate-heatmap__region {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.25;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.climate-heatmap__city {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 3px;
    letter-spacing: 0.01em;
}

.climate-heatmap__cell {
    text-align: center;
    padding: 10px 4px;
    font-size: 0.84rem;
    color: #0f172a;
    line-height: 1.15;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.55);
}

.climate-heatmap--year .climate-heatmap__cell {
    width: 64px;
    min-width: 64px;
}

/* Max et min empilés verticalement : max en évidence, min en filigrane. */
.climate-heatmap__max,
.climate-heatmap__min {
    display: block;
    font-variant-numeric: tabular-nums;
}
.climate-heatmap__max {
    font-weight: 800;
    color: #0f172a;
    font-size: 1.05em;
    letter-spacing: -0.02em;
}
.climate-heatmap__min {
    font-weight: 500;
    color: rgba(15, 23, 42, 0.55);
    font-size: 0.78em;
    margin-top: 1px;
}

.climate-heatmap__cell--empty {
    background: #f8fafc;
    color: #cbd5e1;
}

/* Variante mode mes : table aérée, libellé tendance à droite. */
.climate-heatmap--month .climate-heatmap__cell {
    padding: 14px 18px;
    font-size: 0.96rem;
    text-align: center;
}

.climate-heatmap--month .climate-heatmap__cell--label {
    font-weight: 700;
    text-align: left;
    padding-left: 18px;
    letter-spacing: 0.01em;
}

.climate-heatmap__legend {
    margin: 14px 16px 4px;
    font-size: 0.84rem;
    color: #475569;
    line-height: 1.5;
}

.climate-heatmap__legend strong {
    color: #0f172a;
    font-weight: 700;
}

.climate-heatmap__source {
    margin: 4px 16px 14px;
    font-size: 0.74rem;
    color: #94a3b8;
    font-style: italic;
}

/* Dark mode */
body.dark-mode .climate-heatmap-wrap {
    background: #1c1c1e;
    border-color: rgba(255, 255, 255, 0.08);
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

body.dark-mode .climate-heatmap thead th {
    background: rgba(255, 255, 255, 0.04);
    color: #aeaeb2;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .climate-heatmap__row-header {
    background: #1c1c1e;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.dark-mode .climate-heatmap__region { color: #f5f5f7; }
body.dark-mode .climate-heatmap__city { color: #98989d; }

/* Cellules : on conserve le texte sombre lisible sur fonds pastels.
   Léger overlay sombre uniforme pour atténuer l'éclat en dark mode. */
body.dark-mode .climate-heatmap__cell {
    color: #1d1d1f;
    border-bottom-color: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, 0.06);
}

body.dark-mode .climate-heatmap__legend { color: #aeaeb2; }
body.dark-mode .climate-heatmap__legend strong { color: #f5f5f7; }
body.dark-mode .climate-heatmap__source { color: #6b7280; }

/* Responsive : sur petits écrans, scroll horizontal préserve la lisibilité.
   Pas de sticky-column (qui créait des chevauchements en v1). */
@media (max-width: 880px) {
    .climate-heatmap--year { min-width: 960px; }
    .climate-heatmap__corner,
    .climate-heatmap__row-header { width: 200px; min-width: 200px; }
    .climate-heatmap__region { font-size: 0.84rem; }
    .climate-heatmap__cell { padding: 12px 3px; font-size: 0.78rem; }
    .climate-heatmap--year .climate-heatmap__cell { width: 60px; min-width: 60px; }
}

@media (max-width: 600px) {
    .climate-heatmap--year { min-width: 880px; }
    .climate-heatmap__corner,
    .climate-heatmap__row-header { width: 180px; min-width: 180px; padding: 12px 12px; }
    .climate-heatmap__cell { padding: 10px 2px; font-size: 0.74rem; }
    .climate-heatmap--year .climate-heatmap__cell { width: 56px; min-width: 56px; }
    .climate-heatmap--month .climate-heatmap__cell { font-size: 0.86rem; padding: 11px 12px; }
}

/* Print : palette atténuée, scroll désactivé, table forcée à 100%. */
@media print {
    .climate-heatmap-wrap {
        overflow: visible;
        border: 1px solid rgba(0, 0, 0, 0.3);
        box-shadow: none;
        page-break-inside: avoid;
    }
    .climate-heatmap--year,
    .climate-heatmap--month {
        min-width: 0;
        width: 100%;
    }
    .climate-heatmap__cell {
        font-size: 0.74rem;
        padding: 6px 2px;
    }
}
