/* ==========================================================================
   KMG Agencement — VORTEX AVANT / APRÈS (module réutilisable)
   Styles repris de css/realisations.css + realisations/realisation.php
   (panel-before/after, vortex-overlay, spiral, glow, ray, particle, labels,
   golden-frame, animations vortex-reveal / vortex-hide,
   variante iOS). Seul l'encadrement est harmonisé avec la charte (or + anthracite).
   Toutes les règles sont limitées au conteneur .kv.
   ========================================================================== */

.kv {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  background: #1f1e1c;
  border: 2px solid #f0d57f;
  box-shadow:
    0 0 0 1px rgba(255, 248, 220, .45),
    0 0 14px 2px rgba(255, 235, 164, .45),
    0 0 46px 8px rgba(232, 204, 128, .22),
    0 30px 60px rgba(8, 8, 7, .55);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Images ---------- */
.kv .panel-images {
  position: absolute;
  inset: 0;
}
.kv .panel-before,
.kv .panel-after {
  position: absolute;
  inset: 0;
  background-size: contain;
  background-color: #1f1e1c;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity .5s ease;
}
.kv .panel-before { z-index: 2; }
.kv .panel-after  { z-index: 1; }

/* Vidéos intégrales et centrées sur un fond anthracite. */
.kv .video-container-ios-fix {
  position: absolute;
  inset: 0;
  overflow: hidden;
  will-change: clip-path, opacity;
  -webkit-transform: translate3d(0, 0, 0);
}
.kv .video-container-ios-fix video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.kv .video-main { z-index: 1; object-fit: contain; object-position: center; background: #1f1e1c; transform: none; }

/* ---------- Animation vortex (identique à l'ancienne page) ---------- */
.kv .panel-before.revealing { animation: kv-vortex-reveal 1.8s ease-in-out forwards; }
.kv .panel-before.hiding    { animation: kv-vortex-hide 1.5s ease-in-out forwards; }
@keyframes kv-vortex-reveal {
  0%   { clip-path: circle(100% at 50% 50%); }
  100% { clip-path: circle(0% at 50% 50%); }
}
@keyframes kv-vortex-hide {
  0%   { clip-path: circle(0% at 50% 50%); }
  100% { clip-path: circle(100% at 50% 50%); }
}

/* iOS : opacité + échelle à la place de clip-path (comme l'ancienne page) */
body.is-ios .kv .panel-before.revealing { animation: kv-vortex-reveal-ios 1.8s ease-in-out forwards !important; }
body.is-ios .kv .panel-before.hiding    { animation: kv-vortex-hide-ios 1.5s ease-in-out forwards !important; }
@keyframes kv-vortex-reveal-ios {
  0%   { opacity: 1; transform: scale(1); clip-path: none; }
  50%  { opacity: .8; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.1); clip-path: none; }
}
@keyframes kv-vortex-hide-ios {
  0%   { opacity: 0; transform: scale(1.1); clip-path: none; }
  50%  { opacity: .8; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); clip-path: none; }
}
body.is-ios .kv .panel-after { display: none; z-index: 1 !important; }
body.is-ios .kv .panel-before { z-index: 2 !important; }

/* Portrait videos remain completely inside their frame during the iOS fade. */
body.is-ios .kv.kv--video .panel-before.revealing { animation: kv-video-reveal-ios 1.8s ease-in-out forwards !important; }
body.is-ios .kv.kv--video .panel-before.hiding { animation: kv-video-hide-ios 1.5s ease-in-out forwards !important; }
@keyframes kv-video-reveal-ios {
  from { opacity: 1; transform: none; clip-path: none; }
  to { opacity: 0; transform: none; clip-path: none; }
}
@keyframes kv-video-hide-ios {
  from { opacity: 0; transform: none; clip-path: none; }
  to { opacity: 1; transform: none; clip-path: none; }
}

/* Mouvement réduit : simple fondu */
.kv .panel-before.kv-fade-out { opacity: 0; }

/* ---------- Effets vortex ---------- */
.kv .vortex-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}
.kv .vortex-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.kv .spiral {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: none;
  transform: translate(-50%, -50%);
  background: transparent;
  box-shadow:
    0 0 30px rgba(255, 220, 120, .6),
    0 0 60px rgba(255, 210, 100, .3),
    inset 0 0 30px rgba(255, 225, 130, .4),
    inset 0 0 60px rgba(255, 215, 100, .2);
  filter: blur(3px);
}
.kv .gold-particles {
  position: absolute;
  inset: 0;
  z-index: 16;
  pointer-events: none;
}
.kv .particle {
  position: absolute;
  background: radial-gradient(circle, #ffffff 0%, #fff8dc 25%, #f0d878 55%, transparent 100%);
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(255, 220, 100, .8), 0 0 30px rgba(240, 200, 80, .5);
}
.kv .glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  background: radial-gradient(circle,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 240, 180, .85) 20%,
    rgba(250, 220, 120, .5) 40%,
    rgba(240, 200, 90, .25) 60%,
    transparent 80%);
  border-radius: 50%;
  z-index: 14;
  opacity: 0;
  filter: blur(15px);
}
.kv .light-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 13;
  opacity: 0;
}
.kv .ray {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 150px;
  background: linear-gradient(to top, rgba(255, 235, 150, .9) 0%, rgba(255, 220, 100, .4) 50%, transparent 100%);
  transform-origin: bottom center;
  filter: blur(2px);
}

/* ---------- Cadre doré + coins ---------- */
.kv .golden-frame {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 250, 240, .25);
  border-radius: 14px;
  pointer-events: none;
  z-index: 25;
}
.kv .corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: rgba(255, 220, 130, .7);
  border-style: solid;
}
.kv .corner-tl { top: 10px; left: 10px; border-width: 1px 0 0 1px; }
.kv .corner-tr { top: 10px; right: 10px; border-width: 1px 1px 0 0; }
.kv .corner-bl { bottom: 10px; left: 10px; border-width: 0 0 1px 1px; }
.kv .corner-br { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; }

/* ---------- Commandes Avant / Après ---------- */
.kv .panel-labels {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
}
.kv .label {
  margin: 0;
  padding: 11px 26px;
  border-radius: 25px;
  font-family: "Poppins", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .3s ease;
}
.kv .label:focus-visible { outline: 2px solid #f5e6a3; outline-offset: 3px; }
.kv .label-before {
  background: linear-gradient(135deg, rgba(80, 80, 80, .9) 0%, rgba(50, 50, 50, .9) 50%, rgba(70, 70, 70, .9) 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, .3);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
.kv .label-before.visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  animation: kv-pulse 1.5s ease-in-out infinite;
}
.kv .label-before:hover { transform: scale(1.05); }
.kv .label-after {
  background: linear-gradient(135deg, rgba(255, 225, 150, .95) 0%, rgba(240, 200, 100, .95) 50%, rgba(255, 220, 130, .95) 100%);
  color: #2a2a2a;
  border: 1px solid rgba(255, 240, 200, .5);
  box-shadow: 0 4px 15px rgba(0, 0, 0, .2);
  animation: kv-pulse-gold 1.5s ease-in-out infinite;
}
.kv .label-after:hover { transform: scale(1.05); }
.kv .label-after.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  animation: none;
}
.kv .label-right {
  position: relative;
  display: flex;
  align-items: center;
}
@keyframes kv-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 15px rgba(0, 0, 0, .3), 0 0 0 0 rgba(255, 255, 255, .4); }
  50%      { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0, 0, 0, .4), 0 0 0 8px rgba(255, 255, 255, 0); }
}
@keyframes kv-pulse-gold {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 15px rgba(0, 0, 0, .2), 0 0 0 0 rgba(255, 220, 130, .5); }
  50%      { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0, 0, 0, .3), 0 0 0 10px rgba(255, 220, 130, 0); }
}
/* ---------- Son des vidéos ---------- */
.kv .video-sound-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 30;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(245, 230, 163, .5);
  background: rgba(20, 19, 17, .7);
  color: #f5e6a3;
  cursor: pointer;
}
.kv .video-sound-btn:hover { background: rgba(20, 19, 17, .92); }
.kv .video-sound-btn:focus-visible { outline: 2px solid #f5e6a3; outline-offset: 3px; }

.kv .kv-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 599px) {
  .kv { aspect-ratio: 4 / 5; border-radius: 12px; }
  .kv .panel-labels { bottom: 16px; padding: 0 14px; }
  .kv .label { padding: 9px 18px; font-size: 11px; letter-spacing: 1.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .kv .label-before.visible,
  .kv .label-after { animation: none !important; }
}

/* ---------- Métamorphose WebGL validée (kmg-vortex-gl.js) ---------- */
.kv .kv-gl-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;                 /* au-dessus des photos, sous les boutons */
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}
.kv.kv-gl-playing .kv-gl-canvas { opacity: 1; }
.kv .panel-before.kv-gl-hide { opacity: 0; }

.kv--metamorphosis { border-color: #E8CC80; }
.kv--metamorphosis .panel-before { transition: opacity .45s ease; }
.kv--metamorphosis [data-action]:disabled { cursor: wait; }
.kv--metamorphosis .label-before.visible,
.kv--metamorphosis .label-after { animation: none !important; }
.kv--metamorphosis.kv-gl-playing .gold-particles,
.kv--metamorphosis.kv-gl-playing .vortex-overlay { display: none; }

@media (prefers-reduced-motion: reduce) {
  .kv--metamorphosis .panel-before { transition-duration: .15s; }
}
