/* =========================================================
   Nicolas Pavlovic · effets animés de la page d'accueil
   Chaque effet est activé par une classe sur <html> (fx-xxx), posée par fx.js.
   Sans JavaScript, ou si l'appareil demande moins d'animations,
   la page reste identique à la version sobre.
   Règle d'or : on n'anime que transform / opacity (fluide, 60 i/s).
   ========================================================= */

/* Éléments ajoutés pour les effets : invisibles tant que l'effet est coupé */
.scroll-progress, .aurora, .marquee, .bubbles, .orbit, .swash,
.story-cursor, .cursor-pill, .caret, .ok-b, .nav__indicator { display: none; }

@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

@media (prefers-reduced-motion: no-preference) {

  /* Le flottement d'origine passe sur la propriété `translate`
     pour pouvoir se cumuler avec la 3D (transform) */
  .card-float { animation-name: fx-float; }
  @keyframes fx-float { 50% { translate: 0 -8px; } }

  /* Mise en pause des animations hors écran (économie de batterie) */
  .fx-paused, .fx-paused *, .fx-paused *::before, .fx-paused *::after { animation-play-state: paused !important; }

  /* ---------- 01 · Barre de lecture ---------- */
  .fx-progress .scroll-progress {
    display: block; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 70; pointer-events: none;
    transform-origin: 0 50%; transform: scaleX(var(--p, 0));
    background: linear-gradient(90deg, var(--accent), #f0d39b, var(--accent));
    box-shadow: 0 0 12px rgba(200,150,62,.55);
  }
  @supports (animation-timeline: scroll()) {
    /* 100 % CSS : la barre est pilotée directement par le défilement */
    .fx-progress .scroll-progress { animation: fx-progress linear both; animation-timeline: scroll(root); }
  }
  @keyframes fx-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

  /* ---------- 02 · Arrivée du titre ---------- */
  .fx-intro .nav { animation: fx-fade-down .8s cubic-bezier(.2,.7,.2,1) both; }
  .fx-intro .hero h1:not(.is-split) { visibility: hidden; }
  .fx-intro .hero h1 .w {
    display: inline-block; opacity: 0; filter: blur(8px);
    transform: translateY(.5em) rotate(4deg); transform-origin: 0 100%;
    animation: fx-word .95s cubic-bezier(.2,.75,.2,1) forwards;
    animation-delay: calc(.2s + var(--i) * 55ms);
  }
  @keyframes fx-word { to { opacity: 1; filter: blur(0); transform: none; } }
  .fx-intro .eyebrow { animation: fx-rise .8s .05s cubic-bezier(.2,.7,.2,1) both; }
  .fx-intro .lead { animation: fx-rise .9s .8s cubic-bezier(.2,.7,.2,1) both; }
  .fx-intro .hero__cta { animation: fx-rise .9s .95s cubic-bezier(.2,.7,.2,1) both; }
  .fx-intro .hero__facts li { animation: fx-rise .8s 1.1s cubic-bezier(.2,.7,.2,1) both; }
  .fx-intro .hero__facts li:nth-child(2) { animation-delay: 1.2s; }
  .fx-intro .hero__facts li:nth-child(3) { animation-delay: 1.3s; }
  .fx-intro .hero__visual { animation: fx-visual 1.2s .35s cubic-bezier(.2,.7,.2,1) backwards; }
  @keyframes fx-rise { from { opacity: 0; translate: 0 18px; } }
  @keyframes fx-visual { from { opacity: 0; translate: 0 40px; scale: .94; } }
  @keyframes fx-fade-down { from { opacity: 0; translate: 0 -12px; } }

  /* Trait doré dessiné sous « tourner » */
  .fx-intro .hero h1 em { position: relative; display: inline-block; }
  .fx-intro .swash {
    display: block; position: absolute; left: -2%; width: 104%; bottom: -.1em; height: .3em; overflow: visible; pointer-events: none;
  }
  .fx-intro .swash path {
    fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round;
    stroke-dasharray: 1; stroke-dashoffset: 1;
    animation: fx-draw 1s 1.1s cubic-bezier(.6,0,.2,1) forwards;
  }
  @keyframes fx-draw { to { stroke-dashoffset: 0; } }
  /* Petit bonus : au survol, « tourner »… tourne */
  .fx-intro .hero h1 em .ch { display: inline-block; }
  .fx-intro .hero h1 em:hover .ch { animation: fx-spin .8s cubic-bezier(.3,.7,.3,1) both; animation-delay: calc(var(--j) * 45ms); }
  @keyframes fx-spin { to { transform: rotateY(360deg); } }

  /* ---------- 03 · Fond lumineux + grille au curseur ---------- */
  .fx-aurora .hero { isolation: isolate; }
  .fx-aurora .hero::before { display: none; }
  .fx-aurora .aurora { display: block; position: absolute; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
  .aurora i { position: absolute; border-radius: 50%; will-change: transform; }
  .aurora i:nth-child(1) { width: 680px; height: 680px; right: -180px; top: -240px; background: radial-gradient(closest-side, rgba(200,150,62,.24), transparent); animation: fx-drift-1 22s ease-in-out infinite alternate; }
  .aurora i:nth-child(2) { width: 520px; height: 520px; right: 24%; top: 34%; background: radial-gradient(closest-side, rgba(240,211,155,.30), transparent); animation: fx-drift-2 28s ease-in-out infinite alternate; }
  .aurora i:nth-child(3) { width: 480px; height: 480px; left: -140px; bottom: -220px; background: radial-gradient(closest-side, rgba(47,91,234,.07), transparent); animation: fx-drift-3 34s ease-in-out infinite alternate; }
  @keyframes fx-drift-1 { to { transform: translate(-120px, 90px) scale(1.15); } }
  @keyframes fx-drift-2 { to { transform: translate(150px, -70px) scale(.88); } }
  @keyframes fx-drift-3 { to { transform: translate(200px, -120px) scale(1.2); } }
  .grid-dots { position: absolute; inset: 0; }
  .grid-dots::before, .grid-dots::after { content: ""; position: absolute; inset: 0; background-size: 24px 24px; }
  .grid-dots::before {
    background-image: radial-gradient(rgba(20,23,31,.12) 1px, transparent 1.6px);
    -webkit-mask-image: radial-gradient(ellipse 60% 70% at 72% 45%, #000 10%, transparent 75%);
            mask-image: radial-gradient(ellipse 60% 70% at 72% 45%, #000 10%, transparent 75%);
  }
  .grid-dots::after {
    background-image: radial-gradient(rgba(200,150,62,.95) 1.3px, transparent 1.9px);
    -webkit-mask-image: radial-gradient(190px circle at var(--mx, -500px) var(--my, -500px), #000, transparent);
            mask-image: radial-gradient(190px circle at var(--mx, -500px) var(--my, -500px), #000, transparent);
    opacity: var(--spot, 0); transition: opacity .5s;
  }

  /* ---------- 04 · Maquettes en 3D qui suivent la souris ---------- */
  .fx-tilt .hero__visual {
    transform: perspective(1200px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transform-style: preserve-3d; transition: transform .9s cubic-bezier(.2,.7,.2,1);
  }
  .fx-tilt .hero__visual .card-float--booking { transform: translateZ(70px); }
  .fx-tilt .hero__visual .card-float--code { transform: translateZ(40px); }
  .fx-tilt .window { position: relative; }
  .fx-tilt .window::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
    background: radial-gradient(520px circle at var(--gx, 50%) var(--gy, 0%), rgba(255,255,255,.5), transparent 45%);
    mix-blend-mode: soft-light; opacity: var(--glare, 0); transition: opacity .6s;
  }
  .fx-tilt .project__visual { position: relative; }
  .fx-tilt .project__visual:hover { transform: none; }
  .fx-tilt .window--project {
    transform: perspective(1200px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--sc, 1));
    transition: transform .9s cubic-bezier(.2,.7,.2,1), box-shadow .5s;
  }
  .fx-tilt .project__visual.is-hover .window--project { --sc: 1.02; box-shadow: 0 34px 70px -24px rgba(20,23,31,.4); }
  /* Pastille « Voir la démo » qui suit le curseur */
  .fx-tilt .cursor-pill {
    display: block; position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
    padding: 10px 16px; border-radius: 999px; white-space: nowrap;
    background: var(--accent); color: var(--ink); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow);
    transform: translate(var(--cx, 0px), var(--cy, 0px)) translate(-50%, -50%) scale(0);
    transition: transform .45s cubic-bezier(.2,.7,.2,1);
  }
  .fx-tilt .project__visual.is-hover .cursor-pill { transform: translate(var(--cx), var(--cy)) translate(-50%, -150%) scale(1); }

  /* ---------- 05 · Mini-scénario de réservation (boucle de 10 s) ---------- */
  .fx-story .mock-lines b {
    background: linear-gradient(90deg, var(--bg-alt) 30%, #fffdf8 50%, var(--bg-alt) 70%) 0 0 / 300% 100%;
    animation: fx-shimmer 2.6s linear infinite;
  }
  @keyframes fx-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
  .fx-story .mock-cards span:nth-child(2) { position: relative; animation: fx-slot-booked 10s 1.6s infinite both; }
  .fx-story .mock-cards span:nth-child(2)::after {
    content: "✓"; position: absolute; inset: 0; display: grid; place-items: center;
    color: var(--accent-ink); font-weight: 700; opacity: 0; animation: fx-check 10s 1.6s infinite both;
  }
  @keyframes fx-slot-booked {
    0%, 33% { background: var(--bg-alt); border-color: var(--line); }
    37%, 86% { background: var(--accent-soft); border-color: #ecd9b4; }
    94%, 100% { background: var(--bg-alt); border-color: var(--line); }
  }
  @keyframes fx-check { 0%, 34% { opacity: 0; scale: .4; } 40%, 86% { opacity: 1; scale: 1; } 94%, 100% { opacity: 0; } }

  .fx-story .card-float--booking { animation: fx-float 6s ease-in-out infinite, fx-story-card 10s cubic-bezier(.2,.7,.2,1) 1.6s infinite both; }
  @keyframes fx-story-card {
    0%, 6% { opacity: 0; scale: .9; }
    12%, 86% { opacity: 1; scale: 1; }
    94%, 100% { opacity: 0; scale: .95; }
  }
  .fx-story .cf-label { display: flex; align-items: center; gap: 6px; }
  .fx-story .cf-label::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%; background: #22a35a;
    box-shadow: 0 0 0 0 rgba(34,163,90,.5); animation: fx-ping 2s infinite;
  }
  @keyframes fx-ping { 70%, 100% { box-shadow: 0 0 0 7px rgba(34,163,90,0); } }
  .fx-story .cf-ok { display: grid; position: relative; overflow: hidden; animation: fx-story-btn 10s 1.6s infinite both; }
  .fx-story .cf-ok > span { grid-area: 1 / 1; }
  .fx-story .ok-a { animation: fx-story-a 10s 1.6s infinite both; }
  .fx-story .ok-b { display: block; animation: fx-story-b 10s 1.6s infinite both; }
  .fx-story .cf-ok::after {
    content: ""; position: absolute; left: 88px; top: 50%; width: 10px; height: 10px; margin: -5px;
    border-radius: 50%; background: rgba(255,255,255,.6); animation: fx-ripple 10s 1.6s infinite both;
  }
  @keyframes fx-story-btn { 0%, 33% { background: var(--ink); } 35%, 100% { background: #22a35a; } }
  @keyframes fx-story-a { 0%, 33% { opacity: 1; } 35%, 100% { opacity: 0; } }
  @keyframes fx-story-b { 0%, 33% { opacity: 0; translate: 0 6px; } 37%, 100% { opacity: 1; translate: 0 0; } }
  @keyframes fx-ripple { 0%, 33% { scale: 0; opacity: .8; } 44%, 100% { scale: 14; opacity: 0; } }
  .fx-story .story-cursor {
    display: block; position: absolute; left: 104px; bottom: 6px; width: 20px; height: 20px; pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,.25));
    animation: fx-story-cursor 10s cubic-bezier(.45,0,.2,1) 1.6s infinite both;
  }
  @keyframes fx-story-cursor {
    0%, 18% { opacity: 0; translate: 70px 40px; scale: 1; }
    22% { opacity: 1; translate: 70px 40px; }
    32% { opacity: 1; translate: 0 0; scale: 1; }
    34% { scale: .8; }
    37% { opacity: 1; translate: 0 0; scale: 1; }
    48%, 100% { opacity: 0; translate: 26px 22px; }
  }
  /* Créneaux de la démo coiffure qui s'allument en vague */
  .fx-story .ps-slots b { animation: fx-wave 4.8s ease-in-out infinite; }
  .fx-story .ps-slots b:nth-child(2) { animation-delay: .25s; }
  .fx-story .ps-slots b:nth-child(3) { animation-delay: .5s; }
  .fx-story .ps-slots b:nth-child(4) { animation-delay: .75s; }
  .fx-story .ps-slots b:nth-child(5) { animation-delay: 1s; }
  .fx-story .ps-slots b:nth-child(6) { animation-delay: 1.25s; }
  @keyframes fx-wave { 0%, 60%, 100% { background: rgba(255,255,255,.18); } 72% { background: var(--wave, #e9c79a); } }

  /* ---------- 06 · Code qui s'écrit ---------- */
  .fx-typing .card-float--code code { display: inline-block; min-width: 27.5ch; }
  .fx-typing .caret {
    display: inline-block; width: 2px; height: 1em; margin-left: 1px; vertical-align: -2px;
    background: var(--accent); animation: fx-blink 1s steps(1) infinite;
  }
  @keyframes fx-blink { 50% { opacity: 0; } }

  /* ---------- 07 · Boutons aimantés + reflet ---------- */
  .fx-magnet .btn {
    position: relative; overflow: hidden; isolation: isolate;
    transition: transform .15s ease, background .15s ease, color .25s ease, translate .4s cubic-bezier(.2,.7,.2,1), background-size .4s ease;
  }
  .fx-magnet .btn::after {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.28) 50%, transparent 65%);
    transform: translateX(-110%);
  }
  .fx-magnet .btn:hover::after { transform: translateX(110%); transition: transform .8s cubic-bezier(.2,.7,.2,1); }
  .fx-magnet .btn--ghost { background: linear-gradient(var(--ink), var(--ink)) no-repeat 50% 100% / 100% 0%; }
  .fx-magnet .btn--ghost:hover { background: linear-gradient(var(--ink), var(--ink)) no-repeat 50% 100% / 100% 100%; color: #fff; }
  .fx-magnet .btn span[aria-hidden] { display: inline-block; transition: translate .3s cubic-bezier(.2,.7,.2,1); }
  .fx-magnet .btn:hover span[aria-hidden] { translate: 5px 0; }

  /* ---------- 08 · Cartes « projecteur » ---------- */
  .fx-spot .spot { position: relative; }
  .fx-spot .spot::before, .fx-spot .spot::after {
    content: ""; position: absolute; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .4s ease;
  }
  .fx-spot .spot::before {
    inset: -1px; padding: 1.5px;
    background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), rgba(200,150,62,.95), rgba(200,150,62,.25) 45%, transparent 70%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask-composite: exclude;
  }
  .fx-spot .spot::after { inset: 0; background: radial-gradient(380px circle at var(--mx, -999px) var(--my, -999px), rgba(200,150,62,.11), transparent 60%); }
  .fx-spot .spot-group:hover > .spot::before, .fx-spot .spot-group:hover > .spot::after { opacity: 1; }
  .fx-spot .spot-group > .spot:hover { transform: translateY(-4px); }
  .fx-spot .service__icon { transition: transform .5s cubic-bezier(.2,.7,.2,1); }
  .fx-spot .service:hover .service__icon { transform: rotate(-6deg) scale(1.08); }
  .fx-spot .service:hover .service__icon svg > * { stroke-dasharray: 1; animation: fx-draw-icon .9s cubic-bezier(.6,0,.2,1) both; }
  @keyframes fx-draw-icon { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

  /* ---------- 09 · Apparitions en cascade ---------- */
  .fx-cascade .reveal {
    transform: translateY(34px) scale(.97); filter: blur(6px);
    transition: opacity .9s cubic-bezier(.2,.7,.2,1), transform .9s cubic-bezier(.2,.7,.2,1), filter .9s ease;
    transition-delay: calc(var(--i, 0) * 110ms);
  }
  .fx-cascade .reveal.is-visible { transform: none; filter: none; }
  .fx-cascade .reveal.revealed { transition: opacity .3s, transform .3s ease, box-shadow .3s ease, filter .3s; transition-delay: 0s; }
  .fx-cascade .kicker { display: flex; align-items: center; }
  .fx-cascade .kicker::before {
    content: ""; height: 2px; width: 0; margin-right: 0; border-radius: 2px; background: currentColor;
    transition: width .7s .35s cubic-bezier(.2,.7,.2,1), margin-right .7s .35s cubic-bezier(.2,.7,.2,1);
  }
  .fx-cascade .is-visible .kicker::before { width: 26px; margin-right: 10px; }

  /* ---------- 10 · Bandeau défilant ---------- */
  .fx-marquee .marquee { display: block; background: var(--ink); color: #e9e6df; padding: 20px 0; }
  .marquee__inner {
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
            mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  }
  .marquee__track { display: flex; align-items: center; width: max-content; animation: fx-marquee 60s linear infinite; }
  .marquee:hover .marquee__track { animation-play-state: paused; }
  .marquee__track span { font-family: var(--display); font-weight: 700; font-size: clamp(1.1rem, .9rem + 1vw, 1.6rem); letter-spacing: -.01em; padding: 0 24px; white-space: nowrap; transition: color .3s; }
  .marquee__track span:hover { color: var(--accent); }
  .marquee__track i { color: var(--accent); font-style: normal; }
  @keyframes fx-marquee { to { transform: translateX(-50%); } }

  /* ---------- 11 · Frise de la méthode ---------- */
  .fx-timeline .steps__n { color: #dccfb7; transition: color .6s ease; }
  .fx-timeline .is-lit .steps__n { color: var(--accent); }
  @media (min-width: 981px) {
    .fx-timeline .steps { position: relative; padding-top: 44px; }
    .fx-timeline .steps::before, .fx-timeline .steps::after { content: ""; position: absolute; left: 0; right: 0; top: 14px; height: 2px; border-radius: 2px; }
    .fx-timeline .steps::before { background: var(--line); }
    .fx-timeline .steps::after {
      background: linear-gradient(90deg, var(--accent), #f0d39b); box-shadow: 0 0 10px rgba(200,150,62,.5);
      transform-origin: 0 50%; transform: scaleX(var(--tl, 0)); transition: transform .25s linear;
    }
    .fx-timeline .steps__n::before {
      content: ""; position: absolute; left: 24px; top: -36px; width: 14px; height: 14px; border-radius: 50%;
      background: var(--bg); border: 2px solid var(--line); z-index: 1;
      transition: background .4s, border-color .4s, box-shadow .4s, scale .4s cubic-bezier(.3,1.6,.5,1);
    }
    .fx-timeline .is-lit .steps__n::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 6px rgba(200,150,62,.18); scale: 1.15; }
  }

  /* ---------- 12 · Bordure animée sur la formule phare ---------- */
  .fx-border .price--featured {
    border-color: transparent;
    background:
      linear-gradient(var(--surface), var(--surface)) padding-box,
      conic-gradient(from var(--angle), var(--ink) 0deg, var(--ink) 200deg, var(--accent) 260deg, #f6e2b8 290deg, var(--accent) 320deg, var(--ink) 360deg) border-box;
    animation: fx-spin-border 7s linear infinite;
  }
  @keyframes fx-spin-border { to { --angle: 360deg; } }
  .fx-border .price__badge { background: linear-gradient(110deg, var(--accent) 40%, #f6e2b8 50%, var(--accent) 60%) 0 0 / 250% 100%; animation: fx-sheen 3.5s ease-in-out infinite; }
  @keyframes fx-sheen { 0% { background-position: 100% 0; } 60%, 100% { background-position: 0 0; } }

  /* ---------- 13 · Portrait avec texte en orbite ---------- */
  .fx-orbit .orbit {
    display: block; position: absolute; left: 50%; top: 50%; width: min(84%, 340px); aspect-ratio: 1;
    translate: -50% -50%; pointer-events: none; animation: fx-rotate 40s linear infinite;
  }
  .orbit text { font-family: var(--display); font-weight: 700; font-size: 11px; fill: rgba(240,211,155,.9); }
  .orbit circle { fill: none; stroke: rgba(200,150,62,.5); stroke-width: 1; stroke-dasharray: 2 5; }
  @keyframes fx-rotate { to { rotate: 360deg; } }
  .fx-orbit .about__portrait::before { inset: -24px; translate: var(--px, 0px) var(--py, 0px); transition: translate .7s cubic-bezier(.2,.7,.2,1); }
  .fx-orbit .about__portrait > span { translate: calc(var(--px, 0px) * -.6) calc(var(--py, 0px) * -.6); transition: translate .7s cubic-bezier(.2,.7,.2,1); }

  /* ---------- 14 · Bulles de champagne ---------- */
  .fx-bubbles .contact { position: relative; overflow: hidden; }
  .fx-bubbles .contact__inner { position: relative; z-index: 1; }
  .fx-bubbles .bubbles { display: block; position: absolute; inset: 0; pointer-events: none; }
  .bubbles i {
    position: absolute; bottom: -24px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%; opacity: 0;
    background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.95) 0 16%, rgba(246,226,184,.55) 38%, rgba(200,150,62,.18) 72%);
    box-shadow: inset 0 0 0 1px rgba(246,226,184,.65), 0 0 8px rgba(240,211,155,.35);
    animation: fx-bubble var(--d) linear var(--delay) infinite, fx-sway var(--sw) ease-in-out var(--delay) infinite alternate;
  }
  @keyframes fx-bubble {
    0% { transform: translateY(0); opacity: 0; }
    8%, 80% { opacity: var(--o); }
    100% { transform: translateY(calc(var(--rise) * -1)); opacity: 0; }
  }
  @keyframes fx-sway { from { translate: calc(var(--sx) * -1) 0; } to { translate: var(--sx) 0; } }

  /* ---------- 15 · Menu qui suit la section ---------- */
  @media (min-width: 821px) {
    .fx-spy .nav__menu { position: relative; }
    .fx-spy .nav__menu a.is-active { color: var(--ink); }
    .fx-spy .nav__indicator {
      display: block; position: absolute; left: 0; top: calc(50% + 15px); height: 2px; border-radius: 2px;
      width: var(--w, 0px); background: var(--accent); opacity: var(--o, 0); transform: translateX(var(--x, 0px));
      transition: transform .5s cubic-bezier(.2,.7,.2,1), width .5s cubic-bezier(.2,.7,.2,1), opacity .3s;
    }
  }
}
