/* ==========================================================================
   131 — Copy Clipboard
   Bloc de code + bouton copier : au clic (copie réelle via JS), l'icône
   presse-papiers se morphe en check (crossfade + stroke-dashoffset), un
   tooltip « Copié ! » pop en spring au-dessus, et un halo accent parcourt
   brièvement le bloc. Retour à l'état initial après ~1.6 s (anim.js).
   ========================================================================== */

.copy-clip {
  display: inline-flex;
}

/* --- Bloc de code ----------------------------------------------------------- */

.copy-clip__block {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 11px 11px 11px 16px;
  border-radius: 12px;
  background: var(--ml-surface, #151a24);
  border: 1px solid color-mix(in srgb, var(--ml-muted, #8b91a3) 22%, transparent);
}

/* halo accent bref (pseudo-élément : seul opacity est animé) */
.copy-clip__block::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 12px;
  box-shadow:
    0 0 0 1.5px var(--ml-accent, #7c8cff),
    0 0 22px color-mix(in srgb, var(--ml-accent, #7c8cff) 40%, transparent);
  opacity: 0;
  pointer-events: none;
}

.copy-clip.is-copied .copy-clip__block::after {
  animation: copy-clip-halo 0.9s ease-out;
}

@keyframes copy-clip-halo {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

.copy-clip__code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 0.88rem;
  color: var(--ml-fg, #e8eaf2);
  white-space: nowrap;
}

.copy-clip__code::before {
  content: "$ ";
  color: var(--ml-accent-2, #2dd4bf);
}

/* --- Bouton ------------------------------------------------------------------- */

.copy-clip__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--ml-muted, #8b91a3) 28%, transparent);
  background: color-mix(in srgb, var(--ml-fg, #e8eaf2) 4%, transparent);
  color: var(--ml-muted, #8b91a3);
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.copy-clip__btn:hover {
  color: var(--ml-fg, #e8eaf2);
  border-color: color-mix(in srgb, var(--ml-accent, #7c8cff) 65%, transparent);
}

.copy-clip__btn:active {
  transform: scale(0.88);
}

.copy-clip__btn:focus-visible {
  outline: 2px solid var(--ml-accent, #7c8cff);
  outline-offset: 2px;
}

.copy-clip.is-copied .copy-clip__btn {
  color: var(--ml-accent-2, #2dd4bf);
  border-color: color-mix(in srgb, var(--ml-accent-2, #2dd4bf) 55%, transparent);
}

/* --- Morph presse-papiers → check ------------------------------------------------ */

.copy-clip__icon {
  display: block;
  width: 17px;
  height: 17px;
  overflow: visible;
}

.copy-clip.is-copied .copy-clip__icon {
  animation: copy-clip-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.08s;
}

@keyframes copy-clip-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.copy-clip__icon-copy {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 1;
  transform: none;
  transition: opacity 0.16s ease 0.1s, transform 0.16s ease 0.1s;
}

.copy-clip.is-copied .copy-clip__icon-copy {
  opacity: 0;
  transform: scale(0.55) rotate(-10deg);
  transition-delay: 0s, 0s;
}

.copy-clip__icon-check {
  stroke-width: 2.6;
  stroke-dasharray: 1; /* pathLength="1" */
  stroke-dashoffset: 1;
  opacity: 0;
  transition: opacity 0.12s ease, stroke-dashoffset 0.16s ease;
}

.copy-clip.is-copied .copy-clip__icon-check {
  opacity: 1;
  stroke-dashoffset: 0;
  transition:
    opacity 0.1s ease 0.1s,
    stroke-dashoffset 0.32s cubic-bezier(0.65, 0, 0.35, 1) 0.12s;
}

/* --- Tooltip « Copié ! » ------------------------------------------------------------ */

.copy-clip__tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--ml-fg, #e8eaf2);
  color: var(--ml-bg, #0d1017);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.7);
  transform-origin: 50% 100%;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.copy-clip__tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -5px 0 0 -4px;
  border-radius: 2px;
  background: inherit;
  transform: rotate(45deg);
}

.copy-clip.is-copied .copy-clip__tip {
  animation: copy-clip-tip 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes copy-clip-tip {
  0%   { opacity: 0; transform: translate(-50%, 8px) scale(0.7); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* --- Région lecteur d'écran --------------------------------------------------------- */

.copy-clip__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* --- Wrapper de démo (galerie) -------------------------------------------------------- */

.copy-clip-demo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.copy-clip-demo__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ml-muted, #8b91a3);
}

/* --- Reduced motion --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .copy-clip.is-copied .copy-clip__block::after,
  .copy-clip.is-copied .copy-clip__icon {
    animation: none;
  }

  .copy-clip.is-copied .copy-clip__tip {
    animation: none;
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  .copy-clip__btn,
  .copy-clip__tip,
  .copy-clip__icon-copy,
  .copy-clip__icon-check {
    transition-duration: 0.01s;
    transition-delay: 0s;
  }

  .copy-clip.is-copied .copy-clip__icon-copy,
  .copy-clip.is-copied .copy-clip__icon-check {
    transition-duration: 0.01s, 0.01s;
    transition-delay: 0s, 0s;
  }

  .copy-clip__btn:active {
    transform: none;
  }
}
