/* one-time pen stroke: strikes through the text, swoops around the end and back underneath,
   then the strikethrough pulls away and leaves the underline.
   <span class="scribble">text<svg>…</svg></span>; shape and trigger in js/components/scribble.js */

.scribble {
  position: relative;
  display: inline-block;
}

/* sized to the text; js/components/scribble.js draws the paths in its pixels */
.scribble svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* paths use pathLength="1", so a dash of 1 is the whole line */
.scribble-strike,
.scribble-line {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}

/* the two paths meet end to end, so drawing one straight after the other reads as a single stroke */
.scribble.is-drawn .scribble-strike {
  animation:
    scribble-draw 0.55s cubic-bezier(0.5, 0, 0.9, 0.6) 0.5s forwards,
    scribble-retract 0.45s cubic-bezier(0.5, 0, 0.3, 1) 1.3s forwards;
}

.scribble.is-drawn .scribble-line {
  animation: scribble-draw 0.5s cubic-bezier(0.1, 0.4, 0.3, 1) 1.05s forwards;
}

@keyframes scribble-draw {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* pull the strike away from its start, back into the underline */
@keyframes scribble-retract {
  from {
    stroke-dashoffset: 0;
  }
  99% {
    opacity: 1;
  }
  to {
    stroke-dashoffset: -1;
    opacity: 0;
  }
}

/* no motion: just the underline */
@media (prefers-reduced-motion: reduce) {
  .scribble-strike {
    display: none;
  }

  .scribble .scribble-line {
    animation: none;
    stroke-dashoffset: 0;
  }
}
