/**
 * animations.css — Style Apple.com
 * Promo Est Immobilier — Agence premium La Réunion
 */

/* ============================================================
   1. STICKY HEADER — BLUR GLASSMORPHISM
   ============================================================ */
.site-header,
#masthead,
header.site-header {
  position: sticky;
  top: 0;
  z-index: 9999;
  will-change: transform, backdrop-filter;
  transition:
    background-color .35s cubic-bezier(.23,1,.32,1),
    backdrop-filter   .35s cubic-bezier(.23,1,.32,1),
    box-shadow        .35s cubic-bezier(.23,1,.32,1),
    transform         .4s  cubic-bezier(.23,1,.32,1);
}

.pei-header--scrolled {
  background-color: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: blur(22px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(22px) saturate(180%) !important;
  box-shadow:
    0 1px 0 rgba(0,0,0,.06),
    0 6px 28px rgba(0,0,0,.07) !important;
}

.pei-header--hidden {
  transform: translateY(-100%);
}

/* ============================================================
   2. SCROLL REVEAL + STAGGER
   ============================================================ */
.pei-reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity  .72s cubic-bezier(.23,1,.32,1),
    transform .72s cubic-bezier(.23,1,.32,1);
}

.pei-reveal.pei-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Variante — entrée depuis la gauche */
.pei-reveal--left {
  opacity: 0;
  transform: translateX(-32px);
}
.pei-reveal--left.pei-revealed {
  opacity: 1;
  transform: translateX(0);
}

/* Variante — entrée depuis la droite */
.pei-reveal--right {
  opacity: 0;
  transform: translateX(32px);
}
.pei-reveal--right.pei-revealed {
  opacity: 1;
  transform: translateX(0);
}

/* ============================================================
   3. PARALLAX HERO
   ============================================================ */
.elementor-top-section:first-of-type,
[data-parallax],
.pei-hero {
  overflow: hidden;
}

.elementor-top-section:first-of-type .elementor-background-overlay,
[data-parallax] .elementor-background-overlay,
.pei-hero .elementor-background-overlay {
  will-change: transform;
  transform-origin: top center;
}

/* ============================================================
   4. HOVER 3D PREMIUM — CARDS
   ============================================================ */
.pei-card-hover {
  will-change: transform, box-shadow;
  transform-style: preserve-3d;
  transition:
    transform  .55s cubic-bezier(.23,1,.32,1),
    box-shadow .55s cubic-bezier(.23,1,.32,1);
  cursor: pointer;
  border-radius: 12px;
}

.pei-card-hover:hover {
  box-shadow:
    0 24px 56px rgba(0,0,0,.13),
    0  8px 20px rgba(0,0,0,.07) !important;
}

/* Image dans la card — zoom subtil */
.pei-card-hover img {
  transition: transform .6s cubic-bezier(.23,1,.32,1);
  border-radius: inherit;
  overflow: hidden;
}
.pei-card-hover:hover img {
  transform: scale(1.04);
}

/* ============================================================
   5. BOUTONS CTA — EFFET GLISSE VERTICAL
   ============================================================ */
.pei-btn-slide {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

.pei-btn-default,
.pei-btn-hover {
  display: block;
  transition: transform .42s cubic-bezier(.23,1,.32,1);
  pointer-events: none;
  white-space: nowrap;
}

.pei-btn-hover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(100%);
}

.pei-btn-slide:hover .pei-btn-default {
  transform: translateY(-100%);
}
.pei-btn-slide:hover .pei-btn-hover {
  transform: translateY(0);
}

/* ============================================================
   6. KEYFRAMES UTILITAIRES
   ============================================================ */
@keyframes peiFadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes peiFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes peiScale {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1);   }
}

.pei-animate-fade-up  { animation: peiFadeInUp .65s cubic-bezier(.23,1,.32,1) both; }
.pei-animate-fade-in  { animation: peiFadeIn   .65s ease both; }
.pei-animate-scale    { animation: peiScale    .65s cubic-bezier(.23,1,.32,1) both; }

/* ============================================================
   7. RESPONSIVE + PREFERS-REDUCED-MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .pei-reveal,
  .pei-reveal--left,
  .pei-reveal--right,
  .pei-card-hover,
  .pei-btn-default,
  .pei-btn-hover {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  .site-header,
  #masthead {
    transition: none !important;
  }
}

@media (max-width: 768px) {
  .pei-card-hover {
    /* Désactiver la 3D sur mobile */
    transform-style: flat !important;
  }

  .pei-reveal,
  .pei-reveal--left,
  .pei-reveal--right {
    transform: translateY(16px);
  }
}

/* ============================================================
   PEI STATS RÉUNION — [pei_stats_reunion]
   ============================================================ */

/* Section wrapper */
.pei-stats-section {
  position: relative;
  min-height: 500px;
  display: flex;
  align-items: center;
  overflow: hidden;
  width: 100%;
}

/* Fond image — parallax via JS */
.pei-stats-bg {
  position: absolute;
  inset: -15% 0;
  background-image: url('https://images.unsplash.com/photo-1589308078059-be1415eab4c3?w=1600');
  background-size: cover;
  background-position: center 40%;
  will-change: transform;
  transform: translateZ(0);
}

/* Overlay dégradé sombre */
.pei-stats-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.75) 0%,
    rgba(10, 10, 10, 0.90) 100%
  );
  z-index: 1;
}

/* Contenu centré */
.pei-stats-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 90px 48px;
}

/* ── Titre + sous-titre ── */
.pei-stats-header {
  text-align: center;
  margin-bottom: 72px;
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity  .85s cubic-bezier(.23,1,.32,1),
    transform .85s cubic-bezier(.23,1,.32,1);
}

.pei-stats-section.pei-stats--visible .pei-stats-header {
  opacity: 1;
  transform: translateY(0);
}

.pei-stats-title {
  font-size: clamp(26px, 3.8vw, 44px);
  font-weight: 300;
  color: #ffffff;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 18px;
}

.pei-stats-subtitle {
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  margin: 0;
}

/* ── Layout stats + carte ── */
.pei-stats-layout {
  display: flex;
  align-items: center;
  gap: 56px;
}

/* ── Grille des 4 stats ── */
.pei-stats-grid {
  display: flex;
  align-items: center;
  flex: 1;
}

/* Item stat */
.pei-stat-item {
  flex: 1;
  text-align: center;
  padding: 24px 12px;
  cursor: default;
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity  .7s cubic-bezier(.23,1,.32,1),
    transform .7s cubic-bezier(.23,1,.32,1);
}

.pei-stat-item:hover { transform: translateY(-4px) !important; }

/* Stagger au reveal */
.pei-stats-section.pei-stats--visible .pei-stat-item:nth-child(1) { opacity:1; transform:none; transition-delay:.18s; }
.pei-stats-section.pei-stats--visible .pei-stat-item:nth-child(3) { opacity:1; transform:none; transition-delay:.33s; }
.pei-stats-section.pei-stats--visible .pei-stat-item:nth-child(5) { opacity:1; transform:none; transition-delay:.48s; }
.pei-stats-section.pei-stats--visible .pei-stat-item:nth-child(7) { opacity:1; transform:none; transition-delay:.63s; }

/* Séparateurs */
.pei-stat-sep {
  width: 1px;
  height: 72px;
  flex-shrink: 0;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(201,168,76,.45) 30%,
    rgba(201,168,76,.45) 70%,
    transparent
  );
  opacity: 0;
  transition: opacity .7s ease;
}

.pei-stats-section.pei-stats--visible .pei-stat-sep:nth-child(2) { opacity:1; transition-delay:.25s; }
.pei-stats-section.pei-stats--visible .pei-stat-sep:nth-child(4) { opacity:1; transition-delay:.40s; }
.pei-stats-section.pei-stats--visible .pei-stat-sep:nth-child(6) { opacity:1; transition-delay:.55s; }

/* Chiffre + unité */
.pei-stat-number {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 14px;
  line-height: 1;
}

.pei-stat-count {
  font-size: 80px;
  font-weight: 200;
  color: #ffffff;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: color .35s ease;
}

.pei-stat-item:hover .pei-stat-count { color: #C9A84C; }

.pei-stat-unit {
  font-size: 34px;
  font-weight: 300;
  color: #C9A84C;
  line-height: 1;
  align-self: flex-start;
  margin-top: 8px;
}

/* "Depuis" au-dessus du chiffre 1989 */
.pei-stat-item--year .pei-stat-number {
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.pei-stat-since {
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #C9A84C;
  font-weight: 400;
  line-height: 1;
}

/* Label sous le chiffre */
.pei-stat-label {
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  line-height: 1.6;
}

/* ── Carte SVG La Réunion ── */
.pei-reunion-map {
  position: relative;
  width: 210px;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(16px);
  transition:
    opacity  .8s cubic-bezier(.23,1,.32,1),
    transform .8s cubic-bezier(.23,1,.32,1);
}

.pei-stats-section.pei-stats--visible .pei-reunion-map {
  opacity: 1;
  transform: translateX(0);
  transition-delay: .5s;
}

.pei-reunion-map svg {
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 4px 24px rgba(0,0,0,.5));
}

.pei-map-island {
  fill: rgba(255,255,255,.10);
  stroke: rgba(255,255,255,.30);
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition: fill .4s ease, stroke .4s ease;
}

.pei-reunion-map:hover .pei-map-island {
  fill: rgba(255,255,255,.17);
  stroke: rgba(255,255,255,.45);
}

/* Point lumineux — Saint-Benoît */
.pei-map-dot {
  fill: #C9A84C;
  filter: drop-shadow(0 0 5px rgba(201,168,76,.95));
}

.pei-map-pulse-ring {
  fill: none;
  stroke: #C9A84C;
  stroke-width: 1.5;
  opacity: 0;
  animation: peiMapPulse 2.4s ease-out infinite;
}

.pei-map-pulse-ring--delay { animation-delay: 1.2s; }

@keyframes peiMapPulse {
  0%   { r: 4px;  opacity: .85; }
  100% { r: 20px; opacity: 0;   }
}

/* Tooltip */
.pei-map-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(8,8,8,.94);
  border: 1px solid rgba(201,168,76,.38);
  color: #fff;
  font-size: 11px;
  letter-spacing: .06em;
  line-height: 1.6;
  padding: 10px 16px;
  white-space: nowrap;
  border-radius: 4px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}

.pei-map-tooltip strong {
  display: block;
  color: #C9A84C;
  letter-spacing: .12em;
  font-size: 10px;
  margin-bottom: 3px;
}

.pei-reunion-map:hover .pei-map-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Flèche tooltip */
.pei-map-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(201,168,76,.38);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .pei-stats-layout { flex-direction: column; gap: 44px; }
  .pei-reunion-map  { width: 170px; transform: none; }
  .pei-stats-section.pei-stats--visible .pei-reunion-map { transform: none; }
  .pei-stats-inner  { padding: 72px 32px; }
}

@media (max-width: 768px) {
  .pei-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    row-gap: 0;
  }

  /* 3e séparateur devient horizontal entre les 2 rangées */
  .pei-stat-sep:nth-child(4) {
    grid-column: 1 / -1;
    width: 100%;
    height: 1px;
    background: linear-gradient(
      to right,
      transparent,
      rgba(201,168,76,.4) 30%,
      rgba(201,168,76,.4) 70%,
      transparent
    );
  }

  .pei-stat-sep:nth-child(6) { display: none; }

  .pei-stat-count { font-size: 58px; }
  .pei-stat-unit  { font-size: 26px; }
  .pei-reunion-map { display: none; }
  .pei-stats-inner { padding: 56px 24px; }
}

@media (max-width: 480px) {
  .pei-stats-grid {
    grid-template-columns: 1fr;
  }

  .pei-stat-sep {
    width: 60px !important;
    height: 1px !important;
    margin: 0 auto;
    background: linear-gradient(
      to right,
      transparent,
      rgba(201,168,76,.4) 30%,
      rgba(201,168,76,.4) 70%,
      transparent
    ) !important;
  }

  .pei-stat-sep:nth-child(4)  { grid-column: auto; }
  .pei-stat-sep:nth-child(6)  { display: block !important; }
  .pei-stats-inner { padding: 48px 20px; }
  .pei-stat-count  { font-size: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .pei-stats-header,
  .pei-stat-item,
  .pei-stat-sep,
  .pei-reunion-map {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .pei-map-pulse-ring { animation: none !important; opacity: .6; }
}

/* ============================================================
   STATS — PLEINE LARGEUR + CORRECTION CHEVAUCHEMENT
   ============================================================ */

/* Breakout du container Astra .entry-content */
.pei-stats-section {
  width:  100vw !important;
  margin-left:  calc(50% - 50vw) !important;
  margin-right: calc(50% - 50vw) !important;
  position: relative !important;
  z-index: 1 !important;
  clear: both !important;
  display: flex !important;
  align-items: center !important;
  overflow: hidden !important;
  min-height: 500px !important;
}

/* Le fond ne déborde plus au-dessus (évite chevauchement hero) */
.pei-stats-bg {
  top:    0 !important;
  bottom: 0 !important;
  left:   0 !important;
  right:  0 !important;
  width:  100% !important;
  height: 100% !important;
}
