/* ASTRAL adaptive cursor — a water lens that adapts to link, media, drag, press & scene lighting */

.astral-cursor-host {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.astral-cursor-layer {
  --size: 34px;
  --cursor-scale: 1;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 90;
  width: var(--size);
  height: var(--size);
  margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
  pointer-events: none;
  opacity: 0;
  will-change: transform;
}

.astral-cursor-layer.is-live { opacity: 1; }
.astral-cursor-layer > i {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 50%;
  transform: scale(var(--cursor-scale));
  transition: transform .38s cubic-bezier(.2, .72, .22, 1), border-radius .3s ease, border-color .3s ease;
}

/* Broad displaced haze synced to Scene Lighting */
.astral-cursor-halo > i {
  background:
    radial-gradient(circle at 52% 48%, var(--scene-glow, rgba(255, 232, 198, .24)) 0 18%, rgba(158, 132, 176, .08) 54%, transparent 72%);
  filter: blur(5px);
  mix-blend-mode: screen;
}

/* Refracting ring with slow caustic sweep */
.astral-cursor-ring > i {
  border: 1px solid var(--scene-accent, rgba(240, 213, 179, .52));
  opacity: 0.68;
  box-shadow:
    inset 0 0 14px var(--scene-glow, rgba(236, 192, 156, .16)),
    0 0 12px var(--scene-glow, rgba(228, 176, 148, .10));
}
.astral-cursor-ring > i::after {
  position: absolute;
  inset: -5px;
  content: '';
  border-radius: 50%;
  opacity: .6;
  background: conic-gradient(
    from 8deg,
    rgba(255, 234, 202, .78),
    rgba(255, 234, 202, 0) 22%,
    rgba(202, 163, 202, .4) 46%,
    rgba(255, 234, 202, 0) 64%,
    rgba(255, 234, 202, .7)
  );
  -webkit-mask: radial-gradient(circle, transparent 0 77%, #000 79%);
  mask: radial-gradient(circle, transparent 0 77%, #000 79%);
  animation: cursor-caustic 11s linear infinite;
}

/* Small point of light at the fingertip */
.astral-cursor-dot > i {
  background: radial-gradient(circle at 34% 30%, #fffaf0, var(--scene-accent, #f2d3b2) 64%, #cf9f8c 100%);
  box-shadow:
    0 0 8px rgba(255, 230, 198, .72),
    0 0 20px var(--scene-glow, rgba(216, 162, 152, .34));
  transition: transform .26s cubic-bezier(.2, .72, .22, 1), opacity .26s ease;
}

@keyframes cursor-caustic {
  to { rotate: 360deg; }
}

/* Adaptive cursor states */
html[data-cursor="link"] .astral-cursor-ring { --cursor-scale: 1.5; }
html[data-cursor="link"] .astral-cursor-ring > i { border-color: rgba(255, 233, 199, .9); opacity: 0.9; }
html[data-cursor="link"] .astral-cursor-dot { --cursor-scale: .55; }

html[data-cursor="media"] .astral-cursor-ring { --cursor-scale: 1.95; }
html[data-cursor="media"] .astral-cursor-ring > i {
  border-style: dashed;
  border-color: var(--gold-bright, #ffe1b5);
  opacity: 0.92;
}
html[data-cursor="media"] .astral-cursor-dot { --cursor-scale: 1.35; }
html[data-cursor="media"] .astral-cursor-halo { --cursor-scale: 1.3; }

html[data-cursor="drag"] .astral-cursor-ring { --cursor-scale: 1.32; }
html[data-cursor="drag"] .astral-cursor-ring > i {
  border-radius: 42% 58% 46% 54% / 52% 46% 54% 48%;
  border-color: var(--scene-accent, #d6e0f5);
}
html[data-cursor="drag"] .astral-cursor-dot { --cursor-scale: .85; }

html[data-cursor="press"] .astral-cursor-ring { --cursor-scale: .72; }
html[data-cursor="press"] .astral-cursor-halo { --cursor-scale: 1.25; }

html[data-cursor="text"] .astral-cursor-ring,
html[data-cursor="text"] .astral-cursor-dot { opacity: 0; }
html[data-cursor="text"] .astral-cursor-halo { --cursor-scale: .5; }

/* Hide the system pointer only where the custom one is drawn */
html.astral-cursor-active,
html.astral-cursor-active body,
html.astral-cursor-active *:not(input, textarea, select, [contenteditable=""], [contenteditable="true"]) {
  cursor: none;
}

/* Modal dialogs sit in the top layer above the cursor, so restore the native one there */
html.astral-cursor-active:has(dialog[open]) { cursor: auto; }
html.astral-cursor-active:has(dialog[open]) *:not(input, textarea, select) { cursor: auto; }
html.astral-cursor-active:has(dialog[open]) :is(a, button, summary, label, [role="button"]) { cursor: pointer; }
html.astral-cursor-active:has(dialog[open]) :is(input, textarea, select) { cursor: auto; }
html:has(dialog[open]) .astral-cursor-layer { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .astral-cursor-layer > i::after { animation: none; }
}
