/*
 * ⛔⛔ THE FREALLY CURSOR — how it looks (`cursor.js` moves it and says when).
 * Byte-identical in every app's `src/cursor-kit/` and in the site kit: edit
 * `Freally Bugs/cursor-kit/kit/cursor.css`, then sync; never a copy.
 *
 * The ring and the dot are Freally green: an app's `--color-primary-ink` (the
 * lime on the dark ground, the icon's shadow green on the light one), a site's
 * `--accent`; `--freally-cursor-color` overrides both.
 */

/* Where the page asks for no cursor of its own, the arrow gives way to the
   ring. Zero specificity: every cursor an app or a site asks for wins. */
:where(:root.freally-cursor-on) {
  cursor: none;
}

/* …but where typing goes, the text cursor stays. */
:where(:root.freally-cursor-on)
  :where(
    textarea,
    [contenteditable]:not([contenteditable='false']),
    input:not(
      [type='button'],
      [type='checkbox'],
      [type='color'],
      [type='file'],
      [type='image'],
      [type='radio'],
      [type='range'],
      [type='reset'],
      [type='submit']
    )
  ) {
  cursor: auto;
}

/* The browser's own arrow and hand give way too, before the pointer gets
   there: it draws the arrow on form controls and labels, and the hand on links,
   whatever their parent asks for. Zero specificity again, so every cursor a page
   asks for still wins (and `cursor.js` takes over the page's own arrows and
   hands); `--freally-cursor-asked` says which it was. */
:where(:root.freally-cursor-on)
  :where(
    button,
    label,
    option,
    select,
    input:is(
      [type='button'],
      [type='checkbox'],
      [type='color'],
      [type='file'],
      [type='image'],
      [type='radio'],
      [type='range'],
      [type='reset'],
      [type='submit']
    )
  ) {
  cursor: none;
  --freally-cursor-asked: arrow;
}

:where(:root.freally-cursor-on) :where(a:any-link) {
  cursor: none;
  --freally-cursor-asked: hand;
}

/* The one element under the pointer, when an inline style asks for the arrow or the hand. */
[data-freally-cursor-hide] {
  cursor: none !important;
}

.freally-cursor {
  --freally-cursor-ink: var(
    --freally-cursor-color,
    var(--color-primary-ink, var(--accent, #79d920))
  );
  /* ⚠ Physical on purpose, here and below: the pointer's coordinates never
     mirror, in Arabic or anywhere. */
  position: fixed;
  inset: 0 auto auto 0;
  width: 0;
  height: 0;
  z-index: 2147483647;
  pointer-events: none;
  visibility: hidden;
}

.freally-cursor[data-shown]:not([data-native]) {
  visibility: visible;
}

.freally-cursor-ring,
.freally-cursor-dot {
  position: absolute;
  inset: 0 auto auto 0;
  width: 0;
  height: 0;
  will-change: transform;
}

/* 34 px across, centred on the ring's point (`RING` in cursor.js). */
.freally-cursor-grow {
  position: absolute;
  inset: -17px auto auto -17px;
  width: 34px;
  height: 34px;
}

.freally-cursor-press {
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--freally-cursor-ink);
  border-radius: 50%;
}

.freally-cursor-grow,
.freally-cursor-press {
  transition:
    transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 160ms ease;
}

/* Over something pressable: a little bigger (`HOVER`). */
.freally-cursor[data-hover] .freally-cursor-grow {
  transform: scale(1.45);
}

.freally-cursor[data-hover] .freally-cursor-press {
  background-color: color-mix(in srgb, var(--freally-cursor-ink) 14%, transparent);
}

/* Pressed: a little smaller, then back (`PRESS`, `PRESS_MIN_MS`). */
.freally-cursor[data-pressed] .freally-cursor-press {
  transform: scale(0.78);
  transition-duration: 90ms;
}

/* 6 px across, on the pointer's hotspot (`DOT` in cursor.js). */
.freally-cursor-dot::before {
  content: '';
  position: absolute;
  inset: -3px auto auto -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--freally-cursor-ink);
}

@media (prefers-reduced-motion: reduce) {
  .freally-cursor * {
    transition: none;
  }
}

:root[data-motion='reduce'] .freally-cursor * {
  transition: none;
}
