/* sphinx-annotated-pdf: highlight rectangles, shared by the docs viewer and Annotated PDF Studio.
 *
 * One file, one behaviour: the box, its numbered tag (inside the top-left corner, never wider
 * than the box, number only when the box is narrow), the click ripple, and hiding.
 * Both apps put class "apdf-rect" on a box and "apdf-tag" on its label, expose the colour as
 * --apdf-c, and toggle "apdf-hide-labels" on the container to hide every highlight.
 */
.apdf-rect {
  --apdf-c: var(--apdf-primary, var(--primary, #0a7080));
  position: absolute;
  box-sizing: border-box;
  display: block;
  border: 1.5px solid var(--apdf-c);
  background: color-mix(in srgb, var(--apdf-c) 18%, transparent);
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none !important;
  transition: background .15s, box-shadow .15s;
}
@supports not (background: color-mix(in srgb, #fff 92%, transparent)) {
  .apdf-rect { background: rgba(10, 125, 145, .18); }
}

/* the tag: number + heading inside the box's top-left corner */
.apdf-tag {
  position: absolute;
  left: -1.5px;
  top: -1.5px;
  display: inline-flex;
  align-items: center;
  gap: .35em;
  max-width: calc(100% + 1.5px);   /* never wider than the block it labels */
  padding: 0 .45em 0 0;
  height: 1.3rem;
  border-radius: 2px 0 3px 0;
  background: var(--apdf-c);
  color: #fff;
  font-size: .7rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  pointer-events: none;
  overflow: hidden;
}
.apdf-tag > b { display: inline-flex; align-items: center; justify-content: center; min-width: 1.3rem; height: 100%; padding: 0 .3em; background: rgba(0, 0, 0, .22); font-weight: 700; flex: none; }
.apdf-tag > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* very small boxes: number only */
.apdf-rect.is-narrow .apdf-tag > span { display: none; }
.apdf-rect.is-narrow .apdf-tag { padding: 0; }
@media (max-width: 640px) { .apdf-tag > span { display: none; } .apdf-tag { padding: 0; height: 1.1rem; font-size: .62rem; } }

/* hide = every highlight, box and tag alike */
.apdf-hide-labels .apdf-rect, .apdf-no-labels .apdf-rect { opacity: 0; pointer-events: none; }

/* click feedback: one ring grows outward and fades, like a ripple; never plays back */
.apdf-rect.is-flash { z-index: 4; }
.apdf-rect.is-flash::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; pointer-events: none; animation: apdf-flash .7s ease-out forwards; }
@keyframes apdf-flash { from { box-shadow: 0 0 0 0 var(--apdf-c); opacity: 1; } to { box-shadow: 0 0 0 14px var(--apdf-c); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .apdf-rect.is-flash::after { animation: none; } }
