/* =========================================================
 * Soléa — Showcase Layer
 *
 * Partition cinématique en 7 mouvements :
 *   1. INTRO — séquence boot 3.5s (calligraphie → plan → 3D → fade)
 *   2. ATTAQUE — hero typewriter + reveal cascade
 *   3. CONTINU — section background morph (@property animated)
 *   4. DESSIN — construction by scroll (SVG layered)
 *   5. CALLIGRAPHIE — stats SVG path drawing
 *   6. SIGNATURE — hover trace calligraphique
 *   7. SILENCE — cursor narratif adaptatif
 *
 * Techniques :
 *   - CSS @property animated tokens
 *   - CSS scroll-timeline natif (Chrome 115+, Safari TP)
 *   - SVG path drawing avec stroke-dasharray
 *   - SVG filter primitives (displacement)
 *   - Web Animations API orchestration
 *   - Audio synthèse Web Audio (sound design)
 * ========================================================= */

/* =========================================================
 *  @PROPERTY — Custom properties animatables
 * ========================================================= */
@property --bg-tint {
  syntax: '<color>';
  inherits: true;
  initial-value: #fbf8f2;
}
@property --bg-tint-secondary {
  syntax: '<color>';
  inherits: true;
  initial-value: #ffffff;
}
@property --hero-veil {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}
@property --trace-progress {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

/* =========================================================
 *  MOUVEMENT 1 — CINEMATIC INTRO
 *  Séquence boot 3.5s. Joue 1 fois par session.
 *  html.solea-intro-playing active la scène.
 * ========================================================= */
.solea-intro {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #0a0a0c;
  display: grid;
  place-items: center;
  opacity: 1;
  pointer-events: auto;
  perspective: 1400px;
  overflow: hidden;
  transition: opacity .9s cubic-bezier(0.65, 0, 0.35, 1);
}
html:not(.solea-intro-playing) .solea-intro {
  opacity: 0;
  pointer-events: none;
}

/* Toile noire avec grille architecturale subtile */
.solea-intro::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(246, 183, 44, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(246, 183, 44, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 70%);
  opacity: 0;
  animation: introGrid 0.6s ease-out 0.1s forwards;
}
@keyframes introGrid {
  to { opacity: 1; }
}

/* Lumière focale or — pulsation lente */
.solea-intro::after {
  content: "";
  position: absolute;
  width: 720px;
  height: 720px;
  background: radial-gradient(circle, rgba(246, 183, 44, 0.15) 0%, transparent 60%);
  filter: blur(40px);
  opacity: 0;
  animation: introHalo 3.2s ease-out 0.2s forwards;
}
@keyframes introHalo {
  0%   { opacity: 0; transform: scale(0.4); }
  35%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.3); }
}

.solea-intro-stage {
  position: relative;
  width: clamp(280px, 50vw, 520px);
  height: clamp(280px, 50vw, 520px);
  z-index: 2;
  transform-style: preserve-3d;
}

/* Étape A : path-drawing du "Soléa" */
.solea-intro-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 24px rgba(246, 183, 44, 0.45));
}
.solea-intro-svg .stroke {
  fill: none;
  stroke: #f6b72c;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.solea-intro-svg .stroke-monogram {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: introMonogram 1.6s cubic-bezier(0.65, 0, 0.35, 1) 0.4s forwards;
}
.solea-intro-svg .stroke-plan {
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  opacity: 0;
  animation: introPlan 1.4s cubic-bezier(0.65, 0, 0.35, 1) 1.8s forwards;
}
.solea-intro-svg .stroke-house3d {
  stroke-dasharray: 1800;
  stroke-dashoffset: 1800;
  opacity: 0;
  animation: introHouse 1.0s cubic-bezier(0.65, 0, 0.35, 1) 2.5s forwards;
}

@keyframes introMonogram {
  to { stroke-dashoffset: 0; }
}
@keyframes introPlan {
  0%   { opacity: 0; stroke-dashoffset: 2400; }
  10%  { opacity: 1; }
  100% { opacity: 1; stroke-dashoffset: 0; }
}
@keyframes introHouse {
  0%   { opacity: 0; stroke-dashoffset: 1800; }
  10%  { opacity: 1; }
  100% { opacity: 1; stroke-dashoffset: 0; }
}

/* Rotation 3D de la scène (à mi-parcours, le plan se relève) */
.solea-intro-stage {
  animation: introStageTilt 2.6s cubic-bezier(0.65, 0, 0.35, 1) 1.0s forwards;
}
@keyframes introStageTilt {
  0%   { transform: rotateX(0deg) rotateY(0deg); }
  40%  { transform: rotateX(0deg) rotateY(0deg); }
  100% { transform: rotateX(48deg) rotateY(-12deg) scale(0.85); }
}

/* Le sous-titre apparaît en fin de séquence */
.solea-intro-tagline {
  position: absolute;
  bottom: clamp(48px, 12vh, 96px);
  left: 50%;
  transform: translateX(-50%);
  color: rgba(251, 248, 242, 0.85);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(15px, 2vw, 21px);
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  white-space: nowrap;
  animation: introTagline 1.0s cubic-bezier(0.65, 0, 0.35, 1) 2.2s forwards;
}
.solea-intro-tagline::after {
  content: "";
  display: block;
  width: 64px;
  height: 1px;
  background: rgba(246, 183, 44, 0.6);
  margin: 12px auto 0;
  transform: scaleX(0);
  transform-origin: center;
  animation: introTaglineRule 0.8s cubic-bezier(0.65, 0, 0.35, 1) 2.6s forwards;
}
@keyframes introTagline {
  to { opacity: 1; }
}
@keyframes introTaglineRule {
  to { transform: scaleX(1); }
}

/* Skip button discret */
.solea-intro-skip {
  position: absolute;
  top: clamp(20px, 4vh, 32px);
  right: clamp(20px, 4vw, 32px);
  background: transparent;
  border: 1px solid rgba(251, 248, 242, 0.18);
  color: rgba(251, 248, 242, 0.7);
  padding: 8px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 3;
  transition: border-color .3s, color .3s;
  opacity: 0;
  animation: introSkipIn 0.6s ease-out 0.8s forwards;
}
.solea-intro-skip:hover {
  border-color: #f6b72c;
  color: #f6b72c;
}
@keyframes introSkipIn {
  to { opacity: 1; }
}

/* =========================================================
 *  Bouton "Mode immersif" — opt-in son depuis l'intro
 *  À côté du Skip. Ring qui s'éclaire au click.
 * ========================================================= */
.solea-intro-controls {
  position: absolute;
  top: clamp(20px, 4vh, 32px);
  right: clamp(20px, 4vw, 32px);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  z-index: 3;
}
.solea-intro-controls .solea-intro-skip {
  position: static;
  top: auto;
  right: auto;
}
.solea-intro-immersive {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 13px;
  background: transparent;
  border: 1px solid rgba(251, 248, 242, 0.22);
  border-radius: 999px;
  color: rgba(251, 248, 242, 0.78);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  animation: introSkipIn 0.6s ease-out 0.8s forwards;
  transition:
    border-color 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.solea-intro-immersive:hover {
  border-color: #f6b72c;
  color: #f6b72c;
}
.solea-intro-immersive__ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid currentColor;
  position: relative;
  display: inline-block;
}
.solea-intro-immersive__dot {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.55;
}
.solea-intro-immersive.is-armed {
  border-color: #f6b72c;
  color: #f6b72c;
  background: rgba(246, 183, 44, 0.08);
}
.solea-intro-immersive.is-armed .solea-intro-immersive__ring {
  animation: introImmersiveRing 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.solea-intro-immersive.is-armed .solea-intro-immersive__dot {
  opacity: 1;
  animation: introImmersiveDot 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes introImmersiveRing {
  0%   { box-shadow: 0 0 0 0 rgba(246, 183, 44, 0.7); transform: scale(1); }
  60%  { box-shadow: 0 0 0 12px rgba(246, 183, 44, 0); transform: scale(1.15); }
  100% { box-shadow: 0 0 0 0 rgba(246, 183, 44, 0); transform: scale(1); }
}
@keyframes introImmersiveDot {
  0%   { transform: translate(-50%, -50%) scale(1); }
  60%  { transform: translate(-50%, -50%) scale(1.8); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
@media (max-width: 540px) {
  .solea-intro-controls { gap: 8px; }
  .solea-intro-immersive { padding: 6px 12px 6px 10px; font-size: 10px; letter-spacing: 0.2em; }
}

/* Empêche le scroll pendant l'intro */
html.solea-intro-playing,
html.solea-intro-playing body {
  overflow: hidden;
  height: 100vh;
}

/* =========================================================
 *  MOUVEMENT 2 — HERO TYPEWRITER (attaque rapide)
 *  Le H1 du hero s'écrit caractère par caractère.
 *  Délai variable pour rythme : virgules pause, points = arrêt.
 * ========================================================= */
.hero-luxe-h1.typed {
  position: relative;
  min-height: 1.05em;
}
.hero-luxe-h1.typed .typed-char {
  opacity: 0;
  display: inline-block;
  animation: typedIn 0.001s linear forwards;
}
.hero-luxe-h1.typed .typed-cursor {
  display: inline-block;
  width: 0.05em;
  height: 0.95em;
  background: #f6b72c;
  vertical-align: -0.08em;
  margin-left: 4px;
  animation: typedBlink 0.9s steps(2) infinite;
}
.hero-luxe-h1.typed.is-complete .typed-cursor {
  animation: typedFade 0.6s ease-out forwards;
}
@keyframes typedIn {
  to { opacity: 1; }
}
@keyframes typedBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes typedFade {
  to { opacity: 0; }
}

/* =========================================================
 *  MOUVEMENT 3 — SECTION BACKGROUND MORPH (continu)
 *  Transitions de teinte du body via @property
 *  Lié au scroll : 5 zones de couleur
 * ========================================================= */
body {
  background: var(--bg-tint);
  transition: background 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sections marquées déclenchent le morph via JS */
.section-tint-cream  { --bg-tint: #fbf8f2; }
.section-tint-ink    { --bg-tint: #0d0d10; color: #fbf8f2; }
.section-tint-warm   { --bg-tint: #f6efe2; }
.section-tint-white  { --bg-tint: #ffffff; }

/* La diagonale ne morph pas, elle est fixe noire — laisse passer */

/* =========================================================
 *  MOUVEMENT 4 — CONSTRUCTION BY SCROLL
 *  Maison architecturale en SVG qui se construit en 5 couches.
 *  Couches : sol → fondations → murs → toit → fenêtre lumineuse.
 *  Position : fixed bottom-left sur la home uniquement.
 * ========================================================= */
.solea-construction {
  position: fixed;
  bottom: clamp(80px, 10vh, 120px);
  left: clamp(20px, 3vw, 48px);
  width: clamp(160px, 18vw, 240px);
  height: clamp(120px, 14vw, 180px);
  z-index: 85;
  pointer-events: none;
  opacity: 0;
  transition: opacity .8s ease;
}
.solea-construction.is-active { opacity: 1; }
.solea-construction svg { width: 100%; height: 100%; overflow: visible; }
.solea-construction .layer {
  fill: none;
  stroke: #f6b72c;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  pathLength: 1;
  filter: drop-shadow(0 0 4px rgba(246, 183, 44, 0.35));
}

@supports (animation-timeline: scroll()) {
  .solea-construction .layer {
    animation: cbsDraw linear;
    animation-timeline: scroll(root);
  }
  .solea-construction .layer-1 { animation-range: 0% 18%; }
  .solea-construction .layer-2 { animation-range: 18% 38%; }
  .solea-construction .layer-3 { animation-range: 38% 60%; }
  .solea-construction .layer-4 { animation-range: 60% 82%; }
  .solea-construction .layer-5 { animation-range: 82% 100%; }
  @keyframes cbsDraw {
    to { stroke-dashoffset: 0; }
  }
}

.solea-construction-label {
  position: absolute;
  bottom: -22px;
  left: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(13, 13, 16, 0.4);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .solea-construction { display: none; }
}

/* =========================================================
 *  MOUVEMENT 5 — STATS SVG CALLIGRAPHIE
 *  Les chiffres dans .fx-stat-num se dessinent en SVG path
 *  comme une signature manuscrite (1.2s, easing artistique).
 *  La classe .calligraphed est ajoutée par JS au scroll-in.
 * ========================================================= */
.fx-stat-num.svg-mode {
  display: inline-block;
  width: 1.4em;
  height: 1em;
  position: relative;
  vertical-align: -0.05em;
}
.fx-stat-num.svg-mode svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.fx-stat-num.svg-mode path {
  fill: none;
  stroke: var(--fx-ink, #0d0d10);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  pathLength: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.fx-stat-num.svg-mode.calligraphed path {
  stroke-dashoffset: 0;
}

/* =========================================================
 *  MOUVEMENT 6 — HOVER SIGNATURE TRACE
 *  Au hover sur cards, un trait or se dessine d'un coin à l'autre.
 *  Path SVG en absolute, anime stroke-dashoffset.
 * ========================================================= */
.fx-trace-target {
  position: relative;
}
.fx-trace-target .fx-trace-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}
.fx-trace-target .fx-trace-path {
  fill: none;
  stroke: #f6b72c;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  pathLength: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.65, 0, 0.35, 1);
  filter: drop-shadow(0 0 4px rgba(246, 183, 44, 0.4));
}
.fx-trace-target:hover .fx-trace-path {
  stroke-dashoffset: 0;
}

/* =========================================================
 *  MOUVEMENT 7 — CURSOR NARRATIF ADAPTATIF
 *  Plus qu'un disque : forme qui change selon contexte hover.
 * ========================================================= */
.solea-cursor-narrative {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  transition:
    width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.3s,
    border-radius 0.35s,
    opacity 0.3s;
  opacity: 0;
}
.solea-cursor-narrative.is-on { opacity: 1; }
.solea-cursor-narrative .ring {
  width: 100%;
  height: 100%;
  border: 1px solid #f6b72c;
  border-radius: 50%;
  background: transparent;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.solea-cursor-narrative .label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 11px;
  color: #f6b72c;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

/* Variants */
.solea-cursor-narrative[data-ctx="default"] .ring { border-color: #f6b72c; }
.solea-cursor-narrative[data-ctx="text"] { width: 2px; height: 24px; }
.solea-cursor-narrative[data-ctx="text"] .ring { border-radius: 0; background: #f6b72c; border-color: transparent; }
.solea-cursor-narrative[data-ctx="link"] { width: 56px; height: 56px; }
.solea-cursor-narrative[data-ctx="link"] .ring { background: rgba(246, 183, 44, 0.12); border-color: rgba(246, 183, 44, 0.5); }
.solea-cursor-narrative[data-ctx="cta"] { width: 72px; height: 72px; }
.solea-cursor-narrative[data-ctx="cta"] .ring { background: #f6b72c; border-color: transparent; }
.solea-cursor-narrative[data-ctx="cta"] .label { opacity: 1; color: #0d0d10; font-style: italic; font-weight: 600; }
.solea-cursor-narrative[data-ctx="image"] { width: 80px; height: 80px; }
.solea-cursor-narrative[data-ctx="image"] .ring { background: rgba(13, 13, 16, 0.6); border-color: transparent; }
.solea-cursor-narrative[data-ctx="image"] .label { opacity: 1; color: #fbf8f2; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; font-style: normal; }
.solea-cursor-narrative[data-ctx="3d"] { width: 64px; height: 64px; }
.solea-cursor-narrative[data-ctx="3d"] .ring {
  border: 1px solid #f6b72c;
  background: transparent;
  border-radius: 4px;
  animation: cursorRotate 3s linear infinite;
}
@keyframes cursorRotate {
  to { transform: rotate(360deg); }
}

@media (pointer: coarse) {
  .solea-cursor-narrative { display: none !important; }
}

/* =========================================================
 *  AMBIANCE GLOBALE — Tempo de respiration
 *  Lente vibration de l'ensemble (0.5% pulse breath sur 8s)
 *  Très subtile, ne touche pas le hero.
 * ========================================================= */
@keyframes soleaBreath {
  0%, 100% { transform: scale(1.0); }
  50%      { transform: scale(1.003); }
}
.fx-num-card,
.fx-product-card,
.fx-trust-card {
  /* Pas de breath ici — réservé aux blocs hero stat */
}
.fx-stat {
  animation: soleaBreath 9s ease-in-out infinite;
}
.fx-stat:nth-child(2) { animation-delay: -3s; }
.fx-stat:nth-child(3) { animation-delay: -6s; }

/* =========================================================
 *  REDUCED MOTION — Tout désactivé
 * ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .solea-intro,
  .solea-cursor-narrative,
  .solea-construction { display: none !important; }
  .hero-luxe-h1.typed .typed-char { opacity: 1 !important; animation: none !important; }
  .hero-luxe-h1.typed .typed-cursor { display: none !important; }
  .fx-stat { animation: none !important; }
}
