/* Villa principale v3 — visite 3D.
   Mise en page : la scène occupe tout l'écran ; titre en haut à gauche,
   vues et réglages en bas, liste des pièces en tiroir (feuille du bas sur téléphone). */
:root {
  --fond: #eaf1f0;          /* sous la scène, le temps du chargement */
  --encre: #14232c;
  --verre: rgba(16, 33, 43, 0.74);   /* panneaux posés sur la 3D */
  --verre-fort: rgba(13, 28, 37, 0.9);
  --sur-verre: #f3f6f4;
  --sur-verre-doux: rgba(243, 246, 244, 0.7);
  --trait: rgba(243, 246, 244, 0.16);
  --ocre: #f0b44c;   /* safran */
  --z-jour: #f2c45a; --z-loisirs: #e9876a; --z-pere: #5b86c4; --z-epouse1: #63c2ae; --z-epouse2: #9cc46e;
  --z-proprio: #35a7b5; --z-grands: #a9cfe4; --z-service: #c4cbc8; --z-circulation: #e4e8e2;
  --titre: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --texte: "Instrument Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --fond: #0f1c23; --encre: #eef3f1; color-scheme: dark; }
}
:root[data-theme="dark"] { --fond: #0f1c23; --encre: #eef3f1; color-scheme: dark; }

html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; overflow: hidden; background: var(--fond); color: var(--encre);
  font: 14px/1.4 var(--texte); -webkit-font-smoothing: antialiased;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#etiquettes { position: fixed; inset: 0; pointer-events: none; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--ocre); outline-offset: 2px; }

/* étiquettes des pièces */
.etiquette {
  pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 4px 9px 5px; border: 0; border-radius: 3px; background: var(--verre); color: var(--sur-verre);
  box-shadow: 0 6px 18px rgba(6, 16, 22, 0.25); white-space: nowrap; transition: background 0.2s;
  border-top: 2px solid var(--z, var(--ocre));
}
.etiquette b { font: 600 12px/1.1 var(--texte); letter-spacing: 0.01em; }
.etiquette span { font-size: 10.5px; color: var(--sur-verre-doux); font-variant-numeric: tabular-nums; }
.etiquette:hover { background: var(--verre-fort); }
.zone-jour { --z: var(--z-jour); } .zone-loisirs { --z: var(--z-loisirs); } .zone-pere { --z: var(--z-pere); }
.zone-epouse1 { --z: var(--z-epouse1); } .zone-epouse2 { --z: var(--z-epouse2); } .zone-proprio { --z: var(--z-proprio); }
.zone-grands { --z: var(--z-grands); } .zone-service { --z: var(--z-service); } .zone-circulation { --z: var(--z-circulation); }

/* titre */
.titre {
  position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); left: max(16px, env(safe-area-inset-left, 0px));
  padding: 12px 16px 13px; background: var(--verre); color: var(--sur-verre); border-radius: 4px; max-width: min(380px, calc(100vw - 32px));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.titre .sur { margin: 0 0 2px; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ocre); }
.titre h1 { margin: 0; font: 600 25px/1.05 var(--titre); letter-spacing: -0.01em; text-wrap: balance; }
.titre .chiffres { margin: 5px 0 0; font-size: 12.5px; color: var(--sur-verre-doux); font-variant-numeric: tabular-nums; }

/* barre du bas */
.barre {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: flex-end; justify-content: space-between;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.barre > * { pointer-events: auto; }
.groupe-boutons {
  display: flex; gap: 2px; padding: 3px; background: var(--verre); border-radius: 4px; overflow-x: auto; max-width: 100%;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); scrollbar-width: none;
}
.groupe-boutons button {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--sur-verre); padding: 8px 12px; border-radius: 3px;
  font-size: 13px; white-space: nowrap;
}
.groupe-boutons button:hover { background: rgba(243, 246, 244, 0.1); }
.groupe-boutons button[aria-current="true"], .groupe-boutons button[aria-pressed="true"] { background: var(--sur-verre); color: var(--encre); }
:root[data-theme="dark"] .groupe-boutons button[aria-current="true"], :root[data-theme="dark"] .groupe-boutons button[aria-pressed="true"] { color: #14232c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .groupe-boutons button[aria-current="true"],
  :root:not([data-theme="light"]) .groupe-boutons button[aria-pressed="true"] { color: #14232c; } }
/* boutons d'ambiance (Sahel clair → Lamu → Lagune → Jardin) et de finition des murs : pastille de couleur */
#t-ambiance, #t-murs-teinte { display: inline-flex; align-items: center; gap: 7px; border-left: 1px solid var(--trait); margin-left: 2px; border-radius: 0 3px 3px 0; }
#t-ambiance::before, #t-murs-teinte::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--pastille, var(--ocre)); box-shadow: 0 0 0 1.5px var(--sur-verre-doux); }
#t-murs-teinte { --pastille: #f3f1ec; }
#t-ambiance[data-valeur="sahel"] { --pastille: #2e3033; }
#t-ambiance[data-valeur="lamu"] { --pastille: #3b6aa6; }
#t-ambiance[data-valeur="lagune"] { --pastille: #3fbfc8; }
#t-ambiance[data-valeur="jardin"] { --pastille: #2f8c66; }
.colonne { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; min-width: 0; }
#ouvrir-pieces {
  border: 0; background: var(--ocre); color: #14232c; padding: 11px 16px; border-radius: 4px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(6, 16, 22, 0.25);
}

/* liste des pièces */
#pieces {
  position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--barre-hauteur, 100px) + 28px + env(safe-area-inset-bottom, 0px)); width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; background: var(--verre-fort); color: var(--sur-verre); border-radius: 4px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 18px 50px rgba(6, 16, 22, 0.35);
}
#pieces > header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; border-bottom: 1px solid var(--trait); }
#pieces h2 { margin: 0; font: 600 19px/1 var(--titre); }
#pieces .fermer { border: 0; background: transparent; color: var(--sur-verre-doux); padding: 6px 8px; font-size: 13px; }
#pieces .groupes { overflow-y: auto; padding: 4px 8px 14px; min-height: 0; }
.groupe h3 {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 14px 8px 4px; padding-left: 10px;
  border-left: 3px solid var(--z); font: 600 11px/1.2 var(--texte); letter-spacing: 0.12em; text-transform: uppercase; color: var(--sur-verre-doux);
}
.groupe h3 small { font-weight: 400; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.groupe ul { list-style: none; margin: 0; padding: 0; }
.groupe li button {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border: 0; background: transparent;
  padding: 7px 8px 7px 21px; border-radius: 3px; text-align: left;
}
.groupe li button:hover { background: rgba(243, 246, 244, 0.08); }
.groupe li em { font-style: normal; color: var(--sur-verre-doux); font-size: 12px; }
.groupe li small { color: var(--sur-verre-doux); font-variant-numeric: tabular-nums; flex: 0 0 auto; }

/* fiche de la pièce visitée */
#fiche {
  position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); top: calc(14px + env(safe-area-inset-top, 0px));
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 4px 12px;
  padding: 10px 10px 10px 16px; width: min(380px, calc(100vw - 32px)); box-sizing: border-box;
  background: var(--verre-fort); color: var(--sur-verre); border-radius: 4px; box-shadow: 0 14px 40px rgba(6, 16, 22, 0.3);
}
#fiche .texte { grid-column: 2; min-width: 0; }
#fiche .zone { margin: 0; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ocre); }
#fiche .nom { margin: 1px 0 0; font: 600 21px/1.1 var(--titre); overflow-wrap: anywhere; }
#fiche .info { margin: 2px 0 0; font-size: 12.5px; color: var(--sur-verre-doux); }
#fiche button { border: 0; background: rgba(243, 246, 244, 0.1); color: var(--sur-verre); border-radius: 3px; padding: 10px 12px; }
#fiche .retour { grid-column: 1; grid-row: 1; padding: 10px 11px; }
#fiche .aide { grid-column: 1 / -1; margin: 2px 0 0; font-size: 11.5px; color: var(--sur-verre-doux); }
body[data-mode="piece"] .titre { display: none; }
body[data-mode="piece"] .vues-ext { opacity: 0.75; }

.etiquette.masquee { opacity: 0; pointer-events: none; }
.etiquette { transition: opacity 0.18s; }

/* mini-plan pendant la visite */
#miniplan {
  display: none; position: fixed; margin: 0; top: calc(14px + env(safe-area-inset-top, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  width: 210px; padding: 10px 10px 8px; background: var(--verre-fort); border-radius: 4px; box-shadow: 0 14px 40px rgba(6, 16, 22, 0.3);
}
body[data-mode="piece"] #miniplan { display: block; }
#miniplan svg { display: block; width: 100%; height: auto; }
#miniplan polygon { fill: var(--z); fill-opacity: 0.55; stroke: #0d1c25; stroke-width: 0.12; cursor: pointer; }
#miniplan polygon.ext { fill-opacity: 0.25; }
#miniplan polygon:hover { fill-opacity: 0.85; }
#miniplan polygon.ici { fill: var(--ocre); fill-opacity: 1; stroke: var(--sur-verre); stroke-width: 0.22; }
#miniplan figcaption { margin-top: 6px; font-size: 11px; color: var(--sur-verre-doux); text-align: center; }

/* tournage de la vidéo */
body.film .titre, body.film .barre, body.film #fiche, body.film #miniplan, body.film #pieces { display: none !important; }
#legende-film {
  position: fixed; left: 40px; bottom: 38px; margin: 0; display: flex; flex-direction: column; gap: 4px;
  padding: 14px 20px 15px; background: var(--verre); color: var(--sur-verre); border-radius: 4px; border-left: 3px solid var(--ocre);
}
#legende-film small { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ocre); }
#legende-film span { font: 600 26px/1.1 var(--titre); }

#chargement {
  position: fixed; inset: 0; display: grid; place-items: center; background: var(--fond); color: var(--encre);
  font: 500 15px var(--texte); letter-spacing: 0.04em; transition: opacity 0.6s;
}
#chargement.fini { opacity: 0; pointer-events: none; }

@media (max-width: 720px) {
  .titre { padding: 9px 12px 10px; }
  .titre h1 { font-size: 20px; }
  .titre .chiffres { font-size: 11.5px; }
  .barre { flex-direction: column; align-items: stretch; gap: 8px; }
  .colonne { align-items: stretch; }
  .groupe-boutons button { padding: 9px 11px; }
  #ouvrir-pieces { align-self: stretch; }
  #pieces { top: auto; left: max(16px, env(safe-area-inset-left, 0px)); width: auto; height: 68vh; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }

  .etiquette { padding: 3px 7px 4px; }
  .etiquette b { font-size: 10.5px; }
  .etiquette span { display: none; }
  #miniplan { width: 92px; padding: 7px 7px 5px; }
  #fiche { width: calc(100vw - 150px); padding: 8px; gap: 4px; }
  #fiche .aide, #fiche .zone { display: none; }
  #fiche .nom { font-size: 17px; }
  #fiche button { padding: 7px; }
  body[data-mode="piece"] .titre { display: none; }
  #miniplan figcaption { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
