/**
 * bd-cursor — Tooltip-style cursor label
 * Version: 4.0.0
 * Updated: April 29, 2026
 * Changes: Pivoted from icon-replacement to additive tooltip-style label.
 *          Native cursor stays visible always. Content driven by HTML
 *          (data-cursor-label, data-cursor-icon, data-cursor-icon-end).
 */

/* Hidden by default on touch/tablet/narrow viewports — chrome injects these
   elements on every page, so without this they fall back to block-level
   defaults below the footer and break layout. Desktop pointer query below
   opts them back in. */
.cursor-label,
.cursor-halo {
  display: none;
}

/* Desktop pointer-only — additive overlay on top of the native cursor */
@media (min-width: 991px) and (hover: hover) and (pointer: fine) {
  :root {
    --cursor--color: var(--text-accent);
    --cursor-5:  color-mix(in srgb, var(--cursor--color), var(--alpha-5));
    --cursor-10: color-mix(in srgb, var(--cursor--color), var(--alpha-10));
    --cursor-20: color-mix(in srgb, var(--cursor--color), var(--alpha-20));
    --cursor-50: color-mix(in srgb, var(--cursor--color), var(--alpha-50));
    --cursor-90: color-mix(in srgb, var(--cursor--color), var(--alpha-90));
  }

  /* Label — invisible at rest; .is-visible toggles fade-in.
     Position is set by JS via translate3d on every frame. */
  .cursor-label {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10001;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 0;
    background: var(--cursor--color);
    /* Mode-aware text on the accent fill — off-white on the light-mode blue,
       near-black on the dark-mode yellow. Same token the filled buttons use.
       The icon follows via currentColor. */
    color: var(--text-inverted);
    font-family: inherit;
    font-size: 15px;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity;
    transition: opacity var(--duration-2xs) var(--ease-out);
  }

  /* Solo mode — a flagged element hides the native cursor over itself (and
     its children) and lets the icon-only graphic stand in for it (centered
     on the pointer via JS). Gated behind .bd-cursor-ready, which JS adds only
     once the cursor is confirmed live (desktop, not reduced-motion, DOM
     present), so no-JS / reduced-motion / init-failure never hide the cursor
     with nothing to replace it. The descendant rule is required because
     children set their own cursor (e.g. cursor:pointer on links). When Barba
     removes the element on navigation, the rule stops matching and the native
     cursor self-heals — no JS needed for the hide half. */
  .bd-cursor-ready [data-cursor-solo],
  .bd-cursor-ready [data-cursor-solo] * {
    cursor: none;
  }

  /* In solo mode the icon already sits on the pointer; the click halo would
     bloom underneath it and read as noise. Hide it while solo is active. */
  .bd-cursor-solo-active .cursor-halo {
    display: none;
  }

  .cursor-label.is-visible {
    opacity: 1;
  }

  /* Icon-only variant — circle, no horizontal padding, larger icon. */
  .cursor-label.is-icon-only {
    padding: 6px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    justify-content: center;
  }

  .cursor-label.is-icon-only .cursor-label-icon {
    width: 1em;
    height: 1em;
  }

  /* Solo cursor — larger than the shared .is-icon-only tooltip pill so the icon
     reads as a cursor in its own right. Overrides the 40px above (equal
     specificity, later in source); the 1em icon scales with font-size. */
  .cursor-label.is-solo {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  /* Icon slots — both leading and trailing default to hidden. JS toggles
     .is-active on the slots that are populated for the current target. */
  .cursor-label-icon {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    display: none;
    align-items: center;
    justify-content: center;
  }

  .cursor-label-icon.is-active {
    display: inline-flex;
  }

  .cursor-label-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
  }

  /* Text — collapses when empty so icon-only / icon+icon layouts stay tight. */
  .cursor-label-text:empty {
    display: none;
  }

  /* Halo — invisible at rest; click feedback only via .cursor-pressed (90px). */
  .cursor-halo {
    display: block;
    width: 0;
    height: 0;
    border-radius: 100%;
    background-color: var(--cursor-5);
    border: 2px solid var(--cursor-5);
    position: fixed;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    pointer-events: none;
    z-index: 10000;
    will-change: transform;
    transition: width 0.2s ease-out, height 0.2s ease-out, background-color 0.2s;
  }

  .cursor-pressed {
    width: 90px;
    height: 90px;
    background-color: var(--cursor-20);
    border-color: var(--cursor-10);
  }
}
