/* ==========================================================================
   1. VUE PRINCIPALE DES PORTRAITS (ÉCRAN DE SÉLECTION)
   ========================================================================== */

.portraits-container {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.portrait-section {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  transition: flex 0.7s cubic-bezier(0.4, 0, 0.2, 1), filter 0.5s;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Dégradé en bas de chaque section */
.portrait-section::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 18vh;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, var(--main-bg-color) 100%);
  z-index: 2;
  pointer-events: none;
}

.portrait-video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100vw;
  min-height: 100vh;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
  z-index: 1;
  pointer-events: none;
  transform-origin: center center;
}

/* Ajustements spécifiques des vidéos */
.section1-video { transform: translate(-45%, -50%); }
.section2-video { transform: translate(-40%, -50%); }
.section3-video { transform: translate(-70%, -45%); }
.section4-video { transform: translate(-45%, -55%); }

/* États : survol et section active */
.portrait-section.active,
.portrait-section:hover {
  flex: 2.5;
  filter: none;
}

.portraits-container:not(.no-hover) .portrait-section:not(.active):not(:hover) {
  filter: blur(0.3rem);
}

.portraits-container.no-hover .portrait-section {
  filter: none;
}

.portrait-name {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 20%;
  width: 90%;
  text-align: center;
  color: white;
  font-family: "Libre Baskerville", serif;
  font-size: clamp(1.2rem, 2.5vw, 2.2rem);
  opacity: 0;
  transition: opacity 0.5s 0.15s;
  pointer-events: none;
  z-index: 3;
}

.portrait-section.active .portrait-name,
.portrait-section:hover .portrait-name {
  opacity: 1;
}

/* ==========================================================================
   2. VUE DÉTAILLÉE D'UN PORTRAIT
   ========================================================================== */

.portrait-detail {
  display: none;
  position: relative;
  min-height: 100vh;
  scroll-snap-align: start;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--main-bg-color);
  color: white;
  font-family: "Figtree", sans-serif;
  padding: 40px 10vw;
  box-sizing: border-box;
}

.portrait-detail.active {
  display: flex;
}

.detail-content {
  max-width: 900px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.detail-content h2 {
  font-family: "Libre Baskerville", serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  margin-bottom: 0.7em;
}

.detail-content p {
  font-size: clamp(0.9rem, 1.8vw, 1.15rem);
  line-height: 1.6;
  max-width: 65ch;
  margin: 0 auto 1.5em auto;
  text-align: justify;
  text-indent: 2em;
}

/* --- 2.1 Galerie d'images dans la vue détaillée --- */

.portrait-image-gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin: 2rem 0;
}

.portrait-image-gallery .archive-gallery-item {
  width: clamp(150px, 18vw, 220px);
  height: auto;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.portrait-image-gallery .archive-gallery-item:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.portrait-image-gallery .archive-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* --- 2.2 Vidéo de séparation --- */

.portrait-break-video {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-height: 1000px;
  margin: 5rem 0;
  overflow: hidden;
  pointer-events: none;
}

.portrait-break-video video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  mix-blend-mode: luminosity;
  opacity: 0.8;
}

.portrait-break-video::before,
.portrait-break-video::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 20%;
  z-index: 2;
}

.portrait-break-video::before {
  top: 0;
  background: linear-gradient(to bottom, var(--main-bg-color) 0%, transparent 100%);
}

.portrait-break-video::after {
  bottom: 0;
  background: linear-gradient(to top, var(--main-bg-color) 0%, transparent 100%);
}

/* --- 2.3 Superposition de texte sur la vidéo --- */

.video-text-overlay {
  position: absolute;
  top: 0;
  height: 100%;
  z-index: 3;
  color: #e0e0e0;
  max-width: 50%;
  display: flex;
  align-items: center;
  padding: 2rem 4rem;
  box-sizing: border-box;
}

.video-text-overlay p {
  margin: 0;
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
  line-height: 1.6;
  max-width: 100%;
}

.video-text-overlay.position-left {
  left: 0;
  justify-content: flex-start;
  background: linear-gradient(to right, var(--main-bg-color) 70%, transparent 100%);
}

.video-text-overlay.position-right {
  right: 0;
  justify-content: flex-end;
  background: linear-gradient(to left, var(--main-bg-color) 70%, transparent 100%);
}

/* ==========================================================================
   3. COMPOSANTS D'INTERFACE (BOUTONS, CONTRÔLES)
   ========================================================================== */

.back-to-portraits {
  margin-top: 40px;
  padding: 12px 24px;
  font-size: clamp(0.9rem, 1.6vw, 1.1rem);
  font-family: "Figtree", sans-serif;
  color: #fff;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 100px;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s;
}

.back-to-portraits:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.back-to-portraits span {
  position: relative;
  display: inline-block;
}

.back-to-portraits span::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background-color: rgba(255, 255, 255, 0.8);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.back-to-portraits:hover span::before,
.back-to-portraits:focus span::before {
  transform: scaleX(1);
}

.volume-control {
  position: absolute;
  top: 20px;
  right: 20px;
  color: #fff;
  z-index: 100;
}

#volumeRange {
  vertical-align: middle;
}

.sound-wave-container {
  position: absolute;
  top: 30px;
  left: 30px;
  z-index: 10;
  width: 120px;
  height: 40px;
  pointer-events: none;
}

.sound-wave-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sound-wave-cloud {
  fill: #fff;
  opacity: 0.18;
  filter: url(#blur);
  transition: 0.1s;
}

.sound-wave-line {
  stroke: #fff;
  stroke-width: 3;
  transition: 0.1s;
}

/* ==========================================================================
   4. RESPONSIVE DESIGN
   ========================================================================== */

/* --- Tablettes --- */
@media (max-width: 992px) {
  .section1-video { transform: translate(-45%, -50%) scale(0.9); }
  .section2-video { transform: translate(-40%, -50%) scale(0.9); }
  .section3-video { transform: translate(-65%, -45%) scale(0.9); }
  .section4-video { transform: translate(-45%, -55%) scale(0.9); }

  .portrait-section.active,
  .portrait-section:hover {
    flex: 2.2;
  }

  .portrait-name {
    font-size: clamp(1.1rem, 2.2vw, 1.8rem);
    bottom: 12%;
  }

  .portrait-detail {
    padding: 30px 6vw;
  }

  .portrait-detail h2 {
    font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  }

  .portrait-detail p {
    font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  }
}

/* --- Mobiles --- */
@media (max-width: 768px) {
  .section1-video { transform: translate(-45%, -50%) scale(0.8); }
  .section2-video { transform: translate(-42.5%, -50%) scale(0.8); }
  .section3-video { transform: translate(-65%, -46%) scale(0.8); }
  .section4-video { transform: translate(-45%, -55%) scale(0.8); }

  .portrait-section.active,
  .portrait-section:hover {
    flex: 2;
  }

  .portrait-name {
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    bottom: 10%;
  }

  .portrait-detail {
    padding: 25px 5vw;
  }

  .portrait-detail h2 {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
  }

  .portrait-detail p {
    font-size: clamp(0.8rem, 2vw, 1rem);
  }

  .back-to-portraits {
    padding: clamp(8px, 1.2vw, 12px) clamp(20px, 2.5vw, 30px);
    font-size: clamp(0.8rem, 1.8vw, 1rem);
  }

  .volume-control {
    font-size: clamp(0.75rem, 1.8vw, 0.9rem);
  }

  #volumeRange {
    width: clamp(70px, 12vw, 100px);
  }

  .sound-wave-container {
    width: clamp(60px, 12vw, 100px);
    height: clamp(25px, 6vw, 35px);
  }
}