:root {
  color-scheme: light dark;
  --primary-color: #d4af37;
  --text-dark: #1e1e1e;
  --text-light: #f0f0f0;
  --bg-light: #ffffff;
  --bg-dark: #1a1a1a;
}

@property --imgRotate {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  background: #e6cfb0;
  color: light-dark(var(--text-dark), var(--text-light));
}

.galerie-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 80px 20px 60px;
  min-height: 100vh;
}

.galerie-intro {
  text-align: center;
  max-width: 800px;
  margin: 0 auto 60px;
  padding: 0 20px;
}

.galerie-intro h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: chocolate;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.galerie-intro p {
  font-size: 1.1rem;
  line-height: 1.8;
  color: black;
}

galerie-widget {
  container: galerie-widget / inline-size;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1lh auto auto;
  gap: 0.5rem 2rem;
  inline-size: min(100%, 1000px); /* Augmenté de 500px à 800px */
  margin-inline: auto;
  position: relative;
}

galerie-widget > * {
  grid-area: 1 / 1 / 1 / 1;
}

galerie-widget > .photo-item {
  display: grid;
  grid-template-rows: subgrid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

.photo-item .img {
  grid-column: 1 / 2;
  grid-row: 1 / 4;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
  border: 4px solid light-dark(white, #333);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  rotate: var(--imgRotate, 0deg);
  transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
}

.photo-item .img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(212, 175, 55, 0.1) 0%,
    transparent 50%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.photo-item.active .img::after {
  opacity: 1;
}

.photo-item .img > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.3s;
}

.photo-item:hover .img > img {
  transform: scale(1.05);
}

.photo-item:nth-child(1) .img { --imgRotate: 4deg; }
.photo-item:nth-child(2) .img { --imgRotate: -2deg; }
.photo-item:nth-child(3) .img { --imgRotate: -6deg; }
.photo-item:nth-child(4) .img { --imgRotate: 7deg; }
.photo-item:nth-child(5) .img { --imgRotate: -4deg; }
.photo-item:nth-child(6) .img { --imgRotate: 5deg; }
.photo-item:nth-child(7) .img { --imgRotate: -7deg; }
.photo-item:nth-child(8) .img { --imgRotate: 3deg; }

.photo-item .text {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  color: light-dark(rgba(30, 30, 30, 0.7), rgba(240, 240, 240, 0.7));
  opacity: 0;
  translate: 0 20px;
  transition: 0.5s cubic-bezier(0.85, 0, 0.15, 1);
  pointer-events: none;
  padding: 10px;
}

.photo-item .text h3 {
  color: brown;
  margin: 0 0 8px 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.photo-item .text p {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: black;
}

.photo-item .text .annee {
  display: inline-block;
  background: orangered;
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.photo-item.active .text {
  opacity: 1;
  translate: 0 0;
  pointer-events: all;
}

.photo-item.active .img {
  animation: 0.66s moveOutIn cubic-bezier(0.34, 1.56, 0.64, 1);
  animation-fill-mode: forwards;
}

galerie-widget.children-animating .img {
  animation: 0.75s straightenImages;
}

.galerie-navigation {
  grid-column: 2 / 3;
  grid-row: 3 / 4;
  user-select: none;
  place-self: end;
  z-index: 99;
  display: flex;
  gap: 10px;
}

.galerie-navigation > button {
  border: 2px solid var(--primary-color);
  background: darkred;
  color: white;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.galerie-navigation > button:hover {
  background: gray;
  color: white;
}

.galerie-count {
  grid-column: 2 / -1;
  place-self: start;
  z-index: 99;
  color: gray;
  font-weight: 600;
  font-size: 1.1rem;
}

.no-photos {
  text-align: center;
  padding: 60px 20px;
  color: light-dark(rgba(30, 30, 30, 0.6), rgba(240, 240, 240, 0.6));
  font-size: 1.2rem;
}

@keyframes straightenImages {
  50% {
    --imgRotate: 0deg;
  }
}

@keyframes moveOutIn {
  50% {
    translate: -100% 0;
    scale: 1.15;
  }
  100% {
    translate: 0 0;
    z-index: 1;
  }
}

/* Version tablette - afficher tout en liste */
@media (max-width: 768px) {
  .galerie-container {
    padding: 60px 15px 40px;
  }

  .galerie-intro h1 {
    font-size: 2rem;
  }

  .galerie-intro p {
    font-size: 1rem;
  }

  galerie-widget {
    display: block;
    inline-size: 100%;
    max-width: 400px;
  }

  .photo-item {
    display: block !important;
    margin-bottom: 3rem;
  }

  .photo-item .img {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 1rem;
    grid-column: unset;
    grid-row: unset;
  }

  .photo-item .text {
    opacity: 1 !important;
    translate: 0 0 !important;
    pointer-events: all !important;
    grid-column: unset;
    grid-row: unset;
    padding: 0;
  }

  .galerie-navigation {
    display: none !important;
  }

  .galerie-count {
    display: none !important;
  }
}

/* Supprimer l'ancienne règle @container qui créait le conflit */
@container galerie-widget (width < 300px) {
  /* Cette règle peut être supprimée ou laissée vide */
}