.image-viewer {
  --depth: 0;
  --veil: 0;
  --memory: 0;

  position: relative;
  overflow: hidden;
  background: #000;
}

.zoom-image {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  will-change: transform, filter;
}

/* voile atmosphérique */

.image-viewer::before {
  content: "";
  position: absolute;
  inset: -10%;
  z-index: 4;
  pointer-events: none;

  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.12), transparent 34%),
    radial-gradient(circle at 70% 45%, rgba(255,255,255,0.08), transparent 38%),
    radial-gradient(circle at 46% 78%, rgba(255,255,255,0.10), transparent 42%);

  opacity: var(--veil);
  filter: blur(20px);
  animation: archiveVeil 24s ease-in-out infinite alternate;
}

.image-viewer::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;

  opacity: calc(0.05 + var(--memory) * 0.14);

  box-shadow:
    inset 0 0 calc(28px + var(--memory) * 80px)
    rgba(255,255,255,0.04);
}

/* halo progressif pendant le clic maintenu */

.attention-local-trace {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 30;

  width: 140px;
  height: 96px;

  border-radius: 54% 46% 58% 42% / 48% 55% 45% 52%;

  opacity: 0;
  pointer-events: none;

  will-change: transform, opacity;
}

.attention-local-trace::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;

  background:
    radial-gradient(
      ellipse at center,
      rgba(255,255,255, calc(0.18 + var(--dwell) * 0.3)) 0%,
      rgba(255,255,255, calc(0.08 + var(--dwell) * 0.16)) 34%,
      rgba(255,255,255, calc(0.03 + var(--dwell) * 0.08)) 58%,
      transparent 76%
    );

  filter: blur(calc(18px - var(--dwell) * 10px));
  transform: scale(calc(0.85 + var(--dwell) * 0.55));

  box-shadow:
    0 0 calc(12px + var(--dwell) * 42px)
    rgba(255,255,255,0.22);
}

.attention-local-trace::after {
  content: "";
  position: absolute;
  inset: 42%;
  border-radius: 999px;

  background: rgba(255,255,255,0.9);
  filter: blur(4px);

  opacity: calc(var(--dwell) * 0.8);
}

/* texte */

.archive-whisper {
  position: absolute;
  left: 50%;
  bottom: clamp(24px, 5vh, 52px);
  z-index: 40;

  transform: translateX(-50%);
  max-width: min(72vw, 520px);

  color: rgba(255,255,255,0.65);
  font-size: 0.72rem;
  line-height: 1.45;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  text-align: center;

  opacity: 0;
  filter: blur(5px);

  transition:
    opacity 0.3s ease,
    filter 0.3s ease;

  pointer-events: none;
}

.archive-whisper.is-visible {
  opacity: 1;
  filter: blur(0);
}

/* couche de recomposition */

.memory-recomposition-layer {
  position: absolute;
  inset: 0;
  z-index: 24;

  opacity: 0;
  pointer-events: none;

  transition: opacity 0.25s ease;
}

.memory-recomposition-layer.is-visible {
  opacity: 1;
}

/* fragments mémoire */

.memory-recomposition-mark {
  position: absolute;
  left: 50%;
  top: 50%;

  width: clamp(80px, 10vw, 180px);
  height: clamp(60px, 8vw, 130px);

  overflow: hidden;

  opacity: 0;

  border: none;
  background: transparent;
  box-shadow: none;

  transform-origin: center;
  will-change: transform, opacity, border-radius;
}

.memory-recomposition-crop {
  position: absolute;
  inset: 0;

  background-repeat: no-repeat;
  background-position: center;
  background-size: 260% auto;

  opacity: 0.88;

  filter:
    saturate(0.72)
    contrast(1.08)
    brightness(0.78);

  pointer-events: none;
  user-select: none;
}

/* image principale au retour */

.image-viewer.is-return-blur .zoom-image {
  opacity: 0.6;
}

/* pulse global quand une mémoire est créée */

.image-viewer.archive-pulse::before {
  animation:
    archiveVeil 24s ease-in-out infinite alternate,
    archivePulse 0.5s ease-out 1;
}

/* animation ponctuelle de création de mémoire */

.memory-birth-fx {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 100;

  width: 34px;
  height: 34px;

  border-radius: 999px;
  pointer-events: none;

  background: rgba(255,255,255,0.95);

  transform: translate(-50%, -50%) scale(0.2);
  opacity: 1;

  box-shadow:
    0 0 18px rgba(255,255,255,0.9),
    0 0 52px rgba(255,255,255,0.45),
    0 0 110px rgba(255,255,255,0.22);

  transition:
    transform 0.85s ease-out,
    opacity 0.85s ease-out,
    filter 0.85s ease-out;

  will-change: transform, opacity, filter;
}

.memory-birth-fx.is-active {
  transform: translate(-50%, -50%) scale(4.5);
  opacity: 0;
  filter: blur(18px);
}

.memory-birth-fx::before {
  content: "";
  position: absolute;
  inset: -42px;

  border-radius: inherit;
  border: 1px solid rgba(255,255,255,0.45);

  opacity: 0.8;
}

/* animations */

@keyframes archiveVeil {
  from {
    transform: translate3d(-1%, -1%, 0) scale(1.04);
  }

  to {
    transform: translate3d(2%, 3%, 0) scale(1.08);
  }
}

@keyframes archivePulse {
  0% {
    opacity: var(--veil);
  }

  50% {
    opacity: calc(var(--veil) + 0.12);
  }

  100% {
    opacity: var(--veil);
  }
}

/* mobile */

@media (max-width: 900px) {
  .attention-local-trace {
    width: 110px;
    height: 76px;
  }

  .memory-recomposition-mark {
    width: 110px;
    height: 80px;
  }
}

/* accessibilité */

@media (prefers-reduced-motion: reduce) {
  .image-viewer::before,
  .image-viewer.archive-pulse::before {
    animation: none !important;
  }

  .archive-whisper,
  .memory-recomposition-layer,
  .memory-birth-fx {
    transition: none !important;
  }
}