@font-face {
  font-family: 'Kunafa Calm';
  src: url('assets/fonts/kunafa-calm.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@property --hue { syntax: '<number>'; inherits: true; initial-value: 196; }

:root {
  --bg: #f4f6fb;
  --core: #1e1b4b;
  --core-glow: rgba(99, 102, 241, .55);

  box-sizing: border-box;
  animation: hue 26s ease-in-out infinite alternate;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060914;
    --core: #ffffff;
    --core-glow: rgba(125, 211, 252, .95);
  }
}
:root[data-theme="dark"] {
  --bg: #060914;
  --core: #ffffff;
  --core-glow: rgba(125, 211, 252, .95);
}

@keyframes hue { from { --hue: 178; } to { --hue: 318; } }

html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg);
  touch-action: pinch-zoom; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) { html, body { cursor: none; } }

.stage {
  position: fixed; overflow: hidden;
  top: env(safe-area-inset-top, 0px);
  left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px);
  height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  font-size: min(28vw, 32vh, 15rem);
  font-size: min(28vw, 32svh, 15rem);
}
/* A shared, tightly bounded filter lets the letters and trail fuse on contact. */
.liquid {
  position: absolute; left: 0; top: 0; width: 300px; height: 300px;
  transform-origin: 0 0;
  pointer-events: none;
  filter: url(#liquid) drop-shadow(0 0 26px hsl(var(--hue) 90% 55% / .35));
}
.trail { position: absolute; inset: 0; }
.word {
  position: absolute; left: 0; top: 0; display: flex; margin: 0;
  font: 400 240px/1 'Kunafa Calm', serif;
}
.letter {
  --h: calc(var(--hue) + var(--i) * 12 + var(--stain, 0));
  display: block;
  color: hsl(var(--h) 95% 58%);
  background: radial-gradient(ellipse at 30% 25%,
    hsl(var(--h) 100% 76%), hsl(var(--h) 95% 58%) 70%, hsl(var(--h) 92% 52%));
  background-clip: text; -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.dot {
  --s: calc(76px - var(--i) * 1.9px);
  --h: calc(var(--hue) + var(--i) * 3.6);
  position: absolute; left: 0; top: 0; display: block;
  width: var(--s); height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
}
.orb {
  position: absolute; inset: 0; display: block; border-radius: 50%;
  background: radial-gradient(circle,
    hsl(var(--h) 100% 76%), hsl(var(--h) 95% 58%) 70%, hsl(var(--h) 92% 52%));
  animation: breathe 4.6s ease-in-out infinite, morph 6s ease-in-out infinite;
  animation-delay: calc(var(--i) * -.2s), calc(var(--i) * -.4s);
}
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes morph {
  0%, 100% { border-radius: 50%; }
  33% { border-radius: 56% 44% 52% 48% / 47% 55% 45% 53%; }
  66% { border-radius: 45% 55% 47% 53% / 54% 46% 56% 44%; }
}

.core {
  position: absolute; left: 0; top: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: var(--core); box-shadow: 0 0 18px 4px var(--core-glow);
  transition: opacity .5s;
}
:root.seen:not(.idle) .core { opacity: 1; }
@media (hover: none) { .core { display: none; } }

:root.paused, :root.paused .orb { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  :root { animation: none; }
  .orb { animation: none; }
}
