/* Figurines (figurines.js) : portraits peints dans un cadre de tarot. Tout est préfixé fig- ;
   couleurs de style.css (:root) avec valeurs de repli. Les huiles (classes) et les gravures (boss)
   sont accordées ici : sépia, contraste, teinte, vignettage, une seule lumière venue d'en haut à gauche.
   L'attente vit sur les enfants (.fig-cadre, .fig-img…) : les mises en scène animent .fig sans conflit. */

.fig {
  --fig-or: var(--serment, #F0D9A0);
  --fig-lisere: rgba(240, 217, 160, .78);
  --fig-filet: rgba(240, 217, 160, .32);
  --fig-lumiere: rgba(255, 231, 168, .30);
  --fig-braise: #FFD58A;
  display: inline-block; position: relative; vertical-align: bottom; line-height: 0;
  width: var(--fig-w, 72px); height: var(--fig-h, 96px);
}
.fig-rang-boss {
  --fig-lisere: rgba(200, 66, 58, .85);
  --fig-filet: rgba(240, 217, 160, .30);
  --fig-lumiere: rgba(200, 66, 58, .34);
  --fig-braise: #E9783A;
}
.fig-rang-calamite {
  --fig-lisere: rgba(199, 123, 192, .85);
  --fig-filet: rgba(240, 217, 160, .30);
  --fig-lumiere: rgba(199, 123, 192, .36);
  --fig-braise: #D07BC8;
}

/* ——— Le cadre : liseré d'or, passe-partout d'encre, filet extérieur, coins de tarot ——— */
.fig-cadre {
  position: absolute; inset: 0; overflow: hidden; border-radius: 3px;
  background: #0B0809;
  box-shadow:
    0 0 0 1px var(--fig-lisere),
    0 0 0 3px #140D10,
    0 0 0 4px var(--fig-filet),
    0 12px 26px -8px rgba(0, 0, 0, .85);
  transform-origin: 50% 100%;
  animation: fig-respire 6.4s ease-in-out var(--fig-d, 0s) infinite;
}
/* Coins du tarot, filet intérieur */
.fig-cadre::before, .fig-cadre::after { content: ""; position: absolute; pointer-events: none; z-index: 3; }
.fig-cadre::after { inset: 3.5%; border: 1px solid var(--fig-filet); border-radius: 2px; }
.fig-cadre::before {
  inset: 2%;
  --c: var(--fig-lisere); --l: 16%; --e: 2px;
  background:
    linear-gradient(var(--c), var(--c)) left top / var(--l) var(--e),
    linear-gradient(var(--c), var(--c)) left top / var(--e) calc(var(--l) * .75),
    linear-gradient(var(--c), var(--c)) right top / var(--l) var(--e),
    linear-gradient(var(--c), var(--c)) right top / var(--e) calc(var(--l) * .75),
    linear-gradient(var(--c), var(--c)) left bottom / var(--l) var(--e),
    linear-gradient(var(--c), var(--c)) left bottom / var(--e) calc(var(--l) * .75),
    linear-gradient(var(--c), var(--c)) right bottom / var(--l) var(--e),
    linear-gradient(var(--c), var(--c)) right bottom / var(--e) calc(var(--l) * .75);
  background-repeat: no-repeat;
}

/* ——— La toile ——— */
.fig-img {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: 50% 28%;
  outline: 1px solid rgba(255, 255, 255, .08); outline-offset: -1px;
  user-select: none; -webkit-user-drag: none;
  /* Huiles : on tire vers la patine d'un vieux vernis */
  filter: sepia(.24) saturate(.84) contrast(1.06) brightness(.9);
  transform-origin: 50% 32%;
  animation: fig-kenburns 22s ease-in-out var(--fig-d, 0s) infinite alternate;
  will-change: transform;
}
/* Gravures : le papier blanc devient un parchemin sombre */
.fig-rang-boss .fig-img, .fig-rang-calamite .fig-img {
  filter: grayscale(1) sepia(.6) contrast(1.38) brightness(.74);
}
.fig-neutre .fig-img { object-position: 50% 40%; filter: sepia(.32) saturate(.7) contrast(1.08) brightness(.86); }

/* Teinte d'accord + vignettage (au-dessus de la toile) */
.fig-teinte {
  position: absolute; inset: 0; pointer-events: none; /* pas de z-index : la teinte (::before) doit se fondre dans la toile */
  background:
    radial-gradient(ellipse 80% 72% at 50% 40%, transparent 48%, rgba(8, 5, 6, .78) 100%),
    linear-gradient(to top, rgba(8, 5, 6, .62), transparent 34%);
}
.fig-rang-boss .fig-teinte::before, .fig-rang-calamite .fig-teinte::before {
  content: ""; position: absolute; inset: 0; mix-blend-mode: multiply;
  background: linear-gradient(165deg, #F4DDB4 0%, #D9A07A 45%, #8E2E2A 100%);
}
.fig-rang-calamite .fig-teinte::before { background: linear-gradient(165deg, #E8D3C4 0%, #B985A9 45%, #4A1A45 100%); }

/* Une seule lumière : d'or en haut à gauche pour les héros, braise par en dessous pour les boss */
.fig-reflet {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(ellipse 70% 50% at 18% 8%, var(--fig-lumiere), transparent 70%);
  animation: fig-pulse 4.8s ease-in-out var(--fig-d, 0s) infinite;
}
.fig-rang-boss .fig-reflet, .fig-rang-calamite .fig-reflet {
  background: radial-gradient(ellipse 85% 45% at 50% 104%, var(--fig-lumiere), transparent 72%);
}

/* Poussière d'or, braises ou spores qui montent dans la lumière */
.fig-poussiere { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.fig-poussiere i {
  position: absolute; bottom: 6%; width: 3px; height: 3px; border-radius: 50%; opacity: 0;
  background: var(--fig-braise); box-shadow: 0 0 6px var(--fig-braise);
  animation: fig-monte 7s ease-out infinite;
  will-change: transform, opacity;
}
.fig-poussiere i:nth-child(1) { left: 18%; animation-delay: calc(var(--fig-d, 0s) - .4s); }
.fig-poussiere i:nth-child(2) { left: 46%; animation-delay: calc(var(--fig-d, 0s) - 2.6s); animation-duration: 8.2s; width: 2px; height: 2px; }
.fig-poussiere i:nth-child(3) { left: 70%; animation-delay: calc(var(--fig-d, 0s) - 4.4s); animation-duration: 6.4s; }
.fig-poussiere i:nth-child(4) { left: 84%; animation-delay: calc(var(--fig-d, 0s) - 1.2s); animation-duration: 9s; width: 2px; height: 2px; }
.fig-poussiere i:nth-child(5) { left: 30%; animation-delay: calc(var(--fig-d, 0s) - 5.6s); animation-duration: 7.6s; }
.fig-poussiere i:nth-child(6) { left: 58%; animation-delay: calc(var(--fig-d, 0s) - 3.4s); animation-duration: 8.8s; width: 2px; height: 2px; }
.fig-poussiere i:nth-child(7) { left: 8%; animation-delay: calc(var(--fig-d, 0s) - 6.2s); animation-duration: 6.8s; }

/* Monstre sans portrait : médaillon d'encre, deux yeux de braise */
.fig-img--vide {
  background:
    radial-gradient(ellipse 50% 40% at 50% 45%, rgba(158, 42, 43, .38), transparent 70%),
    repeating-linear-gradient(115deg, rgba(0, 0, 0, .4) 0 1px, transparent 1px 4px),
    radial-gradient(ellipse 70% 80% at 50% 40%, #2A171B, #0B0809 75%);
  animation: none;
}
.fig-yeux {
  position: absolute; left: 50%; top: 40%; width: 34%; height: 8%; transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 22% 50%, #FFE7A8 0 6%, #E9783A 14%, rgba(200, 66, 58, 0) 34%),
    radial-gradient(circle at 78% 50%, #FFE7A8 0 6%, #E9783A 14%, rgba(200, 66, 58, 0) 34%);
  animation: fig-pulse 3.2s ease-in-out infinite;
}

/* Petites tailles (en-tête, bande des joueurs) : cadre allégé, pas de Ken Burns */
.fig-petit .fig-cadre { box-shadow: 0 0 0 1px var(--fig-lisere), 0 0 0 2px #140D10, 0 6px 12px -4px rgba(0, 0, 0, .8); border-radius: 2px; }
.fig-petit .fig-cadre::before { --e: 1px; inset: 4%; }
.fig-petit .fig-cadre::after { display: none; }
.fig-petit .fig-img { animation: none; transform: scale(1.04); }

/* ——— Attente ——— */
@keyframes fig-respire {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  30% { transform: translateY(-.8%) rotate(.35deg) scale(1.008); }
  65% { transform: translateY(-.3%) rotate(-.3deg) scale(1.012); }
}
@keyframes fig-kenburns {
  from { transform: scale(1.05) translate(0, 0); }
  to { transform: scale(1.13) translate(-2%, -1.5%); }
}
@keyframes fig-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes fig-monte {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  15% { opacity: .95; }
  70% { opacity: .6; }
  100% { transform: translate(10px, calc(var(--fig-h, 96px) * -.7)) scale(.4); opacity: 0; }
}

.fig.fig-fige *, .fig-fige *, .fig-fige *::before { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .fig *, .fig *::before { animation: none !important; }
  .fig-poussiere { display: none; }
}
:root[data-anim-reduite="1"] .fig *, :root[data-anim-reduite="1"] .fig *::before { animation: none !important; }
:root[data-anim-reduite="1"] .fig-poussiere { display: none; }

/* ——— Mises en scène (transformation, apparition) ——— */
.fig-scene { position: relative; display: inline-grid; vertical-align: bottom; line-height: 0; pointer-events: none; }
.fig-scene > .fig, .fig-scene > .fig-lambeaux { grid-area: 1 / 1; justify-self: center; align-self: end; will-change: transform, opacity; }
.fig-silhouette { filter: drop-shadow(0 0 10px rgba(200, 66, 58, .8)); }
.fig-silhouette .fig-cadre { filter: brightness(0); }
.fig-scene--calamite .fig-silhouette { filter: drop-shadow(0 0 14px rgba(199, 123, 192, .85)); }

/* Le voyageur se consume : lambeaux de toile, bord de braise */
.fig-lambeaux { position: relative; display: block; opacity: 0; z-index: 2; }
.fig-lambeau {
  position: absolute; display: block; overflow: hidden;
  background-image: url("/portraits/neutre.jpg"); background-repeat: no-repeat;
  filter: sepia(.32) saturate(.7) contrast(1.08) brightness(.86);
  will-change: transform, opacity;
}
.fig-lambeau > i {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse 70% 70% at 50% 100%, rgba(255, 214, 140, .95), rgba(233, 120, 58, .8) 35%, rgba(40, 10, 6, .9) 80%);
  mix-blend-mode: hard-light;
}
.fig-couche.fig-front {
  inset: auto -8%; top: 46%; height: 12%; z-index: 3; mix-blend-mode: screen;
  background: linear-gradient(to bottom, transparent, rgba(233, 120, 58, .35) 30%, rgba(255, 240, 200, .95) 50%, rgba(233, 120, 58, .5) 64%, transparent);
  filter: blur(1.5px);
}

.fig-couche { position: absolute; inset: 0; pointer-events: none; opacity: 0; will-change: transform, opacity; }
.fig-eclat {
  inset: -30% -40%; mix-blend-mode: screen;
  background: radial-gradient(ellipse 40% 45% at 50% 55%, rgba(255, 240, 200, .75), rgba(240, 217, 160, .25) 45%, transparent 70%);
}
.fig-eclat--fort { z-index: 4; background: radial-gradient(ellipse 34% 40% at 50% 50%, rgba(255, 255, 255, .95), rgba(255, 231, 168, .55) 35%, transparent 70%); }
.fig-eclat-sang {
  inset: -25% -35%; z-index: 4; mix-blend-mode: screen;
  background: radial-gradient(ellipse 42% 46% at 50% 55%, rgba(255, 220, 200, .7), rgba(200, 66, 58, .55) 35%, transparent 70%);
}
.fig-eclat-sang--calamite { background: radial-gradient(ellipse 42% 46% at 50% 55%, rgba(255, 220, 240, .7), rgba(199, 123, 192, .6) 35%, transparent 70%); }
.fig-rayon {
  left: 34%; right: 34%; top: -80%; bottom: 0; z-index: 4; transform-origin: 50% 0%; mix-blend-mode: screen;
  background: linear-gradient(to bottom, rgba(255, 231, 168, 0), rgba(255, 231, 168, .75) 55%, rgba(255, 255, 255, .95) 85%, rgba(255, 231, 168, 0));
  -webkit-mask: linear-gradient(to right, transparent, #000 35%, #000 65%, transparent);
  mask: linear-gradient(to right, transparent, #000 35%, #000 65%, transparent);
}
.fig-p { position: absolute; z-index: 5; border-radius: 50%; opacity: 0; pointer-events: none; will-change: transform, opacity; }
.fig-p-or { background: radial-gradient(circle, #FFF6DC 0 30%, var(--serment, #F0D9A0) 55%, rgba(240, 217, 160, 0) 75%); box-shadow: 0 0 6px rgba(255, 231, 168, .7); }
.fig-p-cendre { background: radial-gradient(circle, #8E7F80 0 40%, rgba(107, 91, 94, 0) 75%); }
.fig-p-braise { background: radial-gradient(circle, #FFE7A8 0 25%, #E9783A 55%, rgba(200, 66, 58, 0) 75%); box-shadow: 0 0 6px rgba(233, 120, 58, .8); }
.fig-titre {
  position: absolute; left: 50%; top: calc(100% + 10px); z-index: 5; white-space: nowrap; opacity: 0; line-height: 1.1;
  font: italic 600 clamp(1rem, 2.4vw, 1.5rem) var(--titre, "Cormorant Garamond", Georgia, serif);
  color: var(--serment, #F0D9A0); text-shadow: 0 0 .6em rgba(240, 217, 160, .45), 0 2px 0 rgba(0, 0, 0, .8);
}
.fig-ombre-sol {
  inset: auto -20% -6% -20%; height: 16%; transform-origin: 50% 50%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(0, 0, 0, .95), rgba(30, 6, 8, .6) 55%, transparent 75%);
}
.fig-voile { inset: -25% -40%; background: radial-gradient(ellipse 50% 50% at 50% 70%, rgba(158, 42, 43, .42), rgba(58, 20, 56, .22) 50%, transparent 72%); }
.fig-voile--calamite { background: radial-gradient(ellipse 52% 52% at 50% 65%, rgba(158, 42, 43, .5), rgba(122, 46, 110, .36) 50%, transparent 74%); }
.fig-onde {
  inset: auto auto -4% 50%; width: 130%; height: 12%; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--sang, #C8423A) 85%, transparent);
  box-shadow: 0 0 10px rgba(200, 66, 58, .5);
}

/* iPhone / iPad (Safari) : une image filtrée sous un calque en « multiply » ou « screen » peut sortir noire ou vide.
   Sur iOS seulement, la teinte et la lumière passent par des calques translucides ordinaires. */
@supports (-webkit-touch-callout: none) {
  .fig-rang-boss .fig-teinte::before, .fig-rang-calamite .fig-teinte::before { mix-blend-mode: normal; opacity: .32; }
  .fig-reflet { mix-blend-mode: normal; opacity: .5; }
  .fig-img { will-change: auto; }
}
