@font-face {
    font-family: "Campton";
    src: url("assets/CamptonBook.otf") format("opentype");
    font-display: swap;
}
@font-face {
    font-family: "Carla Sans";
    src: url("assets/CarlaSansLight.otf") format("opentype");
    font-display: swap;
}

:root {
    --bleu: #006b80;
    --bleu-clair: #4fb3c4;
    --encre: #10343c;
    --gris: #61767b;
    --trait: rgba(16, 52, 60, 0.1);
    --fond: #f2f2f2;           /* = fond des rendus : la scène se fond dans la page */
    --verre: rgba(255, 255, 255, 0.66);
    --ombre: 0 10px 40px rgba(0, 45, 55, 0.12), 0 1px 3px rgba(0, 45, 55, 0.08);
    --panneau: 360px;
    --marge: 20px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --g-th-a: #006b80;
    --g-th-b: #4fb3c4;
    --g-c: #c9965b;
    --g-d: #5d6f8f;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--fond);
    color: var(--encre);
    font: 15px/1.4 "Campton", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.verre {
    background: var(--verre);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    backdrop-filter: blur(20px) saturate(170%);
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: var(--ombre);
}
.rond {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-grid; place-items: center;
    transition: background .2s, color .2s;
}
.rond:hover { background: rgba(0, 107, 128, 0.1); color: var(--bleu); }
.rond:disabled { opacity: .3; pointer-events: none; }
.bouton {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 18px;
    border-radius: 999px;
    background: var(--bleu); color: #fff;
    text-decoration: none; font-size: 14px; letter-spacing: .02em;
    transition: background .2s, transform .2s var(--ease);
}
.bouton:hover { background: #00596b; }
.bouton.secondaire { background: rgba(0, 107, 128, 0.1); color: var(--bleu); }
.bouton.secondaire:hover { background: rgba(0, 107, 128, 0.17); }
.lien { display: inline-flex; align-items: center; gap: 4px; color: var(--gris); font-size: 14px; }
.lien:hover { color: var(--bleu); }

/* ---------- scène ---------- */
#plateau {
    position: fixed; inset: 0;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
}
#plateau.glisse { cursor: grabbing; }
#scene {
    position: absolute; left: 0; top: 0;
    width: 1920px; height: 1080px;
    transform-origin: 0 0;
    will-change: transform;
}
#rendu { width: 100%; height: 100%; display: block; }
#reperes { position: absolute; inset: 0; }

.repere {
    position: absolute;
    width: 0; height: 0;
    transform: scale(var(--inv, 1));
}
.repere > b {
    position: absolute;
    left: -17px; top: -17px;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 2px solid transparent;   /* zone de clic discrète : le numéro est déjà dans le rendu */
    display: grid; place-items: center;
    font-weight: normal; font-size: 13px; color: transparent;
    transition: background .18s, color .18s, transform .25s var(--ease), border-color .18s;
    pointer-events: auto; cursor: pointer;
}
.repere.avant > b {   /* filtre actif : on montre où sont les villas retenues */
    background: rgba(0, 107, 128, .55); border-color: rgba(255, 255, 255, .9); color: #fff;
    box-shadow: 0 2px 8px rgba(0, 40, 50, .2);
}
.repere:hover > b, .repere.survol > b {
    background: rgba(0, 107, 128, .92); border-color: #fff; color: #fff; transform: scale(1.12);
    box-shadow: 0 2px 10px rgba(0, 40, 50, .25);
}
.repere.choisi > b {
    background: var(--bleu); color: #fff; border-color: #fff; transform: scale(1.18);
}
.repere.choisi::before {
    content: ""; position: absolute; left: -17px; top: -17px; width: 34px; height: 34px;
    border-radius: 50%; background: var(--bleu); opacity: .35;
    animation: halo 1.8s var(--ease) infinite;
}
@keyframes halo { from { transform: scale(1); opacity: .45; } to { transform: scale(2.6); opacity: 0; } }
.repere.estompe > b { opacity: .0; pointer-events: none; }
.repere.point > b {
    left: -17px; top: -17px; width: 34px; height: 34px;
    border: 5px solid #fff; background: var(--c);
}
.repere.point:hover > b, .repere.point.survol > b { background: var(--c); transform: scale(1.5); color: transparent; }

#infobulle {
    position: fixed; z-index: 30; pointer-events: none;
    padding: 8px 12px; border-radius: 10px;
    background: rgba(16, 52, 60, .92); color: #fff;
    font-size: 13px; line-height: 1.35; white-space: nowrap;
    transform: translate(-50%, calc(-100% - 22px));
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
#infobulle strong { font-weight: normal; font-size: 14px; }
#infobulle span { opacity: .75; }

/* ---------- en-tête ---------- */
#entete {
    position: fixed; z-index: 10;
    top: var(--marge); left: var(--marge);
    right: calc(var(--panneau) + var(--marge) * 2);
    height: 60px;
    border-radius: 18px;
    display: flex; align-items: center; gap: 18px;
    padding: 0 10px 0 18px;
}
.logo img { height: 34px; display: block; }
#onglets {
    margin-left: auto;
    display: flex; gap: 2px;
    padding: 4px; border-radius: 999px;
    background: rgba(16, 52, 60, .05);
    overflow-x: auto; scrollbar-width: none;
}
#onglets::-webkit-scrollbar { display: none; }
#onglets button {
    height: 36px; padding: 0 16px; border-radius: 999px;
    font-size: 14px; color: var(--gris); white-space: nowrap;
    transition: background .2s, color .2s, box-shadow .2s;
}
#onglets button:hover { color: var(--encre); }
#onglets button[aria-selected="true"] {
    background: #fff; color: var(--bleu);
    box-shadow: 0 1px 4px rgba(0, 40, 50, .12);
}

/* ---------- panneau ---------- */
#panneau {
    position: fixed; z-index: 10;
    top: var(--marge); right: var(--marge); bottom: var(--marge);
    width: var(--panneau);
    border-radius: 22px;
    display: flex; flex-direction: column;
    overflow: hidden;
}
#poignee { display: none; }
#vue-liste, #vue-fiche { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panneau-tete { padding: 24px 24px 12px; }
.panneau-tete h1 {
    margin: 0; font: 26px/1.15 "Carla Sans", "Campton", sans-serif; color: var(--bleu); letter-spacing: .01em;
}
.panneau-tete p { margin: 6px 0 0; color: var(--gris); font-size: 14px; }
.recherche {
    margin: 4px 20px 10px;
    display: flex; align-items: center; gap: 8px;
    height: 42px; padding: 0 14px;
    border-radius: 12px; background: rgba(255, 255, 255, .8);
    border: 1px solid var(--trait);
    color: var(--gris);
}
.recherche:focus-within { border-color: rgba(0, 107, 128, .45); box-shadow: 0 0 0 3px rgba(0, 107, 128, .1); }
.recherche input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; color: var(--encre); }
#filtres { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 12px; }
#filtres button {
    height: 30px; padding: 0 12px; border-radius: 999px;
    font-size: 13px; color: var(--gris);
    border: 1px solid var(--trait); background: rgba(255, 255, 255, .55);
}
#filtres button[aria-pressed="true"] { background: var(--bleu); border-color: var(--bleu); color: #fff; }
#liste {
    list-style: none; margin: 0; padding: 0 10px 14px;
    overflow-y: auto; flex: 1;
    border-top: 1px solid var(--trait);
}
#liste li > button {
    width: 100%; display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 12px; text-align: left;
    transition: background .15s;
}
#liste li > button:hover, #liste li > button.survol { background: rgba(0, 107, 128, .08); }
#liste .num { font: 22px/1 "Carla Sans", "Campton", sans-serif; color: var(--bleu); }
#liste .info { font-size: 14px; }
#liste .info small { display: block; color: var(--gris); font-size: 12.5px; }
#liste .fleche { color: #9aabaf; }
#liste .vide { padding: 30px 14px; color: var(--gris); text-align: center; }
#liste .groupe {
    grid-template-columns: 14px 1fr auto;
}
#liste .pastille { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
#liste .groupe .info { font-size: 16px; }

.fiche-nav { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 0 18px; }
#fiche { overflow-y: auto; padding: 8px 24px 24px; flex: 1; }
#fiche .surtitre { color: var(--gris); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin: 8px 0 2px; }
#fiche h2 { margin: 0; font: 40px/1.05 "Carla Sans", "Campton", sans-serif; color: var(--bleu); }
#fiche .type {
    display: inline-block; margin-top: 10px;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(0, 107, 128, .1); color: var(--bleu); font-size: 13px;
}
#fiche .chiffre {
    margin: 22px 0 6px; padding: 16px 18px; border-radius: 16px;
    background: rgba(255, 255, 255, .75); border: 1px solid var(--trait);
    display: flex; justify-content: space-between; align-items: baseline;
}
#fiche .chiffre span { color: var(--gris); font-size: 14px; }
#fiche .chiffre strong { font: 28px/1 "Carla Sans", "Campton", sans-serif; font-weight: normal; }
#fiche table { width: 100%; border-collapse: collapse; margin: 8px 0 22px; font-size: 14px; }
#fiche td { padding: 9px 2px; border-bottom: 1px solid var(--trait); }
#fiche td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#fiche h3 { margin: 0 0 10px; font-size: 13px; font-weight: normal; letter-spacing: .06em; text-transform: uppercase; color: var(--gris); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.plans button {
    position: relative; aspect-ratio: 1132 / 1600; overflow: hidden;
    border-radius: 12px; background: #fff; border: 1px solid var(--trait);
    transition: transform .25s var(--ease), box-shadow .25s;
}
.plans button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 40, 50, .12); }
.plans img { width: 100%; height: 100%; object-fit: cover; object-position: center 40%; display: block; }
.plans span {
    position: absolute; left: 8px; bottom: 8px;
    padding: 3px 8px; border-radius: 999px; font-size: 12px;
    background: rgba(255, 255, 255, .92); box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- commandes ---------- */
#commandes {
    position: fixed; z-index: 10;
    bottom: var(--marge);
    left: calc((100vw - var(--panneau) - var(--marge)) / 2);
    transform: translateX(-50%);
    height: 52px; padding: 0 8px;
    border-radius: 999px;
    display: flex; align-items: center; gap: 4px;
}
#curseur { width: 220px; margin: 0 6px; accent-color: var(--bleu); }
#auto .pause { display: none; }
#auto[aria-pressed="true"] .lecture { display: none; }
#auto[aria-pressed="true"] .pause { display: block; }
#auto svg path { fill: currentColor; stroke: none; }
#zoom {
    position: fixed; z-index: 10;
    right: calc(var(--panneau) + var(--marge) * 2); bottom: var(--marge);
    border-radius: 14px; display: flex; flex-direction: column; overflow: hidden;
}
#zoom button { width: 40px; height: 40px; font-size: 20px; line-height: 1; color: var(--gris); }
#zoom button:hover { color: var(--bleu); background: rgba(0, 107, 128, .08); }
#zoom button + button { border-top: 1px solid var(--trait); }
#legende {
    position: fixed; z-index: 10;
    left: var(--marge); top: calc(var(--marge) + 72px);
    border-radius: 14px; padding: 10px 14px;
    display: grid; gap: 6px; font-size: 13px;
}
#legende span { display: flex; align-items: center; gap: 8px; }
#legende i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
#mention {
    position: fixed; left: var(--marge); bottom: calc(var(--marge) + 14px); margin: 0;
    font-size: 12px; color: rgba(16, 52, 60, .45); pointer-events: none;
}
#aide {
    position: fixed; z-index: 9; left: calc((100vw - var(--panneau) - var(--marge)) / 2); top: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 20px; border-radius: 999px;
    background: rgba(16, 52, 60, .78); color: #fff; font-size: 14px;
    pointer-events: none; transition: opacity .6s;
}
#chargement {
    position: fixed; z-index: 20;
    left: calc((100vw - var(--panneau) - var(--marge)) / 2); top: 50%;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    color: var(--gris); font-size: 14px;
    transition: opacity .4s;
}
#chargement.fini { opacity: 0; pointer-events: none; }
.anneau svg { width: 46px; height: 46px; transform: rotate(-90deg); }
.anneau circle { stroke: rgba(0, 107, 128, .15); stroke-width: 2.5; }
.anneau #progres { stroke: var(--bleu); stroke-dasharray: 97.4; stroke-dashoffset: 97.4; transition: stroke-dashoffset .2s; }

/* ---------- visionneuse de plans ---------- */
#visionneuse {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(242, 242, 242, .96);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    display: flex; flex-direction: column;
    animation: apparait .25s var(--ease);
}
@keyframes apparait { from { opacity: 0; } }
.visionneuse-tete {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 14px 20px; border-bottom: 1px solid var(--trait);
}
.visionneuse-tete strong { font: 22px/1 "Carla Sans", "Campton", sans-serif; color: var(--bleu); font-weight: normal; }
#v-niveaux { display: flex; gap: 4px; flex-wrap: wrap; }
#v-niveaux button { height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; color: var(--gris); }
#v-niveaux button[aria-current="true"] { background: var(--bleu); color: #fff; }
.v-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.visionneuse-corps { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
#v-image { max-height: 100%; max-width: calc(100% - 110px); object-fit: contain; background: #fff; box-shadow: var(--ombre); border-radius: 6px; }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
    :root { --marge: 10px; --panneau: 0px; }
    #entete {
        right: var(--marge); height: auto; flex-direction: column; align-items: stretch;
        gap: 8px; padding: 10px; border-radius: 16px;
    }
    .logo { align-self: center; }
    .logo img { height: 26px; }
    #onglets { margin-left: 0; }
    #onglets button { padding: 0 12px; font-size: 13px; height: 32px; }
    #panneau {
        top: auto; left: var(--marge); right: var(--marge); bottom: var(--marge);
        width: auto; height: 56vh; border-radius: 20px;
        transform: translateY(calc(100% - 118px));
        transition: transform .35s var(--ease);
    }
    #panneau.ouvert { transform: none; }
    #poignee { display: block; width: 100%; height: 22px; flex: none; }
    #poignee span { display: block; width: 40px; height: 5px; border-radius: 3px; background: rgba(16, 52, 60, .2); margin: 8px auto 0; }
    .panneau-tete { padding: 2px 18px 8px; }
    .panneau-tete h1 { font-size: 21px; }
    #commandes { left: 50%; bottom: 136px; height: 46px; }
    #curseur { width: 140px; }
    #zoom { display: none; }   /* on zoome en pinçant */
    body.feuille-ouverte #commandes, body.feuille-ouverte #mention, body.feuille-ouverte #legende { display: none; }
    #legende { top: auto; bottom: 190px; }
    #mention { bottom: 190px; left: auto; right: var(--marge); }
    #aide, #chargement { left: 50%; }
    #aide { white-space: nowrap; font-size: 13px; padding: 10px 16px; }
    #fiche h2 { font-size: 32px; }
    #v-image { max-width: 100%; }
    #v-prec, #v-suiv { display: none; }
}
