/* ============================================================
   Plan 3D immersif — Résidence Oum Kaltoum (section #plan-3d)
   Feuille dédiée : ne pas étendre style.min.css (diff illisible).
   Le rendu 3D lui-même est piloté par assets/js/plan-3d.js.
   ============================================================ */

.p3d-section {
  position: relative;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(201,168,76,0.16) 0%, rgba(201,168,76,0) 55%),
    linear-gradient(180deg, #1f3157 0%, #1B2A4A 40%, #111a30 100%);
  color: #fff;
  overflow: hidden;
}
.p3d-section .section-label { color: var(--gold-light); }
.p3d-section .section-title { color: #fff; }
.p3d-section .section-title .gold { color: var(--gold-light); }
.p3d-section .section-lead { color: #c9d2e4; }

.p3d { max-width: 1120px; margin: 0 auto; }

/* ---------- Scène ---------- */
.p3d__stage {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 320px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(160deg, #26395f 0%, #15213b 55%, #0d1526 100%);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(201,168,76,0.28);
  outline: none;
  isolation: isolate;
}
.p3d__stage:focus-visible { box-shadow: 0 30px 80px rgba(0,0,0,0.45), 0 0 0 3px var(--gold); }

.p3d__poster {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.9s ease;
}
.p3d.is-ready .p3d__poster { opacity: 0; pointer-events: none; }

.p3d__canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.p3d.is-ready .p3d__canvas { opacity: 1; }
.p3d__canvas.is-dragging { cursor: grabbing; }
.p3d__canvas.is-hotspot { cursor: pointer; }

/* ---------- Écran d'accueil (affiche + bouton) ---------- */
.p3d__launch {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(11,18,34,0.08) 0%, rgba(11,18,34,0.55) 100%);
  transition: opacity 0.5s ease;
}
.p3d.is-loading .p3d__launch,
.p3d.is-ready .p3d__launch { opacity: 0; pointer-events: none; }
.p3d__launch-btn {
  font-size: 1.05rem;
  padding: 16px 32px;
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(201,168,76,0.4);
  animation: p3dPulse 2.8s ease-in-out infinite;
}
.p3d__launch-btn i { margin-inline-end: 8px; }
.p3d__launch-note {
  margin: 0;
  font-size: 0.78rem;
  color: #dfe5f2;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}
@keyframes p3dPulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 14px 40px rgba(201,168,76,0.40); }
  50% { transform: translateY(-3px); box-shadow: 0 20px 52px rgba(201,168,76,0.55); }
}

/* ---------- Chargement / erreur ---------- */
.p3d__loader {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  background: rgba(11,18,34,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  text-align: center;
  padding: 24px;
  z-index: 5;
}
.p3d.is-loading .p3d__loader { display: flex; }
.p3d__loader-ring {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: var(--gold);
  animation: p3dSpin 1s linear infinite;
}
@keyframes p3dSpin { to { transform: rotate(360deg); } }
.p3d__loader p { margin: 0; font-size: 0.9rem; color: #dfe5f2; }

.p3d__fallback {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  background: rgba(11,18,34,0.78);
  color: #fff;
  text-align: center;
  padding: 28px;
  z-index: 6;
}
.p3d.is-error .p3d__fallback { display: flex; }
.p3d__fallback p { margin: 0; max-width: 520px; font-size: 0.95rem; line-height: 1.6; }
.p3d__fallback-links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- HUD ---------- */
.p3d__hud { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.p3d__hud > * { pointer-events: auto; }

.p3d__bar {
  position: absolute; top: 14px; inset-inline-end: 14px;
  display: flex; flex-wrap: wrap; justify-content: flex-end;
  gap: 8px;
  max-width: calc(100% - 28px);
}
.p3d__btn,
.p3d__seg button {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(11,18,34,0.58);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  display: inline-flex; align-items: center; gap: 7px;
}
.p3d__btn i, .p3d__seg button i { font-size: 0.8rem; color: var(--gold-light); }
.p3d__btn:hover, .p3d__seg button:hover { background: rgba(27,42,74,0.9); border-color: rgba(201,168,76,0.6); }
.p3d__btn:focus-visible, .p3d__seg button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.p3d__btn.is-on, .p3d__seg button.is-on { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.p3d__btn.is-on i, .p3d__seg button.is-on i { color: var(--navy); }
.p3d__seg { display: inline-flex; border-radius: 999px; overflow: hidden; }
.p3d__seg button { border-radius: 0; }
.p3d__seg button:first-child { border-start-start-radius: 999px; border-end-start-radius: 999px; }
.p3d__seg button:last-child { border-start-end-radius: 999px; border-end-end-radius: 999px; }
.p3d__btn--icon { padding: 10px 12px; }
.p3d__btn--icon .p3d__btn-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.p3d__hint {
  position: absolute; bottom: 14px; inset-inline-start: 14px;
  max-width: min(58%, 460px);
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(11,18,34,0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e6ebf5;
  font-size: 0.74rem;
  line-height: 1.45;
}
.p3d__hint b { color: var(--gold-light); font-weight: 600; }

.p3d__badge {
  position: absolute; top: 14px; inset-inline-start: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  color: var(--navy);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.p3d__badge i { color: var(--gold-dark); }

/* mini-plan : le vrai plan coté, avec la position de la caméra */
.p3d__minimap {
  position: absolute; bottom: 14px; inset-inline-end: 14px;
  width: 210px;
  padding: 5px;
  border-radius: 10px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  cursor: crosshair;
}
.p3d__minimap img { display: block; width: 100%; height: auto; }
.p3d__minimap canvas { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); }

/* ---------- Pièces (puces) ---------- */
.p3d__rooms {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 10px;
  margin-top: 24px;
}
.p3d__room {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}
.p3d__room i { color: var(--gold-light); width: 16px; text-align: center; }
.p3d__room .area { font-size: 0.74rem; color: #aeb8cf; }
.p3d__room:hover { background: rgba(255,255,255,0.12); border-color: rgba(201,168,76,0.55); transform: translateY(-1px); }
.p3d__room:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.p3d__room.is-active { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.p3d__room.is-active i, .p3d__room.is-active .area { color: var(--navy); }

/* ---------- Fiche de la pièce sélectionnée ---------- */
.p3d__info {
  margin: 18px auto 0;
  max-width: 760px;
  min-height: 0;
  display: none;
  grid-template-columns: 1fr auto;
  gap: 6px 18px;
  align-items: center;
  padding: 16px 22px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(201,168,76,0.28);
}
.p3d__info.is-visible { display: grid; }
.p3d__info-name { font-family: var(--font-serif); font-size: 1.25rem; color: #fff; margin: 0; }
.p3d__info-meta { margin: 0; font-size: 0.82rem; color: var(--gold-light); letter-spacing: 0.04em; }
.p3d__info-detail { grid-column: 1 / -1; margin: 0; font-size: 0.9rem; line-height: 1.6; color: #d4dbe9; }
.p3d__info-enter {
  grid-row: 1 / span 2;
  grid-column: 2;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .p3d__info { grid-template-columns: 1fr; }
  .p3d__info-enter { grid-row: auto; grid-column: 1; justify-self: start; }
}

.p3d__note {
  margin: 22px auto 0;
  max-width: 820px;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #aab4c8;
}
.p3d__note a { color: var(--gold-light); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Plein écran ---------- */
.p3d__stage:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
.p3d__stage:-webkit-full-screen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .p3d__minimap { width: 150px; }
  .p3d__hint { max-width: calc(100% - 180px); }
}
@media (max-width: 640px) {
  .p3d__stage { aspect-ratio: 4 / 3; border-radius: 14px; }
  .p3d__btn, .p3d__seg button { padding: 9px 11px; font-size: 0.64rem; }
  .p3d__btn-text--long { display: none; }
  .p3d__hint { display: none; }
  .p3d__minimap { width: 120px; }
  .p3d__badge { display: none; }
  .p3d__launch-btn { font-size: 0.95rem; padding: 14px 24px; }
  .p3d__room { padding: 9px 13px; font-size: 0.78rem; }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  .p3d__launch-btn { animation: none; }
  .p3d__poster, .p3d__canvas, .p3d__launch { transition: none; }
}

/* ---------- Sens de lecture (arabe) ---------- */
html[dir=rtl] .p3d__hint, html[lang=ar] .p3d__hint { direction: rtl; text-align: right; }
html[dir=rtl] .p3d__minimap img, html[lang=ar] .p3d__minimap img { direction: ltr; }
