/* ==========================================================================
   Visit360 — Lecteur de visite 360°
   Interface plein écran posée par-dessus le rendu Pannellum.
   Hérite des variables de site.css.
   ========================================================================== */

html, body { height: 100%; }

/* Le site est en thème clair ; le lecteur, lui, reste sombre — c'est ce qui
   met l'image en valeur. On redéfinit donc les jetons de couleur pour cette
   page seulement, en gardant la même famille de bleu mais éclaircie pour
   rester lisible sur fond noir. */
body.viewer-page {
  /* Le site est en clair ; le lecteur reste sombre — c'est ce qui met l'image
     en valeur. On garde la famille chaude du thème Organic, éclaircie pour
     rester lisible sur fond sombre. */
  --accent: #e8a06a;
  --accent-soft: #f6c39a;
  --accent-rgb: 232, 160, 106;
  --accent-2: #aebf92;
  --on-accent: #2e2b25;

  --text: #f9f4ed;
  --text-dim: #c0b6a5;
  --text-faint: #a19786;
  --surface: rgba(249, 244, 237, 0.06);
  --surface-hi: rgba(249, 244, 237, 0.11);
  --line: rgba(249, 244, 237, 0.12);
  --line-hi: rgba(249, 244, 237, 0.22);
  --bg-card: #241f1a;

  --font: var(--font-body, "Figtree", system-ui, sans-serif);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  overflow: hidden;
  background: #17140f;
  color: var(--text);
}

/* Pannellum applique box-sizing:content-box à tout son contenu : on rétablit
   un modèle de boîte cohérent pour nos propres éléments (repères, étiquettes). */
#pano *,
#pano *::before,
#pano *::after { box-sizing: border-box; }

.viewer {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#pano {
  position: absolute;
  inset: 0;
}
#pano .pnlm-container { background: #17140f !important; }
#pano .pnlm-controls-container,
#pano .pnlm-compass,
#pano .pnlm-load-box,
#pano .pnlm-panorama-info,
#pano .pnlm-about-msg { display: none !important; }

/* Zones d'interface ------------------------------------------------------- */
.v-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  display: flex;
  flex-direction: column;
}
.v-layer > * { pointer-events: auto; }

.glass {
  background: rgba(23, 20, 15, 0.74);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.11);
}

/* Barre supérieure -------------------------------------------------------- */
.v-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin: 14px;
  border-radius: 18px;
  box-shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.9);
  transition: transform 0.45s var(--ease), opacity 0.35s;
}

/* En plein écran, l'image prend toute la place : la barre s'efface et ne
   revient que lorsque le visiteur bouge le pointeur ou touche l'écran. */
.viewer.is-immersive .v-top {
  transform: translateY(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}
.viewer.is-immersive.show-ui .v-top {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.v-back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px 9px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 90, 95, 0.5);
  background: rgba(255, 60, 66, 0.14);
  font-size: 14px;
  font-weight: 700;
  color: #ff8d92;
  transition: background 0.25s, border-color 0.25s, color 0.25s, box-shadow 0.25s;
  flex: none;
}
.v-back:hover {
  background: #e5484d;
  border-color: #e5484d;
  color: #fff;
  box-shadow: 0 10px 26px -10px rgba(229, 72, 77, 0.9);
}
.v-back svg { flex: none; }
@media (max-width: 640px) { .v-back span { display: none; } .v-back { padding: 9px 11px; } }

/* flex-basis 0 + min-width 0 à chaque niveau : sans cela, le texte en
   white-space:nowrap impose sa largeur minimale et pousse les boutons hors
   de l'écran sur mobile. */
.v-titles {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}
.v-titles h1,
.v-titles p { min-width: 0; max-width: 100%; }
.v-titles h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v-titles p {
  font-size: 12.5px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v-titles p b { color: var(--accent); font-weight: 700; }

.v-top__actions { display: flex; gap: 8px; flex: none; }

.v-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
  padding: 0;
}
.v-btn:hover { background: var(--surface-hi); color: var(--text); border-color: var(--line-hi); }
.v-btn:active { transform: scale(0.94); }
.v-btn[aria-pressed='true'] {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--accent);
}
.v-btn svg { width: 19px; height: 19px; }
.v-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.v-btn:disabled:hover { background: var(--surface); color: var(--text-dim); border-color: var(--line); }

@media (max-width: 560px) {
  .v-top { margin: 10px; padding: 10px 12px; gap: 10px; }
  .v-btn { width: 38px; height: 38px; border-radius: 11px; }
  .v-top__actions { gap: 6px; }
}

/* Sous 430 px, le nom de la scène a besoin de toute la place disponible ;
   le nombre de points de vue reste lisible dans le bandeau du bas. */
@media (max-width: 430px) {
  .v-titles p .v-sep,
  .v-titles p #sceneCount { display: none; }
}

/* Rail d'outils latéral --------------------------------------------------- */
.v-rail {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  box-shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.9);
}
.v-rail hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 3px 4px;
}
/* Le rail reste vertical sur mobile en portrait : il n'entre alors en conflit
   ni avec le bandeau de miniatures ni avec la fiche d'information. Il ne
   bascule à l'horizontale que lorsque la hauteur manque (paysage). */
@media (max-height: 620px) {
  .v-rail {
    top: auto;
    bottom: 118px;
    left: 10px;
    transform: none;
    flex-direction: row;
    flex-wrap: wrap;
    max-width: calc(100vw - 20px);
  }
  .v-rail hr { border-top: 0; border-left: 1px solid var(--line); margin: 4px 3px; }
}

/* Étage du bas : miniatures + plan ---------------------------------------- */
.v-bottom {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 0 14px 14px;
  pointer-events: none;
}
.v-bottom > * { pointer-events: auto; }

/* Miniatures -------------------------------------------------------------- */
.v-scenes {
  flex: 1;
  min-width: 0;
  border-radius: 18px;
  padding: 10px 12px 12px;
  box-shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.9);
  transition: transform 0.35s var(--ease), opacity 0.3s;
}
.v-scenes__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  padding-inline: 2px;
}
.v-scenes__head span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.v-thumbs {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  padding-bottom: 3px;
}
.v-thumbs::-webkit-scrollbar { height: 5px; }
.v-thumbs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 3px; }
.v-thumbs::-webkit-scrollbar-track { background: transparent; }

.v-thumb {
  position: relative;
  flex: none;
  width: 128px;
  border: 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #241f1a;
  outline: 1.5px solid transparent;
  outline-offset: 0;
  transition: outline-color 0.25s, transform 0.25s var(--ease);
}
.v-thumb img {
  width: 100%;
  height: 74px;
  object-fit: cover;
  opacity: 0.62;
  transition: opacity 0.3s, transform 0.5s var(--ease);
}
.v-thumb figcaption,
.v-thumb .v-thumb__label {
  position: absolute;
  inset: auto 0 0 0;
  padding: 16px 9px 7px;
  font-size: 11.5px;
  font-weight: 700;
  text-align: left;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(23, 20, 15, 0.92));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v-thumb:hover img { opacity: 0.95; transform: scale(1.05); }
.v-thumb:hover { outline-color: var(--line-hi); }
.v-thumb.is-active { outline-color: var(--accent); }
.v-thumb.is-active img { opacity: 1; }
.v-thumb.is-active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.5), 0 0 22px -4px rgba(var(--accent-rgb), 0.6);
  pointer-events: none;
}

.v-scenes.is-collapsed { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }

/* Plan interactif ---------------------------------------------------------- */
.v-map {
  flex: none;
  width: min(340px, 34vw);
  border-radius: 18px;
  padding: 10px 12px 12px;
  box-shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.9);
  transition: transform 0.35s var(--ease), opacity 0.3s;
}
.v-map__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  padding-inline: 2px;
}
.v-map__head span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.v-map__canvas {
  position: relative;
  border-radius: 11px;
  overflow: hidden;
  background: #241f1a;
  line-height: 0;
}
/* Le plan est dessiné directement aux couleurs du lecteur (tools/build-plan.py) :
   aucun filtre d'inversion n'est nécessaire. */
.v-map__canvas img { width: 100%; }

.v-pin {
  position: absolute;
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(124, 140, 255, 0.9);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s var(--ease), border-color 0.2s;
}
.v-pin:hover { transform: translate(-50%, -50%) scale(1.35); background: #fff; }
.v-pin.is-active {
  background: var(--accent);
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.28);
}
.v-pin.is-active::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  animation: pin-ping 2.2s ease-out infinite;
}
@keyframes pin-ping {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

.v-map.is-collapsed { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }

@media (max-width: 900px) {
  .v-map { display: none; }
}

@media (max-width: 560px) {
  .v-bottom { padding: 0 10px 10px; }
  .v-thumb { width: 106px; }
  .v-thumb img { height: 62px; }
}

/* Repères dans le panorama ------------------------------------------------ */
.hs {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Passerelle vers une autre scène */
.hs-link { width: 92px; height: 78px; justify-content: center; }
.hs-link__ring {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 18px -4px rgba(0, 0, 0, 0.7);
  transition: transform 0.25s var(--ease), background 0.25s;
}
.hs-link__ring::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  animation: hs-ping 2.6s ease-out infinite;
}
.hs-link__ring svg { width: 20px; height: 20px; }
.hs-link:hover .hs-link__ring { transform: scale(1.16); background: var(--accent); }

@keyframes hs-ping {
  0% { transform: scale(0.85); opacity: 0.85; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.hs__label {
  margin-top: 8px;
  max-width: 120px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  background: rgba(23, 20, 15, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.hs-link:hover .hs__label { background: var(--accent); color: var(--on-accent); border-color: transparent; }

/* Point d'information */
.hs-info { width: 76px; height: 66px; justify-content: center; }
.hs-info__dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font);
  font-weight: 800;
  font-size: 16px;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(var(--accent-rgb), 0.22), 0 6px 16px -4px rgba(0, 0, 0, 0.7);
  transition: transform 0.25s var(--ease), box-shadow 0.25s;
}
.hs-info:hover .hs-info__dot {
  transform: scale(1.16);
  box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0.24), 0 6px 16px -4px rgba(0, 0, 0, 0.7);
}
.hs-info:hover .hs__label { background: rgba(23, 20, 15, 0.92); border-color: var(--accent); }

@media (max-width: 560px) {
  .hs-link { width: 78px; height: 70px; }
  .hs-link__ring { width: 38px; height: 38px; }
  .hs__label { font-size: 10.5px; max-width: 96px; }
}

/* Fiche d'information ------------------------------------------------------ */
.v-info {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translate(calc(100% + 24px), -50%);
  width: min(340px, calc(100vw - 28px));
  border-radius: 18px;
  padding: 22px 22px 24px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.95);
  transition: transform 0.4s var(--ease), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}
.v-info.is-open { transform: translate(0, -50%); opacity: 1; pointer-events: auto; }
.v-info__tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.v-info h2 { font-size: 20px; margin-bottom: 10px; padding-right: 32px; }
.v-info p { font-size: 14.5px; color: var(--text-dim); }
.v-info__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.v-info__close:hover { color: var(--text); background: var(--surface-hi); }

@media (max-width: 900px) {
  /* Ancrée à droite plutôt qu'en pleine largeur : le rail latéral reste
     atteignable pendant la lecture d'une fiche. */
  .v-info {
    top: auto;
    bottom: 130px;
    right: 10px;
    left: auto;
    width: min(340px, calc(100vw - 78px));
    transform: translateY(calc(100% + 200px));
  }
  .v-info.is-open { transform: none; }

  /* Le plan n'est pas affiché à cette taille : son bouton non plus. */
  #btnMap { display: none; }
}

@media (max-height: 620px) {
  /* Le rail passe à l'horizontale juste au-dessus des miniatures : l'aide de
     démarrage occuperait la même bande. */
  .v-hint { display: none; }
}

/* Écran de chargement ------------------------------------------------------ */
.v-loader {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #17140f;
  transition: opacity 0.6s var(--ease), visibility 0.6s;
}
.v-loader.is-done { opacity: 0; visibility: hidden; }
.v-loader__inner { text-align: center; padding: 24px; max-width: 380px; }
.v-loader__mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 22px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  animation: loader-float 2.6s ease-in-out infinite;
}
@keyframes loader-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.v-loader h2 { font-size: 21px; margin-bottom: 8px; }
.v-loader p { font-size: 14px; color: var(--text-faint); }
.v-loader__bar {
  margin: 24px auto 0;
  width: 220px;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.v-loader__bar i {
  display: block;
  height: 100%;
  width: 30%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: loader-slide 1.3s ease-in-out infinite;
}
@keyframes loader-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(440%); }
}

/* Message d'erreur --------------------------------------------------------- */
.v-error {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  background: #17140f;
  text-align: center;
  padding: 24px;
}
.v-error.is-shown { display: grid; }
.v-error h2 { font-size: 24px; margin-bottom: 12px; }
.v-error p { color: var(--text-dim); margin-bottom: 24px; max-width: 46ch; }

/* Aide au premier lancement ------------------------------------------------ */
.v-hint {
  position: absolute;
  left: 50%;
  bottom: 172px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  z-index: 6;
  transition: opacity 0.5s, transform 0.5s var(--ease);
}
.v-hint.is-hidden { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
.v-hint svg { color: var(--accent); flex: none; }
@media (max-width: 560px) { .v-hint { bottom: 158px; font-size: 12.5px; padding: 9px 15px; } }

/* Notification brève ------------------------------------------------------- */
.v-toast {
  position: absolute;
  left: 50%;
  top: 92px;
  transform: translate(-50%, -14px);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
.v-toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* Panneau d'aide clavier --------------------------------------------------- */
.v-help {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: none;
  place-items: center;
  background: rgba(23, 20, 15, 0.72);
  backdrop-filter: blur(6px);
  padding: 24px;
}
.v-help.is-open { display: grid; }
.v-help__card {
  width: min(460px, 100%);
  border-radius: 20px;
  padding: 28px;
  position: relative;
}
.v-help__card h2 { font-size: 20px; margin-bottom: 6px; }
.v-help__card > p { font-size: 14px; color: var(--text-faint); margin-bottom: 20px; }
.v-help dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 18px;
  align-items: center;
  font-size: 14px;
}
.v-help dt { text-align: right; }
.v-help dd { margin: 0; color: var(--text-dim); }
.v-help kbd {
  display: inline-block;
  min-width: 26px;
  padding: 3px 8px;
  border-radius: 7px;
  border: 1px solid var(--line-hi);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.06);
  font: 700 12px var(--font);
  text-align: center;
}

/* Présentation de la visite, dans le panneau d'aide ------------------------ */
.v-help__about {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.v-help__about h3 { font-size: 16px; margin-bottom: 4px; }
.v-help__meta {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
}
.v-help__about p:last-child { font-size: 14px; color: var(--text-dim); }

/* Intégration dans la page d'accueil et invitation après interaction. */
.is-embedded .v-back { display: none; }
.v-full-prompt[hidden] { display: none; }
.v-full-prompt {
  position: absolute; z-index: 12; top: 100px; right: 24px;
  width: min(340px, calc(100% - 48px)); padding: 18px 44px 18px 18px;
  border-radius: 18px; box-shadow: 0 12px 36px rgba(0,0,0,.25);
  font-family: var(--font); color: var(--text);
}
.v-full-prompt p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.v-full-prompt__action {
  border: 0; border-radius: 999px; padding: 12px 16px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font: inherit;
  font-size: 13px; font-weight: 700;
}
.v-full-prompt__close {
  position: absolute; top: 6px; right: 6px; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--text); cursor: pointer; font-size: 24px;
}
.v-full-prompt button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
