/* =====================================================================
   Immersion : animations et profondeur (Fermes École DJIDJOHO)
   Tout ce qui bouge est dans @media (prefers-reduced-motion: no-preference).
   ===================================================================== */

/* ---------- Hero : image vivante (zoom lent + parallaxe) + vague organique ---------- */
.modern-hero,
.page-header {
   position: relative;
   overflow: hidden;
   isolation: isolate;
   background: var(--primary-dark);
}

.modern-hero::before,
.page-header::before {
   content: '';
   position: absolute;
   inset: -8% 0;
   z-index: -2;
   background: linear-gradient(135deg, rgba(18, 87, 55, 0.85), rgba(73, 91, 16, 0.6)), url('../images/images_ferme/vueferme_dehaut.webp') center/cover no-repeat;
   translate: 0 var(--py, 0px);
   will-change: translate, scale;
}

.page-header::before {
   background: linear-gradient(135deg, rgba(18, 87, 55, 0.88), rgba(73, 91, 16, 0.78)), url('../images/images_ferme/vueferme_dehaut.webp') center/cover no-repeat;
}

.page-header .container,
.modern-hero .container { position: relative; z-index: 3; }

/* Vague de séparation (forme organique de la charte) : remplace l'ancien biseau */
.modern-hero::after,
.page-header::after {
   content: '';
   position: absolute;
   left: 0;
   right: 0;
   bottom: -1px;
   height: clamp(40px, 7vw, 90px);
   background: var(--wave-fill, #ffffff);
   -webkit-mask: url('../images/brand/vague.svg') center bottom / 100% 100% no-repeat;
   mask: url('../images/brand/vague.svg') center bottom / 100% 100% no-repeat;
   transform: none;
   z-index: 4;
}
.page-contact { --wave-fill: var(--bg-base); }

/* Lumière qui suit la souris (bureau uniquement) */
.hero-spot {
   position: absolute;
   inset: 0;
   z-index: -1;
   pointer-events: none;
   background: radial-gradient(520px circle at var(--mx, 72%) var(--my, 30%), rgba(191, 211, 88, 0.22), transparent 62%);
   mix-blend-mode: screen;
}

/* Feuilles qui montent doucement */
.leaves { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.leaf {
   position: absolute;
   bottom: -60px;
   background-repeat: no-repeat;
   background-size: contain;
   opacity: 0;
}

/* Indicateur de défilement */
.scroll-cue {
   position: absolute;
   left: 50%;
   bottom: 78px;
   z-index: 6;
   width: 28px;
   height: 46px;
   margin-left: -14px;
   border: 2px solid rgba(255, 255, 255, 0.85);
   border-radius: 20px;
   display: block;
}
.scroll-cue::after {
   content: '';
   position: absolute;
   left: 50%;
   top: 8px;
   width: 4px;
   height: 8px;
   margin-left: -2px;
   border-radius: 4px;
   background: var(--secondary);
}

/* ---------- Titre du hero : mots qui se lèvent ---------- */
.split-word { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.28em 0.04em 0.2em; margin: -0.28em -0.04em -0.2em; }
.split-word > span { display: inline-block; }

/* ---------- Bandeau de chiffres ---------- */
.stats-band { background: #fff; position: relative; z-index: 8; padding-bottom: 1rem; }
.stats-grid {
   display: grid;
   grid-template-columns: repeat(4, 1fr);
   gap: 20px;
   margin-top: -92px;
}
.stat-tile {
   background: #fff;
   border-radius: var(--radius);
   padding: 28px 18px 24px;
   text-align: center;
   box-shadow: 0 18px 45px rgba(18, 87, 55, 0.14);
   border-top: 5px solid var(--secondary);
   position: relative;
   overflow: hidden;
}
.stat-tile::after {
   content: '';
   position: absolute;
   right: -26px;
   bottom: -26px;
   width: 96px;
   height: 96px;
   background: url('../images/brand/feuille.svg') center / contain no-repeat;
   opacity: 0.18;
}
.stat-num {
   display: block;
   font-family: var(--font-head);
   font-weight: 800;
   font-size: clamp(2.2rem, 4.5vw, 3.4rem);
   line-height: 1.1;
   color: var(--primary-dark);
}
.stat-num em { font-style: normal; color: var(--green-mid); }
.stat-cap { display: block; margin-top: 6px; font-weight: 500; color: var(--text-muted); font-size: 0.98rem; }

/* ---------- Ruban défilant des produits ---------- */
.ribbon-wrap { overflow: hidden; padding: 34px 0; background: #fff; }
.ribbon {
   background: var(--primary-dark);
   color: var(--secondary);
   transform: rotate(-1.4deg);
   margin: 0 -3%;
   box-shadow: 0 12px 30px rgba(18, 87, 55, 0.25);
   overflow: hidden;
   white-space: nowrap;
}
.ribbon-track { display: inline-flex; padding: 16px 0; }
.ribbon-track span {
   font-family: var(--font-head);
   font-weight: 700;
   text-transform: uppercase;
   letter-spacing: 1.5px;
   font-size: 1.05rem;
   padding: 0 28px 0 54px;
   position: relative;
}
.ribbon-track span::before {
   content: '';
   position: absolute;
   left: 22px;
   top: 50%;
   width: 20px;
   height: 20px;
   margin-top: -10px;
   background: url('../images/brand/feuille.svg') center / contain no-repeat;
}

/* ---------- Apparition au défilement ---------- */
.rv { opacity: 0; transform: translateY(34px) scale(0.97); transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); transition-delay: var(--d, 0ms); }
.rv.in { opacity: 1; transform: none; }

.about-img-frame img { clip-path: none !important; scale: 1 !important; opacity: 1 !important; }
.reveal-img { clip-path: inset(0 100% 0 0 round 24px); scale: 1.14; transition: clip-path 1.2s cubic-bezier(0.7, 0, 0.2, 1), scale 1.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.reveal-img.in { clip-path: inset(0 0 0 0 round 24px); scale: 1; }

.js-anim .section-title h2::after { transform: translateX(-50%) scaleX(0); transform-origin: center; transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s; }
.js-anim .section-title.in h2::after { transform: translateX(-50%) scaleX(1); }
.js-anim .section-title .badge { transition: transform 0.6s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.6s; transform: scale(0.6); opacity: 0; }
.js-anim .section-title.in .badge { transform: scale(1); opacity: 1; }

/* ---------- Boutons : reflet + pulsation du bouton principal ---------- */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after {
   content: '';
   position: absolute;
   top: 0;
   left: -130%;
   width: 55%;
   height: 100%;
   background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
   transform: skewX(-20deg);
   pointer-events: none;
}

/* ---------- Barre de progression + en-tête compact ---------- */
#fedProgress {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   height: 4px;
   z-index: 1100;
   background: linear-gradient(90deg, var(--green-mid), var(--secondary));
   transform: scaleX(0);
   transform-origin: left;
   pointer-events: none;
}
.modern-header { transition: padding 0.35s ease, box-shadow 0.35s ease, background 0.35s ease; }
.modern-header.is-scrolled { padding: 7px 0; box-shadow: 0 8px 30px rgba(18, 87, 55, 0.12); }
.modern-header .brand-logo { transition: height 0.35s ease; }
.modern-header.is-scrolled .brand-logo { height: 42px; }

/* ---------- Introduction (première visite de la session) ---------- */
.splash {
   position: fixed;
   inset: 0;
   z-index: 5000;
   background: radial-gradient(circle at 50% 40%, #1b6b45, var(--primary-dark) 70%);
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   gap: 18px;
   pointer-events: none;
}
.splash img { width: 118px; height: auto; }
.splash p { margin: 0; font-family: var(--font-script); color: var(--secondary); font-size: 1.15rem; text-align: center; padding: 0 20px; }

/* ---------- Rideau de transition entre pages ---------- */
.curtain {
   position: fixed;
   inset: 0;
   z-index: 4000;
   background: var(--primary-dark);
   transform: translateY(100%);
   pointer-events: none;
   display: flex;
   align-items: center;
   justify-content: center;
}
.curtain img { width: 84px; height: auto; opacity: 0.95; }

/* ---------- Mouvement autorisé ---------- */
@media (prefers-reduced-motion: no-preference) {
   .modern-hero::before,
   .page-header::before { animation: kenburns 26s ease-in-out infinite alternate; }
   @keyframes kenburns { from { scale: 1; } to { scale: 1.12; } }

   .leaf { animation: drift var(--dur, 16s) linear var(--delay, 0s) infinite; }
   @keyframes drift {
      0%   { transform: translate3d(0, 0, 0) rotate(var(--r0, 0deg)); opacity: 0; }
      12%  { opacity: var(--o, 0.55); }
      50%  { transform: translate3d(var(--sway, 40px), -55vh, 0) rotate(calc(var(--r0, 0deg) + 140deg)); }
      88%  { opacity: var(--o, 0.55); }
      100% { transform: translate3d(calc(var(--sway, 40px) * -0.6), -115vh, 0) rotate(calc(var(--r0, 0deg) + 300deg)); opacity: 0; }
   }

   .scroll-cue::after { animation: wheel 1.8s ease-in-out infinite; }
   @keyframes wheel { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(16px); opacity: 0; } 100% { opacity: 0; } }

   .split-word > span { transform: translateY(115%); animation: wordUp 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; animation-delay: calc(var(--i, 0) * 80ms + 250ms); }
   .splashing .split-word > span { animation-delay: calc(var(--i, 0) * 80ms + 1900ms); }
   @keyframes wordUp { to { transform: translateY(0); } }

   .ribbon-track { animation: marquee 38s linear infinite; }
   .ribbon:hover .ribbon-track { animation-play-state: paused; }
   @keyframes marquee { to { transform: translateX(-50%); } }

   .btn-primary:hover::after { animation: shine 0.9s ease; }
   @keyframes shine { to { left: 150%; } }
   .modern-hero .btn-primary { animation: glow 3.2s ease-in-out infinite; }
   @keyframes glow { 0%, 100% { box-shadow: 0 10px 22px rgba(191, 211, 88, 0.35); } 50% { box-shadow: 0 10px 38px rgba(191, 211, 88, 0.75); } }

   .splash { animation: splashOut 0.8s cubic-bezier(0.7, 0, 0.2, 1) 1.7s forwards; }
   .splash img { animation: splashIcon 1.2s cubic-bezier(0.2, 0.9, 0.2, 1) both; }
   .splash p { animation: splashText 0.9s ease 0.5s both; }
   @keyframes splashIcon { from { transform: scale(0.4) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
   @keyframes splashText { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
   @keyframes splashOut { to { transform: translateY(-100%); visibility: hidden; } }

   .curtain.curtain-in { animation: curtainIn 0.42s cubic-bezier(0.7, 0, 0.3, 1) forwards; }
   .curtain.curtain-out { transform: translateY(0); animation: curtainOut 0.6s cubic-bezier(0.7, 0, 0.3, 1) 0.1s forwards; }
   @keyframes curtainIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
   @keyframes curtainOut { to { transform: translateY(-100%); } }

   .choose-item:hover .choose-icon { animation: wiggle 0.7s ease; }
   @keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg) scale(1.08); } 60% { transform: rotate(10deg) scale(1.08); } }

   .stat-tile { transition: transform 0.4s ease, box-shadow 0.4s ease; }
   .stat-tile:hover { transform: translateY(-8px); box-shadow: 0 26px 55px rgba(18, 87, 55, 0.2); }
}

/* ---------- Mouvement réduit : tout est statique et visible ---------- */
@media (prefers-reduced-motion: reduce) {
   .leaf, .hero-spot, .scroll-cue, .splash, .curtain { display: none !important; }
   .rv, .reveal-img, .section-title .badge { opacity: 1 !important; transform: none !important; clip-path: none !important; scale: 1 !important; }
   .section-title h2::after { transform: translateX(-50%) scaleX(1) !important; }
   .ribbon-track { animation: none !important; }
}

/* ---------- Adaptations mobiles ---------- */
@media (max-width: 991px) {
   .stats-grid { grid-template-columns: repeat(2, 1fr); margin-top: -70px; gap: 14px; }
}
@media (max-width: 575px) {
   .scroll-cue { display: none; }
   .stat-tile { padding: 20px 10px 18px; }
   .stat-cap { font-size: 0.85rem; }
   .ribbon-track span { font-size: 0.9rem; }
}

/* Le bandeau de chiffres chevauche le hero : on lui laisse la place */
.modern-hero .hero-content { padding-bottom: 10.5rem; }
.scroll-cue { bottom: 118px; }
@media (max-width: 991px) { .modern-hero .hero-content { padding-bottom: 8.5rem; } }
