/*
 * IKTISAR — ANIMATIONS DE L'AVATAR
 * ------------------------------------------------------------------
 * Couleur unique, selon le thème (variable --ikt-av-couleur) :
 *   thèmes sombres (noir, maquette) → or ; thèmes clairs (blanc, beige) → vert du site.
 *
 * Avatar du header (#userAvatar, enveloppé dans .ikt-av) :
 *   1. Le relais  — à chaque changement de menu : la silhouette sort par le
 *                   bas du cercle, revient, le cercle s'allume.
 *   2. Le regard  — au survol : la silhouette se soulève et grandit dans son
 *                   cercle (la capuche dépasse), un anneau + une lueur apparaissent.
 *   3. Le tour    — au clic : l'avatar s'enfonce, se retourne comme une
 *                   pièce, une onde part.
 * Page profil (.profil-user-avatar) : cercle cerclé, au survol un anneau
 * pointillé tourne avec 4 sphères ; au clic « le tour » et de nouvelles sphères
 * et losanges jaillissent (créés par js/avatar-animations.js).
 * Spécification : NewFeatureAvatar (vidéo « L'avatar marron, 3 animations »).
 * Toutes les classes commencent par « ikt-av » : rien d'autre n'est touché.
 */

:where(html.mode-test) body {
  --ikt-av-couleur: var(--accent, #1a5238);
  --ikt-av-rgb: 26, 82, 56;
}
:where(html.mode-test) body.theme-noir {
  --ikt-av-couleur: var(--accent-gold, #b89e14);
  --ikt-av-rgb: 184, 158, 20;
}
:where(html.mode-test) body.theme-maquette {
  --ikt-av-couleur: #c7993f;
  --ikt-av-rgb: 199, 153, 63;
}

/* ---------- Enveloppe du header ---------- */
/* .ikt-av-clip (non animé) découpe la silhouette : le haut reste libre (la capuche peut
   dépasser du cercle au survol), le bas est coupé selon le cercle — sans lui, l'agrandissement
   fait déborder le bas du manteau hors de l'anneau. Demi-cercle bas : rayon horizontal 50 %,
   vertical 31,25 % de la hauteur étendue (160 % du cercle). */
:where(html.mode-test) .ikt-av-clip {
  display: inline-flex;
  position: relative;
  z-index: 1; /* au-dessus de l'anneau (::after) : quand la capuche dépasse en haut, elle passe SUR le trait */
  /* Bas : coupé à l'intérieur de l'anneau (2 px de bordure) pour que le trait reste visible tout autour ;
     haut : ouvert, la tête peut dépasser. 29 % ≈ rayon de l'anneau intérieur / hauteur étendue (160 %). */
  clip-path: inset(-60% 2px 2px 2px round 0 0 50% 50% / 0 0 29% 29%);
}

/* Le disque est porté par l'enveloppe (et non par l'image) : seule la silhouette
   bouge, le cercle reste en place. */
:where(html.mode-test) .ikt-av {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--panel, #fdf9f1);
  transition: box-shadow .35s ease;
}
:where(html.mode-test) .ikt-av img#userAvatar {
  position: relative;
  z-index: 1; /* au-dessus de l'anneau (::after) et de l'onde (::before) : la silhouette qui dépasse le cache */
  background: transparent !important;
  border-color: transparent !important; /* l'anneau est dessiné par ::after */
  transform-origin: 50% 100%;
}
:where(html.mode-test) .ikt-av::after { /* anneau */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color .25s ease;
}
:where(html.mode-test) .ikt-av::before { /* onde du « tour » */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ikt-av-couleur);
  opacity: 0;
  pointer-events: none;
}

/* 1. Le relais */
:where(html.mode-test) .ikt-av.is-relais { overflow: hidden; }
:where(html.mode-test) .ikt-av.is-relais img { animation: ikt-av-relais-img .9s both; }
:where(html.mode-test) .ikt-av.is-relais::after { animation: ikt-av-relais-cercle .9s both; }
@keyframes ikt-av-relais-img {
  0%   { transform: translateY(0); animation-timing-function: cubic-bezier(.5, 0, .9, .5); }
  34%  { transform: translateY(112%); }
  42%  { transform: translateY(112%); animation-timing-function: cubic-bezier(.2, .8, .3, 1.1); }
  80%, 100% { transform: translateY(0); }
}
@keyframes ikt-av-relais-cercle {
  0%   { border-color: transparent; }
  42%, 80% { border-color: var(--ikt-av-couleur); box-shadow: 0 0 10px rgba(var(--ikt-av-rgb), .6); }
  100% { border-color: transparent; box-shadow: 0 0 0 rgba(var(--ikt-av-rgb), 0); }
}

/* 2. Le regard (survol réel uniquement : pas de survol collant au tactile) */
@media (hover: hover) {
  :where(html.mode-test) .ikt-av:not(.is-relais):not(.is-tour) img { transition: transform .35s cubic-bezier(.2, .8, .3, 1.2); }
  :where(html.mode-test) .auth-dropdown-trigger:hover .ikt-av:not(.is-relais):not(.is-tour) { box-shadow: 0 0 12px rgba(var(--ikt-av-rgb), .55); }
  :where(html.mode-test) .auth-dropdown-trigger:hover .ikt-av:not(.is-relais):not(.is-tour)::after { border-color: var(--ikt-av-couleur); }
  :where(html.mode-test) .auth-dropdown-trigger:hover .ikt-av:not(.is-relais):not(.is-tour) img { transform: scale(1.2); }
}

/* 3. Le tour */
:where(html.mode-test) .ikt-av.is-tour img { animation: ikt-av-tour .75s both; }

@keyframes ikt-av-tour {
  0%   { transform: perspective(260px) scale(1) rotateY(0); animation-timing-function: ease-in; }
  18%  { transform: perspective(260px) scale(1.06) rotateY(0); animation-timing-function: cubic-bezier(.3, 0, .25, 1); }
  75%  { transform: perspective(260px) scale(1.06) rotateY(360deg); }
  100% { transform: perspective(260px) scale(1) rotateY(360deg); }
}
@keyframes ikt-av-onde {
  0%   { opacity: .7; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.9); }
}

/* ---------- Page profil : « Les mêmes, en or » ---------- */
/* Une seule couleur selon le thème : on neutralise les bordures hover du site
   (vert / or) qui se mélangeraient avec elle. */
:where(html.mode-test) body .profil-user-avatar,
:where(html.mode-test) body .profil-user-avatar:hover { border-color: var(--ikt-av-couleur) !important; }

:where(html.mode-test) .ikt-av-orbite { /* anneau pointillé + 4 sphères, créé par le JS */
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px dotted var(--ikt-av-couleur);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
:where(html.mode-test) .ikt-av-orbite i { position: absolute; inset: 0; transform: rotate(var(--a)); }
:where(html.mode-test) .ikt-av-orbite i::before { /* la sphère, posée sur l'anneau */
  content: '';
  position: absolute;
  left: 50%;
  top: -3px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--ikt-av-couleur);
  box-shadow: 0 0 6px rgba(var(--ikt-av-rgb), .8);
}
:where(html.mode-test) .ikt-av-orbite i:nth-child(even)::before { width: 5px; height: 5px; margin-left: -2.5px; top: -1.5px; }
@media (hover: hover) {
  :where(html.mode-test) .profil-user-avatar:hover > .ikt-av-orbite { opacity: 1; animation: ikt-av-anneau 8s linear infinite; }
}
@keyframes ikt-av-anneau { to { transform: rotate(360deg); } }
/* Tactile : pas de survol, l'anneau apparaît le temps du clic. */
:where(html.mode-test) .profil-user-avatar.is-orbite > .ikt-av-orbite, :where(html.mode-test) .profil-user-avatar.is-tour > .ikt-av-orbite { opacity: 1; animation: ikt-av-anneau 8s linear infinite; }
/* (is-orbite : même effet pour l'avatar personnalisé, dont le clic est animé par « Le tour » du lot) */
:where(html.mode-test) .profil-user-avatar.is-orbite > .ikt-av-orbite i::before, :where(html.mode-test) .profil-user-avatar.is-tour > .ikt-av-orbite i::before { animation: ikt-av-sphere-pulse .8s ease-out; }
@keyframes ikt-av-sphere-pulse {
  0%, 100% { transform: scale(1); }
  35%      { transform: scale(2); }
}

/* Particules du clic (créées par le JS, retirées en fin d'animation) */
:where(html.mode-test) .ikt-av-particule {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--ikt-av-couleur);
  box-shadow: 0 0 6px rgba(var(--ikt-av-rgb), .7);
  pointer-events: none;
  animation: ikt-av-jaillit .85s cubic-bezier(.15, .7, .3, 1) both;
}
:where(html.mode-test) .ikt-av-particule--sphere { border-radius: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; }
:where(html.mode-test) .ikt-av-particule--losange { transform: rotate(45deg); }
@keyframes ikt-av-jaillit {
  0%   { opacity: 1; translate: 0 0; scale: .4; }
  100% { opacity: 0; translate: var(--dx) var(--dy); scale: 1; }
}

/* ---------- Avatar personnalisé (lib/avatar-config.js, classes .ikt-avc*) ---------- */
/* Mêmes trois animations que l'avatar numéroté, appliquées à la silhouette (.ikt-avc-img, qui reste dans son disque)
   et au contour (.ikt-avc-contour). Le cercle gris et son anneau du header sont remplacés par le contour choisi. */
:where(html.mode-test) .ikt-av.ikt-av--custom { background: transparent; border-radius: 0; overflow: visible; }
:where(html.mode-test) .ikt-av--custom .ikt-av-clip { clip-path: none; }
:where(html.mode-test) .ikt-av--custom::after { display: none; }
:where(html.mode-test) .ikt-av--custom .ikt-avc-host { display: inline-flex; line-height: 0; }
:where(html.mode-test) .ikt-av--custom .ikt-avc-img { transform-origin: 50% 100%; }
/* Au repos : exactement le rendu de l'éditeur (le disque est un cercle, la silhouette y reste entière, le contour passe par-dessus ; rien ne dépasse).
   Au survol seulement : la silhouette grandit, la capuche dépasse en HAUT par-dessus le contour ; le bas et les côtés restent coupés selon un cercle un peu
   à l'intérieur du contour (rayon 45,5 sur 47), le BAS ne dépasse jamais. Le fond est un disque à part (::before) qui va jusqu'au contour dans les deux états.
   Haut étendu de 60 % (hauteur coupée ≈ 158 % du disque) : rayon vertical du bas = 48,4 / 158,4 = 30,56 %. */
:where(html.mode-test) .ikt-av--custom .ikt-avc-disc,
:where(html.mode-test) .profil-user-avatar--custom .ikt-avc-disc {
  overflow: visible;
  clip-path: inset(0 round 50%);
  transition: clip-path .35s cubic-bezier(.2, .8, .3, 1.2);
}
:where(html.mode-test) .ikt-av--custom .ikt-avc-contour,
:where(html.mode-test) .profil-user-avatar--custom .ikt-avc-contour { clip-path: inset(-30% -30% -30% -30%); transition: clip-path .35s cubic-bezier(.2, .8, .3, 1.2); }
:where(html.mode-test) .ikt-av--custom .ikt-avc-flip::before,
:where(html.mode-test) .profil-user-avatar--custom .ikt-avc-flip::before { content: ''; position: absolute; inset: 3%; border-radius: 50%; background-color: var(--ikt-avc-fond); z-index: 0; }

/* Le contour passe SOUS la silhouette : quand la capuche dépasse en haut, elle recouvre le trait ; en bas, le disque reste coupé. */
:where(html.mode-test) .ikt-av--custom .ikt-avc-contour,
:where(html.mode-test) .profil-user-avatar--custom .ikt-avc-contour { z-index: 1; }

/* 1. Le relais : la silhouette sort par le bas du disque et revient, le contour s'allume. */
:where(html.mode-test) .ikt-av.ikt-av--custom.is-relais { overflow: visible; }
:where(html.mode-test) .ikt-av--custom.is-relais .ikt-avc-img { animation: ikt-av-relais-img .9s both; }
:where(html.mode-test) .ikt-av--custom.is-relais .ikt-avc-contour { animation: ikt-avc-halo .9s both; }
@keyframes ikt-avc-halo {
  0%, 100% { filter: none; }
  42%, 80% { filter: drop-shadow(0 0 4px rgba(var(--ikt-av-rgb), .85)); }
}

/* 2. Survol de l'avatar personnalisé du header : « Le salut » du lot livré (section en fin de fichier). L'ancien « regard » (silhouette agrandie) est retiré ;
   seule la lueur rectangulaire de l'enveloppe reste neutralisée (le contour choisi a sa propre forme). */
@media (hover: hover) {
  :where(html.mode-test) .auth-dropdown-trigger:hover .ikt-av.ikt-av--custom:not(.is-relais):not(.is-tour) { box-shadow: none; }
}

/* 3. Le tour : tout l'avatar (disque et contour) change en fondu léger. */
:where(html.mode-test) .ikt-av--custom.is-tour .ikt-avc-flip { animation: ikt-av-tour .75s both; }

/* Page profil : le contour choisi remplace le cercle et l'anneau ; l'orbite des sphères l'entoure à distance. */
:where(html.mode-test) body .profil-user-avatar.profil-user-avatar--custom,
:where(html.mode-test) body .profil-user-avatar.profil-user-avatar--custom:hover { border-color: transparent !important; background: transparent; overflow: visible; }
:where(html.mode-test) .profil-user-avatar--custom .ikt-avc-host {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  line-height: 0;
  pointer-events: none;
}
:where(html.mode-test) .profil-user-avatar--custom > .ikt-av-orbite { inset: -22px; }
:where(html.mode-test) .profil-user-avatar--custom.is-tour .ikt-avc-flip { animation: ikt-av-tour .75s both; }
:where(html.mode-test) .profil-user-avatar--custom .ikt-avc-img { transition: transform .35s cubic-bezier(.2, .8, .3, 1.2); transform-origin: 50% 100%; }
/* Accessibilité : avatar fixe si l'utilisateur a demandé moins de mouvement. */
@media (prefers-reduced-motion: reduce) {
  :where(html.mode-test) .ikt-av,
:where(html.mode-test) .ikt-av img,
:where(html.mode-test) .ikt-av::before,
:where(html.mode-test) .ikt-av::after,
:where(html.mode-test) .profil-user-avatar img,
:where(html.mode-test) .ikt-av-orbite,
:where(html.mode-test) .ikt-av-orbite i::before,
:where(html.mode-test) .ikt-av-particule,
:where(html.mode-test) .ikt-avc-img,
:where(html.mode-test) .ikt-avc-flip,
:where(html.mode-test) .ikt-avc-contour {
    animation: none !important;
    transition: none !important;
  }
  :where(html.mode-test) .ikt-av-particule { display: none; }
  :where(html.mode-test) .auth-dropdown-trigger:hover .ikt-av img,
:where(html.mode-test) .ikt-avc-img { transform: none !important; }
}

/* ---------- Logo du header : « le point qui saute » ---------- */
/* Animation reprise de NewFeatureAvatar/animation-logo (une fois, au survol). */
:where(html.mode-test) .ikt-logo { position: relative; display: block; line-height: 0; z-index: 2; }
:where(html.mode-test) .ikt-logo-point {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
:where(html.mode-test) .ikt-logo-point path { fill: #b89e14; }
:where(html.mode-test) .ikt-logo-point .ikt-point-onde { stroke: #b89e14; }
:where(html.mode-test) body.theme-noir .ikt-logo-point path { fill: var(--accent-gold); }
:where(html.mode-test) body.theme-noir .ikt-logo-point .ikt-point-onde { stroke: var(--accent-gold); }
:where(html.mode-test) body.theme-maquette .ikt-logo-point path { fill: #C7993F; }
:where(html.mode-test) body.theme-maquette .ikt-logo-point .ikt-point-onde { stroke: #C7993F; }

:where(html.mode-test) .ikt-point-saut,
:where(html.mode-test) .ikt-point-ecrase { transform-box: fill-box; transform-origin: 50% 100%; }
:where(html.mode-test) .ikt-point-tour,
:where(html.mode-test) .ikt-point-onde { transform-box: fill-box; transform-origin: 50% 50%; }
:where(html.mode-test) .ikt-point-onde { opacity: 0; }

/* Mode 1 : en boucle */
:where(html.mode-test) .ikt-point-saute .ikt-point-saut { animation: ikt-point-saut 3.2s infinite; }
:where(html.mode-test) .ikt-point-saute .ikt-point-ecrase { animation: ikt-point-ecrase 3.2s infinite; }
:where(html.mode-test) .ikt-point-saute .ikt-point-tour { animation: ikt-point-tour 3.2s infinite; }
:where(html.mode-test) .ikt-point-saute .ikt-point-onde { animation: ikt-point-onde 3.2s infinite; }

/* Mode 2 : une fois, au survol (l'élan démarre tout de suite) */
:where(html.mode-test) .ikt-point-saute-survol.is-saute .ikt-point-saut { animation: ikt-point-saut 3.2s -.35s 1 both; }
:where(html.mode-test) .ikt-point-saute-survol.is-saute .ikt-point-ecrase { animation: ikt-point-ecrase 3.2s -.35s 1 both; }
:where(html.mode-test) .ikt-point-saute-survol.is-saute .ikt-point-tour { animation: ikt-point-tour 3.2s -.35s 1 both; }
:where(html.mode-test) .ikt-point-saute-survol.is-saute .ikt-point-onde { animation: ikt-point-onde 3.2s -.35s 1 both; }

@keyframes ikt-point-saut {
  0%, 22% { transform: translateY(0); animation-timing-function: cubic-bezier(.2, .75, .35, 1); }
  42%     { transform: translateY(-118px); animation-timing-function: cubic-bezier(.55, 0, .8, .45); }
  58%     { transform: translateY(0); animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  65%     { transform: translateY(-16px); animation-timing-function: cubic-bezier(.5, 0, .8, .5); }
  71%, 100% { transform: translateY(0); }
}
@keyframes ikt-point-ecrase {
  0%, 12% { transform: scale(1, 1); }
  19%     { transform: scale(1.14, .8); }
  25%     { transform: scale(.92, 1.1); }
  34%, 56% { transform: scale(1, 1); }
  60%     { transform: scale(1.16, .8); }
  66%     { transform: scale(.96, 1.05); }
  72%, 100% { transform: scale(1, 1); }
}
@keyframes ikt-point-tour {
  0%, 22% { transform: rotate(0deg); animation-timing-function: cubic-bezier(.3, 0, .25, 1); }
  56%, 100% { transform: rotate(180deg); }
}
@keyframes ikt-point-onde {
  0%, 57% { opacity: 0; transform: scale(.55); }
  59%     { opacity: .55; transform: scale(.7); }
  80%, 100% { opacity: 0; transform: scale(1.9); }
}

/* Accessibilité : logo fixe si l'utilisateur a demandé moins de mouvement. */
@media (prefers-reduced-motion: reduce) {
  :where(html.mode-test) .ikt-point-saut,
:where(html.mode-test) .ikt-point-ecrase,
:where(html.mode-test) .ikt-point-tour,
:where(html.mode-test) .ikt-point-onde { animation: none !important; }
}

/* ---------- Lot « animations de l'avatar » (NewFeatureAvatarAnimations/, js/avatar-anim-lot.js) ---------- */
/* Calques d'effet ajoutés par le JS au premier appel (lueur, arche, éclats, sceau, trait d'encre, onde) ; invisibles au repos. */
:where(html.mode-test) .ikt-avc-ring, :where(html.mode-test) .ikt-avc-fx-burst, :where(html.mode-test) .ikt-avc-fx-seal, :where(html.mode-test) .ikt-avc-fx-tip, :where(html.mode-test) .ikt-avc-fx-pulse { transform-box: view-box; transform-origin: 50px 50px; }
:where(html.mode-test) .ikt-avc-flip, :where(html.mode-test) .ikt-avc-disc { transform-origin: 50% 50%; }
:where(html.mode-test) .ikt-avc-fx { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 3; }
:where(html.mode-test) .ikt-avc-glow { position: absolute; inset: -20%; border-radius: 50%; background: radial-gradient(closest-side, rgba(226, 196, 126, .42), rgba(226, 196, 126, 0)); opacity: 0; pointer-events: none; }
:where(html.mode-test) .ikt-avc-arch { position: absolute; left: 6%; right: 6%; top: -20%; bottom: 4%; border-radius: 50% 50% 12% 12% / 46% 46% 12% 12%; background: radial-gradient(ellipse at 50% 30%, rgba(226, 196, 126, .55), rgba(226, 196, 126, 0) 70%); opacity: 0; pointer-events: none; }
:where(html.mode-test) .ikt-av--custom .ikt-avc, :where(html.mode-test) .profil-user-avatar--custom .ikt-avc { overflow: visible; }
@media (prefers-reduced-motion: reduce) {
  :where(html.mode-test) .ikt-avc-fx *, :where(html.mode-test) .ikt-avc-glow, :where(html.mode-test) .ikt-avc-arch { animation: none !important; transition: none !important; }
}

:where(html.mode-test) .ikt-avc-attente { visibility: hidden; } /* avant « L'éveil » : l'avatar n'est pas encore montré */

/* « Le salut » (survol de l'avatar de l'en-tête et de la page profil) : classe ikt-av-survol sur le lien qui contient l'avatar ; is-survol produit le même effet depuis le code. */
:where(html.mode-test) .ikt-av-survol .ikt-avc-ring { transition: transform .9s cubic-bezier(.3, 1.3, .5, 1); }
:where(html.mode-test) .ikt-av-survol .ikt-avc-flip { transition: transform .4s cubic-bezier(.3, 1.6, .5, 1); }
:where(html.mode-test) .ikt-av-survol .ikt-avc-glow { transition: opacity .35s; }
@media (hover: hover) {
  :where(html.mode-test) .ikt-av-survol:hover .ikt-avc-ring, :where(html.mode-test) .ikt-av-survol:focus-visible .ikt-avc-ring, :where(html.mode-test) .ikt-av-survol.is-survol .ikt-avc-ring { transform: rotate(180deg); }
  :where(html.mode-test) .ikt-av-survol:hover .ikt-avc-flip, :where(html.mode-test) .ikt-av-survol:focus-visible .ikt-avc-flip, :where(html.mode-test) .ikt-av-survol.is-survol .ikt-avc-flip { transform: translateY(-2px) scale(1.07); }
  :where(html.mode-test) .ikt-av-survol:hover .ikt-avc-glow, :where(html.mode-test) .ikt-av-survol:focus-visible .ikt-avc-glow, :where(html.mode-test) .ikt-av-survol.is-survol .ikt-avc-glow { opacity: 1; }
}
