/* ==========================================================
   MAQUETTE ORBITALE — interface
   ========================================================== */
html, body { height: 100%; overflow: hidden; }
body.viewer { background: #0f1311; color: var(--glass-text); user-select: none; -webkit-user-select: none; }

#app { position: fixed; inset: 0; display: grid; grid-template-columns: 1fr; }

/* ---------- Scène ---------- */
#stage {
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, #1c2420 0%, #0f1311 70%);
  cursor: grab; touch-action: none; overflow: hidden;
}
#stage.dragging { cursor: grabbing; }
#stage.pan { cursor: move; }
#stage.hot { cursor: pointer; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage canvas#overlay { pointer-events: none; }

/* Vignette douce en bord de scène pour ancrer le chrome */
#stage::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(15,19,17,.55) 0%, rgba(15,19,17,0) 18%),
    linear-gradient(0deg, rgba(15,19,17,.6) 0%, rgba(15,19,17,0) 26%);
}

/* ---------- Chrome commun ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-2);
}
.hud { position: absolute; z-index: 5; }
/* `translate` est animée séparément de `transform` pour ne pas écraser les centrages */
.hud.fade { opacity: 0; translate: 0 8px; animation: hud-in .7s var(--ease-out) forwards; }
@keyframes hud-in { to { opacity: 1; translate: 0 0; } }

/* Barre haute : retour + titre */
#topbar { top: 20px; left: 20px; right: 20px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 14px; padding: 10px 18px 10px 12px; border-radius: var(--r-pill); }
.brand .back {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.08); transition: background .2s;
}
.brand .back:hover { background: rgba(255,255,255,.18); }
.brand .back svg { width: 18px; height: 18px; }
.brand .mark { height: 34px; width: auto; }
.brand-name { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .02em; line-height: 1.1; }
.brand-sub { font-size: .7rem; letter-spacing: .22em; text-transform: uppercase; color: var(--glass-muted); }

/* ---------- Menu des étages ---------- */
#floors {
  right: 20px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 20px;
  animation-delay: .15s;
}
#floors .floor {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-width: 140px; padding: 10px 14px 10px 10px; border-radius: 14px;
  color: var(--glass-muted); text-align: left;
  transition: color .25s, background .25s;
}
#floors .floor .k {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  background: rgba(255,255,255,.07); transition: background .25s, color .25s;
}
#floors .floor .l { font-weight: 600; font-size: .9rem; }
#floors .floor .h { display: block; font-size: .68rem; font-weight: 500; color: var(--glass-muted); letter-spacing: .04em; }
#floors .floor:hover { color: var(--glass-text); background: rgba(255,255,255,.06); }
#floors .floor[aria-pressed="true"] { color: var(--ink); background: var(--paper); }
#floors .floor[aria-pressed="true"] .k { background: var(--moss); color: #fff; }
#floors .floor[aria-pressed="true"] .h { color: var(--muted); }
#floors .floor .dot { position: absolute; right: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity .25s; }
#floors .floor[aria-pressed="true"] .dot { opacity: 1; }
#floors .sep { height: 1px; margin: 4px 10px; background: var(--glass-line); }

/* ---------- Rail d'outils (droite, en haut) ---------- */
#rail { left: 20px; top: 92px; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 18px; animation-delay: .25s; }
#rail .tool {
  width: 52px; padding: 8px 0 6px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--glass-muted); font-size: .58rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  transition: background .2s, color .2s;
}
#rail .tool svg { width: 20px; height: 20px; }
#rail .tool:hover, #rail .tool[aria-expanded="true"] { background: rgba(255,255,255,.1); color: var(--glass-text); }

/* ---------- Barre de navigation (footer) ---------- */
#toolbar {
  left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: var(--r-pill);
  animation-delay: .3s;
}
#toolbar .tb {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  color: var(--glass-text); position: relative; transition: background .2s, transform .2s var(--ease);
}
#toolbar .tb svg { width: 20px; height: 20px; }
#toolbar .tb:hover { background: rgba(255,255,255,.12); }
#toolbar .tb:active { transform: scale(.94); }
#toolbar .tb[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
#toolbar .tb[disabled] { opacity: .35; pointer-events: none; }
#toolbar .sep { width: 1px; height: 26px; background: var(--glass-line); margin: 0 4px; }
#toolbar .tb::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%) translateY(4px);
  padding: 5px 9px; border-radius: 8px; white-space: nowrap; font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  background: var(--paper); color: var(--ink); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toolbar .tb:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Indicateur de rotation (arc de 20 crans) */
#frame-ring { display: flex; align-items: center; gap: 3px; padding: 0 10px; }
#frame-ring i { width: 3px; height: 10px; border-radius: 2px; background: rgba(255,255,255,.18); transition: background .2s, height .2s; }
#frame-ring i.on { background: var(--paper); height: 16px; }

/* ---------- Légende typologies ---------- */
#legend { left: 20px; bottom: 24px; padding: 10px 12px; border-radius: 18px; display: flex; flex-direction: column; gap: 8px; animation-delay: .35s; }
#legend .title { font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; color: var(--glass-muted); padding: 0 4px; }
#legend .chips { display: flex; gap: 6px; }
#legend .chip {
  display: flex; align-items: center; gap: 7px; padding: 7px 11px 7px 8px; border-radius: var(--r-pill);
  font-size: .78rem; font-weight: 700; color: var(--glass-text); background: rgba(255,255,255,.06);
  border: 1px solid transparent; transition: background .2s, border-color .2s, opacity .2s;
}
#legend .chip i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
#legend .chip:hover { background: rgba(255,255,255,.12); }
#legend .chip[aria-pressed="true"] { background: rgba(255,255,255,.14); border-color: var(--c); }
#legend.filtering .chip:not([aria-pressed="true"]) { opacity: .5; }
#legend .hint { font-size: .68rem; color: var(--glass-muted); padding: 0 4px; }

/* ---------- Boussole ---------- */
#compass { right: 24px; bottom: 24px; width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; animation-delay: .4s; }
#compass svg { width: 76px; height: 76px; overflow: visible; }
#compass .rose { transition: transform .35s var(--ease); transform-origin: 50% 50%; }
#compass text { font-family: var(--font-ui); font-weight: 800; font-size: 9px; letter-spacing: .04em; fill: var(--glass-muted); }
#compass .n { fill: var(--accent); font-size: 10px; }
#compass .lbl { position: absolute; bottom: -18px; font-size: .58rem; letter-spacing: .2em; text-transform: uppercase; color: var(--glass-muted); }

/* ---------- Fiche lot (survol) ---------- */
#lotcard {
  position: absolute; z-index: 8; pointer-events: none; min-width: 240px; max-width: 300px;
  padding: 14px 16px 14px; border-radius: 16px; color: var(--ink);
  background: rgba(245,242,236,.96); box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(6px) scale(.98); transition: opacity .18s var(--ease), transform .18s var(--ease);
}
#lotcard.show { opacity: 1; transform: none; }
#lotcard .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
#lotcard .type { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 1.35rem; }
#lotcard .type i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }
#lotcard .floorlbl { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
#lotcard .row { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; font-size: .82rem; padding: 6px 0; border-top: 1px solid var(--stone); }
#lotcard .row b { font-weight: 700; }
#lotcard .row span { color: var(--ink-2); }
#lotcard .status { display: inline-block; padding: 3px 9px; border-radius: var(--r-pill); font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
#lotcard .status.disponible { background: #dcefe1; color: #1f6b45; }
#lotcard .status.reserve { background: #fbe7cf; color: #a05a1c; }
#lotcard .status.vendu { background: #e6e1d6; color: #6a6660; }
#lotcard .more { font-size: .72rem; color: var(--muted); padding-top: 6px; }
#lotcard .empty { font-size: .8rem; color: var(--ink-2); }

/* ---------- Aide au glisser ---------- */
#drag-hint {
  left: 50%; bottom: 96px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border-radius: var(--r-pill);
  font-size: .78rem; font-weight: 600; color: var(--glass-text);
  transition: opacity .4s; pointer-events: none;
}
#drag-hint svg { width: 22px; height: 22px; animation: nudge 1.6s var(--ease) infinite; }
@keyframes nudge { 0%,100% { transform: translateX(-4px);} 50% { transform: translateX(4px);} }
#drag-hint.hide { opacity: 0; }

/* ---------- Chargement (barre discrète) ---------- */
#loadbar { position: absolute; z-index: 9; left: 0; top: 0; height: 2px; width: 0; background: var(--accent); transition: width .3s var(--ease), opacity .4s; }
#loadbar.done { opacity: 0; }

/* ---------- Intro ---------- */
#intro {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #0f1311;
  transition: opacity .8s var(--ease), visibility .8s;
}
#intro.out { opacity: 0; visibility: hidden; }
#intro .bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .18; filter: saturate(.7); transform: scale(1.04); animation: intro-zoom 12s var(--ease) forwards; }
@keyframes intro-zoom { to { transform: scale(1); } }
#intro video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#intro .center { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 24px; }
#intro .logo { width: min(340px, 70vw); opacity: 0; translate: 0 8px; animation: hud-in 1s var(--ease-out) .2s forwards; }
#intro .tag { max-width: 34ch; font-family: var(--font-display); font-weight: 400; font-size: clamp(1rem, 2vw, 1.3rem); color: var(--glass-muted); opacity: 0; translate: 0 8px; animation: hud-in 1s var(--ease-out) .5s forwards; }
#intro .progress { width: 220px; height: 2px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
#intro .progress i { display: block; height: 100%; width: 0; background: var(--wood); transition: width .3s var(--ease); }
#intro .pct { font-size: .68rem; letter-spacing: .24em; text-transform: uppercase; color: var(--glass-muted); }
#intro .enter { opacity: 0; transform: translateY(8px); transition: opacity .5s, transform .5s var(--ease-out); pointer-events: none; }
#intro.ready .enter { opacity: 1; transform: none; pointer-events: auto; }
#intro.ready .progress, #intro.ready .pct { display: none; }
#intro .skip { position: absolute; right: 24px; bottom: 24px; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--glass-muted); }

/* ---------- Panneaux latéraux (plan de masse, coupes, galerie…) ---------- */
#panel {
  position: absolute; z-index: 20; top: 20px; bottom: 20px; right: 20px; width: min(520px, calc(100% - 40px));
  border-radius: 24px; display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass-strong);
  transform: translateX(calc(100% + 40px)); transition: transform .5s var(--ease-out);
}
#panel.open { transform: none; }
#panel header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px 22px; border-bottom: 1px solid var(--glass-line); }
#panel header h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; }
#panel header .close { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.08); }
#panel header .close:hover { background: rgba(255,255,255,.18); }
#panel header .close svg { width: 16px; height: 16px; }
#panel .body { overflow: auto; padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
#panel .body p { color: var(--glass-muted); font-size: .9rem; }
#panel figure { margin: 0; border-radius: 14px; overflow: hidden; background: #fff; }
#panel figure img { width: 100%; height: auto; cursor: zoom-in; }
#panel figcaption { padding: 10px 12px; font-size: .78rem; color: var(--glass-muted); background: rgba(255,255,255,.04); }
#panel .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#panel .grid figure { aspect-ratio: 4/3; }
#panel .grid figure img { width: 100%; height: 100%; object-fit: cover; }
#panel .lots { display: flex; flex-direction: column; gap: 6px; }
#panel .lot { display: grid; grid-template-columns: 12px 64px 1fr auto auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.05); font-size: .82rem; }
#panel .lot i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }
#panel .lot b { font-weight: 700; }
#panel .lot .st { font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: var(--r-pill); }
#panel .lot .st.disponible { background: rgba(95,207,156,.2); color: #8ee2b6; }
#panel .lot .st.reserve { background: rgba(239,138,74,.2); color: #f4b287; }
#panel .lot .st.vendu { background: rgba(255,255,255,.08); color: var(--glass-muted); }
#panel .lot.dim { opacity: .45; }
#panel .link { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 10px 16px; border-radius: var(--r-pill); background: var(--paper); color: var(--ink); font-weight: 700; font-size: .82rem; }
#panel .link svg { width: 16px; height: 16px; }
#panel .contact { display: flex; flex-direction: column; gap: 10px; font-size: .95rem; }
#panel .contact a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.05); }
#panel .contact a:hover { background: rgba(255,255,255,.1); }
#panel .contact svg { width: 18px; height: 18px; color: var(--wood); }

/* ---------- Visite virtuelle 360° (popup) ---------- */
#tourbox { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(10,12,11,.86); backdrop-filter: blur(6px); opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
#tourbox.open { opacity: 1; visibility: visible; }
#tourbox .frame { width: min(1400px, 100%); height: min(860px, 100%); display: flex; flex-direction: column; border-radius: 20px; overflow: hidden; background: #000; box-shadow: var(--shadow-2); transform: scale(.97); transition: transform .35s var(--ease-out); }
#tourbox.open .frame { transform: none; }
#tourbox header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 18px; background: var(--glass-strong); border-bottom: 1px solid var(--glass-line); }
#tourbox header .t { font-family: var(--font-display); font-size: 1.05rem; }
#tourbox header .acts { display: flex; gap: 6px; }
#tourbox header a, #tourbox header .close { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.08); color: var(--glass-text); }
#tourbox header a:hover, #tourbox header .close:hover { background: rgba(255,255,255,.18); }
#tourbox header svg { width: 16px; height: 16px; }
#tourbox iframe { flex: 1; width: 100%; border: 0; background: #000; }
@media (max-width: 700px) { #tourbox { padding: 0; } #tourbox .frame { border-radius: 0; } }

/* Bouton visite dans la fiche et la liste des lots */
#lotcard .tour { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 9px 12px; border-radius: 10px; background: var(--moss); color: #fff; font-size: .78rem; font-weight: 700; }
#lotcard .tour svg { width: 16px; height: 16px; }
#panel .lot { grid-template-columns: 12px 64px 1fr auto auto auto; }
#panel .lot .go360 { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: var(--r-pill); background: var(--paper); color: var(--ink); font-size: .66rem; font-weight: 800; letter-spacing: .04em; }
#panel .lot .go360 svg { width: 13px; height: 13px; }
#panel .lot .go360:hover { background: #fff; }

/* ---------- Lightbox ---------- */
#lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(10,12,11,.92); opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
#lightbox.open { opacity: 1; visibility: visible; }
#lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#lightbox img { max-width: min(94vw, calc(100vw - 160px)); max-height: 86vh; border-radius: 10px; box-shadow: var(--shadow-2); animation: lb-in .3s var(--ease-out); }
@keyframes lb-in { from { opacity: 0; transform: scale(.97); } }
#lightbox figcaption { color: rgba(255,255,255,.75); font-size: .85rem; text-align: center; min-height: 1.2em; }
#lightbox figcaption:empty { display: none; }
#lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; backdrop-filter: blur(8px); transition: background .2s, transform .2s; }
#lightbox .nav:hover { background: rgba(255,255,255,.24); }
#lightbox .nav:active { transform: translateY(-50%) scale(.94); }
#lightbox .nav svg { width: 22px; height: 22px; }
#lightbox .nav.prev { left: 24px; }
#lightbox .nav.next { right: 24px; }
#lightbox .nav[hidden] { display: none; }
#lightbox .count { position: absolute; top: 32px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.7); font-size: .78rem; font-weight: 700; letter-spacing: .12em; }
@media (max-width: 700px) {
  #lightbox img { max-width: 100vw; max-height: 78vh; border-radius: 0; }
  #lightbox .nav { width: 44px; height: 44px; top: auto; bottom: 24px; transform: none; }
  #lightbox .nav:active { transform: scale(.94); }
  #lightbox .nav.prev { left: calc(50% - 60px); }
  #lightbox .nav.next { right: calc(50% - 60px); }
}
#lightbox .close { position: absolute; top: 20px; right: 20px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.1); display: grid; place-items: center; }
#lightbox .close svg { width: 18px; height: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  #floors { right: 12px; padding: 4px; }
  #floors .floor { min-width: 0; padding: 8px; }
  #floors .floor .l, #floors .floor .h, #floors .floor .dot { display: none; }
  #rail { left: 12px; top: 68px; flex-direction: row; gap: 2px; padding: 4px; border-radius: 14px; }
  #rail .tool { width: 48px; padding: 6px 0 5px; font-size: .52rem; }
  #rail .tool svg { width: 18px; height: 18px; }
  #topbar { top: 12px; left: 12px; right: 12px; }
  .brand { padding: 8px 14px 8px 8px; }
  .brand-sub { display: none; }
  #legend { left: 12px; bottom: 82px; padding: 6px; }
  #legend .title, #legend .hint { display: none; }
  #legend .chip { padding: 6px 9px 6px 7px; font-size: .72rem; }
  #compass { right: 12px; bottom: 82px; width: 64px; height: 64px; }
  #compass svg { width: 50px; height: 50px; }
  #toolbar { bottom: 14px; padding: 4px; max-width: calc(100% - 24px); }
  #toolbar .tb { width: 42px; height: 42px; }
  #frame-ring { display: none; }
  #panel { top: auto; bottom: 0; right: 0; left: 0; width: 100%; height: 78vh; border-radius: 24px 24px 0 0; transform: translateY(110%); }
  #lotcard { min-width: 200px; }
  #drag-hint { bottom: 130px; }
}
