/* ─── Charte BatExplore V2 ────────────────────────────────────────────────────
   Jetons et composants partagés de toutes les pages : carte, bâtiment
   (Synthèse · Simulation · Données) et Méthode & sources.
   Référence : docs/batexplore-refonte/PROMPT.md et maquettes (valeurs d'exemple).
   Les pages héritant de show.php en transition chargent aussi show.css : les jetons
   ci-dessous portent des noms différents (--marine… contre --brand…) pour éviter
   toute collision. */

:root {
    /* Marque */
    --marine: #17305A;        /* en-têtes, boutons principaux */
    --marine-fonce: #0F2340;  /* fond de la vue 3D */
    --marine-clair: #E6ECF6;
    --jaune: #F5C243;         /* réservé aux actions « Simuler » */
    --jaune-pale: #FFF4D6;

    /* Surfaces */
    --fond: #F2F4F7;
    --carte: #FFFFFF;
    --bordure: #DCE1E8;
    --bordure-forte: #C3CAD5;

    /* Texte (contraste ≥ 4,5:1 sur blanc) */
    --texte: #172033;
    --texte-2: #3A4456;
    --texte-3: #5A6474;

    /* Étiquettes DPE (reprises de la légende actuelle de la carte) et inconnu */
    --dpe-a: #319834;  --dpe-b: #33cc31;  --dpe-c: #cbfc34;  --dpe-d: #fbfe06;
    --dpe-e: #fdb515;  --dpe-f: #f9702a;  --dpe-g: #d7191c;  --inconnu: #DADADA;

    /* Îlot de chaleur : paliers calés sur la distribution réelle (Sat4BDNB, 1955 grands
       quartiers : min 4,5 °C, quartiles 6,3 / 7,0 / 7,7, max 10,1 °C → 6,5 / 7,5 / 8,5) */
    --icu-1: #FCE7C8;  --icu-2: #F4A259;  --icu-3: #D9532B;  --icu-4: #8E1F17;

    /* Étiquettes d'échelle : chaque bloc de données en porte une (PROMPT.md) */
    --ech-batiment-bg: #E6ECF6;   --ech-batiment-txt: #17305A;
    --ech-logement-bg: #FFF4D6;   --ech-logement-txt: #6B4E00;
    --ech-quartier-bg: #EFE7DA;   --ech-quartier-txt: #5B3B12;
    --ech-parcelle-bg: #E7F3E4;   --ech-parcelle-txt: #2F5A36;

    --ombre: 0 2px 10px rgba(23, 32, 51, 0.14);
    --radius-carte: 16px;
    --radius-btn: 12px;
}

/* Jetons du composant 3D d'EPSim (sim/css/viewer.css, partagé avec epsim.app) : ex-:root de show.css,
   limités à la page bâtiment pour ne polluer aucune autre feuille. */
.page-batiment { --ink: var(--texte); --muted: var(--texte-3); --line: var(--bordure); --card: var(--carte); --bg: var(--fond); --brand: var(--marine); }

/* box-sizing : la fiche bâtiment le tenait de show.css (retiré) */
.page-batiment, .page-batiment *, .page-batiment *::before, .page-batiment *::after,
.page-methode, .page-methode *, .page-methode *::before, .page-methode *::after { box-sizing: border-box; }

/* ── Base des pages V2 (classes dédiées : pas de body {} global) ────────────── */
.page-batiment,
.page-methode,
.page-carte {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--fond);
    color: var(--texte);
    line-height: 1.45;
    min-height: 100vh;
}
.page-batiment code,
.page-methode code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: #EEF1F6;
    padding: 1px 5px;
    border-radius: 4px;
    word-break: break-all;
}

/* Accessibilité : focus toujours visible */
.page-batiment a:focus-visible,
.page-batiment button:focus-visible,
.page-methode a:focus-visible,
.page-methode button:focus-visible {
    outline: 3px solid var(--jaune);
    outline-offset: 2px;
}

/* ── En-tête de site (marine, commun à toutes les pages) ────────────────────── */
.site-head { background: var(--marine); color: #FFFFFF; }
.site-head .head-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px; /* zones tactiles ≥ 44 px */
    padding: 0 8px;
}
.site-head a { color: #FFFFFF; }
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 0 8px;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0.08em;
    font-size: 0.9rem;
    color: #FFFFFF;
    margin: 0 auto; /* mobile : centré entre « ← Carte » et « Partager » */
}
.brand:hover { color: #FFFFFF; }
.head-back {           /* mobile : retour à la carte */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: #FFFFFF;
}
.head-share {          /* mobile : bouton Partager */
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: #FFFFFF;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 10px;
    padding: 0 10px;
}
.head-search {         /* ordinateur */
    display: none;
    flex: 1 1 300px;
    max-width: 520px;
}
.head-search input {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 10px;
    padding: 0 14px;
    font: inherit;
    font-size: 0.9rem;
    background: #FFFFFF;
    color: var(--texte);
}
/* Résultats de recherche d'adresse (API de géocodage de l'IGN) — carte et page bâtiment */
.head-search { position: relative; }
#address-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 10;
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--carte);
    color: var(--texte);  /* hérité sinon du blanc de .site-head */
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(23, 32, 51, 0.2);
    overflow: hidden;
    font-size: 0.9rem;
}
#address-results li { padding: 10px 12px; cursor: pointer; }
#address-results li:hover, #address-results li.active { background: var(--marine-clair); }
#address-results li.empty { color: var(--texte-3); cursor: default; }
.head-nav {            /* ordinateur */
    display: none;
    gap: 4px;
    margin-left: auto;
}
.head-nav a {
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: #FFFFFF;
}
.head-nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.16); font-weight: 700; }
@media (min-width: 1024px) {
    .site-head .head-inner { padding: 0 20px; gap: 20px; }
    .head-back, .head-share { display: none; }
    .brand { margin: 0; }
    .head-search, .head-nav { display: flex; }
}

/* ── Onglets de la page bâtiment (chaque onglet a sa propre URL) ───────────── */
.onglets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.onglets a {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--texte-3);
    text-decoration: none;
    border-bottom: 3px solid transparent;
}
.onglets a:hover { color: var(--texte); }
.onglets a[aria-current="page"] {
    color: var(--marine);
    border-bottom-color: var(--marine);
    font-weight: 700;
}

/* ── Boutons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius-btn);
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn-marine { background: var(--marine); color: #FFFFFF; }
.btn-jaune { background: var(--jaune); color: var(--texte); }
.btn-secondaire {
    background: var(--carte);
    color: var(--texte);
    border: 1px solid var(--bordure-forte);
}

/* ── Pastilles couleur : lettre DPE/GES, valeur d'îlot de chaleur, inconnu ──── */
.badge-lettre {
    min-width: 38px;
    height: 38px;
    padding: 0 6px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}
/* Estimation statistique (pas un diagnostic) : pastille éclaircie, contour pointillé (comme le confort d'été estimé) */
.badge-lettre.estime, .letter.estime { opacity: 0.72; outline: 1.5px dashed rgba(23, 32, 51, 0.6); outline-offset: -2px; }
/* Couleurs DPE (identiques à la légende de la carte actuelle), GES, inconnu */
.c-dpe-A { background: var(--dpe-a); color: #071A08; }
.c-dpe-B { background: var(--dpe-b); color: #10270F; }
.c-dpe-C { background: var(--dpe-c); color: #1B2A00; }
.c-dpe-D { background: var(--dpe-d); color: #2A2A00; }
.c-dpe-E { background: var(--dpe-e); color: #2E1D00; }
.c-dpe-F { background: var(--dpe-f); color: #2B1200; }
.c-dpe-G { background: var(--dpe-g); color: #FFFFFF; }
.c-ges-A { background: #E9E3F3; color: #2B2340; }
.c-ges-B { background: #D2C4E8; color: #2B2340; }
.c-ges-C { background: #B9A2DA; color: #241A3A; }
.c-ges-D { background: #9A7FC8; color: #160F27; }
.c-ges-E { background: #7B5BB0; color: #FFFFFF; }
.c-ges-F { background: #5F3F97; color: #FFFFFF; }
.c-ges-G { background: #43266F; color: #FFFFFF; }
.c-inconnu { background: var(--inconnu); color: var(--texte-2); }
.c-icu-1 { background: var(--icu-1); color: #4A2B00; }
.c-icu-2 { background: var(--icu-2); color: #3D2200; }
.c-icu-3 { background: var(--icu-3); color: #FFFFFF; }
.c-icu-4 { background: var(--icu-4); color: #FFFFFF; }

/* ── Confort d'été : indicateur du DPE (bon / moyen / insuffisant), échelle 1 logement ──
   Badge qualitatif de la fiche ; à distinguer de l'îlot de chaleur (c-icu-*, quartier) et du
   confort d'été simulé (onglet Simulation). */
.badge-qualitative {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.95rem;
    text-align: center;
}
.c-ete-bon { background: #1a9850; color: #FFFFFF; }
.c-ete-moyen { background: #f2b705; color: #2A1F00; }
.c-ete-insuffisant { background: #d73027; color: #FFFFFF; }
.c-ete-inconnu { background: var(--inconnu); color: var(--texte-2); }

/* ── Étiquettes d'échelle (BÂTIMENT · 1 LOGEMENT · QUARTIER · PARCELLE) ─────── */
.echelle {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 999px;
    vertical-align: middle;
    white-space: nowrap;
}
.echelle-batiment { background: var(--ech-batiment-bg); color: var(--ech-batiment-txt); }
.echelle-logement { background: var(--ech-logement-bg); color: var(--ech-logement-txt); }
.echelle-quartier { background: var(--ech-quartier-bg); color: var(--ech-quartier-txt); }
.echelle-parcelle { background: var(--ech-parcelle-bg); color: var(--ech-parcelle-txt); }

/* ── Vignettes « En un coup d'œil » et pastilles d'en-tête ───────────────────── */
.vignettes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.vignette {
    background: var(--carte);
    border: 1px solid var(--bordure);
    border-radius: 14px;
    padding: 12px;
    text-decoration: none;
    color: var(--texte);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vignette:hover { border-color: var(--marine); }
.vignette-titre {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--texte-3);
}
.vignette-detail { font-size: 0.78rem; color: var(--texte-2); }
.badge-lettre.compact { min-width: 30px; height: 30px; font-size: 1.05rem; border-radius: 6px; }
.pastille {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    font-size: 0.82rem;
    background: var(--carte);
}

/* ── Pied de page : avertissement conservé sur toutes les pages ─────────────── */
.site-foot { font-size: 0.75rem; color: var(--texte-3); line-height: 1.5; }
.site-foot a { color: var(--marine); }

/* ── Page simple (Méthode & sources) ─────────────────────────────────────────── */
.page-simple { max-width: 880px; margin: 0 auto; padding: 20px 16px 70px; }
.page-simple .bloc {
    background: var(--carte);
    border: 1px solid var(--bordure);
    border-radius: var(--radius-carte);
    padding: 18px 18px 14px;
}
.page-simple .bloc + .bloc { margin-top: 14px; }
.page-simple h1 { margin: 0 0 14px; font-size: 1.45rem; font-weight: 800; }
.page-simple h2 { margin: 0 0 10px; font-size: 1.05rem; font-weight: 800; color: var(--marine); }
.page-simple p, .page-simple li { font-size: 0.92rem; color: var(--texte-2); text-wrap: pretty; }
.page-simple p { margin: 0 0 10px; }
.page-simple ul { margin: 0 0 10px; padding-left: 1.2rem; }
.page-simple li { margin-bottom: 6px; }
.page-simple .note { background: var(--jaune-pale); border-radius: 10px; padding: 10px 12px; }
.page-simple table.sources { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.page-simple table.sources th,
.page-simple table.sources td { text-align: left; padding: 8px 10px 8px 0; vertical-align: top; }
.page-simple table.sources th { color: var(--texte-3); font-size: 0.8rem; }
.page-simple table.sources tr { border-bottom: 1px solid var(--bordure); }
.page-simple table.sources a { color: var(--marine); }

/* ── Menu « Colorer par » de la vue 3D (page bâtiment) ──────
   (mêmes teintes et même hauteur que les boutons « Zones », réinitialiser, capture). */
.b3d .v-color { padding: 0; background: none; box-shadow: none; border-radius: 0; }
.b3d .v-color select {
    appearance: auto;
    border: 0;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    padding: 0.35em 1.6em 0.35em 0.7em;
    font: inherit;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.2;
    width: auto;
    min-width: 0;
    max-width: none;
    cursor: pointer;
}
.b3d .v-color select:hover { background-color: #fff; }
.b3d .v-color select:focus-visible { outline: 3px solid var(--jaune); outline-offset: 1px; }

/* Page bâtiment : le libellé « Colorer par » reste visible, dans la même pastille blanche que le menu */
.b3d .v-color {
    gap: 0.2rem;
    padding: 0 0 0 0.7em;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
}
.b3d .v-color > span { white-space: nowrap; font-weight: 600; color: #1a1a2e; line-height: 1.2; }
.b3d .v-color select { background-color: transparent; box-shadow: none; padding-left: 0.3em; }
.b3d .v-color select:hover { background-color: rgba(15, 52, 96, 0.08); }

/* ── Finitions d'interaction (toutes pages V2) ──────────────────────────────── */
.page-batiment, .page-methode, .page-carte {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
.page-batiment ::selection, .page-methode ::selection, .page-carte ::selection { background: var(--jaune-pale); color: var(--texte); }
.page-batiment :is(h1, h2, h3), .page-methode :is(h1, h2, h3) { text-wrap: balance; }
.page-batiment p, .page-methode p { text-wrap: pretty; }

/* Retour visuel homogène : survol, appui, désactivé */
.btn, .vignette, .onglets a, .head-nav a, .head-share, .head-back, .head-aide {
    transition: background-color .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .1s ease, filter .15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn-secondaire:hover:not(:disabled) { border-color: var(--marine); background: var(--marine-clair); filter: none; }
.vignette:hover { box-shadow: var(--ombre); }

/* Focus clavier visible aussi sur les champs et les menus repliables */
:is(.page-batiment, .page-methode, .page-carte) :is(input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--jaune);
    outline-offset: 2px;
}

/* Barres de défilement discrètes */
:is(.page-batiment, .page-methode, .page-carte) * { scrollbar-width: thin; scrollbar-color: var(--bordure-forte) transparent; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
