/* ==========================================================================
   Maison connectée en vue isométrique (page Réalisations)
   Construction, caméra et ouverture des pièces : client/realisations.js.
   ========================================================================== */

.house {
  display: grid;
  gap: 1rem;
  margin-top: clamp(1.25rem, 4vw, 2.5rem);
}

.house-stage {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse 70% 60% at 50% 55%, rgba(31, 111, 235, 0.22), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 0%, #121c33, #070c17 75%);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* La « caméra » : c'est elle qui zoome sur une pièce */
.house-cam {
  position: relative;
  transform-origin: 50% 50%;
}

.house-svg {
  display: block;
  width: 100%;
  height: clamp(340px, calc(100svh - 20rem), 680px);
  min-height: 300px;
}

/* ---------- Pièces et appareils ---------- */
.house .device {
  cursor: pointer;
  outline: none;
  transition: opacity 0.4s ease;
}

.house .room-floor {
  fill: #58a6ff;
  fill-opacity: 0;
  stroke: #58a6ff;
  stroke-opacity: 0;
  stroke-width: 2;
  pointer-events: all;
  transition:
    fill-opacity 0.35s ease,
    stroke-opacity 0.35s ease;
}

.house .device.is-hot .room-floor {
  fill-opacity: 0.12;
  stroke-opacity: 0.6;
}

.house .device:focus-visible .room-floor {
  fill-opacity: 0.12;
  stroke-opacity: 1;
  stroke-width: 3;
}

/* Une pièce survolée : les autres passent dans l'ombre */
.house[data-hot] .device:not(.is-hot) {
  opacity: 0.45;
}

.house .dev-body {
  transition: translate 0.4s var(--ease-out, ease-out);
}

.house .device.is-hot .dev-body {
  translate: 0 -6px;
}

.house .drop,
.house .wall,
.house .partition,
.house .tile {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

/* Câbles et données */
.house .cable {
  fill: none;
  stroke: #2b384c;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.35s ease;
}

.house[data-hot='reseau'] .cable,
.house[data-hot='montage'] .cable-pc {
  stroke: #58a6ff;
}

.house[data-hot='hebergement'] .cable-nas {
  stroke: #3fb950;
}

.house .packet {
  fill: #a5d6ff;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.house .packet-alt {
  fill: #7ee787;
}

.house.is-live .packet {
  opacity: 1;
}

/* Onde de clic (au sol) */
.house .ping {
  fill: none;
  stroke: #58a6ff;
  stroke-width: 3;
  opacity: 0;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
}

.house .ping.is-pinging {
  animation: hs-ping 0.8s var(--ease-out, ease-out);
}

.house .coverage .ring {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.house .fan-blades {
  transform-box: fill-box;
  transform-origin: center;
}

.house .wall-cable {
  fill: none;
  stroke: #2b384c;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.house .tag-anchor {
  pointer-events: none;
}

/* ---------- Étiquettes flottantes ---------- */
.house-tags {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.house-tag {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  justify-items: center;
  padding: 0.4rem 0.85rem 0.45rem;
  border-radius: 12px;
  border: 1px solid rgba(240, 246, 252, 0.18);
  background: rgba(13, 17, 23, 0.82);
  backdrop-filter: blur(6px);
  color: #e6edf3;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  translate: -50% -100%;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    scale 0.35s var(--ease-out, ease-out);
}

.house-tag small {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b949e;
  transition: color 0.3s ease;
}

/* Petite pointe vers l'appareil */
.house-tag::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  rotate: 45deg;
  background: inherit;
  border-right: inherit;
  border-bottom: inherit;
}

.house-tag .tag-ic {
  display: none;
}

.house-tag::after {
  translate: var(--arrow-x, 0px) 0;
}

.house-tag.is-hot,
.house-tag.is-active {
  background: #1f6feb;
  border-color: #58a6ff;
  scale: 1.06;
}

.house-tag.is-hot small,
.house-tag.is-active small {
  color: #cfe3ff;
}

html:not(.js) .house-tags {
  display: none;
}

/* ---------- États avant la construction (uniquement si JavaScript la jouera) ---------- */
.js .house.is-waiting :is(.tile, .slab, .wall, .partition, .drop, .h-fill, .cable, .coverage, .house-tag) {
  opacity: 0;
}

@media (max-width: 699px) {
  .house-svg {
    height: auto;
    min-height: 0;
  }

  /* Sur téléphone, les étiquettes deviennent des pastilles-icônes (le texte est sur les boutons dessous) */
  .house-tag {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 50%;
    place-items: center;
    font-size: 0;
    line-height: 0;
  }

  .house-tag small {
    display: none;
  }

  .house-tag .tag-ic {
    display: grid;
    color: #58a6ff;
  }

  .house-tag.is-hot .tag-ic,
  .house-tag.is-active .tag-ic {
    color: #fff;
  }

  /* Zone tactile de 44 px */
  .house-tag::before {
    content: '';
    position: absolute;
    inset: -0.25rem;
    border-radius: 50%;
  }

  .house-tag::after {
    bottom: -5px;
    width: 8px;
    height: 8px;
    margin-left: -4px;
  }
}

/* ---------- Ambiance : peu de boucles, lentes, transform / opacity uniquement ---------- */
@media (prefers-reduced-motion: no-preference) {
  .house.is-live .wave {
    animation: hs-wave 2.8s var(--ease-in-out) infinite;
  }

  .house.is-live .w2 {
    animation-delay: 0.35s;
  }

  .house.is-live .w3 {
    animation-delay: 0.7s;
  }

  .house.is-live .ring.r1 {
    animation: hs-ring 6s var(--ease-out) infinite;
  }

  .house.is-live .ring.r2 {
    animation: hs-ring 6s var(--ease-out) 3s infinite;
  }

  .house.is-live .ap-led {
    animation: hs-breathe 3.2s ease-in-out infinite;
  }

  .house.is-live .fan-blades {
    animation: hs-spin 1.4s linear infinite;
  }

  .house.is-live .led.blink {
    animation: hs-blink 2.6s ease-in-out infinite;
  }
}

@media (prefers-reduced-motion: reduce) {
  .house .packets {
    display: none;
  }
}

@keyframes hs-wave {
  0%,
  100% {
    opacity: 0.18;
  }
  40% {
    opacity: 1;
  }
}

@keyframes hs-ring {
  0% {
    opacity: 0.6;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(9);
  }
}

@keyframes hs-breathe {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

@keyframes hs-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes hs-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}

@keyframes hs-ping {
  0% {
    opacity: 1;
    transform: scale(0.4);
  }
  100% {
    opacity: 0;
    transform: scale(2.2);
  }
}

@media (hover: none) {
  .hint-fine {
    display: none;
  }
}

@media (hover: hover) {
  .hint-touch {
    display: none;
  }
}

/* ---------- Invitation à entrer (intégrée à la scène, disparaît au premier toucher) ---------- */
.house-cue {
  position: absolute;
  left: 50%;
  bottom: 0.9rem;
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.9rem 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(240, 246, 252, 0.14);
  background: rgba(13, 17, 23, 0.72);
  color: #c9d1d9;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.5s var(--ease-out, ease-out),
    translate 0.5s var(--ease-out, ease-out);
}

.house-cue .cue-dot {
  position: relative;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #58a6ff;
}

.house-cue .cue-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #58a6ff;
}

.house.is-live:not(.is-explored) .house-cue {
  opacity: 1;
  transition-delay: 0.6s;
}

.house.is-explored .house-cue {
  translate: -50% 0.5rem;
}

@media (prefers-reduced-motion: no-preference) {
  .house.is-live:not(.is-explored, .is-paused) .house-cue .cue-dot::after {
    animation: cue-ping 1.8s var(--ease-out, ease-out) infinite;
  }
}

@keyframes cue-ping {
  from {
    opacity: 0.9;
    scale: 1;
  }
  to {
    opacity: 0;
    scale: 3;
  }
}

@media (max-width: 699px) {
  /* Pastilles un peu plus petites et relevées : celle du PC ne masque plus l'écran du bureau */
  .house-tag {
    width: 2rem;
    height: 2rem;
    translate: -50% calc(-100% - 0.4rem);
  }

  .house-tag::before {
    inset: -0.375rem; /* zone tactile 44 px */
  }

  .house-cue {
    bottom: 0.6rem;
    font-size: 0.8rem;
  }
}

/* Téléphone : maison cadrée serré sur les appareils (le coin gauche du bureau sort du cadre),
   environ 1,7 fois plus grande ; le cadrage est fait en CSS (aucun recalcul, aucun décalage au chargement). */
@media (max-width: 599px) {
  .house-svg {
    width: 168%;
    max-width: none;
    margin-left: -62.1%;
  }

  .house-tag {
    width: 2.5rem;
    height: 2.5rem;
  }

  .house-tag::before {
    inset: -0.125rem; /* zone tactile 44 px */
  }

  .house-tag .tag-ic svg {
    width: 20px;
    height: 20px;
  }
}
