/* Source : quartz_alpeo_box_app, _paladru_animation.html.erb, révision cfb65eee3. */
/* ============================================================================
       GUIDE DE COHÉRENCE CARDIAQUE — Lac de Paladru (Isère)
       Composant autonome : JS vanilla + SVG. Aucune dépendance.
       ----------------------------------------------------------------------------
       POUR MODIFIER FACILEMENT :
       - Durées de respiration  -> objet BREATH (dans le <script>, tout en haut)
       - Lueur d'horizon         -> GLOW_RY_MIN / GLOW_RY_MAX / GLOW_RX_RATIO
       - Palettes par moment     -> objet PALETTES (aube / jour / crépuscule / nuit)
       - Plages horaires         -> fonction bucketForHour()
       ========================================================================== */

    .client-desk-paladru-animation {
      /* Ces variables sont (ré)écrites par le JS selon l'heure de la journée.
         Valeurs par défaut = ambiance "jour" (au cas où le JS ne tourne pas). */
      --sky-top:    #8ecbe6;
      --sky-bottom: #d8f0ec;
      --hill-far:   #9fc98f;
      --hill-near:  #6cae79;
      --water-top:  #38b9b1;
      --water-bot:  #218a8f;
      --reed:       #4f8f5e;
      --reed-dark:  #3d7a4d;
      --lily:       #4a9a6e;
      --lily-flower:#f6e7b8;
      /* Couleurs VÉGÉTALES pilotées par la SAISON (réécrites par applyPalette).
         Elles ne déforment rien : seuls les aplats/contours changent de teinte.
           --blade        : limbe des joncs/feuilles rubanées (vert tendre -> fauve -> sec)
           --blade-dark   : limbe en ombre
           --cattail-spike: épi brun de la massette (été/automne)
           --cattail-hi   : reflet clair sur l'épi
           --cattail-stalk: fine inflorescence mâle au-dessus de l'épi
           --fluff        : bourre/aigrette blanche de l'épi éclaté (hiver) */
      --blade:        #4f8f5e;
      --blade-dark:   #3d7a4d;
      --cattail-spike:#6b3f24;
      --cattail-hi:   #8a5a37;
      --cattail-stalk:#9c7c4c;
      --fluff:        #f3f0e6;
      --bird-back:  #2bb6c4;
      --bird-belly: #f0a45c;
      --bird-dark:  #1d3b4a;
      --celest:     #fff6cf;
      --celest-glow:#fff2bb;
      --glow:       #fff4d6;   /* couleur du halo lumineux de respiration */
      --ring:       #ffffff;   /* couleur de l'anneau de progression       */
      --text:       #1f3b46;   /* couleur du texte « Inspirez / Expirez »  */
      --ui:         #1f3b46;   /* couleur des contrôles                    */
      --ui-bg:      rgba(255,255,255,.30);
    }

    .client-desk-paladru-animation, .client-desk-paladru-animation * { box-sizing: border-box; }

    /* --- La bulle : toujours carrée et centrée, du mobile au desktop --------- */
    .client-desk-paladru-animation .bubble {
      position: relative;
      width: min(100%, 56vh);
      aspect-ratio: 1 / 1;
      border-radius: 50%;
      box-shadow: none;
    }

    .client-desk-paladru-animation .bubble svg {
      display: block;
      width: 100%;
      height: 100%;
    }

    /* Liseré très discret pour détacher le bord de l'image du fond.
       Pas de reflet/brillance : on veut une fenêtre sur un paysage, pas un hublot. */
    .client-desk-paladru-animation .bubble::after {
      content: "";
      position: absolute;
      inset: 0;
      border-radius: 50%;
      pointer-events: none;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
    }

    /* ============================================================================
       ANIMATIONS D'AMBIANCE (CSS) — lentes, fluides, en boucle.
       Toutes désactivées si .reduced est posée sur la bulle (reduced-motion).
       ========================================================================== */

    /* Roseaux qui oscillent à peine */
    .client-desk-paladru-animation .reed-cluster {
      transform-box: fill-box;
      transform-origin: 50% 100%;
      animation: sway 8s ease-in-out infinite;
    }
    .client-desk-paladru-animation .reed-cluster.b { animation-duration: 10.5s; animation-delay: -3s; }
    .client-desk-paladru-animation .reed-cluster.c { animation-duration: 9s;    animation-delay: -1.5s; }
    @keyframes sway {
      0%, 100% { transform: rotate(-2.2deg); }
      50%      { transform: rotate(2.2deg); }
    }

    /* Nuages qui dérivent lentement */
    .client-desk-paladru-animation .cloud { animation: drift 70s linear infinite; }
    .client-desk-paladru-animation .cloud.b { animation-duration: 95s; animation-delay: -40s; }
    @keyframes drift {
      from { transform: translateX(-120px); }
      to   { transform: translateX(520px); }
    }

    /* Reflets / ondulations légères sur l'eau */
    .client-desk-paladru-animation .ripple { animation: shimmer 7s ease-in-out infinite; transform-box: fill-box; }
    .client-desk-paladru-animation .ripple.b { animation-duration: 9s;  animation-delay: -2s; }
    .client-desk-paladru-animation .ripple.c { animation-duration: 11s; animation-delay: -4s; }
    @keyframes shimmer {
      0%, 100% { opacity: .35; transform: translateX(-3px) scaleX(1); }
      50%      { opacity: .7;  transform: translateX(3px)  scaleX(1.04); }
    }

    /* Reflet lunaire/solaire qui frémit et s'étale doucement.
       L'opacité ici est relative : elle se multiplie avec l'opacité de base
       posée sur le groupe parent de chaque trait (voir buildReflection). */
    .client-desk-paladru-animation .reflect { animation: glint 6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
    @keyframes glint {
      0%, 100% { opacity: .5; transform: translateX(-1px) scaleX(.9); }
      50%      { opacity: 1;  transform: translateX(1px)  scaleX(1.14); }
    }

    /* Souffle discret des deux oiseaux, ancré au niveau des pattes. */
    .client-desk-paladru-animation .bird { transform-box: fill-box; transform-origin: 50% 100%; animation: bird-breathe 7s ease-in-out infinite; }
    @keyframes bird-breathe {
      0%, 100% { transform: scaleY(1); }
      50%      { transform: scaleY(1.008); }
    }

    /* Petit rééquilibrage sur le perchoir : le bec bouge, les pattes restent à l'appui. */
    .client-desk-paladru-animation .kingfisher-body { transform-origin: 30% 97%; animation: kingfisher-perch 8s ease-in-out infinite; }
    @keyframes kingfisher-perch {
      0%, 15%, 100% { transform: rotate(0deg) scaleY(1); }
      40% { transform: rotate(-2.5deg) scaleY(1.02); }
      70% { transform: rotate(1.5deg) scaleY(1.01); }
    }

    .client-desk-paladru-animation .bird-eye { transform-box: fill-box; transform-origin: 50% 50%; animation: paladru-blink 6.5s ease-in-out infinite; }
    @keyframes paladru-blink {
      0%, 90%, 100% { transform: scaleY(1); }
      94%           { transform: scaleY(.08); }
    }

    /* La chouette tourne lentement la tête (crépuscule / nuit) */
    .client-desk-paladru-animation .owl-head { transform-box: fill-box; transform-origin: 50% 100%; animation: owl-look 9s ease-in-out infinite; }
    @keyframes owl-look {
      0%, 40%, 100% { transform: rotate(0deg); }
      55%           { transform: rotate(-1.5deg); }
      78%           { transform: rotate(1.2deg); }
    }

    /* Étoiles scintillantes (nuit seulement) */
    .client-desk-paladru-animation .star { animation: twinkle 4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
    @keyframes twinkle {
      0%, 100% { opacity: .25; transform: scale(.8); }
      50%      { opacity: 1;   transform: scale(1.1); }
    }

    /* Déco saisonnière qui tombe doucement : pétales (printemps), feuilles
       (automne), neige (hiver). La durée/le délai sont posés par le JS. */
    .client-desk-paladru-animation .fall {
      transform-box: fill-box;
      transform-origin: 50% 50%;
      animation-name: fall;
      animation-timing-function: linear;
      animation-iteration-count: infinite;
    }
    @keyframes fall {
      0%   { transform: translateY(-22px) translateX(0)   rotate(0deg);   opacity: 0; }
      10%  { opacity: .9; }
      90%  { opacity: .9; }
      100% { transform: translateY(415px) translateX(14px) rotate(220deg); opacity: 0; }
    }

    /* Flocons de neige : chute lente qui louvoie doucement de gauche à droite. */
    .client-desk-paladru-animation .snowflake {
      transform-box: fill-box;
      transform-origin: 50% 50%;
      animation-name: snowfall;
      animation-timing-function: ease-in-out;
      animation-iteration-count: infinite;
    }
    @keyframes snowfall {
      0%   { transform: translate(0, -22px);    opacity: 0; }
      10%  { opacity: .95; }
      35%  { transform: translate(11px, 120px); }
      60%  { transform: translate(-8px, 250px); }
      85%  { transform: translate(8px, 360px);  opacity: .9; }
      100% { transform: translate(0, 418px);    opacity: 0; }
    }

    /* Particules magiques : pollen lumineux le jour, lucioles la nuit */
    .client-desk-paladru-animation .spark {
      transform-box: fill-box; transform-origin: 50% 50%;
      animation: floaty 11s ease-in-out infinite;
    }
    @keyframes floaty {
      0%   { transform: translate(0, 0)      scale(.7); opacity: .15; }
      25%  { transform: translate(6px, -10px) scale(1.15); opacity: .9; }
      50%  { transform: translate(-4px, -20px) scale(.85); opacity: .5; }
      75%  { transform: translate(7px, -30px) scale(1.1); opacity: .8; }
      100% { transform: translate(0, -42px)  scale(.7); opacity: 0; }
    }

    /* Rayons de lumière qui traversent doucement la scène */
    .client-desk-paladru-animation .rays { animation: breathe-rays 12s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0%; }
    @keyframes breathe-rays {
      0%, 100% { opacity: .12; }
      50%      { opacity: .30; }
    }

    /* Brume légère qui dérive sur la rive */
    .client-desk-paladru-animation .mist { animation: mist-drift 40s ease-in-out infinite; transform-box: fill-box; }
    .client-desk-paladru-animation .mist.b { animation-duration: 55s; animation-delay: -20s; }
    @keyframes mist-drift {
      0%, 100% { transform: translateX(-14px); opacity: .25; }
      50%      { transform: translateX(14px);  opacity: .5; }
    }

    /* Scintillements sur l'eau (petits éclats) */
    .client-desk-paladru-animation .glitter { animation: glitter 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
    @keyframes glitter {
      0%, 100% { opacity: 0;   transform: scale(.4); }
      50%      { opacity: .95; transform: scale(1); }
    }

    /* Respiration de secours en CSS — uniquement si le JS ne tourne pas.
       Dès que le JS démarre, il pose .js-on et reprend la main sur le halo. */
    .client-desk-paladru-animation .breath-group { animation: breathe 10s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
    .client-desk-paladru-animation .js-on .breath-group { animation: none; }
    @keyframes breathe {
      0%, 100% { transform: scale(.52); }
      50%      { transform: scale(1);   }
    }

    /* Respect de prefers-reduced-motion : on coupe toute l'ambiance.
       Le guide de respiration, lui, reste actif mais piloté en douceur par le JS. */
    .client-desk-paladru-animation .bubble.reduced .reed-cluster,
    .client-desk-paladru-animation .bubble.reduced .cloud,
    .client-desk-paladru-animation .bubble.reduced .ripple,
    .client-desk-paladru-animation .bubble.reduced .reflect,
    .client-desk-paladru-animation .bubble.reduced .bird,
    .client-desk-paladru-animation .bubble.reduced .owl-head,
    .client-desk-paladru-animation .bubble.reduced .bird-eye,
    .client-desk-paladru-animation .bubble.reduced .star,
    .client-desk-paladru-animation .bubble.reduced .spark,
    .client-desk-paladru-animation .bubble.reduced .rays,
    .client-desk-paladru-animation .bubble.reduced .mist,
    .client-desk-paladru-animation .bubble.reduced .fall,
    .client-desk-paladru-animation .bubble.reduced .snowflake,
    .client-desk-paladru-animation .bubble.reduced .glitter {
      animation: none !important;
    }

    /* Transitions de couleur cohérentes entre les plages horaires */
    .client-desk-paladru-animation .scene-fill,
    [id$="-skyTop"], [id$="-skyBot"], [id$="-waterTop"], [id$="-waterBot"] {
      transition: fill 1.4s ease, stop-color 1.4s ease;
    }

/* Adaptation à la page vitrine. */
.client-desk-paladru-animation .bubble { width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .client-desk-paladru-animation * { animation: none !important; transition: none !important; }
}
