/**
 * bd-cursor — The single cursor stylesheet: native keyword cursors + animated overlay
 * Version: 4.4.1
 * Updated: June 8, 2026
 * Changes: v4.4.1 the float LABEL wraps long client text to two lines (max-width
 *          22ch) instead of running off-screen; it stays anchored by its top edge
 *          so extra lines grow downward and never creep toward the native cursor.
 *          v4.4 dropped the base64 PNG cursors — native cursors are now bare CSS
 *          keywords (data-cursor="grab" etc.), the free no-JS base layer. Added the
 *          REPLACE BADGE (data-cursor-badge — a graphic-in-circle that IS the cursor)
 *          and renamed the attributes: data-cursor-solo → data-cursor-replace,
 *          data-cursor-hide → data-cursor-native. Press-swap (data-cursor-replace-press)
 *          is wired in bd-cursor.js. Added a forced-colors guard. Terminology:
 *          NATIVE / ICON / BADGE / LABEL · FLOAT (native shown) vs REPLACE (native hidden).
 *          v4.3 restored the overlay's trailing motion (LABEL_LERP 0.75 / HALO_LERP 0.2
 *          in bd-cursor.js). v4.2 consolidated all cursor CSS into this one file.
 *          v4.1 added replace + native-carve-out modes, gated behind .bd-cursor-ready.
 *          v4.0 pivoted from icon-replacement to the additive tooltip-style label.
 */

/* ============================================================================
   NATIVE KEYWORD CURSORS — bare OS pointers, applied by a data-cursor attribute
   ============================================================================
   The actual OS pointer, swapped per element by data-cursor="grab" (etc.).
   v4.4 dropped the base64 PNG images — these are now plain CSS keywords: the
   free, no-JS base layer (also the fallback whenever the JS overlay can't run —
   reduced-motion, touch, forced-colors). For a CUSTOM graphic cursor use the JS
   overlay below (data-cursor-replace / -badge). Apply by adding the ATTRIBUTE
   (not a class, so it never starts a combo class). Touch devices ignore it. */
[data-cursor="default"]   { cursor: auto; }
[data-cursor="text"]      { cursor: text; }
[data-cursor="pointer"]   { cursor: pointer; }
[data-cursor="grab"]      { cursor: grab; }
[data-cursor="grabbing"]  { cursor: grabbing; }

/* 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;
}

/* Forced-colors (Windows high-contrast) — the overlay can't honour the forced
   palette, so hide it and let the native keyword cursor take over. */
@media (forced-colors: active) {
  .cursor-label,
  .cursor-halo { display: none !important; }
}

/* 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);
    /* Dark text on the light brand-green accent fill (single mode) — white read
       too low-contrast on the lime green; the icon follows via currentColor. */
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    /* 1.3 (was 1) gives a wrapped two-line label breathing room; a single-line
       label just gains a few px of height. */
    line-height: 1.3;
    /* Client-entered labels can run long — cap the width so the text wraps to a
       second line instead of running off-screen. The pill is anchored by its TOP
       edge (LABEL_OFFSET_Y below the pointer in bd-cursor.js), so extra lines grow
       DOWNWARD: a two-line label never creeps back up toward the native cursor.
       overflow-wrap breaks a single unbroken long token; text-align centres the
       ragged lines under the pointer-centred pill. ~22ch ≈ a short phrase — tune. */
    max-width: 22ch;
    text-align: center;
    overflow-wrap: break-word;
    pointer-events: none;
    opacity: 0;
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity;
    transition: opacity var(--duration-2xs) var(--ease-out);
  }

  /* Replace / Badge mode — a flagged element hides the native cursor over itself
     (and its children) and lets the riding graphic stand in for it (centred on
     the pointer via JS). Covers data-cursor-replace (bare graphic), -badge
     (graphic in a circle) and -replace-press (press swap). 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. */
  .bd-cursor-ready [data-cursor-replace],
  .bd-cursor-ready [data-cursor-replace] *,
  .bd-cursor-ready [data-cursor-replace-press],
  .bd-cursor-ready [data-cursor-replace-press] *,
  .bd-cursor-ready [data-cursor-badge],
  .bd-cursor-ready [data-cursor-badge] * {
    cursor: none;
  }

  /* Native carve-out — a control flagged data-cursor-native inside a replace
     region restores the native cursor (the rule above set cursor:none on every
     descendant). Later in source so it wins on equal specificity. */
  .bd-cursor-ready [data-cursor-native],
  .bd-cursor-ready [data-cursor-native] * {
    cursor: auto;
  }

  /* 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;
  }

  /* Replace cursor — the graphic IS the cursor: a raw graphic riding the pointer
     with NO pill/badge background and no forced tint, so multi-colour sprite
     symbols (e.g. a black + white pointer) render exactly as drawn. Centred on
     the pointer by labelTransform. Overrides the .is-icon-only badge above (equal
     specificity, later in source). */
  .cursor-label.is-solo {
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
  }

  /* Badge cursor — like .is-solo it's a graphic that IS the cursor (native hidden,
     centred on the pointer), but it KEEPS the .is-icon-only lime circle instead of
     stripping to a bare graphic. JS sets .is-icon-only + .is-badge together; this
     rule just sizes the glyph inside the circle. */
  .cursor-label.is-badge .cursor-label-icon {
    width: 1.1em;
    height: 1.1em;
  }

  /* Replace cursor size — the DEFAULT for every graphic cursor. To size one cursor
     differently, add a per-cursor override below (keyed on the icon name, which
     bd-cursor.js sets on .cursor-label as data-cursor-name). */
  .cursor-label.is-solo .cursor-label-icon {
    width: 44px;
    height: 44px;
  }

  /* Per-cursor size overrides — one rule per cursor that needs its own size. */
  .cursor-label.is-solo[data-cursor-name="cursor-hand-pointing"] .cursor-label-icon {
    width: 64px;
    height: 64px;
  }

  /* 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);
  }
}
