/* Kenney Cursor Pack 1.1 (CC0) — https://kenney.nl/assets/cursor-pack
   Direct 32px SVG URLs avoid density selection in native cursor rendering.
   Original 64px PNGs provide a second image fallback with matching hotspots. */
:root {
    --reef-cursor-hidden:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGklEQVR4nO3BAQEAAACCIP+vbkhAAQAAAO8GECAAARlDNO4AAAAASUVORK5CYII=") 0 0, none;
    --reef-cursor-kind:default;
    --reef-cursor-default:url("./pointer_a.svg") 10 8, url("./pointer_a.png") 20 16, default;
    --reef-cursor-pointer:url("./hand_point.svg") 8 4, url("./hand_point.png") 16 8, pointer;
    --reef-cursor-grab:url("./hand_open.svg") 16 16, url("./hand_open.png") 32 32, grab;
    --reef-cursor-grabbing:url("./hand_closed.svg") 16 16, url("./hand_closed.png") 32 32, grabbing;
    --reef-cursor-aim:url("./target_a.svg") 16 16, url("./target_a.png") 32 32, crosshair;
    --reef-cursor-busy:url("./cursor_busy.svg") 4 3, url("./cursor_busy.png") 8 6, progress;
    --reef-cursor-disabled:url("./cursor_disabled.svg") 3 3, url("./cursor_disabled.png") 6 6, not-allowed;
}
@media (any-pointer:fine) {
    html,body { cursor:var(--reef-cursor-default); }
    /* Icon/text children keep their control's cursor across hit-test boundaries. */
    :where(a[href],button,summary,[role="button"]) * { --reef-cursor-kind:inherit;cursor:inherit!important; }
    a[href],button,summary,select,label[for],[role="button"],
    label:has(input[type="checkbox"]),label:has(input[type="radio"]),
    input:is([type="checkbox"],[type="radio"],[type="range"],[type="submit"],[type="button"],[type="reset"]) {
        --reef-cursor-kind:pointer;cursor:var(--reef-cursor-pointer)!important;
    }
    input:not([type]),input:is([type="text"],[type="email"],[type="password"],[type="search"],[type="url"],[type="tel"],[type="number"]),
    textarea,[contenteditable]:not([contenteditable="false"]) { --reef-cursor-kind:text;cursor:text!important; }
    :disabled,[aria-disabled="true"],label:has(:disabled) { --reef-cursor-kind:disabled;cursor:var(--reef-cursor-disabled)!important; }
    [aria-busy="true"],[data-open-sim][aria-disabled="true"],
    .overlay:not(.hidden),.overlay:not(.hidden) *,
    .superheart-connect button:disabled,.photo-shutter:disabled {
        --reef-cursor-kind:busy;cursor:var(--reef-cursor-busy)!important;
    }
}

/* This small layer moves only on input and never participates in hit testing. */
.reef-pointer {
    position:fixed!important;left:0!important;top:0!important;right:auto!important;bottom:auto!important;
    width:32px!important;height:32px!important;margin:0!important;padding:0!important;
    border:0!important;outline:0!important;background:transparent!important;box-shadow:none!important;
    overflow:visible!important;display:block!important;z-index:2147483647;
    pointer-events:none!important;user-select:none;opacity:0;will-change:transform;
}
.reef-pointer[data-visible="true"] { opacity:1; }
.reef-pointer img { display:block;width:32px;height:32px;max-width:none;pointer-events:none!important; }
/* Keep one explicit transparent native bitmap while this document owns a
   software pointer. Do not alternate OS cursor modes on blur/frame crossings. */
html:root[data-reef-pointer="on"],
html:root[data-reef-pointer="on"] body,
html:root[data-reef-pointer="on"] body *,
html:root[data-reef-pointer="on"] body *::before,
html:root[data-reef-pointer="on"] body *::after,
html:root[data-reef-pointer="on"] *::backdrop { cursor:var(--reef-cursor-hidden)!important; }
.reef-pointer::backdrop { pointer-events:none!important;background:transparent!important; }

/* Text editing changes only the field cursor, never the document's native mode. */
html:root[data-reef-pointer="on"] input:not([type]),
html:root[data-reef-pointer="on"] input:is([type="text"],[type="email"],[type="password"],[type="search"],[type="url"],[type="tel"],[type="number"]),
html:root[data-reef-pointer="on"] textarea,
html:root[data-reef-pointer="on"] [contenteditable]:not([contenteditable="false"]),
html:root[data-reef-pointer="on"] [contenteditable]:not([contenteditable="false"]) * {cursor:text!important;}

/* One native cursor on macOS: no hidden OS arrow + separate software sprite.
   Use fixed-size raster images instead of SVG/64px density fallbacks so AppKit
   receives a predictable bitmap and hotspot, including after shake-to-locate. */
html:root[data-reef-pointer="native"] {
    --reef-cursor-default:url("./native/pointer_a.png") 10 8, default;
    --reef-cursor-pointer:url("./native/hand_point.png") 8 4, pointer;
    --reef-cursor-grab:url("./native/hand_open.png") 16 16, grab;
    --reef-cursor-grabbing:url("./native/hand_closed.png") 16 16, grabbing;
    --reef-cursor-aim:url("./native/target_a.png") 16 16, crosshair;
    --reef-cursor-busy:url("./native/cursor_busy.png") 4 3, progress;
    --reef-cursor-disabled:url("./native/cursor_disabled.png") 3 3, not-allowed;
}
@media(any-pointer:fine){
    html:root[data-reef-pointer="native"] *::backdrop{cursor:var(--reef-cursor-default)}
}
