/* ============================================================
   HEPIDEI — MOTION
   Keyframes, animasi masuk, marquee, scroll progress, custom
   cursor, dan tombol back-to-top.

   Aturan: hanya animate `opacity`, `translate`, `scale`,
   `rotate`, dan `transform`. Jangan animate blur/box-shadow.
   ============================================================ */

/* ---------- Keyframes ---------- */
@keyframes letter-up {
  from {
    opacity: 0;
    translate: 0 60%;
    rotate: -10deg;
    scale: 0.7;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    translate: 0 22px;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    scale: 0.9;
    rotate: -2deg;
  }
}

/* Animasi loop memakai `transform`, bukan properti translate/rotate,
   supaya tetap bisa digabung dengan parallax `translate` di elemen
   yang sama. */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-9px);
  }
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-6px) rotate(2deg);
  }
}

@keyframes spin-slow {
  to {
    transform: rotate(360deg);
  }
}

@keyframes jelly {
  0%,
  100% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.12, 0.88);
  }
  45% {
    transform: scale(0.92, 1.08);
  }
  60% {
    transform: scale(1.05, 0.96);
  }
  75% {
    transform: scale(0.98, 1.02);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.7) rotate(45deg);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.07) rotate(8deg);
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes progress-fill {
  from {
    scale: 0 1;
  }
  to {
    scale: 1 1;
  }
}

@keyframes marquee {
  to {
    translate: -50% 0;
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(163, 82, 106, 0.45);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(163, 82, 106, 0);
  }
}

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

/* ---------- Utility animation ---------- */
.animate-float {
  animation: float 5s ease-in-out infinite;
}

.animate-wiggle {
  animation: wiggle 4.5s ease-in-out infinite;
}

.animate-bob {
  animation: bob 5s ease-in-out infinite;
}

.animate-spin-slow {
  animation: spin-slow 18s linear infinite;
}

.animate-twinkle {
  animation: twinkle 3.4s ease-in-out infinite;
}

.animate-breathe {
  animation: breathe 9s ease-in-out infinite;
}

.animate-jelly:hover {
  animation: jelly 0.6s var(--ease-out);
}

/* Huruf hero: satu span per huruf, delay via --i */
.bouncy-letter {
  display: inline-block;
  animation: letter-up 0.75s var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

/* ---------- Scroll progress ---------- */
.progress {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 300;
  height: 4px;
  background: transparent;
  pointer-events: none;
}

.progress__bar {
  display: block;
  height: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(
    90deg,
    var(--color-rose),
    var(--color-blush) 55%,
    var(--color-gold)
  );
}

/* ---------- Marquee band ---------- */
.marquee-band {
  position: relative;
  overflow: hidden;
  padding-block: 16px;
  border-block: var(--border-w) solid var(--color-ink);
  background: var(--color-ink);
  color: var(--color-cream);
}

.marquee {
  overflow: hidden;
  mask-image: linear-gradient(
    90deg,
    transparent,
    #000 6%,
    #000 94%,
    transparent
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent,
    #000 6%,
    #000 94%,
    transparent
  );
}

.marquee__track {
  display: flex;
  width: max-content;
  animation: marquee 36s linear infinite;
}

.marquee:hover .marquee__track,
.marquee:focus-within .marquee__track {
  animation-play-state: paused;
}

.marquee__group {
  display: flex;
  align-items: center;
  gap: 30px;
  padding-right: 30px;
}

.marquee__item {
  display: inline-flex;
  align-items: center;
  gap: 30px;
  font: 600 18px/1 var(--font-display);
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.marquee__item::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-blush);
}

/* ---------- Back to top ---------- */
.totop {
  position: fixed;
  right: 22px;
  bottom: 92px;
  z-index: 400;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 50%;
  background: var(--color-blush);
  color: var(--color-ink);
  box-shadow: var(--shadow-hard-sm);
  opacity: 0;
  scale: 0.5;
  translate: 0 20px;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    translate 0.3s var(--ease-out),
    scale 0.3s var(--ease-spring);
}

.totop.is-visible {
  opacity: 1;
  scale: 1;
  translate: 0 0;
  pointer-events: auto;
}

.totop:hover {
  animation: jelly 0.6s var(--ease-out);
}

.totop svg {
  width: 20px;
  height: 20px;
}

/* ---------- Custom cursor ---------- */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 350;
  display: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  will-change: transform;
}

.cursor.is-visible {
  opacity: 1;
}

.cursor__inner {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  translate: -50% -50%;
}

.cursor__blob {
  position: absolute;
  inset: 0;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 46% 54% 55% 45% / 50% 44% 56% 50%;
  background: var(--color-blush);
  box-shadow: 0 2px 0 0 rgba(42, 30, 44, 0.55);
  animation: spin-cursor 22s linear infinite;
}

.cursor__label {
  position: relative;
  font: 600 12px/1 var(--font-display);
  letter-spacing: 0.2px;
  color: var(--color-ink);
  white-space: nowrap;
}

@media (pointer: fine) {
  html.custom-cursor,
  html.custom-cursor * {
    cursor: none;
  }

  html.custom-cursor input,
  html.custom-cursor textarea {
    cursor: text;
  }

  .cursor {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor {
    display: none !important;
  }

  .marquee__track {
    animation: none;
  }
}
