.intro > :not(.intro-note) { grid-column: 1; }

/* Note manuscrite, avec une flèche dessinée vers les photos. */
.intro-note {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: end;
  color: var(--green-mint);
}

.intro-note p {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 1.5rem;
  transform: rotate(-4deg);
}

/* La flèche déborde sur la section crème. Elle part du bas de la note, à 56px (padding bas de .intro)
   du bord de la bande sombre : le dégradé de la flèche passe du menthe au vert feuille à cet endroit. */
.intro-note svg {
  position: absolute;
  top: 100%;
  left: 24px;
  width: 110px;
  height: 130px;
}

/* Même mise en scène que le hero de l'accueil, puis la note s'écrit et la flèche se dessine vers les photos. */
@media (prefers-reduced-motion: no-preference) {
  .intro-note p { animation: intro-note-write 0.9s ease-out 0.9s both; }
  .intro-note svg { animation: intro-arrow-draw 0.5s ease-in-out 1.75s both; }
}

/* Débords verticaux et à gauche pour ne pas couper les jambages et les boucles de Kalam. */
@keyframes intro-note-write {
  from { clip-path: inset(-0.4em 100% -0.4em -8px); }
  to { clip-path: inset(-0.4em -8px -0.4em -8px); }
}

/* La flèche descend surtout : un masque qui se lève de haut en bas la dessine, pointe en dernier. */
@keyframes intro-arrow-draw {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0); }
}

/* Gallery : photo cliquable, qui s'ouvre dans la visionneuse plein écran. */
.photo-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: rgba(var(--shadow-tint), 0.08);
  cursor: zoom-in;
}

.photo-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.photo-button:hover img { transform: scale(1.04); }

/* La maison, pièce par pièce, avec un sommaire collant à gauche. */
.gallery-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: start;
  gap: 56px;
}

.house { padding-top: 56px; }

.gallery-index {
  position: sticky;
  top: 96px;
}

.gallery-index ol {
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(var(--shadow-tint), 0.14);
  list-style: none;
}

.gallery-index a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 12px 14px;
  border-bottom: 1px solid rgba(var(--shadow-tint), 0.14);
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: rgba(var(--shadow-tint), 0.65);
  text-decoration: none;
  transition: color 0.2s;
}

.gallery-index a span { font: 500 0.75rem var(--font-body); }
.gallery-index a:hover { color: var(--green-dark); }

.gallery-index a.is-current {
  color: var(--green-dark);
  box-shadow: inset 3px 0 0 var(--green-leaf);
}

.gallery-index a.is-current span { color: var(--green-leaf); }

.gallery-room + .gallery-room { margin-top: 72px; }

.gallery-room-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.gallery-room-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.gallery-room-count {
  margin: 0;
  font-size: 0.8rem;
  color: var(--green-leaf);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: clamp(140px, 15vw, 210px);
  grid-auto-flow: dense;
  gap: 12px;
}

.gallery-grid > :first-child:not(.is-portrait) { grid-column: span 2; grid-row: span 2; }
.gallery-grid > .is-portrait { grid-row: span 2; }

/* La dernière photo complète sa rangée, pour ne pas laisser de trou. */
.gallery-room .gallery-grid > :last-child:nth-child(3n + 1):not(.is-portrait) { grid-column: span 3; }
.gallery-room .gallery-grid > :last-child:nth-child(3n + 2):not(.is-portrait) { grid-column: span 2; }

.gallery-grid--island {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 48px;
}

.gallery-grid--island .photo-button { background: rgba(253, 246, 234, 0.06); }
.gallery-grid--island > :nth-last-child(-n + 2) { grid-column: span 2; }

/* Au chargement, pendant que la note s'écrit : le sommaire et l'en-tête de la première pièce apparaissent,
   puis ses photos en cascade, comme la mosaïque de l'accueil. Les autres pièces sont hors de l'écran. */
@media (prefers-reduced-motion: no-preference) {
  .gallery-index,
  #dehors .gallery-room-header { animation: intro-fade-rise 0.6s ease-out 0.6s both; }

  #dehors .photo-button { animation: gallery-photo-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.75s both; }
  #dehors .photo-button:nth-child(2) { animation-delay: 0.81s; }
  #dehors .photo-button:nth-child(3) { animation-delay: 0.87s; }
  #dehors .photo-button:nth-child(4) { animation-delay: 0.93s; }
}

@keyframes gallery-photo-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}

/* Visionneuse plein écran */
.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 64px 88px 32px;
  overscroll-behavior: contain;
  border: 0;
  background: rgba(var(--shadow-tint), 0.95);
  color: var(--cream);
}

.lightbox::backdrop { background: transparent; }

/* La page derrière la visionneuse ne défile pas. */
html:has(.lightbox[open]) { overflow: hidden; }

.lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  margin: 0;
}

.lightbox-figure img {
  width: auto;
  height: auto;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100% - 48px);
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-figure figcaption {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.lightbox-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.lightbox-count {
  font-size: 0.85rem;
  color: var(--green-mint);
}

.lightbox-button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  color: var(--green-dark);
  font: 500 1.2rem var(--font-body);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(var(--shadow-tint), 0.3);
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.lightbox-close { top: 16px; right: 16px; }

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-nav--prev { left: 20px; }
.lightbox-nav--next { right: 20px; }
.lightbox-nav--prev:hover { transform: translate(-3px, -50%); }
.lightbox-nav--next:hover { transform: translate(3px, -50%); }

/* Responsive */
@media (max-width: 860px) {
  .intro-note { display: none; }

  .house { padding-top: 40px; }

  .gallery-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .gallery-index { position: static; }

  .gallery-index ol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
  }

  .gallery-grid,
  .gallery-grid--island {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 34vw;
  }

  .gallery-room .gallery-grid > :last-child:nth-child(3n + 1):not(.is-portrait),
  .gallery-room .gallery-grid > :last-child:nth-child(3n + 2):not(.is-portrait) { grid-column: auto; }

  .gallery-room .gallery-grid > :last-child:nth-child(even):not(.is-portrait) { grid-column: span 2; }

  .gallery-room .gallery-grid > .is-portrait:last-child:nth-child(odd) {
    grid-column: span 2;
    grid-row: span 1;
  }

  .gallery-grid--island { margin-top: 32px; }

  .lightbox { padding: 64px 16px 24px; }
  .lightbox-figure { padding-bottom: 64px; }

  .lightbox-nav,
  .lightbox-nav--prev:hover,
  .lightbox-nav--next:hover {
    top: auto;
    bottom: 20px;
    transform: none;
  }
}
