:root {
  --accent: #1f6f5c;
  --accent-light: #2f9c82;
  --route-accent: #d97706;
  --overlay-bg: rgba(17, 17, 17, 0.55);
  --control-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

/* ---------- Écran de chargement ---------- */
#loading-screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #101010;
  color: #eee;
  transition: opacity 0.4s ease;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Scène ---------- */
#scene-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.scene-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}
.scene-image.visible {
  opacity: 1;
  pointer-events: auto;
}

#hotspots-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
}

/* ---------- Hotspots ---------- */
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  background: transparent;
  padding: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
  animation: pop-in 0.35s ease both;
}
@keyframes pop-in {
  from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.hotspot-nav {
  flex-direction: column;
  gap: 6px;
  width: auto;
  height: auto;
  animation: pop-in 0.35s ease both;
}
.nav-arrow-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-nav 2.2s ease-in-out infinite 0.6s;
}
.nav-arrow-icon svg {
  width: 26px;
  height: 26px;
  stroke: #ffffff;
}
.nav-caption {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  max-width: 112px;
  padding: 3px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: normal;
}
.hotspot-nav:active .nav-arrow-icon { transform: scale(0.92); }

@keyframes pulse-nav {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.35); }
  50% { box-shadow: 0 0 0 10px rgba(255,255,255,0); }
}

.hotspot-info {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  color: #fff;
  animation: pop-in 0.35s ease both, pulse-info 2.2s ease-in-out infinite 0.6s;
}
.hotspot-info svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
}
.hotspot-info:active { transform: translate(-50%, -50%) scale(0.92); }

@keyframes pulse-info {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31,111,92,0.55); }
  50% { box-shadow: 0 0 0 10px rgba(31,111,92,0); }
}

/* Suite du circuit conseillé (empreintes) — même principe que la loupe, autre couleur/icône */
.hotspot-route {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--route-accent);
  border: 2px solid #fff;
  animation: pop-in 0.35s ease both, pulse-route 2.2s ease-in-out infinite 0.6s;
}
.hotspot-route img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.hotspot-route:active { transform: translate(-50%, -50%) scale(0.92); }

@keyframes pulse-route {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,119,6,0.55); }
  50% { box-shadow: 0 0 0 10px rgba(217,119,6,0); }
}

/* ---------- Titre de la scène ---------- */
#scene-title-bar {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 8px 18px;
  border-radius: 20px;
  background: var(--overlay-bg);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  max-width: 80%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Bouton coin (accueil) ---------- */
.corner-btn {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 16px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--overlay-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.corner-btn svg { width: 22px; height: 22px; }
.corner-btn img { width: 22px; height: 22px; object-fit: contain; }
.corner-btn.hidden { display: none; }
.corner-btn:active { background: rgba(0,0,0,0.7); }
.corner-btn-right { left: auto; right: 16px; }

/* ---------- Écran d'accueil ---------- */
.home-flags {
  position: absolute;
  top: calc(var(--safe-top) + 12px + 44px + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 6px;
  animation: pop-in 0.35s ease both;
}
.home-flag {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.7);
  background: rgba(17,17,17,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  padding: 0;
  opacity: 1;
}
.home-flag:disabled {
  opacity: 0.45;
  cursor: default;
}
.home-flag:not(:disabled) { cursor: pointer; }
.home-flag:not(:disabled):active { transform: scale(0.92); }
.home-flag.active {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(47, 156, 130, 0.5);
}

.home-start-btn {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 16px 34px;
  border: none;
  border-radius: 32px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  animation: pop-in 0.4s ease both, pulse-info 2.4s ease-in-out infinite 0.8s;
}
.home-start-btn:active { transform: translateX(-50%) scale(0.96); }

.home-schedule-btn {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 10px 20px;
  border: none;
  border-radius: 20px;
  background: var(--overlay-bg);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  white-space: nowrap;
}
.home-schedule-btn:active { background: rgba(0,0,0,0.7); }

/* ---------- Contrôles bas ---------- */
#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 14px);
  z-index: 10;
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  pointer-events: none;
}

.control-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 18px;
  border-radius: 28px;
  border: none;
  background: var(--overlay-bg);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.control-btn svg { width: 20px; height: 20px; }
.control-btn:disabled { opacity: 0.35; }
.control-btn:active:not(:disabled) { background: rgba(0,0,0,0.7); }

/* ---------- Modales ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  transition: opacity 0.25s ease;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 78vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  padding: 24px 22px calc(28px + var(--safe-bottom));
  animation: slide-up 0.28s ease;
  -webkit-overflow-scrolling: touch;
}
@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #f0f0f0;
  color: #333;
  font-size: 16px;
  line-height: 1;
}

#modal-title, #map-title {
  margin: 0 32px 14px 0;
  font-size: 21px;
  color: #1a1a1a;
}

#modal-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: #333;
  white-space: pre-line;
}

/* Audio player */
.modal-audio {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: #f4f6f5;
  border-radius: 14px;
}
.modal-audio.hidden { display: none; }

.audio-toggle {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.audio-toggle svg { width: 20px; height: 20px; }
.audio-toggle .hidden { display: none; }

.audio-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-audio.tts-mode .audio-progress-wrap { display: none; }

.audio-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #d8ddda;
  overflow: hidden;
}
.audio-progress {
  width: 0%;
  height: 100%;
  background: var(--accent-light);
}

.audio-time {
  flex: 0 0 auto;
  font-size: 13px;
  color: #666;
  font-variant-numeric: tabular-nums;
}

.audio-tts-label {
  display: none;
  flex: 1;
  font-size: 13px;
  color: #666;
  font-style: italic;
}
.modal-audio.tts-mode .audio-tts-label { display: block; }

/* Plan du site */
#map-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.map-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid #e6e6e6;
  background: #fafafa;
  text-align: left;
  font-size: 16px;
  color: #1a1a1a;
}
.map-item.current {
  border-color: var(--accent-light);
  background: rgba(47, 156, 130, 0.08);
}
.map-item img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
  background: #ddd;
}
.map-item .map-item-label { flex: 1; }
.map-item .map-item-tag {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Carte interactive du site ---------- */
#sitemap-view {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #111;
}
#sitemap-view.hidden { display: none; }

#sitemap-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
#sitemap-viewport.grabbing { cursor: grabbing; }

#sitemap-content {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#sitemap-image {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

#sitemap-pins {
  position: absolute;
  inset: 0;
}

.sitemap-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.sitemap-pin img {
  width: 34px;
  height: 34px;
  display: block;
}
.sitemap-pin-label {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translate(-50%, -100%);
  max-width: 120px;
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Petits écrans très bas (paysage) */
@media (max-height: 420px) {
  #controls { bottom: 10px; }
  .control-btn { height: 44px; padding: 0 14px; }
  #scene-title-bar { top: 8px; }
}
