/* Native CSS cursors cost no per-pointer JS and preserve semantic cursor types. */
/* Softened derivatives of original cursor bitmaps. Sources: img/cursors/soft/README.md */
:root {
  --hardware-arrow: url('img/cursors/soft/x11/arrow.png') 2 2;
  --hardware-hand: url('img/cursors/soft/x11/hand.png') 0 2;
  --hardware-wait: url('img/cursors/soft/x11/wait.png') 30 18;
  --hardware-text: url('img/cursors/soft/x11/text.png') 8 16;
  --hardware-move: url('img/cursors/soft/x11/move.png') 16 16;
  --hardware-resize-ew: url('img/cursors/soft/x11/resize-ew.png') 14 8;
  --hardware-resize-ns: url('img/cursors/soft/x11/resize-ns.png') 8 14;
  --hardware-resize-nesw: url('img/cursors/soft/x11/resize-nesw.png') 2 28;
  --hardware-resize-nwse: url('img/cursors/soft/x11/resize-nwse.png') 28 28;
  --hardware-zoom-in: url('img/cursors/soft/kenney/32/zoom-in.png') 16 16;
  --hardware-zoom-out: url('img/cursors/soft/kenney/32/zoom-out.png') 16 16;
  --hardware-disabled: url('img/cursors/soft/kenney/32/disabled.png') 16 16;
}
:root[data-cursor-theme='kenney'][data-cursor-size='16'] {
  --hardware-arrow: url('img/cursors/soft/kenney/arrow.png') 1 1;
  --hardware-hand: url('img/cursors/soft/kenney/hand.png') 4 3;
  --hardware-wait: url('img/cursors/soft/kenney/wait.png') 8 8;
  --hardware-text: url('img/cursors/soft/kenney/text.png') 8 8;
  --hardware-move: url('img/cursors/soft/kenney/move.png') 8 8;
  --hardware-resize-ew: url('img/cursors/soft/kenney/resize-ew.png') 8 8;
  --hardware-resize-ns: url('img/cursors/soft/kenney/resize-ns.png') 8 8;
  --hardware-resize-nesw: url('img/cursors/soft/kenney/resize-nesw.png') 8 8;
  --hardware-resize-nwse: url('img/cursors/soft/kenney/resize-nwse.png') 8 8;
  --hardware-zoom-in: url('img/cursors/soft/kenney/zoom-in.png') 8 8;
  --hardware-zoom-out: url('img/cursors/soft/kenney/zoom-out.png') 8 8;
  --hardware-disabled: url('img/cursors/soft/kenney/disabled.png') 8 8;
}
:root[data-cursor-theme='kenney'][data-cursor-size='32'] {
  --hardware-arrow: url('img/cursors/soft/kenney/32/arrow.png') 2 2;
  --hardware-hand: url('img/cursors/soft/kenney/32/hand.png') 8 6;
  --hardware-wait: url('img/cursors/soft/kenney/32/wait.png') 16 16;
  --hardware-text: url('img/cursors/soft/kenney/32/text.png') 16 16;
  --hardware-move: url('img/cursors/soft/kenney/32/move.png') 16 16;
  --hardware-resize-ew: url('img/cursors/soft/kenney/32/resize-ew.png') 16 16;
  --hardware-resize-ns: url('img/cursors/soft/kenney/32/resize-ns.png') 16 16;
  --hardware-resize-nesw: url('img/cursors/soft/kenney/32/resize-nesw.png') 16 16;
  --hardware-resize-nwse: url('img/cursors/soft/kenney/32/resize-nwse.png') 16 16;
  --hardware-zoom-in: url('img/cursors/soft/kenney/32/zoom-in.png') 16 16;
  --hardware-zoom-out: url('img/cursors/soft/kenney/32/zoom-out.png') 16 16;
  --hardware-disabled: url('img/cursors/soft/kenney/32/disabled.png') 16 16;
}
:root[data-cursor-theme='x11'][data-cursor-size='16'] {
  --hardware-arrow: url('img/cursors/soft/x11/16/arrow.png') 1 1;
  --hardware-hand: url('img/cursors/soft/x11/16/hand.png') 0 1;
  --hardware-wait: url('img/cursors/soft/x11/16/wait.png') 15 9;
  --hardware-text: url('img/cursors/soft/x11/16/text.png') 4 8;
  --hardware-move: url('img/cursors/soft/x11/16/move.png') 8 8;
  --hardware-resize-ew: url('img/cursors/soft/x11/16/resize-ew.png') 7 4;
  --hardware-resize-ns: url('img/cursors/soft/x11/16/resize-ns.png') 4 7;
  --hardware-resize-nesw: url('img/cursors/soft/x11/16/resize-nesw.png') 1 14;
  --hardware-resize-nwse: url('img/cursors/soft/x11/16/resize-nwse.png') 14 14;
  --hardware-zoom-in: url('img/cursors/soft/kenney/zoom-in.png') 8 8;
  --hardware-zoom-out: url('img/cursors/soft/kenney/zoom-out.png') 8 8;
  --hardware-disabled: url('img/cursors/soft/kenney/disabled.png') 8 8;
}
:root[data-cursor-theme='x11'][data-cursor-size='32'] {
  --hardware-arrow: url('img/cursors/soft/x11/arrow.png') 2 2;
  --hardware-hand: url('img/cursors/soft/x11/hand.png') 0 2;
  --hardware-wait: url('img/cursors/soft/x11/wait.png') 30 18;
  --hardware-text: url('img/cursors/soft/x11/text.png') 8 16;
  --hardware-move: url('img/cursors/soft/x11/move.png') 16 16;
  --hardware-resize-ew: url('img/cursors/soft/x11/resize-ew.png') 14 8;
  --hardware-resize-ns: url('img/cursors/soft/x11/resize-ns.png') 8 14;
  --hardware-resize-nesw: url('img/cursors/soft/x11/resize-nesw.png') 2 28;
  --hardware-resize-nwse: url('img/cursors/soft/x11/resize-nwse.png') 28 28;
  --hardware-zoom-in: url('img/cursors/soft/kenney/32/zoom-in.png') 16 16;
  --hardware-zoom-out: url('img/cursors/soft/kenney/32/zoom-out.png') 16 16;
  --hardware-disabled: url('img/cursors/soft/kenney/32/disabled.png') 16 16;
}
@media (any-pointer: fine) {
  :root[data-retro-cursor='true'] body { cursor: var(--hardware-arrow), default; }
  :root[data-retro-cursor='true'] :is(button, a, summary, select, input[type='checkbox'], input[type='range']) { cursor: var(--hardware-hand), pointer; }
  :root[data-retro-cursor='true'] :is(input[type='text'], input[type='search'], textarea, [contenteditable='true']) { cursor: var(--hardware-text), text; }
  :root[data-retro-cursor='true'] [data-window-handle] { cursor: var(--hardware-move), grab; }
  :root[data-retro-cursor='true'] .is-maximized [data-window-handle] { cursor: var(--hardware-arrow), default; }
  :root[data-retro-cursor='true'] .window-dragging,
  :root[data-retro-cursor='true'] .window-dragging * { cursor: var(--hardware-move), grabbing !important; }
  :root[data-retro-cursor='true'] :is(.resize-n, .resize-s) { cursor: var(--hardware-resize-ns), ns-resize; }
  :root[data-retro-cursor='true'] :is(.resize-e, .resize-w) { cursor: var(--hardware-resize-ew), ew-resize; }
  :root[data-retro-cursor='true'] :is(.resize-ne, .resize-sw) { cursor: var(--hardware-resize-nesw), nesw-resize; }
  :root[data-retro-cursor='true'] :is(.resize-nw, .resize-se) { cursor: var(--hardware-resize-nwse), nwse-resize; }
  :root[data-retro-cursor='true'] :is(button:disabled, input:disabled) { cursor: not-allowed; }
  :root[data-retro-cursor='true'][data-hardware-busy='true'] body:not(.window-dragging):not(.window-resizing),
  :root[data-retro-cursor='true'][data-hardware-busy='true'] body:not(.window-dragging):not(.window-resizing) :is(button, a, summary, select, .lightbox-img, .image-viewer-stage, .post-figure img) { cursor: var(--hardware-wait), wait !important; }
}
/* Below the fixed glass effects: only the emitted image powers up. */
:root[data-hardware-startup='on']::after {
  content: ''; position: fixed; inset: 0; z-index: 9997; pointer-events: none;
  background: #020304;
  animation: hardware-panel-on 1200ms cubic-bezier(.22,.6,.3,1) both;
}
@keyframes hardware-panel-on {
  0% { opacity: 1; }
  18% { opacity: .85; }
  65% { opacity: .2; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { :root[data-hardware-startup='on']::after { display: none; animation: none; } }

.hardware-controls select { display: block; width: 100%; padding: 7px; margin-bottom: 12px; font: inherit; color: var(--terminal-text, #dedce4); background: var(--terminal-bg, #101115); border: 1px solid var(--terminal-rule, #ffffff20); }
.hardware-controls select:focus-visible { outline: 1px solid var(--terminal-accent, #ef5754); outline-offset: 3px; }

/* One small compositor surface under the glass, with a short pseudo-element trail. */
.hardware-screen-cursor {
  position: fixed; left: 0; top: 0; z-index: 9996;
  pointer-events: none; user-select: none; image-rendering: pixelated;
  background-repeat: no-repeat; background-size: 100% 100%;
  contain: layout style; will-change: transform;
}
.hardware-screen-cursor[hidden] { display: none; }
.hardware-screen-cursor::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: inherit; opacity: 0; transition: opacity 75ms linear;
  transform: translate(var(--cursor-trail-x, 0px), var(--cursor-trail-y, 0px));
}
.hardware-screen-cursor.has-trail::before { opacity: .1; }
@media (any-pointer: fine) {
  :root[data-retro-cursor='true'][data-screen-cursor-active='true'],
  :root[data-retro-cursor='true'][data-screen-cursor-active='true'] body,
  :root[data-retro-cursor='true'][data-screen-cursor-active='true'] body * { cursor: none !important; }
  :root[data-retro-cursor='true'][data-screen-cursor-active='true'][data-hardware-busy='true'] body:not(.window-dragging):not(.window-resizing),
  :root[data-retro-cursor='true'][data-screen-cursor-active='true'][data-hardware-busy='true'] body:not(.window-dragging):not(.window-resizing) :is(button, a, summary, select, .lightbox-img, .image-viewer-stage, .post-figure img) { cursor: none !important; }
}
@media (prefers-reduced-motion: reduce) { .hardware-screen-cursor::before { display: none; transition: none; } }
