/* ==========================================================================
   Thierry Scianimanico - Motion system (même moteur que screen97.fr)
   - courbes ease-out fortes, UI < 300 ms, révélations 500-700 ms
   - on n'anime que transform / opacity (propriétés individuelles translate / scale)
   - hover réservé aux pointeurs précis, :active = scale(0.97)
   - prefers-reduced-motion respecté partout
   Les valeurs --hp, --pv, --is sont écrites par motion.js à chaque frame.
   ========================================================================== */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Barre de progression de lecture ---------- */
.scroll-progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 70;
  background: var(--acc);
  transform-origin: 0 50%; transform: scaleX(0);
  pointer-events: none; will-change: transform;
}

/* ---------- En-tête : ombre douce au scroll ---------- */
.top { transition: box-shadow 0.3s var(--ease-out), background-color 0.25s, border-color 0.3s var(--ease-out); }
.top.is-scrolled { box-shadow: 0 10px 30px -18px rgba(15, 36, 48, 0.35); }
[data-theme="dark"] .top.is-scrolled { box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8); }

/* ---------- Menu : section active + ouverture douce ---------- */
#menu a { transition: color 0.2s var(--ease-out), padding-left 0.3s var(--ease-out); }
#menu a.is-active { color: var(--acc); }
@media (hover: hover) and (pointer: fine) {
  #menu a:hover { padding-left: 6px; }
}
@media (prefers-reduced-motion: no-preference) {
  #menu.open { animation: menuIn 0.3s var(--ease-out) both; transform-origin: 0 0; }
  @keyframes menuIn { from { opacity: 0; transform: translateY(-8px) scale(0.97); } to { opacity: 1; transform: none; } }
}

/* ---------- Boutons : retour tactile ---------- */
.btn, .tools button, .lang-switch, #burger {
  transition-property: background-color, color, border-color, transform, box-shadow;
  transition-duration: 0.2s;
  transition-timing-function: var(--ease-out);
}
.btn:active, .tools button:active, .lang-switch:active, #burger:active { transform: scale(0.97); transition-duration: 0.1s; }
.flag { transition: transform 0.3s var(--ease-out); }
#theme { transition: transform 0.1s var(--ease-out), background-color 0.2s; }
@media (hover: hover) and (pointer: fine) {
  .btn:not(.ghost):hover { transform: translateY(-2px); box-shadow: 0 12px 24px -12px color-mix(in srgb, var(--acc) 70%, transparent); }
  .btn:hover:active { transform: translateY(0) scale(0.97); }
  .lang-switch:hover .flag { transform: scale(1.12); }
}

/* Transition de thème : cercle qui s'étend depuis le bouton */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

/* ---------- Héro ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero .kicker { animation: fadeUp 0.7s 0s var(--ease-out) both; }
  .hero .lead   { animation: fadeUp 0.8s 0.45s var(--ease-out) both; }
  .hero .cta    { animation: fadeUp 0.8s 0.6s var(--ease-out) both; }
  @keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

  /* Portrait : apparition en douceur, puis léger décalage à la souris (propriété `translate`) */
  .hero .portrait { animation: rise 1s var(--ease-out) both; translate: calc(var(--px, 0) * -10px) calc(var(--py, 0) * -10px); }
  @keyframes rise { from { opacity: 0; transform: translateY(28px) scale(0.95); } to { opacity: 1; transform: none; } }
}

/* Héro : le texte s'efface et la photo glisse quand on quitte l'écran d'accueil */
.hero-text { translate: 0 calc(var(--hp, 0) * -40px); opacity: calc(1 - var(--hp, 0) * 1.1); }
.hero-photo { translate: 0 calc(var(--hp, 0) * 48px); }

/* ---------- Phrase manifeste : les mots s'allument ---------- */
section.statement { max-width: 1000px; padding: clamp(32px, 6vw, 72px) 24px; }
.scrub {
  margin: 0; max-width: 19em;
  font-size: clamp(1.7rem, 4.4vw, 3.4rem); line-height: 1.14;
  letter-spacing: -0.02em; font-weight: 800;
}

/* ---------- Révélations au scroll (classes posées par motion.js) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .rv { opacity: 0; translate: 0 26px; scale: 0.97;
        transition: opacity 0.7s var(--ease-out), translate 0.7s var(--ease-out), scale 0.7s var(--ease-out);
        transition-delay: calc(var(--d, 0) * 70ms); }
  .rv.in { opacity: 1; translate: 0 0; scale: 1; }
  .timeline li.rv { translate: -18px 0; scale: 1; }
  .timeline li.rv.in { translate: 0 0; }
  h2.rv { translate: 0 18px; scale: 1; }
  img.img-fade { opacity: 0; transition: opacity 0.6s var(--ease-out); }
  img.img-fade.loaded { opacity: 1; }
}

/* Parallaxe par profondeur et zoom d'arrivée des images */
[data-speed] { translate: 0 calc(var(--pv, 0) * 1px); }
img.sz { scale: var(--is, 1); }
.gallery a, .gallery a:hover { overflow: hidden; }

/* ---------- Cartes : survols précis ---------- */
.cards article, .stats div, .gallery a, a.price {
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.35s var(--ease-out), opacity 0.7s var(--ease-out), translate 0.7s var(--ease-out), scale 0.7s var(--ease-out);
}
.rv.in { transition-delay: calc(var(--d, 0) * 70ms); }
.gallery img { transition: transform 0.7s var(--ease-out); }
.cards a { transition: transform 0.3s var(--ease-out); }
.gallery a:active, a.price:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) {
  .cards article:hover, .stats div:hover { transform: translateY(-4px); box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.35); border-color: color-mix(in srgb, var(--acc) 45%, var(--bd)); }
  .gallery a:hover { transform: translateY(-3px); }
  .gallery a:hover img { transform: scale(1.06); }
  .cards a:hover { transform: translateX(4px); }
}
.stats b { font-variant-numeric: tabular-nums; }

/* ---------- Chronologie : la ligne se dessine ---------- */
@media (prefers-reduced-motion: no-preference) {
  .timeline { border-left-color: transparent; position: relative; }
  .timeline::before {
    content: ""; position: absolute; left: -3px; top: 0; bottom: 0; width: 3px; background: var(--acc);
    transform-origin: 0 0; transform: scaleY(0); transition: transform 1.1s var(--ease-out);
  }
  .timeline.in::before { transform: scaleY(1); }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-progress { display: none; }
  .top, #menu a { transition: none; }
  .scrub .sw { opacity: 1 !important; }
  .btn:active, .tools button:active, .lang-switch:active, #burger:active { transform: none; }
  .cards article:hover, .stats div:hover, .gallery a:hover, .btn:hover { transform: none; }
}
