/* ==========================================================================
   cursor.css: custom cursors and click-effect styles (CONTRACTS.md section 8).
   Sets: html[data-cursor="A"|"B"|"C"], missing = A.
     A chunky cream arrow, cocoa outline, rose heart at the tail (click: three tiny hearts)
     B tilted rose heart, lace edge, cocoa outline, tip = pointer (click: one sparkle burst)
     C star wand, cream star on a short rose stick, cocoa outline (click: four tiny stars)
   Normal on body, hover on interactive elements, pressed while html.cursor-pressed. Cursor rules exist
   only for fine pointers and never in the editor preview. Each cursor value is written twice: a plain
   url() first, then image-set() 1x/2x, so a browser without image-set() in `cursor` keeps the 1x image.
   Hotspots: A 2 2, B 2 2, C 3 2 (identical for the three states of a set).
   G: the generated cushion arrow (assets/cursors/G-*.png, made by scripts/key-out.py from the art book's cursor
     image). Under html[data-art~="cursor"] it replaces the set chosen by data-cursor on the whole page.
     Hotspot 2 2. Click: three small faded pink hearts with a cocoa edge.
   ========================================================================== */

/* Effect paint, composed from tokens only. Light surfaces (blush, cream) are covered by the fill or the
   cocoa edge, the pale band and the rose pill by the lace edge or the cream fill. */
:root {
  --cur-heart: var(--c-rose-700);      /* heart particles (one step deeper than the order pill) */
  --cur-cream: var(--c-cream);         /* star and sparkle particles */
  --cur-edge-light: var(--c-lace);     /* edge round a rose heart, so it reads on the rose pill and the band */
  --cur-edge-dark: var(--c-cocoa);     /* edge round a cream star or sparkle, so it reads on cream */
  --cur-heart-g: var(--c-rose);        /* G hearts: faded pink, with the cocoa edge so they read on pink too */
}

@media (pointer: fine) {
  /* ---------- normal ---------- */
  html:not(.is-editor-preview) body {
    cursor: url("../assets/cursors/A-normal-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/A-normal-32.png") 1x, url("../assets/cursors/A-normal-64.png") 2x) 2 2, url("../assets/cursors/A-normal-32.png") 2 2, auto;
  }
  html:not(.is-editor-preview):where([data-cursor="B"]) body {
    cursor: url("../assets/cursors/B-normal-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/B-normal-32.png") 1x, url("../assets/cursors/B-normal-64.png") 2x) 2 2, url("../assets/cursors/B-normal-32.png") 2 2, auto;
  }
  html:not(.is-editor-preview):where([data-cursor="C"]) body {
    cursor: url("../assets/cursors/C-normal-32.png") 3 2, auto;
    cursor: image-set(url("../assets/cursors/C-normal-32.png") 1x, url("../assets/cursors/C-normal-64.png") 2x) 3 2, url("../assets/cursors/C-normal-32.png") 3 2, auto;
  }

  /* ---------- hover (interactive elements; children inherit) ---------- */
  html:not(.is-editor-preview) body :where(a[href], button:not([aria-disabled="true"]), [role="tab"], .photo-card, summary, label[for]) {
    cursor: url("../assets/cursors/A-hover-32.png") 2 2, pointer;
    cursor: image-set(url("../assets/cursors/A-hover-32.png") 1x, url("../assets/cursors/A-hover-64.png") 2x) 2 2, url("../assets/cursors/A-hover-32.png") 2 2, pointer;
  }
  html:not(.is-editor-preview):where([data-cursor="B"]) body :where(a[href], button:not([aria-disabled="true"]), [role="tab"], .photo-card, summary, label[for]) {
    cursor: url("../assets/cursors/B-hover-32.png") 2 2, pointer;
    cursor: image-set(url("../assets/cursors/B-hover-32.png") 1x, url("../assets/cursors/B-hover-64.png") 2x) 2 2, url("../assets/cursors/B-hover-32.png") 2 2, pointer;
  }
  html:not(.is-editor-preview):where([data-cursor="C"]) body :where(a[href], button:not([aria-disabled="true"]), [role="tab"], .photo-card, summary, label[for]) {
    cursor: url("../assets/cursors/C-hover-32.png") 3 2, pointer;
    cursor: image-set(url("../assets/cursors/C-hover-32.png") 1x, url("../assets/cursors/C-hover-64.png") 2x) 3 2, url("../assets/cursors/C-hover-32.png") 3 2, pointer;
  }

  /* ---------- not hover: unset links and disabled controls get the normal cursor.
     :is() (not :where) on purpose: beats component rules for [aria-disabled="true"] ---------- */
  html:not(.is-editor-preview) body :is(.is-unset, [aria-disabled="true"]) {
    cursor: url("../assets/cursors/A-normal-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/A-normal-32.png") 1x, url("../assets/cursors/A-normal-64.png") 2x) 2 2, url("../assets/cursors/A-normal-32.png") 2 2, auto;
  }
  html:not(.is-editor-preview):where([data-cursor="B"]) body :is(.is-unset, [aria-disabled="true"]) {
    cursor: url("../assets/cursors/B-normal-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/B-normal-32.png") 1x, url("../assets/cursors/B-normal-64.png") 2x) 2 2, url("../assets/cursors/B-normal-32.png") 2 2, auto;
  }
  html:not(.is-editor-preview):where([data-cursor="C"]) body :is(.is-unset, [aria-disabled="true"]) {
    cursor: url("../assets/cursors/C-normal-32.png") 3 2, auto;
    cursor: image-set(url("../assets/cursors/C-normal-32.png") 1x, url("../assets/cursors/C-normal-64.png") 2x) 3 2, url("../assets/cursors/C-normal-32.png") 3 2, auto;
  }

  /* ---------- pressed (while the primary mouse button is down), everywhere but text fields ---------- */
  html.cursor-pressed:not(.is-editor-preview) body,
  html.cursor-pressed:not(.is-editor-preview) body :where(*) {
    cursor: url("../assets/cursors/A-pressed-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/A-pressed-32.png") 1x, url("../assets/cursors/A-pressed-64.png") 2x) 2 2, url("../assets/cursors/A-pressed-32.png") 2 2, auto;
  }
  html.cursor-pressed:not(.is-editor-preview):where([data-cursor="B"]) body,
  html.cursor-pressed:not(.is-editor-preview):where([data-cursor="B"]) body :where(*) {
    cursor: url("../assets/cursors/B-pressed-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/B-pressed-32.png") 1x, url("../assets/cursors/B-pressed-64.png") 2x) 2 2, url("../assets/cursors/B-pressed-32.png") 2 2, auto;
  }
  html.cursor-pressed:not(.is-editor-preview):where([data-cursor="C"]) body,
  html.cursor-pressed:not(.is-editor-preview):where([data-cursor="C"]) body :where(*) {
    cursor: url("../assets/cursors/C-pressed-32.png") 3 2, auto;
    cursor: image-set(url("../assets/cursors/C-pressed-32.png") 1x, url("../assets/cursors/C-pressed-64.png") 2x) 3 2, url("../assets/cursors/C-pressed-32.png") 3 2, auto;
  }

  /* ---------- text fields keep the system text cursor (also while pressed) ---------- */
  html:not(.is-editor-preview) body :is(input:not([type="button"], [type="submit"], [type="reset"], [type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="image"]), textarea, [contenteditable]:not([contenteditable="false"])) {
    cursor: text;
  }

  /* ---------- G: the generated cursor, whenever its PNGs exist (data-art~="cursor"), whatever data-cursor says.
     One more attribute than the A/B/C rules, so it wins over them at every state. ---------- */
  html:not(.is-editor-preview)[data-art~="cursor"] body {
    cursor: url("../assets/cursors/G-normal-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/G-normal-32.png") 1x, url("../assets/cursors/G-normal-64.png") 2x) 2 2, url("../assets/cursors/G-normal-32.png") 2 2, auto;
  }
  html:not(.is-editor-preview)[data-art~="cursor"] body :where(a[href], button:not([aria-disabled="true"]), [role="tab"], .photo-card, summary, label[for], .patch) {
    cursor: url("../assets/cursors/G-hover-32.png") 2 2, pointer;
    cursor: image-set(url("../assets/cursors/G-hover-32.png") 1x, url("../assets/cursors/G-hover-64.png") 2x) 2 2, url("../assets/cursors/G-hover-32.png") 2 2, pointer;
  }
  html:not(.is-editor-preview)[data-art~="cursor"] body :is(.is-unset, [aria-disabled="true"]) {
    cursor: url("../assets/cursors/G-normal-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/G-normal-32.png") 1x, url("../assets/cursors/G-normal-64.png") 2x) 2 2, url("../assets/cursors/G-normal-32.png") 2 2, auto;
  }
  html.cursor-pressed:not(.is-editor-preview)[data-art~="cursor"] body,
  html.cursor-pressed:not(.is-editor-preview)[data-art~="cursor"] body :where(*) {
    cursor: url("../assets/cursors/G-pressed-32.png") 2 2, auto;
    cursor: image-set(url("../assets/cursors/G-pressed-32.png") 1x, url("../assets/cursors/G-pressed-64.png") 2x) 2 2, url("../assets/cursors/G-pressed-32.png") 2 2, auto;
  }
  html:not(.is-editor-preview)[data-art~="cursor"] body :is(input:not([type="button"], [type="submit"], [type="reset"], [type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="image"]), textarea, [contenteditable]:not([contenteditable="false"])) {
    cursor: text;
  }
}

/* ==========================================================================
   Click-effect layer and effect paint. Not cursor rules, so they sit outside the
   (pointer: fine) block: the touch mini-heart pop (contract 8) needs them on touch screens too.
   cursor-fx.mjs never spawns anything under reduced motion or in the editor preview.
   ========================================================================== */
.cursor-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-cursor-fx);
  overflow: hidden;
}
.cursor-fx .cfx {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}
.cfx :is(g, path) { transform-origin: 0 0; }

/* Particles (shapes are about 19 units across, scaled to 11-24px by cursor-fx.mjs). The edge is drawn
   under the fill (paint-order), so only its outer half shows. */
.cfx :is(.cfx-heart, .cfx-star, .cfx-sparkle) { stroke-linejoin: round; paint-order: stroke fill; }
.cfx .cfx-heart { fill: var(--cur-heart); stroke: var(--cur-edge-light); stroke-width: 6px; }
.cfx .cfx-star { fill: var(--cur-cream); stroke: var(--cur-edge-dark); stroke-width: 5.5px; }
.cfx .cfx-sparkle { fill: var(--cur-cream); stroke: var(--cur-edge-dark); stroke-width: 5px; }
.cfx .cfx-gheart { fill: var(--cur-heart-g); stroke: var(--cur-edge-dark); stroke-width: 4.5px; }

/* Belt and braces: nothing visible under reduced motion even if a node slipped through. */
@media (prefers-reduced-motion: reduce) {
  .cursor-fx .cfx { display: none; }
}
