/* Review marks (bd-annotate.js): pen loops, leaders and margin notes over a frame.
   Inks are tokens so a host page can retune them; the hand is --an-font. */
.an {
  --an-issue: #e5402a;            /* something wrong */
  --an-fix: #16865a;              /* what changed, or what to do */
  --an-note: #4a4a4a;             /* a neutral aside */
  --an-font: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --an-margin: 15.5rem;           /* room for the notes, right of the frame */
  position: relative;
  margin: 0;
  padding: 0 var(--an-margin) var(--an-notes-h, 0px) 0;
}
.an-frame { position: relative; }
.an-clip { position: relative; overflow: hidden; border-radius: var(--r-m, 10px); height: 100%; }
.an-frame[style*="aspect-ratio"] .an-clip { position: absolute; inset: 0; }
.an-clip > img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* the ink layer spans the whole figure, so leaders can cross into the margin */
.an-ink { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.an-mark path {
  fill: none; stroke: var(--an-issue); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
}
.an-mark.is-fix path { stroke: var(--an-fix); }
.an-mark.is-note path { stroke: var(--an-note); }
.an-mark path.an-lead { stroke-width: 1; stroke-opacity: .6; }

.an[data-on] .an-mark path { stroke-dashoffset: 0; transition: stroke-dashoffset .6s cubic-bezier(.4, 0, .2, 1) calc(var(--i) * .45s + .55s); }
.an[data-on] .an-mark path.an-lead { transition-duration: .3s; transition-delay: calc(var(--i) * .45s + .25s); }
/* a followed mark draws quickly, since its target may only stay a couple of seconds */
.an[data-on] .an-mark[data-follow] path { transition: stroke-dashoffset .45s cubic-bezier(.4, 0, .2, 1) .3s; }
.an[data-on] .an-mark[data-follow] path.an-lead { transition-duration: .25s; transition-delay: .05s; }
.an[data-on] .an-note[data-follow] { transition: opacity .3s ease .1s; }
/* a followed target that leaves: the ink lifts at once, and draws again when it returns */
.an .an-mark[data-hide] path, .an[data-on] .an-mark[data-hide] path { stroke-dashoffset: 1; transition: stroke-dashoffset 0s .3s; }
.an[data-on] .an-mark:not([data-hide]) path { will-change: stroke-dashoffset; }
.an-mark[data-hide] { opacity: 0; transition: opacity .3s ease; }

.an-notes { position: absolute; top: 0; left: 100%; width: calc(var(--an-margin) - 22px); margin: 0; padding: 0; list-style: none; }
.an-note {
  position: absolute; left: var(--dx, 0px); width: max-content; max-width: calc(var(--an-margin) - 34px);
  transform: rotate(var(--tilt, 0deg)); transform-origin: 0 12px;
  font: 500 1.5rem/1.02 var(--an-font); letter-spacing: -.005em; text-wrap: balance;
  color: var(--an-issue); opacity: 0;
}
.an-note.is-fix { color: var(--an-fix); }
.an-note.is-note { color: var(--an-note); }
.an[data-on] .an-note { opacity: 1; transition: opacity .35s ease calc(var(--i) * .45s + .15s); }
.an[data-on] .an-note[data-hide] { opacity: 0; transition: opacity .3s ease; }

/* numbers only matter once the notes leave the margin */
.an-num { display: none; }

@media (prefers-reduced-motion: reduce) {
  .an .an-mark path, .an .an-note { transition: none !important; }
}

/* narrow: the margin folds away, marks get numbers, the notes list under the frame */
.an[data-compact] { padding: 0; }
.an[data-compact] .an-lead { display: none; }
.an[data-compact] .an-notes { position: static; width: auto; margin: .9rem 0 0; display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; counter-reset: an; }
.an[data-compact] .an-note { position: static; transform: none; max-width: none; font-size: 1.3rem; }
.an[data-compact] .an-note::before { content: attr(value) "  "; font: 600 .7rem/1 var(--font, sans-serif); vertical-align: .25em; }
.an[data-compact] .an-num {
  display: grid; place-items: center; position: absolute; width: 18px; height: 18px; translate: -50% -50%;
  border-radius: 50%; background: var(--an-issue); color: #fff; font: 600 .65rem/1 var(--font, sans-serif);
  opacity: 0; pointer-events: none;
}
.an[data-compact] .an-num.is-fix { background: var(--an-fix); }
.an[data-compact] .an-num.is-note { background: var(--an-note); }
.an[data-compact][data-on] .an-num { opacity: 1; transition: opacity .3s ease calc(var(--i) * .45s + .9s); }
.an[data-compact] .an-num[data-hide] { opacity: 0 !important; }
