/* ==========================================================================
   SYSTÈME FLORAL AQUARELLE VECTORIEL (SVG RETINA & PAPILLONS TURQUOISE)
   Fichier : assets/css/flowers.css
   60 fps garanti : animations exclusivement sur transform et opacity
   ========================================================================== */

:root {
    /* Réglages rapides du décor floral */
    --floral-bloom-duration: 1.15s;
    --floral-petal-duration: 0.95s;
    --floral-sway-angle: 2.3deg;
    --floral-sway-speed: 6.6s;
    --garland-grow-duration: 1.55s;
    --butterfly-wing-speed: 0.34s;
    --butterfly-flight-duration: 24s;
    --petal-max-opacity: 0.72;
}

/* Conteneur caché des dégradés SVG partagés */
.floral-svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ==========================================================================
   1. EMPLACEMENTS FLORAUX DE L'ARCHE (PNG PRIORITAIRE -> FALLBACK SVG VECTORIEL)
   ========================================================================== */
.floral-slot {
    position: absolute;
    pointer-events: none;
    z-index: 2;
    transform: translate3d(0, var(--parallax-floral-y, 0px), 0);
    will-change: transform;
}

/* Si aucun PNG personnalisé n'est présent (ou s'il échoue au chargement), le SVG s'affiche */
.floral-slot .floral-svg-wrap {
    display: none;
    width: 100%;
    height: 100%;
}

.floral-slot.is-svg-active .floral-svg-wrap,
.floral-slot.is-fallback .floral-svg-wrap {
    display: block;
}

.floral-vector-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.floral-top-left .floral-img,
.floral-top-right .floral-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.floral-bottom .floral-img {
    width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center bottom;
}

/* Coins supérieurs épousant la courbe dorée de l'arche */
.floral-top-left {
    top: 6px;
    left: 2px;
    width: 138px;
    height: 138px;
}

.floral-top-right {
    top: 6px;
    right: 2px;
    width: 138px;
    height: 138px;
}

/* Grand bouquet symétrique en bas de l'arche */
.floral-bottom {
    left: 0;
    right: 0;
    bottom: -4px;
    width: 100%;
    height: 170px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.floral-bottom .floral-svg-wrap {
    width: 104%;
    max-width: 680px;
    height: 100%;
}

@media (min-width: 640px) {
    .floral-top-left {
        top: 16px;
        left: 14px;
        width: 245px;
        height: 245px;
    }

    .floral-top-right {
        top: 16px;
        right: 14px;
        width: 245px;
        height: 245px;
    }

    .floral-bottom {
        height: 205px;
    }
}

/* ==========================================================================
   2. ÉPANOUISSEMENT DES FLEURS & PÉTALES SÉPARÉS + VENT DOUX SUR FEUILLAGES
   ========================================================================== */
.svg-flower {
    transform-box: fill-box;
    transform-origin: 50% 50%;
}

.svg-petal {
    transform-box: fill-box;
    transform-origin: 50% 92%;
}

/* État initial avant ouverture (hors mode cinématographique piloté par reveal.css) */
body.js-anim-ready:not(.invitation-opened):not(.is-cinematic-reveal):not(.reveal-complete) .hero-arch .svg-petal {
    opacity: 0;
    transform: scale(0.28) rotate(-9deg);
}

/* Épanouissement direct uniquement si reveal.js n'est pas en charge */
body.invitation-opened:not(.is-cinematic-reveal):not(.reveal-complete) .hero-arch .svg-petal {
    animation: petalBloomOpen var(--floral-petal-duration) cubic-bezier(0.22, 1.22, 0.36, 1) both;
    animation-delay: calc(0.15s + var(--petal-delay, 0s));
}

/* Épanouissement des guirlandes et bouquets de titres au scroll */
body.js-anim-ready .reveal-garland:not(.is-visible) .svg-petal,
body.js-anim-ready .reveal-on-scroll:not(.is-visible) .title-bouquet-sprig .svg-petal {
    opacity: 0;
    transform: scale(0.25) rotate(-8deg);
}

.reveal-garland.is-visible .svg-petal,
.reveal-on-scroll.is-visible .title-bouquet-sprig .svg-petal {
    animation: petalBloomOpen 0.85s cubic-bezier(0.22, 1.2, 0.36, 1) both;
    animation-delay: calc(0.35s + var(--petal-delay, 0s));
}

@keyframes petalBloomOpen {
    0% {
        opacity: 0;
        transform: scale(0.26) rotate(-10deg);
    }
    68% {
        opacity: 1;
        transform: scale(1.05) rotate(1.5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Balancement très léger limité à la carte ouverte uniquement sur écrans larges (zéro surcharge GPU mobile) */
@media (min-width: 768px) {
    body.reveal-complete .hero-arch:not(.is-offscreen-paused) .svg-branch {
        transform-box: fill-box;
        transform-origin: 50% 96%;
        animation: floralBreezeSway var(--sway-duration, var(--floral-sway-speed)) ease-in-out infinite alternate;
    }
}

@keyframes floralBreezeSway {
    0% {
        transform: rotate(calc(var(--floral-sway-angle) * -1));
    }
    100% {
        transform: rotate(var(--floral-sway-angle));
    }
}

/* ==========================================================================
   3. GUIRLANDES SÉPARATRICES ANIMÉES ENTRE LES SECTIONS
   ========================================================================== */
.floral-garland-divider {
    width: 100%;
    max-width: 440px;
    margin: -6px auto 18px;
    padding: 0 12px;
    pointer-events: none;
}

.garland-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.garland-grow-stem {
    stroke-dasharray: 560;
    stroke-dashoffset: 0;
}

body.js-anim-ready .reveal-garland:not(.is-visible) .garland-grow-stem {
    stroke-dashoffset: 560;
    opacity: 0.2;
}

.reveal-garland.is-visible .garland-grow-stem {
    animation: stemGrowLeftToRight var(--garland-grow-duration) cubic-bezier(0.25, 1, 0.4, 1) forwards;
}

.reveal-garland.is-visible .garland-stem-sage {
    animation-delay: 0.18s;
}

@keyframes stemGrowLeftToRight {
    0% {
        stroke-dashoffset: 560;
        opacity: 0.2;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

/* ==========================================================================
   4. PETITS BOUQUETS DÉCORATIFS AUTOUR DES TITRES DE SECTIONS
   ========================================================================== */
.section-title-with-florals {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 100%;
    margin: 0 auto 18px;
}

.section-title-with-florals .section-script-title {
    margin: 0;
}

.title-bouquet-sprig {
    width: 66px;
    height: 30px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    opacity: 0.92;
}

.title-bouquet-sprig svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.title-bouquet-sprig.sprig-right {
    transform: scaleX(-1);
}

@media (max-width: 400px) {
    .title-bouquet-sprig {
        width: 48px;
        height: 24px;
    }
}

/* ==========================================================================
   5. PAPILLONS TURQUOISE AQUARELLE VOLANT SUR CHEMIN COURBE
   ========================================================================== */
.butterflies-stage {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.butterfly-actor {
    position: absolute;
    width: 42px;
    height: 35px;
    pointer-events: none;
    will-change: transform, opacity;
    filter: drop-shadow(0 4px 8px rgba(40, 142, 145, 0.18));
}

.butterfly-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Battement des ailes articulées autour du thorax (x=34) */
.bfly-wing-left {
    transform-origin: 34px 30px;
    animation: bflyFlapLeft var(--butterfly-wing-speed) ease-in-out infinite alternate;
}

.bfly-wing-right {
    transform-origin: 34px 30px;
    animation: bflyFlapRight var(--butterfly-wing-speed) ease-in-out infinite alternate;
}

@keyframes bflyFlapLeft {
    0% { transform: scaleX(1) skewY(0deg); }
    100% { transform: scaleX(0.32) skewY(5deg); }
}

@keyframes bflyFlapRight {
    0% { transform: scaleX(1) skewY(0deg); }
    100% { transform: scaleX(0.32) skewY(-5deg); }
}

/* Trajectoire courbe moderne (CSS offset-path) + fallback keyframe universel */
@supports (offset-path: path('M 0 0 C 10 10, 20 20, 30 30')) {
    .butterfly-flight-1 {
        top: 0;
        left: 0;
        offset-path: path('M -40 240 C 90 120, 240 280, 380 140 C 490 40, 580 190, 700 95');
        offset-rotate: auto 90deg;
        animation: butterflyOffsetGlide var(--butterfly-flight-duration) ease-in-out infinite;
    }

    .butterfly-flight-2 {
        top: 0;
        left: 0;
        width: 34px;
        height: 28px;
        offset-path: path('M 690 520 C 540 420, 410 580, 260 450 C 130 340, 50 470, -50 380');
        offset-rotate: auto 90deg;
        animation: butterflyOffsetGlide calc(var(--butterfly-flight-duration) * 1.25) ease-in-out infinite;
        animation-delay: -9s;
    }
}

@keyframes butterflyOffsetGlide {
    0% {
        offset-distance: 0%;
        opacity: 0;
    }
    8% {
        opacity: 0.88;
    }
    90% {
        opacity: 0.85;
    }
    100% {
        offset-distance: 100%;
        opacity: 0;
    }
}

@supports not (offset-path: path('M 0 0 C 10 10, 20 20, 30 30')) {
    .butterfly-flight-1 {
        top: 18%;
        left: -45px;
        animation: butterflyFallbackArc 22s ease-in-out infinite;
    }
    .butterfly-flight-2 {
        display: none;
    }
}

@keyframes butterflyFallbackArc {
    0% { transform: translate3d(0, 40px, 0) rotate(18deg); opacity: 0; }
    15% { opacity: 0.88; }
    50% { transform: translate3d(52vw, -35px, 0) rotate(8deg); opacity: 0.9; }
    88% { opacity: 0.8; }
    100% { transform: translate3d(105vw, -90px, 0) rotate(22deg); opacity: 0; }
}

/* Sur mobile, on ne garde qu'un seul papillon discret pour la légèreté */
@media (max-width: 639px) {
    .butterfly-flight-2 {
        display: none;
    }
    .butterfly-actor {
        width: 34px;
        height: 28px;
    }
}

/* ==========================================================================
   6. PLUIE DOUCE DE PÉTALES AQUARELLE EN ARRIÈRE-PLAN (15–25 MAX)
   ========================================================================== */
.falling-petal-node {
    position: absolute;
    top: -36px;
    left: var(--petal-x, 50%);
    width: var(--petal-w, 14px);
    height: var(--petal-h, 18px);
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity;
    animation: petalGracefulFall var(--petal-dur, 16s) linear infinite;
    animation-delay: var(--petal-delay, 0s);
}

.falling-petal-node svg {
    width: 100%;
    height: 100%;
    display: block;
    animation: petalSwaySpin var(--petal-spin-dur, 5.5s) ease-in-out infinite alternate;
}

@keyframes petalGracefulFall {
    0% {
        transform: translate3d(0, -35px, 0);
        opacity: 0;
    }
    10% {
        opacity: var(--petal-max-opacity);
    }
    88% {
        opacity: calc(var(--petal-max-opacity) * 0.8);
    }
    100% {
        transform: translate3d(var(--petal-drift, 55px), 106vh, 0);
        opacity: 0;
    }
}

@keyframes petalSwaySpin {
    0% {
        transform: translateX(-14px) rotate(-28deg) scaleX(0.88);
    }
    100% {
        transform: translateX(14px) rotate(34deg) scaleX(1.05);
    }
}
