/*
 * Carte interactive des secteurs (ville/_carte.html.twig). Les tailles des
 * textes et des points sont exprimées en unités SVG divisées par --zoom :
 * quand la carte zoome sur un département, ils gardent leur taille à l'écran.
 */

.secteurs-carte {
    display: grid;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 62rem) {
    .secteurs-carte {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    }
}

.secteurs-carte__scene {
    position: relative;
    overflow: hidden;
    border: 1px solid rgb(15 8 65 / 0.08);
    border-radius: var(--rayon-lg);
    background:
        radial-gradient(40rem 30rem at 30% 20%, rgb(46 163 242 / 0.1), transparent 60%),
        linear-gradient(180deg, #f3f7ff, #eef1fb);
    box-shadow: 0 30px 70px -45px rgb(15 8 65 / 0.5);
}

.sc {
    display: block;
    /* Au zoom, le dessin déborde du SVG jusqu'aux bords du cadre (qui coupe),
       au lieu de s'arrêter net au milieu. */
    overflow: visible;
    /* Le cadre garde les proportions de la vue d'ensemble : zoomer change la
       portion affichée, jamais la taille de la carte à l'écran. */
    inline-size: min(100%, calc(78vh * var(--ratio, 0.7)));
    aspect-ratio: var(--ratio, 0.7);
    margin-inline: auto;
}

/* — Départements — */
.sc-dep {
    cursor: pointer;
    outline: none;
}

.sc-dep__fond {
    fill: #fff;
    transition: fill 0.35s var(--ease-sortie);
}

.sc-dep__trame {
    fill: url(#sc-trame);
    opacity: 0;
    transition: opacity 0.35s var(--ease-sortie);
}

.sc-dep__trait {
    fill: none;
    stroke: rgb(55 50 255 / 0.35);
    stroke-width: 1.2px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    transition: stroke 0.35s var(--ease-sortie), stroke-width 0.35s var(--ease-sortie);
}

.sc-dep--atelier .sc-dep__fond {
    fill: rgb(55 50 255 / 0.06);
}

.sc-dep__numero {
    font-family: var(--police-titre);
    font-size: calc(22px / var(--zoom, 1));
    font-weight: 700;
    fill: transparent;
    stroke: rgb(55 50 255 / 0.28);
    stroke-width: 0.8px;
    vector-effect: non-scaling-stroke;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    transition: stroke 0.35s var(--ease-sortie), opacity 0.35s var(--ease-sortie);
}

.sc-dep.est-allume .sc-dep__fond,
.sc-dep.est-choisi .sc-dep__fond {
    fill: rgb(46 163 242 / 0.12);
}

.sc-dep.est-allume .sc-dep__trame,
.sc-dep.est-choisi .sc-dep__trame {
    opacity: 1;
}

.sc-dep.est-allume .sc-dep__trait,
.sc-dep.est-choisi .sc-dep__trait,
.sc-dep:focus-visible .sc-dep__trait {
    stroke: var(--electrique);
    stroke-width: 2.2px;
}

.sc-dep.est-allume .sc-dep__numero {
    stroke: var(--electrique);
}

/* Zoomé : le département choisi devant, les autres en retrait. */
.secteurs-carte--zoom .sc-dep:not(.est-choisi) {
    opacity: 0.45;
}

.secteurs-carte--zoom .sc-dep.est-choisi .sc-dep__numero {
    opacity: 0;
}

/* — Cercles de distance — */
.sc-cercles circle {
    fill: none;
    stroke: rgb(46 163 242 / 0.45);
    stroke-width: 1px;
    stroke-dasharray: 3 4;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.sc-cercles text {
    font-family: var(--police-texte);
    font-size: calc(4px / var(--zoom, 1));
    font-weight: 600;
    fill: var(--cyan);
    text-anchor: middle;
    pointer-events: none;
}

/* — Liaisons — */
.sc-liaisons path {
    fill: none;
    stroke: rgb(55 50 255 / 0.22);
    stroke-width: 1px;
    stroke-dasharray: 2 3;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
    transition: stroke 0.3s var(--ease-sortie);
}

.sc-liaisons path.est-allume {
    stroke: var(--cyan);
    stroke-width: 2px;
    stroke-dasharray: none;
    filter: drop-shadow(0 0 2px rgb(46 163 242 / 0.9));
}

/* — Communes — */
.sc-ville {
    cursor: pointer;
    outline: none;
}

.sc-ville__point {
    r: calc(2.3px / var(--zoom, 1));
    fill: var(--electrique);
    stroke: #fff;
    stroke-width: 1.4px;
    vector-effect: non-scaling-stroke;
    transition: fill 0.25s var(--ease-sortie);
}

.sc-ville__halo {
    r: calc(7px / var(--zoom, 1));
    fill: rgb(46 163 242 / 0.25);
    opacity: 0;
    /* Invisible au repos, il ne doit pas capter la souris à la place d'un voisin. */
    pointer-events: none;
    transition: opacity 0.25s var(--ease-sortie);
}

.sc-ville__nom {
    font-family: var(--police-texte);
    font-size: calc(4.6px / var(--zoom, 1));
    font-weight: 600;
    fill: var(--encre);
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 3px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    transform: translate(calc(3.6px / var(--zoom, 1)), calc(1.6px / var(--zoom, 1)));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease-sortie);
}

.sc-ville.est-allume .sc-ville__point,
.sc-ville:focus-visible .sc-ville__point {
    fill: var(--cyan);
}

.sc-ville.est-allume .sc-ville__halo,
.sc-ville:focus-visible .sc-ville__halo {
    opacity: 1;
}

/* À l'ouest de l'atelier, le nom passe à gauche du point : les noms
   s'écartent de l'amas autour des Herbiers au lieu de s'y empiler. */
.sc-ville--gauche .sc-ville__nom {
    text-anchor: end;
    transform: translate(calc(-3.6px / var(--zoom, 1)), calc(1.6px / var(--zoom, 1)));
}

/* L'atelier porte déjà le nom des Herbiers. */
.sc-ville[data-slug="les-herbiers"] .sc-ville__nom {
    display: none;
}

/* Les noms apparaissent pour les communes du département choisi (sauf sur
   une carte étroite, où ils se chevaucheraient : la bulle les donne). */
.sc-ville.est-choisie .sc-ville__nom {
    opacity: 1;
}

.secteurs-carte--zoom .sc-ville:not(.est-choisie) {
    opacity: 0.35;
}

/* — Atelier — */
.sc-atelier__point {
    fill: var(--electrique);
    stroke: #fff;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.sc-atelier__onde {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
    transform-box: fill-box;
    transform-origin: center;
    animation: sc-onde 2.8s ease-out infinite;
}

.sc-atelier__onde--2 {
    animation-delay: 1.4s;
}

@keyframes sc-onde {
    from { transform: scale(1); opacity: 0.9; }
    to { transform: scale(5); opacity: 0; }
}

.sc-atelier__nom {
    font-family: var(--police-texte);
    font-size: calc(5px / var(--zoom, 1));
    font-weight: 700;
    fill: var(--electrique);
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 3px;
    vector-effect: non-scaling-stroke;
}

/* — Bulle, retour, légende — */
.sc-bulle {
    position: absolute;
    z-index: 2;
    padding: 0.4rem 0.75rem;
    border-radius: var(--rayon-sm);
    background: rgb(7 3 32 / 0.92);
    color: #fff;
    font-size: var(--t-xs);
    font-weight: 500;
    white-space: nowrap;
    translate: -50% calc(-100% - 0.6rem);
    pointer-events: none;
    box-shadow: 0 10px 24px -10px rgb(7 3 32 / 0.8);
}

.sc-retour {
    position: absolute;
    inset-block-start: 1rem;
    inset-inline-start: 1rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid rgb(55 50 255 / 0.25);
    border-radius: var(--rayon-plein);
    background: #fff;
    color: var(--electrique);
    font: inherit;
    font-size: var(--t-sm);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 20px -12px rgb(15 8 65 / 0.5);
}

.sc-legende {
    position: absolute;
    inset-block-end: 0.75rem;
    inset-inline-start: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin: 0;
    color: var(--texte-tres-doux);
    font-size: 0.75rem; /* 12 px minimum (audit du 14/10/2026) */
}

.sc-legende span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.sc-legende i {
    display: inline-block;
    inline-size: 0.6rem;
    block-size: 0.6rem;
}

.sc-legende__atelier {
    border-radius: 2px;
    background: var(--electrique);
}

.sc-legende__ville {
    border: 1.5px solid #fff;
    border-radius: 50%;
    background: var(--electrique);
    box-shadow: 0 0 0 1px rgb(55 50 255 / 0.3);
}

.sc-legende__cercle {
    border: 1px dashed var(--cyan);
    border-radius: 50%;
}

.sc-source {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--texte-tres-doux);
    font-size: 0.75rem; /* 12 px minimum (audit du 14/10/2026) */
}

/* — Panneau — */
.sc-panneau {
    display: grid;
}

.sc-fiche[hidden] {
    display: none;
}

.sc-fiche {
    display: grid;
    gap: 1rem;
    padding: clamp(1.4rem, 3vw, 2rem);
    border: 1px solid rgb(15 8 65 / 0.08);
    border-radius: var(--rayon-lg);
    background: #fff;
    box-shadow: 0 30px 60px -45px rgb(15 8 65 / 0.5);
    animation: sc-fiche 0.45s var(--ease-sortie);
}

@keyframes sc-fiche {
    from { opacity: 0; transform: translateY(8px); }
}

.sc-fiche__surtitre {
    color: var(--electrique);
    font-size: var(--t-xs);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sc-fiche__titre {
    font-family: var(--police-titre);
    font-size: var(--t-lg);
    font-weight: 700;
    line-height: 1.2;
}

.sc-fiche__texte {
    color: var(--texte-doux);
}

.sc-fiche__liste,
.sc-communes {
    display: grid;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sc-choix {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    inline-size: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid rgb(15 8 65 / 0.08);
    border-radius: var(--rayon);
    background: #fff;
    color: var(--texte);
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color 0.3s var(--ease-sortie), background-color 0.3s var(--ease-sortie), transform 0.3s var(--ease-sortie);
}

.sc-choix:hover,
.sc-choix:focus-visible {
    border-color: rgb(46 163 242 / 0.6);
    background: rgb(46 163 242 / 0.06);
    transform: translateX(4px);
    outline: none;
}

.sc-choix__numero {
    font-family: var(--police-titre);
    font-size: 1.5rem;
    font-weight: 700;
    color: transparent;
    -webkit-text-stroke: 1.2px var(--electrique);
}

.sc-choix__nom {
    font-weight: 600;
}

.sc-choix__compte {
    display: grid;
    place-items: center;
    min-inline-size: 1.8rem;
    padding: 0.15rem 0.45rem;
    border-radius: var(--rayon-plein);
    background: rgb(55 50 255 / 0.08);
    color: var(--electrique);
    font-size: var(--t-xs);
}

.sc-communes a {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--rayon-sm);
    color: var(--texte);
    text-decoration: none;
    transition: background-color 0.25s var(--ease-sortie), box-shadow 0.25s var(--ease-sortie);
}

.sc-communes a:hover,
.sc-communes a:focus-visible {
    background: rgb(46 163 242 / 0.08);
    box-shadow: inset 2px 0 0 var(--cyan);
    outline: none;
}

.sc-communes__km {
    color: var(--texte-tres-doux);
    font-size: var(--t-xs);
}

.sc-fiche__lien {
    justify-self: start;
}

@media (prefers-reduced-motion: reduce) {
    .sc-atelier__onde {
        animation: none;
        opacity: 0;
    }
}

/* — Version compacte (accueil) : la carte seule, sans panneau — */
.secteurs-carte--compacte {
    grid-template-columns: minmax(0, 1fr);
}

.secteurs-carte--compacte .sc {
    inline-size: 100%;
    max-inline-size: none;
}

.secteurs-carte--compacte .sc-dep[data-lien] {
    cursor: pointer;
}

/* — Page Contact — */
.contact__zone-entete {
    display: grid;
    gap: 0.75rem;
    max-inline-size: 44rem;
    margin-block-end: clamp(1.5rem, 4vw, 2.5rem);
}

.sc-atelier__nom--gauche {
    text-anchor: end;
}

.sc--etroite .sc-ville.est-choisie .sc-ville__nom {
    opacity: 0;
}

/* Petite carte de l'accueil sur mobile : la légende recouvrirait les points. */
@media (max-width: 40rem) {
    .secteurs-carte--compacte .sc-legende {
        display: none;
    }
}

/* « Partout en France » (téléphonie, logiciels) : hors de la carte, encadré en bleu, renvoie à l'appel du bas. */
.sc-choix--france {
    border: 1.5px solid var(--electrique);
    background: linear-gradient(90deg, rgb(55 50 255 / 0.07), #fff);
    text-decoration: none;
}

.sc-choix--france .sc-choix__nom small {
    display: block;
    font-size: var(--t-xs);
    font-weight: 400;
    color: var(--texte-doux);
}
