/* ===========================================
   WHY — "Pourquoi nos clients restent."
   6 raisons sous forme de cards. Chaque card a sa couleur d'accent
   (violet, orange, mint, blue, yellow×2) pour son shadow + accent texte.
   Layout : 3 cols desktop, 2 cols tablet, 1 col mobile.
   =========================================== */

.why {
  display: flex;
  flex-direction: column;
  gap: 60px;
  padding: 100px 85px;
  position: relative;
  overflow: hidden;
}

/* --- Titre --- */
.why__heading {
  width: 100%;
  max-width: 1270px;
  padding: 10px;
  margin: 0;
  font-size: 36px;
  font-weight: var(--fw-semibold);
  line-height: 54px;
  text-align: center;
  color: var(--color-text);
}

.why__heading-accent {
  color: var(--color-accent);
}

/* --- Container des 6 cards (grid) --- */
.why__cards {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 60px;
  padding: 10px;
  max-width: 1270px;
  margin: 0 auto;
  width: 100%;
}

/* --- Wrapper card + sun ---
   Le sun jaune est attaché à la 1ère card (angle haut-gauche),
   le sun bleu à la dernière card (angle bas-droite). Les wraps
   prennent leur cellule de grille, le sun se positionne absolute
   relativement au wrap. */
.why-card-wrap {
  position: relative;
}

/* La card prend toute la cellule pour que les bordures soient au bord */
.why-card-wrap .why-card {
  height: 100%;
}

/* --- Décor : sun centré pile sur l'angle de la card --- */
.why__decor {
  position: absolute;
  width: 595px;
  height: 595px;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

/* Sun jaune : centre au milieu du côté gauche de la 1ère card
   (évite le chevauchement avec le titre selon la hauteur d'écran). */
.why-card-wrap--first .why__decor {
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  color: var(--color-yellow);
}

/* Sun bleu : centre EXACT sur l'angle bas-droite de la dernière card */
.why-card-wrap--last .why__decor {
  bottom: 0;
  right: 0;
  transform: translate(50%, 50%);
  color: var(--color-blue);
}

/* --- Why card ---
   Couleurs d'accent surchargées par variant via --why-accent / --why-shadow */
.why-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 15px 30px 15px;
  background-color: var(--color-bg);
  border: 2px solid var(--color-text);
  box-shadow: 8px 8px 0 0 var(--why-shadow, var(--color-accent));
}

.why-card--quality {
  --why-shadow: var(--color-violet);
  --why-accent: var(--color-violet-dark);
}

.why-card--refund {
  --why-shadow: var(--color-accent);
  --why-accent: var(--color-accent);
}

.why-card--contact {
  --why-shadow: var(--color-mint-dark);
  --why-accent: var(--color-mint-dark);
}

.why-card--price {
  --why-shadow: var(--color-blue);
  --why-accent: var(--color-blue-dark);
}

.why-card--privacy {
  --why-shadow: var(--color-yellow);
  --why-accent: var(--color-yellow-dark);
}

.why-card--details {
  --why-shadow: var(--color-yellow);
  --why-accent: var(--color-yellow-dark);
}

/* Titre de la card (24px Poppins 500) avec accent bicolore */
.why-card__title {
  margin: 0;
  padding: 10px 30px;
  font-size: 24px;
  font-weight: var(--fw-medium);
  line-height: 36px;
  color: var(--color-text);
}

.why-card__title-accent {
  color: var(--why-accent);
}

/* Description : paragraphes séparés par gap */
.why-card__description {
  margin: 0;
  padding: 30px 10px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  font-size: 20px;
  line-height: 30px;
  color: var(--color-text);
}

.why-card__description p {
  margin: 0;
}

/* ============================
   TABLET (768-1199px)
   2 cols.
   ============================ */
@media (max-width: 1199px) {
  .why {
    padding: 100px 50px;
  }

  .why__cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 60px;
    max-width: 794px;
  }
}

/* ============================
   MOBILE (< 768px)
   1 col, fonts plus petits.
   ============================ */
@media (max-width: 767px) {
  .why {
    padding: 60px 20px;
    gap: 60px;
  }

  .why__heading {
    font-size: 32px;
    line-height: 48px;
    text-align: left;
    padding: 10px 20px;
  }

  .why__cards {
    grid-template-columns: 1fr;
    gap: 60px;
    max-width: 353px;
  }

  .why-card__description {
    font-size: 16px;
    line-height: 24px;
  }

  /* Suns plus petits sur mobile (position toujours sur l'angle de la card) */
  .why__decor {
    width: 400px;
    height: 400px;
  }
}

/* Reveal au scroll : titre slide-up, 6 cartes (incluant les 2 wraps
   décorés) en cascade slide-from-left (gauche → droite), 100ms entre
   chaque. Scoped sous .js. */
@keyframes why-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes why-slide-from-right {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

.js .why__heading[data-reveal],
.js .why__cards[data-reveal] > * {
  opacity: 0;
}

.why__heading.is-visible {
  animation: why-slide-up 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.why__cards.is-visible > * {
  animation: why-slide-from-right 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.why__cards.is-visible > *:nth-child(1) { animation-delay:   0ms; }
.why__cards.is-visible > *:nth-child(2) { animation-delay: 100ms; }
.why__cards.is-visible > *:nth-child(3) { animation-delay: 200ms; }
.why__cards.is-visible > *:nth-child(4) { animation-delay: 300ms; }
.why__cards.is-visible > *:nth-child(5) { animation-delay: 400ms; }
.why__cards.is-visible > *:nth-child(6) { animation-delay: 500ms; }

@media (prefers-reduced-motion: reduce) {
  .js .why__heading[data-reveal],
  .js .why__cards[data-reveal] > * {
    opacity: 1;
    animation: none;
  }
}

/* Rotation des décors-soleils liée au scroll de la section why.
   Réutilise les keyframes sun-spin-* d'audience.css : les translate
   values sont identiques. */
.why {
  view-timeline-name: --why-view;
}

.why-card-wrap--first .why__decor {
  animation: sun-spin-particulier linear;
  animation-timeline: --why-view;
}

.why-card-wrap--last .why__decor {
  animation: sun-spin-professionnel linear;
  animation-timeline: --why-view;
}

@media (prefers-reduced-motion: reduce) {
  .why__decor {
    animation: none;
  }
}
