/* ============================================
   Animations & 3D : Amelle Sebatrijal
   Extension de style.css
   ============================================ */

/* ---------- Body fade on load ---------- */
html { background: var(--bg); }
body { opacity: 0; transition: opacity .7s cubic-bezier(.22,.61,.36,1); }
body.is-ready { opacity: 1; }

/* ---------- Page transition overlay ---------- */
.page-fade {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .55s cubic-bezier(.55,.05,.4,1);
}
.page-fade.show {
  opacity: 1;
  pointer-events: all;
}

/* ============================================
   Atmosphère thématique (fond animé par page)
   Injectée par atmosphere.js dans .hero / .page-head.
   3 couches : image (Nano Banana) · wash de couleur · grain.
   ============================================ */
.atmos {
  position: absolute;
  inset: 0;
  z-index: 0;            /* derrière .hero-3d (même niveau, injecté avant) */
  overflow: hidden;
  pointer-events: none;
  will-change: transform;
}
.atmos-img,
.atmos-wash,
.atmos-grain {
  position: absolute;
  inset: -15%;           /* overscan : laisse de la marge à la parallaxe / au zoom */
}

/* Couche image : visible seulement quand --page-bg est défini (Phase 2) */
.atmos-img {
  background-image: var(--page-bg, none);
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.4s cubic-bezier(.22,.61,.36,1);
}
.atmos.has-img .atmos-img {
  opacity: .92;
  animation: ken-burns 32s ease-in-out infinite alternate;
}

/* Couche wash : dégradés thématiques qui dérivent en continu */
.atmos-wash {
  background:
    radial-gradient(46% 56% at 78% 26%, color-mix(in oklch, var(--theme-1) 78%, transparent) 0%, transparent 70%),
    radial-gradient(42% 52% at 60% 74%, color-mix(in oklch, var(--theme-3) 62%, transparent) 0%, transparent 72%),
    radial-gradient(58% 64% at 90% 58%, color-mix(in oklch, var(--theme-2) 70%, transparent) 0%, transparent 76%);
  animation: atmos-drift 28s ease-in-out infinite alternate;
  will-change: transform;
}

/* Couche grain : texture fine, casse le côté "plat" */
.atmos-grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: .05;
  mix-blend-mode: multiply;
}

/* Pages à fond fixe (réalisations, actualités, formules) :
   l'image est posée directement sur .page-head (voir style.css).
   On masque la couche d'ambiance animée ET le voile pour garantir la visibilité de la photo. */
body.bg-static .atmos { display: none; }
/* Voile écru léger : rend la photo légèrement transparente tout en gardant le texte lisible */
body.bg-static .page-head::after {
  background: color-mix(in oklch, var(--theme-veil) 38%, transparent);
}

@keyframes atmos-drift {
  0%   { transform: translate3d(-2.5%, -1.5%, 0) scale(1.04); }
  100% { transform: translate3d( 2.5%,  2%,   0) scale(1.12); }
}
@keyframes ken-burns {
  0%   { transform: scale(1.04) translate(0, 0); }
  100% { transform: scale(1.16) translate(-2.5%, -2.5%); }
}

/* ============================================
   Lenis (smooth scroll) — styles recommandés
   ============================================ */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-smooth iframe { pointer-events: none; }

/* ---------- Reveal on scroll ---------- */
.reveal,
.reveal-up,
.reveal-fade {
  opacity: 0;
  transition: opacity .9s cubic-bezier(.22,.61,.36,1),
              transform .9s cubic-bezier(.22,.61,.36,1);
  will-change: transform, opacity;
}
.reveal,
.reveal-up { transform: translateY(28px); }

.reveal.in,
.reveal-up.in,
.reveal-fade.in {
  opacity: 1;
  transform: none;
}

/* Stagger children */
.stagger > * {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .8s cubic-bezier(.22,.61,.36,1),
              transform .8s cubic-bezier(.22,.61,.36,1);
  will-change: transform, opacity;
}
.stagger.in > * { opacity: 1; transform: none; }
.stagger.in > *:nth-child(1) { transition-delay: .03s; }
.stagger.in > *:nth-child(2) { transition-delay: .10s; }
.stagger.in > *:nth-child(3) { transition-delay: .17s; }
.stagger.in > *:nth-child(4) { transition-delay: .24s; }
.stagger.in > *:nth-child(5) { transition-delay: .31s; }
.stagger.in > *:nth-child(6) { transition-delay: .38s; }
.stagger.in > *:nth-child(7) { transition-delay: .45s; }
.stagger.in > *:nth-child(8) { transition-delay: .52s; }
.stagger.in > *:nth-child(9) { transition-delay: .59s; }

/* Line-by-line text reveal (used on h1/h2 split) */
.split-line {
  display: block;
  overflow: hidden;
}
.split-line > .split-inner {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 1s cubic-bezier(.22,.61,.36,1);
  will-change: transform;
}
.split-line.in > .split-inner {
  transform: translateY(0);
}
.split-line:nth-child(2) > .split-inner { transition-delay: .08s; }
.split-line:nth-child(3) > .split-inner { transition-delay: .16s; }
.split-line:nth-child(4) > .split-inner { transition-delay: .24s; }
.split-line:nth-child(5) > .split-inner { transition-delay: .32s; }
.split-line:nth-child(6) > .split-inner { transition-delay: .40s; }

/* ---------- Tilt 3D cards ---------- */
.tilt {
  transform-style: preserve-3d;
  transform: perspective(900px) rotateX(0deg) rotateY(0deg);
  transition: transform .35s cubic-bezier(.22,.61,.36,1),
              box-shadow .35s ease,
              border-color .35s ease;
  will-change: transform;
}
.tilt:hover {
  border-color: oklch(0.76 0.02 75);
  box-shadow:
    0 30px 60px -20px oklch(0.40 0.05 60 / 0.18),
    0 14px 28px -16px oklch(0.40 0.05 60 / 0.12);
}
.tilt > * {
  transform: translateZ(0);
  transition: transform .35s cubic-bezier(.22,.61,.36,1);
}
.tilt:hover > h3,
.tilt:hover > .label,
.tilt:hover > .tag {
  transform: translateZ(22px);
}
.tilt:hover > p,
.tilt:hover > ul {
  transform: translateZ(14px);
}

/* ---------- Hero with 3D canvas ---------- */
.hero {
  position: relative;
  overflow: hidden;
}

.hero-3d {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.4s cubic-bezier(.22,.61,.36,1);
  pointer-events: none;
}
.hero-3d.loaded { opacity: 1; }
.hero-3d canvas { display: block; width: 100%; height: 100%; }

.hero .wrap {
  position: relative;
  z-index: 2;
}

/* Cream fade on right side so text stays legible over 3D + atmosphère */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(100deg,
      var(--theme-veil, var(--bg)) 0%,
      var(--theme-veil, var(--bg)) 44%,
      color-mix(in oklch, var(--theme-veil, var(--bg)) 72%, transparent) 60%,
      color-mix(in oklch, var(--theme-veil, var(--bg)) 22%, transparent) 78%,
      transparent 100%);
}

@media (max-width: 880px) {
  .hero::after {
    background: linear-gradient(180deg,
      var(--theme-veil, var(--bg)) 0%,
      var(--theme-veil, var(--bg)) 55%,
      color-mix(in oklch, var(--theme-veil, var(--bg)) 60%, transparent) 80%,
      transparent 100%);
  }
  .hero-3d { opacity: 0.55; }
  .hero-3d.loaded { opacity: 0.55; }
}

/* ---------- Floating decoration on sub-page heads ---------- */
.page-head {
  position: relative;
  overflow: hidden;
}
.page-head .float-3d {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 50%;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.4s cubic-bezier(.22,.61,.36,1);
  pointer-events: none;
}
.page-head .float-3d.loaded { opacity: 1; }
.page-head .float-3d canvas { display: block; width: 100%; height: 100%; }
.page-head .wrap { position: relative; z-index: 2; }
.page-head::after {
  content: "";
  position: absolute;
  inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(95deg,
    var(--theme-veil, var(--bg)) 0%,
    var(--theme-veil, var(--bg)) 30%,
    color-mix(in oklch, var(--theme-veil, var(--bg)) 50%, transparent) 60%,
    transparent 100%);
}
@media (max-width: 880px) {
  .page-head .float-3d { width: 100%; opacity: 0.35 !important; }
}

/* ---------- Custom cursor halo for desktop ---------- */
@media (hover: hover) and (pointer: fine) {
  .cursor-halo {
    position: fixed;
    top: 0; left: 0;
    width: 36px; height: 36px;
    border-radius: 999px;
    border: 1px solid color-mix(in oklch, var(--accent) 70%, transparent);
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width .25s ease, height .25s ease, border-color .25s ease, background .25s ease;
    mix-blend-mode: multiply;
  }
  .cursor-halo.is-hover {
    width: 64px; height: 64px;
    background: color-mix(in oklch, var(--accent) 14%, transparent);
    border-color: transparent;
  }
}
@media (hover: none), (pointer: coarse) {
  .cursor-halo { display: none; }
}

/* ---------- Hero CTA buttons get a subtle shine ---------- */
.btn {
  position: relative;
  overflow: hidden;
}
.btn::before {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, oklch(1 0 0 / .15), transparent);
  transition: left .7s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.btn:hover::before { left: 100%; }

/* ---------- Soften service grid borders into card-like blocks ---------- */
.service {
  transition: background .4s ease;
}
.service:hover {
  background: color-mix(in oklch, var(--cream) 100%, transparent);
}

/* ---------- Hero stat numbers gentle pulse ---------- */
.stat .num {
  display: inline-block;
  transform-origin: left center;
}

/* ---------- Marquee strip for collaborations (optional decorative) ---------- */
.marquee {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 26px 0;
  margin: 60px 0 0;
}
.marquee-track {
  display: flex;
  gap: 60px;
  white-space: nowrap;
  animation: marq 40s linear infinite;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  font-style: italic;
  color: var(--ink-soft);
}
.marquee-track span { display: inline-flex; align-items: center; gap: 60px; }
.marquee-track span::after {
  content: "✦";
  color: var(--accent);
  font-style: normal;
}
@keyframes marq {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ---------- Header hides on scroll-down ---------- */
.site-header {
  transition: transform .4s cubic-bezier(.22,.61,.36,1),
              background .25s ease,
              border-color .25s ease;
}
.site-header.hide { transform: translateY(-100%); }

/* ---------- Gradient text on em in headings ---------- */
h1 em, h2 em {
  font-style: italic;
  background: linear-gradient(110deg, var(--accent) 0%, color-mix(in oklch, var(--accent) 58%, white) 62%, color-mix(in oklch, var(--accent) 26%, white) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Rotating badge ---------- */
.badge-spin {
  position: absolute;
  top: clamp(60px, 10vw, 110px);
  right: clamp(18px, 5vw, 64px);
  width: clamp(100px, 12vw, 140px);
  height: clamp(100px, 12vw, 140px);
  z-index: 3;
  pointer-events: none;
}
.badge-spin svg {
  width: 100%;
  height: 100%;
  animation: badge-rotate 14s linear infinite;
}
.badge-spin text {
  font-family: var(--mono);
  font-size: 28px;
  fill: var(--accent);
  letter-spacing: 2px;
}
.badge-spin .badge-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  color: var(--accent);
}
@keyframes badge-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@media (max-width: 680px) {
  .badge-spin { display: none; }
}

/* ---------- Marquee keywords strip ---------- */
.kw-strip {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 20px 0;
  margin: 0;
  background: var(--bg);
}
.kw-track {
  display: flex;
  gap: 0;
  white-space: nowrap;
  animation: kw-scroll 15s linear infinite;
  font-family: var(--serif);
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  font-style: italic;
  color: var(--ink-soft);
}
.kw-track span {
  display: inline-flex;
  align-items: center;
  padding: 0 28px;
  gap: 28px;
}
.kw-track .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
@keyframes kw-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
/* Mobile : bande plus courte -> on raccourcit la durée pour garder une vraie vitesse de défilement */
@media (max-width: 760px) {
  .kw-track { animation-duration: 9s; }
}

/* ---------- Stat count-up : chiffre qui grossit à l'entrée ---------- */
.stat .num {
  display: inline-block;
  transform-origin: left center;
  transition: transform .4s cubic-bezier(.22,.61,.36,1);
}
.stats.in .stat .num {
  animation: stat-pop .6s cubic-bezier(.22,.61,.36,1) both;
}
.stats.in .stat:nth-child(2) .num { animation-delay: .12s; }
.stats.in .stat:nth-child(3) .num { animation-delay: .24s; }
@keyframes stat-pop {
  0%   { transform: scale(.7); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Carte univers : accent bar au survol ---------- */
.universe-card {
  position: relative;
  overflow: hidden;
}
.universe-card::before {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), color-mix(in oklch, var(--accent) 45%, white));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .45s cubic-bezier(.22,.61,.36,1);
}
.universe-card:hover::before { transform: scaleX(1); }

/* ---------- Quote card : légère teinte au survol ---------- */
.quote:hover {
  background: oklch(0.97 0.006 75);
}

/* ---------- CTA strip text shimmer ---------- */
.cta-strip h2 em {
  background: linear-gradient(110deg, oklch(0.92 0.02 75) 0%, white 50%, oklch(0.92 0.02 75) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3.5s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% center; }
  to   { background-position: -200% center; }
}

/* ============================================
   Page Social Media : 2 photos fournies en fond
   (avec un peu de transparence + lisibilité)
   ============================================ */

/* La photo remplace la scène 3D dans l'en-tête */
body[data-theme="smm"] .page-head .float-3d { display: none; }

/* Photo 1 (café / dashboard) : plus présente derrière l'en-tête */
body[data-theme="smm"] .atmos.has-img .atmos-img { opacity: .45; }

/* Admin : photo de fond (bureau) en légère transparence */
body[data-theme="admin"] .page-head .float-3d { display: none; }
body[data-theme="admin"] .atmos.has-img .atmos-img { opacity: .72; }
/* Cadrage sur les lunettes + le bloc-notes (partie basse de la photo) */
body[data-theme="admin"] .atmos-img { background-position: center 78%; }

/* SMM utilise désormais le voile uniforme léger commun (voir body.bg-static .page-head::after) */

/* Photo CTA Social Media retirée (à la demande) */

/* ---------- Respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .hero-3d, .page-head .float-3d { display: none; }
  .reveal, .reveal-up, .reveal-fade, .stagger > *,
  .split-line > .split-inner { opacity: 1 !important; transform: none !important; }
  .badge-spin svg { animation: none; }
  .kw-track { animation: none; }
  .stats.in .stat .num { animation: none; }
}
