/* ============ cursor — the sampler (js/core/cursor.js) ============
   Loaded last: supersedes the old dot + ring rules (base.css) and the difference blend (theme.css).
   Difference blending is avoided on purpose: over mid-grey film and particle fields it cancels to
   grey and the hotspot disappears. Instead every precise mark is two-tone: a fill in the ink of
   the chapter plus a hairline rim in its opposite, so it reads on dark, paper, video and WebGL. */

html.has-cursor, html.has-cursor * { cursor: none !important; }

.cursor {
  --cur-ink: #ece8e1;
  --cur-rim: rgba(8, 8, 9, 0.72);
  --cur-accent: var(--signal);
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 10000;
  pointer-events: none;
  mix-blend-mode: normal;
  opacity: 0;
  transition: opacity 200ms var(--ease-ui);
}
.cursor.is-visible { opacity: 1; }
.cursor[data-mode="hide"] { opacity: 0; }
.cursor.is-paper {
  --cur-ink: #0b0b0c;
  --cur-rim: rgba(255, 255, 255, 0.9);
}

/* ---------- trail: one canvas under everything else ---------- */
.cursor__trail {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* ---------- the hotspot: written straight from pointermove, never eased ---------- */
.cursor__at {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  will-change: transform;
}

.cursor__pt {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 6px;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--cur-ink);
  box-shadow: 0 0 0 1px var(--cur-rim);
  transition:
    width 180ms var(--ease-ui),
    height 180ms var(--ease-ui),
    border-radius 180ms var(--ease-ui),
    background-color 160ms var(--ease-ui),
    box-shadow 160ms var(--ease-ui),
    scale 120ms var(--ease-ui);
}
/* armed: the point takes the accent while something is framed or labelled */
.cursor[data-mode="link"] .cursor__pt,
.cursor[data-mode="lock"] .cursor__pt { background: var(--cur-accent); box-shadow: 0 0 0 1px var(--cur-rim); }
.cursor[data-mode="label"] .cursor__pt,
.cursor[data-mode="drag"] .cursor__pt {
  width: 7px;
  height: 7px;
  background: var(--cur-accent);
  box-shadow: 0 0 0 1px rgba(8, 8, 9, 0.5), 0 0 10px 1px var(--cur-accent);
}
/* the nav: a plain, small dot — its own hover glow does the talking */
.cursor[data-mode="nav"] .cursor__pt { width: 5px; height: 5px; }
.cursor.is-down .cursor__pt { scale: 0.6; }

/* crosshair hairlines (fine) and I-beam serifs (caret) hang off the point */
.cursor__pt::before,
.cursor__pt::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  opacity: 0;
  transition: opacity 160ms var(--ease-ui);
}

/* fine — inside the live demos and the Lab plane: a 3px point with a gapped hairline cross */
.cursor[data-mode="fine"] .cursor__pt {
  width: 3px;
  height: 3px;
  box-shadow: none;
  filter: drop-shadow(0 0 1px var(--cur-rim)) drop-shadow(0 0 0.5px var(--cur-rim));
}
.cursor[data-mode="fine"] .cursor__pt::before {
  width: 23px;
  height: 1px;
  background: linear-gradient(90deg, var(--cur-ink) 0 7px, transparent 7px 16px, var(--cur-ink) 16px);
  opacity: 0.9;
}
.cursor[data-mode="fine"] .cursor__pt::after {
  width: 1px;
  height: 23px;
  background: linear-gradient(180deg, var(--cur-ink) 0 7px, transparent 7px 16px, var(--cur-ink) 16px);
  opacity: 0.9;
}

/* caret — text fields: an I-beam centred on the hotspot */
.cursor[data-mode="caret"] .cursor__pt {
  width: 1.5px;
  height: 20px;
  border-radius: 1px;
  box-shadow: none;
  filter: drop-shadow(0 0 1px var(--cur-rim)) drop-shadow(0 0 0.5px var(--cur-rim));
}
.cursor[data-mode="caret"] .cursor__pt::before,
.cursor[data-mode="caret"] .cursor__pt::after {
  width: 7px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--cur-ink);
  opacity: 1;
}
.cursor[data-mode="caret"] .cursor__pt::before { top: 0; translate: -50% 0; }
.cursor[data-mode="caret"] .cursor__pt::after { top: auto; bottom: 0; translate: -50% 0; }

/* ---------- label: a pill grown out of the point, the word resolving from noise ---------- */
.cursor__tag {
  position: absolute;
  top: -15px;
  left: -15px;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 12px 0 29px;
  border-radius: 15px;
  background: rgba(11, 11, 12, 0.84);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 10px 28px rgba(0, 0, 0, 0.34);
  -webkit-backdrop-filter: blur(10px) saturate(1.5);
  backdrop-filter: blur(10px) saturate(1.5);
  color: #ece8e1;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  clip-path: inset(0 calc(100% - 30px) 0 0 round 15px);
  transform-origin: 15px 50%;
  transition:
    clip-path 380ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 120ms linear,
    scale 140ms var(--ease-ui);
}
.cursor__tag.is-flip {
  left: auto;
  right: -15px;
  padding: 0 29px 0 12px;
  clip-path: inset(0 0 0 calc(100% - 30px) round 15px);
  transform-origin: calc(100% - 15px) 50%;
}
.cursor[data-mode="label"] .cursor__tag,
.cursor[data-mode="drag"] .cursor__tag {
  opacity: 1;
  clip-path: inset(0 0 0 0 round 15px);
}
.cursor[data-mode="drag"] .cursor__word::before { content: "\2039\00a0"; opacity: 0.6; }
.cursor[data-mode="drag"] .cursor__word::after { content: "\00a0\203A"; opacity: 0.6; }
.cursor.is-down .cursor__tag { scale: 0.95; }
/* on paper the pill turns to ink: the same contrast, the paper's own colour */
.cursor.is-paper .cursor__tag {
  background: rgba(11, 11, 12, 0.9);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 24px rgba(11, 11, 12, 0.22);
}

/* ---------- corner brackets: a reticle at rest, a detection box over controls ---------- */
.cursor__tick {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 6px;
  border: 0 solid var(--cur-ink);
  will-change: transform;
  filter: drop-shadow(0 0 0.5px var(--cur-rim)) drop-shadow(0 0 1px var(--cur-rim));
  opacity: 0.7;
  transition: opacity 180ms var(--ease-ui), border-color 160ms var(--ease-ui);
}
.cursor__tick[data-c="tl"] { border-width: 1.5px 0 0 1.5px; border-top-left-radius: 2px; }
.cursor__tick[data-c="tr"] { border-width: 1.5px 1.5px 0 0; border-top-right-radius: 2px; }
.cursor__tick[data-c="bl"] { border-width: 0 0 1.5px 1.5px; border-bottom-left-radius: 2px; }
.cursor__tick[data-c="br"] { border-width: 0 1.5px 1.5px 0; border-bottom-right-radius: 2px; }

.cursor[data-mode="link"] .cursor__tick { opacity: 1; }
.cursor[data-mode="lock"] .cursor__tick { opacity: 1; border-color: var(--cur-accent); }
.cursor.is-down .cursor__tick { border-color: var(--cur-accent); }
.cursor[data-mode="label"] .cursor__tick,
.cursor[data-mode="drag"] .cursor__tick,
.cursor[data-mode="caret"] .cursor__tick,
.cursor[data-mode="fine"] .cursor__tick,
.cursor[data-mode="nav"] .cursor__tick { opacity: 0; transition-duration: 120ms; }
