
/* =========================================================================
   Image SVG zoomable (menu TinyMCE « Insérer / Image SVG »)
   Styles scopés à .svg-container pour pouvoir avoir plusieurs SVG par page
   et ne pas interférer avec le reste du site.
   ========================================================================= */

.svg-container,
.svg-container * {
    box-sizing: border-box;
}

/* Instructions souris */
.svg-instructions {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: fadeInInstructions 0.5s ease-in-out;
}

.instruction-icon {
    font-size: 16px;
}

.instruction-text {
    line-height: 1.4;
}

.instruction-text strong {
    color: #4CAF50;
}

/* Niveau de zoom en cours, sous la ligne d'instructions */
.zoom-level {
    display: inline-block;
    margin-top: 4px;
    font-weight: 700;
    color: #FFD54F;
}

/* Moteur de zoom actif (viewbox / hybride), sous le niveau de zoom */
.zoom-mode {
    display: inline-block;
    margin-top: 2px;
    font-size: 11px;
    opacity: 0.75;
}

@keyframes fadeInInstructions {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mode normal : taille personnalisée, pas de zoom */
.svg-container {
    width: 80%;       /* Taille en mode normal : 80% de la largeur du conteneur parent */
    height: auto;     /* Hauteur proportionnelle au SVG */
    margin: 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    cursor: zoom-in;  /* loupe : indique qu'un clic agrandit */
    border: 1px solid black;
    background-color: white;
    transition: none;
    touch-action: auto;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Mode plein écran : zoom activé */
.svg-container.expanded {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    z-index: 9999;
    cursor: grab;
    border: none;
    touch-action: none;
}

.svg-container.expanded.dragging {
    cursor: grabbing;
}

/* Contour de sélection dans l'éditeur TinyMCE (objet non éditable sélectionné).
   data-mce-selected n'existe que dans l'éditeur => aucun effet sur le site publié. */
.svg-container[data-mce-selected] {
    outline: 3px solid #3399ff !important;
    outline-offset: 2px;
}

/* Wrapper du SVG */
.svg-wrapper {
    transform-origin: 0 0;
    position: relative;
    width: 100%;
    height: auto;
    transition: none;
    pointer-events: auto;
    touch-action: auto;
}

.svg-container.expanded .svg-wrapper {
    height: 100%;
    touch-action: none;
}

/* Mode normal : pleine largeur du conteneur, hauteur proportionnelle */
.svg-wrapper svg,
.svg-wrapper img.svg-img {
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    display: block;
}

/* Plein écran : on remplit la hauteur pour permettre le zoom/pan */
.svg-container.expanded .svg-wrapper svg,
.svg-container.expanded .svg-wrapper img.svg-img {
    height: 100% !important;
    max-height: none !important;   /* parité pi0 : laisse object-fit gérer l'échelle */
    object-fit: contain;
}

/* Le SVG ne doit pas bloquer les events de pan/zoom */
.svg-wrapper svg {
    pointer-events: none;
    touch-action: none;
}

/* Boutons de zoom pour mobile */
.mobile-zoom-controls {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

/* Instructions tactiles (mobile) */
.touch-instructions {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 11px;
    z-index: 1000;
    pointer-events: none;
}

/* Masquer tous les contrôles sauf le bouton expand en mode normal */
.svg-container:not(.expanded) .svg-instructions,
.svg-container:not(.expanded) .touch-instructions,
.svg-container:not(.expanded) .mobile-zoom-controls {
    display: none !important;
}

/* Indice flottant en HAUT À GAUCHE (évite le chevauchement avec le bloc
   d'informations situé en haut à droite). Hors flux (position:absolute). */
.escape-hint {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    max-width: 70vw;
    cursor: pointer;  /* tap pour sortir, utile sur tactile */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: fadeInEscape 0.4s ease-in-out;
}

@keyframes fadeInEscape {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Visibilité des libellés selon l'état (normal/plein écran, desktop/mobile) --- */

/* Astuce « cliquer pour zoomer » : masquée par défaut ; montrée seulement en mode
   normal sur mobile (voir media query plus bas). */
.escape-hint .hint-zoom { display: none; }

/* Libellés de sortie : uniquement en plein écran (jamais en mode normal). */
.svg-container:not(.expanded) .escape-hint .hint-desktop,
.svg-container:not(.expanded) .escape-hint .hint-mobile { display: none !important; }

/* En plein écran : ordinateur => « Échap » ; mobile traité dans la media query. */
.svg-container.expanded .escape-hint .hint-desktop { display: inline; }
.svg-container.expanded .escape-hint .hint-mobile  { display: none; }

/* Mode normal : conteneur masqué sur ordinateur (rien à signaler), visible sur mobile. */
.svg-container:not(.expanded) .escape-hint { display: none !important; }

@media (max-width: 1000px) {
    /* Plein écran sur mobile : « Échap » -> « Appuyer ici » */
    .svg-container.expanded .escape-hint .hint-desktop { display: none; }
    .svg-container.expanded .escape-hint .hint-mobile  { display: inline; }

    /* Mode normal sur mobile : on affiche le conteneur + l'astuce de zoom */
    .svg-container:not(.expanded) .escape-hint { display: flex !important; }
    .svg-container:not(.expanded) .escape-hint .hint-zoom { display: inline; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media screen and (max-width: 768px) {
    .svg-container {
        width: 90vw;
    }

    .svg-container.expanded {
        width: 100vw;
    }

    .svg-instructions {
        display: none;
    }

    .touch-instructions {
        display: block;
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* Détection tactile (tablettes) */
@media (max-width: 968px), (pointer: coarse) {
    .mobile-zoom-controls {
        display: flex;
    }

    .svg-instructions {
        display: none;
    }

    .touch-instructions {
        display: block;
    }
}
