/* Retrouvailles · la fiche maison (fiche.js), sa fenêtre et la visionneuse de photos. Jetons de /ds.css,
   composants décrits dans DESIGN.md. */

/* ---------- Fiche ---------- */

.fiche {
  display: grid;
  gap: var(--e-5);
  color: var(--encre);
}
.fiche-galerie {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--e-2);
}
.fiche-photo {
  display: block;
  padding: 0;
  border: 0;
  overflow: hidden;
  border-radius: var(--rayon-photo);
  background: var(--pre);
  cursor: zoom-in;
}
.fiche-photo img {
  width: 100%;
  height: 100%;
  aspect-ratio: var(--ratio-photo);
  object-fit: cover;
  transition: transform var(--duree-panneau) var(--ease-out);
}
.fiche-photo-grande {
  grid-column: 1 / -1;
}
@media (hover: hover) and (pointer: fine) {
  .fiche-photo:hover img {
    transform: scale(1.03);
  }
}
@media (min-width: 760px) {
  .fiche-galerie {
    grid-template-columns: 2fr 1fr 1fr;
    grid-auto-rows: 1fr;
  }
  .fiche-photo-grande {
    grid-column: 1;
    grid-row: span 2;
  }
  .fiche-photo:not(.fiche-photo-grande) img {
    aspect-ratio: auto;
  }
  /* une galerie réduite à une ou deux photos garde une belle grande photo */
  .fiche-galerie:not(:has(.fiche-photo:nth-child(3))) {
    grid-template-columns: 2fr 1fr;
  }
  /* trois photos : les deux petites s'empilent à droite, sans case vide */
  .fiche-galerie:has(.fiche-photo:nth-child(3)):not(:has(.fiche-photo:nth-child(4))) {
    grid-template-columns: 2fr 1fr;
  }
  /* quatre photos : la dernière prend toute la ligne du bas */
  .fiche-galerie:has(.fiche-photo:nth-child(4)):not(:has(.fiche-photo:nth-child(5))) .fiche-photo:nth-child(4) {
    grid-column: span 2;
  }
}
.fiche-galerie {
  position: relative;
}
.fiche-galerie-tout {
  position: absolute;
  right: var(--e-3);
  bottom: var(--e-3);
  min-height: var(--cible-petite);
  padding: var(--e-2) var(--e-3);
  border: 0;
  border-radius: var(--rayon-petit);
  background: var(--nappe);
  color: var(--sapin);
  font: inherit;
  font-size: var(--t-petit);
  font-weight: 700;
  box-shadow: var(--ombre-carte);
  cursor: pointer;
}

/* Visite pièce par pièce : une case par pièce, son intitulé dessous ; un rail qui défile sur mobile */
.fiche-visite-liste {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 78%;
  gap: var(--e-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  padding-bottom: var(--e-2);
}
.fiche-bloc .fiche-visite-liste {
  max-width: none;
}
.fiche-visite-piece {
  scroll-snap-align: start;
}
.fiche-visite-photos {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--e-1);
}
.fiche-visite-nom {
  margin-top: var(--e-2);
  font-weight: 700;
  color: var(--sapin);
}
@media (min-width: 760px) {
  .fiche-visite-liste {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    overflow: visible;
  }
}

.fiche-tete {
  display: grid;
  gap: var(--e-1);
}
.fiche-nom {
  font-family: var(--police-titre);
  font-size: var(--t-h2);
  line-height: var(--interligne-titre);
  color: var(--sapin);
}
.fiche-pour {
  font-size: var(--t-chapo);
  color: var(--encre-douce);
}
.fiche-chiffres {
  margin-top: var(--e-2);
  font-weight: 700;
  color: var(--sapin);
}
.fiche-resume {
  max-width: var(--mesure);
  font-size: var(--t-chapo);
  line-height: var(--interligne-serre);
}
.fiche-forts {
  display: grid;
  gap: var(--e-2);
}
.fiche-forts li {
  padding: var(--e-3) var(--e-4);
  border-radius: var(--rayon-petit);
  background: var(--pre);
  font-weight: 600;
}
@media (min-width: 760px) {
  .fiche-forts {
    grid-template-columns: repeat(3, 1fr);
  }
}
.fiche-bloc {
  display: grid;
  gap: var(--e-3);
  padding-top: var(--e-5);
  border-top: var(--trait) solid var(--filet-clair);
}
.fiche-bloc-titre {
  font-family: var(--police-titre);
  font-size: var(--t-h3);
  color: var(--sapin);
}
.fiche-bloc .coches li:first-child {
  margin-top: 0;
}
.fiche-bloc p,
.fiche-bloc ul,
.fiche-bloc dl {
  max-width: var(--mesure);
}

/* Couchage : une carte par pièce */
.fiche-chambres {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: var(--e-3);
  max-width: none;
}
.fiche-bloc .fiche-chambres {
  max-width: none;
}
.carte-chambre {
  display: grid;
  align-content: start;
  overflow: hidden;
  border-radius: var(--rayon);
  box-shadow: inset 0 0 0 var(--trait) var(--filet);
}
.carte-chambre-texte {
  display: grid;
  gap: var(--e-1);
  padding: var(--e-4);
}
.carte-chambre-photo {
  display: block;
  padding: 0;
  border: 0;
  background: var(--pre);
}
button.carte-chambre-photo {
  cursor: zoom-in;
}
.carte-chambre-photo img {
  width: 100%;
  aspect-ratio: var(--ratio-photo);
  object-fit: cover;
}
.carte-chambre-piece {
  font-weight: 700;
  color: var(--sapin);
}
.carte-chambre-detail {
  font-size: var(--t-petit);
  color: var(--encre-douce);
}

/* Pour les familles : le bloc mis en avant */
.fiche-famille {
  padding: var(--e-5);
  border-top: 0;
  border-radius: var(--rayon);
  background: var(--creme);
}
.fiche-famille .coches {
  columns: 2 16rem;
  column-gap: var(--e-6);
  max-width: none;
}
.fiche-famille .coches li {
  break-inside: avoid;
}

/* Équipements : 8 visibles, le reste se déplie */
.fiche-equipements {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--e-4);
}
.fiche-equipements-titre {
  font-weight: 700;
  font-size: var(--t-base);
}
.fiche-equipements .coches li:first-child {
  margin-top: var(--e-2);
}
.fiche-equipements.replie .fiche-en-plus {
  display: none;
}
.fiche-bloc > .bouton {
  justify-self: start;
}
.fiche-horaires div,
.fiche-proximite div {
  display: flex;
  justify-content: space-between;
  gap: var(--e-4);
  padding-block: var(--e-2);
  border-bottom: var(--trait) solid var(--filet-clair);
}
.fiche-horaires dt,
.fiche-proximite dd {
  font-weight: 700;
  color: var(--sapin);
}
.fiche-horaires dt {
  flex: none;
}
.fiche-proximite dd {
  flex: none;
  text-align: right;
}
.fiche-regles li {
  margin-top: var(--e-2);
}

/* ---------- La fenêtre de la fiche : centrée en desktop, glissée du bas en mobile ---------- */

.fiche-fenetre {
  width: min(64rem, 100% - 2 * var(--gouttiere));
  max-width: none;
  max-height: 92svh;
  padding: 0;
  border: 0;
  border-radius: var(--rayon);
  background: var(--nappe);
  box-shadow: var(--ombre-fenetre);
  overflow: hidden;
  opacity: 1;
  transform: none;
  transition:
    transform var(--duree-panneau) var(--ease-drawer),
    opacity var(--duree-ui) ease,
    overlay var(--duree-panneau) allow-discrete,
    display var(--duree-panneau) allow-discrete;
}
.fiche-fenetre[open] {
  display: flex;
  flex-direction: column;
}
.fiche-fenetre:not([open]) {
  opacity: 0;
  transform: translateY(var(--e-5));
}
@starting-style {
  .fiche-fenetre[open] {
    opacity: 0;
    transform: translateY(var(--e-5));
  }
}
.fiche-fenetre::backdrop {
  background: var(--fond-fenetre);
}
.fiche-fenetre-tete {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--e-3);
  padding: var(--e-2) var(--e-4);
  border-bottom: var(--trait) solid var(--filet-clair);
}
.fiche-fenetre-fermer,
.visionneuse-fermer,
.visionneuse-pas {
  display: grid;
  place-items: center;
  width: var(--cible);
  height: var(--cible);
  padding: 0;
  border: 0;
  border-radius: var(--rayon-rond);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .fiche-fenetre-fermer:hover {
    background: var(--pre);
  }
}
.fiche-fenetre-corps {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--e-5) var(--e-5) var(--e-7);
}
@media (max-width: 759px) {
  .fiche-fenetre {
    width: 100%;
    height: 100svh;
    max-height: 100svh;
    margin: 0;
    border-radius: 0;
  }
  .fiche-fenetre:not([open]) {
    opacity: 1;
    transform: translateY(100%);
  }
  @starting-style {
    .fiche-fenetre[open] {
      opacity: 1;
      transform: translateY(100%);
    }
  }
  .fiche-fenetre-corps {
    padding: var(--e-4) var(--gouttiere) var(--e-7);
  }
}

/* ---------- Visionneuse ---------- */

.visionneuse {
  width: 100%;
  max-width: none;
  height: 100svh;
  max-height: none;
  margin: 0;
  padding: var(--e-6) var(--gouttiere);
  border: 0;
  background: var(--sapin-nuit);
  color: var(--nappe);
}
.visionneuse[open] {
  display: grid;
  place-items: center;
}
.visionneuse::backdrop {
  background: var(--sapin-nuit);
}
.visionneuse-cadre {
  display: grid;
  gap: var(--e-2);
  max-width: 100%;
  max-height: 100%;
}
.visionneuse-cadre img {
  touch-action: pan-y; /* le glisser horizontal change de photo */
  user-select: none;
  -webkit-user-drag: none;
  max-width: 100%;
  max-height: calc(100svh - 2 * var(--e-8));
  object-fit: contain;
  border-radius: var(--rayon-photo);
}
.visionneuse-cadre figcaption {
  color: var(--mousse);
  text-align: center;
}
.visionneuse-fermer {
  position: absolute;
  top: var(--e-2);
  right: var(--e-2);
}
.visionneuse-pas {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  background: var(--voile-texte);
  font-size: var(--t-1);
}
.visionneuse-avant {
  left: var(--e-2);
}
.visionneuse-apres {
  right: var(--e-2);
}

/* ---------- Page /maisons/ ---------- */

.maisons-page {
  padding-top: calc(var(--hauteur-entete) + var(--e-5));
}
.maisons-nav {
  position: sticky;
  top: var(--hauteur-entete);
  z-index: 10;
  display: flex;
  gap: var(--e-2);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: var(--e-2) var(--gouttiere);
  background: var(--nappe);
  box-shadow: 0 var(--trait) 0 var(--filet-clair);
}
.maisons-nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--cible-petite);
  padding: 0 var(--e-3);
  border-radius: var(--rayon-petit);
  color: var(--sapin);
  font-weight: 600;
  text-decoration: none;
  scroll-snap-align: start;
}
.maisons-nav a[aria-current="true"] {
  background: var(--sapin);
  color: var(--nappe);
}
.maisons-liste {
  display: grid;
  gap: var(--e-8);
}
.maisons-liste .fiche {
  scroll-margin-top: calc(var(--hauteur-entete) + var(--e-7));
}
.maisons-tete .titre {
  max-width: none;
}
