/* ============================================================
   Lecteur public Photo Sphere Viewer — mobile-first (§9.2)
   Palette sombre pour l'immersion, overlay header + scene nav
   ============================================================ */

/* ---- Variables ---- */
:root {
    --viewer-header-h: 52px;
    --viewer-nav-h:    72px;   /* hauteur du bandeau plat (flat) — ne pas modifier en JS */
    --viewer-scene-h:  72px;   /* hauteur de la rangée de vignettes en mode groupé */
    --overlay-bg:      rgba(0, 0, 0, 0.65);
    --overlay-blur:    blur(8px);
    --accent:          var(--studio-viewer-accent, #f97316); /* lot 042 — défaut orange-500 inchangé */
    --text-on-dark:    #f3f4f6;
    --radius-sm:       6px;
    --transition:      0.2s ease;
}

/* ---- Reset minimal ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    overflow: hidden;
    background: #000;
}
body {
    height: 100%;
    overflow: hidden;
    background: #000;
    color: var(--text-on-dark);
    font-family: system-ui, -apple-system, sans-serif;
}

body.viewer-page {
    display: flex;
    flex-direction: column;
}

/* ============================================================
   Bandeau aperçu admin
   ============================================================ */
.preview-banner {
    background: #f59e0b;
    color: #1c1917;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 16px;
    flex-shrink: 0;
    z-index: 200;
}
.preview-banner a {
    color: #1c1917;
    text-decoration: underline;
    margin-left: 8px;
}
.preview-banner--archived {
    background: #dc2626;
    color: #fff;
}
.preview-banner--archived a { color: #fff; }

/* ============================================================
   En-tête overlay
   ============================================================ */
.viewer-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--viewer-header-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    background: var(--overlay-bg);
    backdrop-filter: var(--overlay-blur);
    -webkit-backdrop-filter: var(--overlay-blur);
    /* Transition d'opacité pour l'auto-hide futur */
    transition: opacity var(--transition);
}

.viewer-header__back {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-dark);
    text-decoration: none;
}

.viewer-header__title {
    flex: 1;
    min-width: 0;        /* obligatoire : sans ça, text-overflow ne fonctionne pas en flex */
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-on-dark);
}

.viewer-header__btn {
    /* Zone de touche ≥ 44 px (§9.2) */
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: transparent;
    border: none;
    color: var(--text-on-dark);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    flex-shrink: 0;
}
.viewer-header__btn:hover,
.viewer-header__btn:focus-visible {
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

/* ---- Groupe boutons droite (like + fullscreen) ---- */
.viewer-header__right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: nowrap;   /* explicite : résiste aux règles externes qui pourraient hériter wrap */
}

/* ---- Bouton j'aime ---- */
.viewer-header__btn--like {
    gap: 5px;
}

/* Sélecteur ID (1,0,1) — spécificité supérieure aux règles svg des CDN PSV (max 0,1,1).
   Même principe que #btn-fullscreen pour les icônes expand/compress (§11.2). */
#btn-like .icon-heart-filled { display: none; color: #f43f5e; }

#btn-like.is-liked .icon-heart-outline { display: none; }
#btn-like.is-liked .icon-heart-filled  { display: block; }
#btn-like.is-liked                     { opacity: .75; cursor: default; }

.like-count {
    font-size: .72rem;
    font-weight: 700;
    line-height: 1;
    min-width: 1ch;
}

/* ---- Icônes du bouton plein écran ----
   Gestion par classe CSS, indépendante de l'attribut [hidden] qui peut
   être écrasé par des feuilles de style externes (PSV CDN, reset…).
   icon-compress est caché par défaut ; visible uniquement quand le bouton
   porte la classe .is-fullscreen (ajoutée par JS). */
#btn-fullscreen .icon-compress { display: none; }
#btn-fullscreen.is-fullscreen .icon-expand  { display: none; }
#btn-fullscreen.is-fullscreen .icon-compress { display: flex; }

/* ---- Faux plein écran CSS (iPhone / Safari sans Fullscreen API) ----
   Le bouton de sortie est en position fixe, hors du header,
   pour rester accessible quand le header est masqué. */
.fake-fs-exit {
    position: fixed;
    top: 6px; right: 6px;
    z-index: 150;
    display: none;   /* caché par défaut */
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: var(--overlay-bg);
    backdrop-filter: var(--overlay-blur);
    -webkit-backdrop-filter: var(--overlay-blur);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-on-dark);
    cursor: pointer;
    transition: background var(--transition);
}
.fake-fs-exit:hover { background: rgba(255, 255, 255, 0.2); }

/* Quand body.is-fake-fs est actif :
   – l'en-tête disparaît (position: fixed, hors du flux → display: none suffit)
   – le bandeau et son toggle glissent hors écran
   – le bouton de sortie apparaît */
body.is-fake-fs .viewer-header { display: none; }
body.is-fake-fs .scene-nav     { transform: translateY(100%); }
body.is-fake-fs .nav-toggle    { display: none; }
body.is-fake-fs .fake-fs-exit  { display: flex; }

/* ============================================================
   Lecteur principal
   ============================================================ */
.viewer-main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#psv-viewer {
    width: 100%;
    height: 100%;
    /* Laisse PSV gérer tous les événements tactiles */
    touch-action: none;
}

/* PSV injecte son canvas directement dans #psv-viewer */
#psv-viewer .psv-container {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================
   Spinner de chargement
   ============================================================ */
.viewer-loader {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #0a0a0a;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.viewer-loader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.viewer-loader__ring {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.viewer-loader__text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================================
   Bouton de repli de la barre de scènes
   Flotte juste au-dessus de la barre, reste visible même quand la barre est repliée
   ============================================================ */
.nav-toggle {
    position: fixed;
    bottom: var(--grouped-nav-h, var(--viewer-nav-h)); /* JS met à jour --grouped-nav-h en mode groupé */
    right: 16px;
    z-index: 101;             /* au-dessus de .scene-nav (z-index: 100) */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    backdrop-filter: var(--overlay-blur);
    -webkit-backdrop-filter: var(--overlay-blur);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px 8px 0 0;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                color  0.2s ease;
}
.nav-toggle:hover { color: #fff; }

.nav-toggle__icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* État replié : bouton descend au ras du bas, chevron se retourne */
.nav-toggle.is-collapsed {
    bottom: 0;
    border-radius: 8px 8px 0 0;
}
.nav-toggle.is-collapsed .nav-toggle__icon {
    transform: rotate(180deg);
}

/* ============================================================
   Navigation entre scènes — barre fixée en bas (§9.2)
   Scrollable horizontalement si plusieurs scènes
   ============================================================ */
.scene-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--viewer-nav-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--overlay-bg);
    backdrop-filter: var(--overlay-blur);
    -webkit-backdrop-filter: var(--overlay-blur);
    /* La nav doit être scrollable au doigt sans interférer avec PSV */
    touch-action: pan-x;
    /* Scrollbar invisible mais fonctionnelle */
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: opacity var(--transition),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.scene-nav::-webkit-scrollbar { display: none; }

/* État replié : la barre glisse hors écran vers le bas */
.scene-nav.is-collapsed {
    transform: translateY(100%);
}

.scene-nav__btn {
    /* Zone de touche ≥ 44 × 44 px (§9.2) */
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 0 12px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    color: var(--text-on-dark);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    text-align: left;
    white-space: nowrap;
}

.scene-nav__btn:hover,
.scene-nav__btn:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    outline: none;
}

.scene-nav__btn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.scene-nav__thumb {
    width: 46px;
    height: 26px;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.scene-nav__label {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   Bandeau avec onglets de groupes (feature 5)
   Sélecteur double-classe (0,2,0) > tous les sélecteurs .scene-nav (0,1,0)
   incluant ceux du bloc @supports — pas besoin de !important
   ============================================================ */
.scene-nav.scene-nav--grouped {
    flex-direction: column;
    height: auto;       /* s'étire pour contenir onglets + vignettes */
    padding: 0;
    gap: 0;
    overflow-x: visible;
    overflow-y: visible;
    touch-action: none; /* les enfants gèrent chacun leur touch-action */
}

/* Ligne des onglets */
.scene-nav__tabs {
    display: flex;
    gap: 4px;
    padding: 6px 12px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex-shrink: 0;
    touch-action: pan-x;
}
.scene-nav__tabs::-webkit-scrollbar { display: none; }

/* Bouton onglet */
.scene-nav__tab {
    min-height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: 6px 6px 0 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: none;
    color: var(--text-on-dark);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.scene-nav__tab:hover { background: rgba(255, 255, 255, 0.18); }
.scene-nav__tab.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Ligne des vignettes de scènes (dans le mode groupé) */
.scene-nav__scenes {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    min-height: var(--viewer-scene-h); /* variable stable — jamais modifiée par JS */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    touch-action: pan-x;
    flex-shrink: 0;
}
.scene-nav__scenes::-webkit-scrollbar { display: none; }

/* ============================================================
   Hotspot markers PSV (§9.2 : zone de touche ≥ 44 px)
   ============================================================ */

/* Cible de clic agrandie — le visuel est plus petit */
.psv-hotspot {
    /* Zone de touche garantie à 44 × 44 px */
    min-width:  44px;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Transparence pour ne pas bloquer la vue */
    -webkit-tap-highlight-color: transparent;
}

/* Pastille visible */
.psv-marker--hotspot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.9);
    /* Anneau sombre extérieur : visible sur fond clair ; blanc intérieur : visible sur fond sombre */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), 0 0 0 1.5px rgba(0, 0, 0, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    /* Animation de pulsation pour les hotspots de navigation */
    animation: hotspot-pulse 2.5s ease-in-out infinite;
}

.psv-marker--nav {
    /* --marker-color injecté en inline style par viewer.js si une couleur est définie */
    background: var(--marker-color, var(--accent));
    color: #fff;
}

.psv-marker--text {
    background: rgba(30, 30, 30, 0.85);
    color: #fff;
}

.psv-marker--hotspot:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 0 1.5px rgba(0, 0, 0, 0.45);
    animation-play-state: paused;
}

@keyframes hotspot-pulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(0,0,0,0.5), 0 0 0 1.5px rgba(0,0,0,0.45), 0 0 0 0 rgba(249,115,22,0.4); }
    50%       { box-shadow: 0 2px 12px rgba(0,0,0,0.5), 0 0 0 1.5px rgba(0,0,0,0.45), 0 0 0 8px rgba(249,115,22,0); }
}

.psv-marker--text {
    animation: none; /* pas de pulsation pour les hotspots d'information */
}

.psv-marker--gallery {
    background: rgba(99, 102, 241, 0.9); /* indigo — distinct de nav (orange) et text (noir) */
    color: #fff;
    animation: none;
}

.psv-marker--video {
    background: rgba(220, 38, 38, 0.9); /* rouge — associé instinctivement à la vidéo */
    color: #fff;
    animation: none;
}

.psv-marker--iframe {
    background: rgba(6, 182, 212, 0.9); /* cyan-500 — distinct de tous les autres types */
    color: #fff;
    animation: none;
}

/* ============================================================
   Étiquette permanente — visible sur écrans tactiles (§mobile)
   Masquée sur desktop : seul le tooltip PSV s'affiche au survol.
   ============================================================ */
.psv-label-text {
    display: none;
    margin-top: 4px;
    padding: 2px 8px;
    /* Mêmes valeurs que .psv-marker--text — déjà présentes dans viewer.css */
    background: rgba(30, 30, 30, 0.85);
    color: #fff;
    font-size: 0.72rem;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 3px;
    /* rgba(0,0,0,0.5) est présent dans viewer.css (box-shadow des pastilles) */
    text-shadow: 0 1px rgba(0, 0, 0, 0.5);
    user-select: none;
    line-height: 1.4;
    /* Hérité par les enfants — les cercles restent les seuls éléments interactifs */
    pointer-events: none;
}

/* Tactile détecté par la média query avant tout événement */
@media (hover: none) and (pointer: coarse) {
    .psv-label-text { display: block; }
}

/* PSV pose .psv--is-touch après le premier événement touch : complément */
.psv--is-touch .psv-label-text { display: block; }

/* Variante deux-parties : corps tronquable + ↗ jamais coupé */
.psv-label--newtab {
    max-width: 150px;
    padding: 0;
    text-overflow: clip;
    align-items: center;
}
.psv-label--newtab .psv-label-body {
    padding: 2px 0 2px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}
.psv-label--newtab .psv-label-arrow {
    padding: 2px 8px 2px 2px;
    flex-shrink: 0;
}
@media (hover: none) and (pointer: coarse) {
    .psv-label--newtab { display: flex; }
}
.psv--is-touch .psv-label--newtab { display: flex; }

/* ============================================================
   Polygone cliquable — zone de surface (A5)
   Discret au repos, perceptible grâce à la respiration lente.
   La couleur blanche s'applique à tout fond (intérieur, extérieur).
   pointer-events géré par PSV : drag → panorama, tap → action.
   ============================================================ */
.psv-polygon-hotspot {
    /* Respiration lente : signal mobile "je suis là" sans couvrir la photo */
    animation: psv-poly-breathe 3s ease-in-out infinite;
    cursor: pointer;
}

@keyframes psv-poly-breathe {
    0%, 100% { opacity: 0.50; }
    50%       { opacity: 1.00; }
}

/* Survol (desktop uniquement — pas de :hover sur mobile) */
@media (hover: hover) {
    .psv-polygon-hotspot:hover {
        animation-play-state: paused;
        opacity: 1;
        /* La densité de remplissage et de contour augmente via l'opacité pleine */
    }
}

/* ============================================================
   Popup de contenu (hotspots type "text")
   ============================================================ */
.content-popup__backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
}

.content-popup {
    position: fixed;
    z-index: 210;
    bottom: 0; left: 0; right: 0;
    max-height: 70vh;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    overflow-y: auto;
    /* Animation slide-up */
    animation: slide-up 0.25s ease;
}

@keyframes slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@media (min-width: 640px) {
    /* Sur desktop : centré et plus compact */
    .content-popup {
        top: 50%; left: 50%; right: auto; bottom: auto;
        transform: translate(-50%, -50%);
        width: min(500px, 90vw);
        max-height: 80vh;
        border-radius: 12px;
        animation: none;
    }
}

.content-popup__close {
    position: absolute;
    top: 12px; right: 16px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-on-dark);
    font-size: 1.4rem;
    cursor: pointer;
    transition: background var(--transition);
}
.content-popup__close:hover { background: rgba(255,255,255,0.2); }

.content-popup__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 12px;
    padding-right: 48px;
    color: var(--text-on-dark);
}

/* ---- Mode vidéo : popup élargie, iframe en 16:9 ---- */
/* Mobile : full-width bottom sheet déjà adapté — juste l'iframe en ratio */
.popup-video-iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 8px;
    background: #000;
}

@media (min-width: 640px) {
    /* Desktop : popup plus large pour un visionnage confortable */
    .content-popup--video {
        width: min(800px, 92vw);
    }
}

/* ---- Mode iframe : popup quasi-plein écran, défilement vertical interne ----
   Différent de la vidéo : pas de ratio imposé, contenu web qui défile. */
.content-popup--iframe {
    max-height: 90vh; /* plus haute que le popup texte (70vh) */
}

@media (min-width: 640px) {
    .content-popup--iframe {
        width: min(960px, 92vw);
        max-height: 90vh;
    }
}

/* L'iframe occupe toute la largeur disponible avec une hauteur fixe.
   65vh sur mobile garantit que titre + bouton + note restent visibles.
   72vh sur desktop tire parti de l'espace plus grand. */
.popup-iframe-frame {
    display: block;
    width: 100%;
    height: 65vh;
    border: none;
    border-radius: 8px;
    background: #f0f0f0;
    margin-top: 4px;
}

@media (min-width: 640px) {
    .popup-iframe-frame {
        height: 72vh;
    }
}

/* Lien « Ouvrir dans un nouvel onglet » — visible uniquement pour les popups iframe.
   Caché par défaut via l'attribut [hidden] géré par JS. */
.popup-newtab-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    padding: 4px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    transition: color var(--transition);
}
.popup-newtab-link[hidden] { display: none; }
.popup-newtab-link:hover,
.popup-newtab-link:focus-visible {
    color: #fff;
    outline: none;
}

/* Note de repli sous l'iframe */
.popup-iframe-note {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 8px;
    font-style: italic;
    text-align: center;
}

.content-popup__body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================================
   Fallback sans JavaScript
   ============================================================ */
.noscript-info {
    padding: 2rem 1rem;
    max-width: 640px;
    margin: 0 auto;
    color: #fff;
}
.noscript-info h1 { font-size: 1.4rem; margin-bottom: 0.75rem; }
.noscript-info p  { margin-bottom: 1rem; color: rgba(255,255,255,0.75); }

.noscript-info__thumbs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.noscript-info__thumbs figure { flex: 1 1 180px; }
.noscript-info__thumbs img {
    width: 100%; border-radius: 6px;
    display: block; margin-bottom: 4px;
}
.noscript-info__thumbs figcaption {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
}

/* ============================================================
   Ajustements pour les grands écrans (desktop)
   ============================================================ */
@media (min-width: 768px) {
    :root {
        --viewer-header-h: 56px;
        --viewer-nav-h:   80px;
        --viewer-scene-h: 80px;
    }

    .viewer-header__title { font-size: 1rem; }

    .scene-nav__btn { min-height: 56px; }
    .scene-nav__thumb { width: 56px; height: 32px; }
    .scene-nav__label { max-width: 140px; }
}

/* ============================================================
   Respect du safe-area iOS (encoche, barre de home)
   ============================================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    .viewer-header {
        padding-top: max(0px, env(safe-area-inset-top));
    }

    /* Bandeau plat : hauteur fixe + safe-area */
    .scene-nav:not(.scene-nav--grouped) {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        height: calc(var(--viewer-nav-h) + env(safe-area-inset-bottom));
    }

    /* Bandeau groupé : hauteur auto, safe-area en padding uniquement */
    .scene-nav.scene-nav--grouped {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    /* Bouton de repli : utilise --grouped-nav-h (mis à jour par JS) en mode groupé,
       sinon --viewer-nav-h (valeur statique) en mode plat */
    .nav-toggle {
        bottom: calc(var(--grouped-nav-h, var(--viewer-nav-h)) + env(safe-area-inset-bottom));
    }
    .nav-toggle.is-collapsed {
        bottom: env(safe-area-inset-bottom);
    }
    #btn-sound {
        bottom: calc(var(--grouped-nav-h, var(--viewer-nav-h)) + 8px + env(safe-area-inset-bottom));
    }
    .scene-nav.is-collapsed ~ #btn-sound,
    body.viewer-no-nav #btn-sound,
    body.is-fake-fs #btn-sound {
        bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* ============================================================
   Bouton ambiance sonore — étape 16-B
   Position : côté gauche, au-dessus de la scene-nav.
   Le DOM place #btn-sound APRÈS .scene-nav → le sélecteur ~ fonctionne.
   #btn-floorplan (floorplan.css) occupe left:12px quand présent →
   body.viewer-has-floorplan décale #btn-sound à left:64px.
   ============================================================ */
#btn-sound {
    position: fixed;
    bottom: calc(var(--grouped-nav-h, var(--viewer-nav-h)) + 8px);
    left: 12px;
    z-index: 101;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, .75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, .7);
    cursor: pointer;
    transition: background .15s, color .15s,
                bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
#btn-sound:hover,
#btn-sound:focus-visible {
    background: rgba(10, 10, 10, .9);
    color: #fff;
    outline: 2px solid rgba(255, 255, 255, .5);
    outline-offset: 2px;
}
#btn-sound.is-playing {
    background: rgba(249, 115, 22, .85);
    border-color: transparent;
    color: #fff;
}
/* Icônes : off visible par défaut, on masquée */
#btn-sound .icon-sound-on            { display: none; }
#btn-sound.is-playing .icon-sound-off { display: none; }
#btn-sound.is-playing .icon-sound-on  { display: block; }

/* Plan d'étage présent → décale le bouton son à droite pour ne pas superposer */
body.viewer-has-floorplan #btn-sound { left: 64px; }

/* Nav repliée (sélecteur sibling ~ car #btn-sound vient après .scene-nav dans le DOM) */
.scene-nav.is-collapsed ~ #btn-sound { bottom: 8px; }

/* Pas de scene-nav (visite à une seule scène) ou faux plein écran iPhone */
body.viewer-no-nav #btn-sound  { bottom: 16px; }
body.is-fake-fs #btn-sound     { bottom: 16px; }

/* ============================================================
   Cadre de consentement RGPD — lot 047b
   ============================================================ */
.consent-gate {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}

.consent-gate__msg {
    color: var(--text-on-dark, #f3f4f6);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-wrap: break-word;  /* noms de domaine longs */
}

.consent-gate__btn {
    align-self: flex-start;
    background: var(--accent, #f97316);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm, 6px);
    padding: 12px 20px;
    min-height: 44px;           /* cible tactile minimale */
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition, 0.2s ease);
}
.consent-gate__btn:hover,
.consent-gate__btn:focus-visible {
    opacity: 0.85;
    outline: 2px solid var(--accent, #f97316);
    outline-offset: 2px;
}

.consent-gate__link {
    font-size: 0.78rem;
    color: rgba(243, 244, 246, 0.55);
    text-decoration: underline;
}
.consent-gate__link:hover,
.consent-gate__link:focus-visible { color: var(--text-on-dark, #f3f4f6); }

