.musi-blobcompare {
  /* Tokens: cambia estos valores para adaptar el comparador */
  --musi-accent: #2b4bff; /* la gota y el borde de la ola */
  --musi-fg-on: #ffffff;
  --musi-label-bg: #2b4bff;
  --musi-label-fg: #ffffff;
  --musi-radius: 1.6em; /* redondeo de la imagen */
  --musi-knob: 2.8em; /* lado de la gota */
  --musi-edge: 3px; /* grosor del borde de la ola: 0 = sin borde */
  --musi-size: 1rem; /* todo el componente escala con este tamaño */
  --musi-width: 34em; /* ancho del comparador */
  --musi-ratio: 16 / 10; /* proporción de la imagen */

  position: relative;
  isolation: isolate;
  width: var(--musi-width);
  max-width: 100%;
  aspect-ratio: var(--musi-ratio);
  overflow: hidden;
  border-radius: var(--musi-radius);
  color: inherit;
  cursor: ew-resize;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  /* Inter es opcional: si tu sitio no la carga, se usa la fuente del sistema */
  font: 400 var(--musi-size) / 1 "Inter", system-ui, sans-serif;
}

/* Las dos imágenes, una encima de la otra */
.musi-blobcompare__after,
.musi-blobcompare__before {
  position: absolute;
  inset: 0;
}

.musi-blobcompare__after > *,
.musi-blobcompare__before > * {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* La de antes solo se ve hasta el divisor (--musi-pos la pone el script) */
.musi-blobcompare__before {
  clip-path: inset(0 calc(100% - var(--musi-pos, 50%)) 0 0);
}

/* Etiquetas: se apartan cuando el divisor pasa por encima (--musi-p de 0 a 1) */
.musi-blobcompare__label {
  position: absolute;
  top: 0.9em;
  z-index: 2;
  padding: 0.45em 0.75em;
  border-radius: 2em;
  background: var(--musi-label-bg);
  color: var(--musi-label-fg);
  font-size: 0.75em;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.musi-blobcompare__label--before {
  left: 0.9em;
  opacity: clamp(0, (var(--musi-p, 0.5) - 0.16) * 8, 1);
}

.musi-blobcompare__label--after {
  right: 0.9em;
  opacity: clamp(0, (0.84 - var(--musi-p, 0.5)) * 8, 1);
}

/* El tirador: va sobre el divisor */
.musi-blobcompare__handle {
  position: absolute;
  top: var(--musi-handle-y, 50%);
  left: var(--musi-pos, 50%);
  z-index: 3;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  cursor: grab;
  translate: -50% -50%;
  -webkit-tap-highlight-color: transparent;
}

.musi-blobcompare[data-musi-dragging] .musi-blobcompare__handle {
  cursor: grabbing;
}

.musi-blobcompare__handle svg {
  width: 55%;
  height: 55%;
}

.musi-blobcompare__handle:focus-visible {
  outline: 2px solid var(--musi-accent);
  outline-offset: 3px;
}

/* La ola: el script dibuja el recorte de la imagen de antes y este borde */
.musi-blobcompare__edge {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: var(--musi-accent);
  stroke-width: var(--musi-edge);
  pointer-events: none;
}

.musi-blobcompare:not([data-musi-ready]) .musi-blobcompare__edge {
  display: none;
}

/* La gota: el script la estira con la velocidad (--musi-stretch) */
.musi-blobcompare__handle {
  width: var(--musi-knob);
  height: var(--musi-knob);
  border-radius: 50%;
  background: var(--musi-accent);
  color: var(--musi-fg-on);
  transform: scale(calc(1 + var(--musi-stretch, 0)), calc(1 - var(--musi-stretch, 0) * 0.45));
  transition: scale 0.45s cubic-bezier(0.34, 1.8, 0.64, 1);
}

.musi-blobcompare__handle:hover {
  scale: 1.08;
}

.musi-blobcompare[data-musi-dragging] .musi-blobcompare__handle {
  scale: 0.9;
}

@media (prefers-reduced-motion: reduce) {
  .musi-blobcompare *,
  .musi-blobcompare *::before,
  .musi-blobcompare *::after {
    animation: none !important;
    transition: none !important;
  }
}
