/*
 * With a mouse or trackpad, the arrow gives way to a soft circle like
 * iPad's pointer: it dims and blurs what's under
 * it, grows in when the mouse first moves, and shrinks a little while
 * pressed. The shelf and the CV both use it, with pointer.js.
 */
@media (hover: hover) and (pointer: fine) {
  html.pointing:not(:has(dialog[open])),
  html.pointing:not(:has(dialog[open])) * {
    cursor: none;
  }
}

/*
 * a playing talk sits in the browser's top layer, above the circle, so
 * while it's open the ordinary cursor comes back and the circle goes
 */
html:has(dialog[open]) .pointer {
  visibility: hidden;
}

/*
 * The pointer is an anchor at the mouse and a shape drawn around it, so
 * the shape can change size and stay centred. At rest it's a small
 * circle; over a link it snaps to a soft highlight behind it, as iPad's
 * pointer does, and over a product, photo or video it stretches into a
 * pill that says what a click will do.
 */
.pointer {
  --w: 24px;
  --h: 24px;
  --r: 12px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  pointer-events: none;
}

.pointer::before {
  content: "";
  position: absolute;
  top: calc(var(--h) / -2);
  left: calc(var(--w) / -2);
  width: var(--w);
  height: var(--h);
  border-radius: var(--r);
  -webkit-backdrop-filter: invert(30%) blur(10px);
  backdrop-filter: invert(30%) blur(10px);
  opacity: 0;
  scale: 0.1;
  transition:
    opacity 0.25s,
    scale 0.35s cubic-bezier(0.3, 1.6, 0.6, 1),
    top 0.2s, left 0.2s, width 0.2s, height 0.2s, border-radius 0.2s;
}

.pointer.shown::before {
  opacity: 1;
  scale: 1;
}

.pointer.shown.pressed::before {
  scale: 0.9;
}

/*
 * behind a link, a plain grey tint that darkens the page but not the
 * link's text, which a blur would smear
 */
.pointer.snapped {
  mix-blend-mode: multiply;
}

.pointer.snapped::before {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: #ececec;
}

/* the pill's label fades in once the shape has stretched */
.pointer::after {
  content: attr(data-label);
  position: absolute;
  top: 0;
  left: 0;
  translate: -50% -50%;
  font: 500 13px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: #fff;
  text-shadow: 0 0 3px rgb(0 0 0 / 0.45); /* readable on the pill's light or dark blur */
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}

.pointer.shown.labelled::after {
  opacity: 1;
  transition-delay: 0.1s;
}

/* moving onto or off a link, the shape glides rather than jumps */
.pointer.gliding {
  transition: translate 0.18s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .pointer::before { transition: opacity 0.25s; scale: 1; }
  .pointer.gliding { transition: none; }
}

/* and on paper there's no mouse */
@media print {
  .pointer { display: none; }
}
