/* ==========================================================================
   animations.css — semua keyframes & efek gerak.
   Kecepatan utama diatur lewat variabel di themes.css (--dur-*, --stagger).
   Hanya memakai transform / opacity supaya tetap 60fps.
   ========================================================================== */

/* ---------- KEYFRAMES UMUM ---------- */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes blink   { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes fadeIn  { to { opacity: 1; } }
@keyframes draw    { to { stroke-dashoffset: 0; } }
@keyframes shimmer { to { background-position: -260% 0; } }
@keyframes eq      { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }
@keyframes ripple  { from { transform: scale(0); opacity: 1; } to { transform: scale(1); opacity: 0; } }
@keyframes trail {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1); opacity: .85; }
  100% { transform: translate(var(--dx, 10px), var(--dy, 40px)) rotate(var(--rot, 180deg)) scale(.35); opacity: 0; }
}
@keyframes pageIn {
  from { opacity: 0; transform: translateX(26px); filter: blur(10px); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 79, 112, .6), 0 0 22px rgba(217, 79, 112, .45); transform: scale(1); }
  50%      { box-shadow: 0 0 0 16px rgba(217, 79, 112, 0), 0 0 34px rgba(217, 79, 112, .7); transform: scale(1.05); }
}
@keyframes bloom {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes burst {
  0%   { opacity: 0; transform: translate(0, 0) scale(.2) rotate(0deg); }
  12%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); }
}

/* ---------- TRANSISI ANTAR HALAMAN (fade + slide + blur) ---------- */
#app { transition: opacity .26s ease, transform .26s ease, filter .26s ease; }
#app.leaving { opacity: 0; transform: translateX(-22px); filter: blur(8px); pointer-events: none; }
#app.entering { animation: pageIn var(--dur-base) var(--ease) backwards; }

/* ---------- SCROLL REVEAL + STAGGER ---------- */
.reveal {
  opacity: 0;
  translate: var(--tx, 0) var(--ty, 24px);
  transition:
    opacity var(--dur-slow) var(--ease) calc(min(var(--i, 0), 10) * var(--stagger)),
    translate var(--dur-slow) var(--ease) calc(min(var(--i, 0), 10) * var(--stagger));
}
.reveal.in { opacity: 1; translate: 0 0; }

/* ---------- HOVER TILT 3D ---------- */
[data-tilt] {
  transform: perspective(800px) translateY(var(--lift, 0px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .18s ease-out, box-shadow var(--dur-base);
}
.reveal[data-tilt] {
  transition:
    opacity var(--dur-slow) var(--ease) calc(min(var(--i, 0), 10) * var(--stagger)),
    translate var(--dur-slow) var(--ease) calc(min(var(--i, 0), 10) * var(--stagger)),
    transform .18s ease-out 0s,
    box-shadow var(--dur-base) 0s;
}
[data-tilt].tilting { --lift: -4px; }
[data-tilt].tilt-reset { transition-duration: .5s; }

/* ---------- SHIMMER METALIK PADA BORDER ---------- */
.card:hover::before { animation: shimmer 1.8s linear infinite; }

/* ---------- GLITCH PADA JUDUL ---------- */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%;
  pointer-events: none; opacity: 0; text-align: inherit; overflow-wrap: anywhere;
}
.glitch::before { color: var(--c-rose); }
.glitch::after  { color: var(--c-silver); }
.page-title.glitch::before { animation: glitch-a 5.5s infinite; }
.page-title.glitch::after  { animation: glitch-b 5.5s infinite; }
@keyframes glitch-a {
  0%, 90%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
  91% { opacity: .9; transform: translate(-4px, 1px); clip-path: inset(8% 0 58% 0); }
  94% { opacity: .9; transform: translate(3px, -1px); clip-path: inset(62% 0 10% 0); }
  97% { opacity: .8; transform: translate(-2px, 0); clip-path: inset(30% 0 42% 0); }
}
@keyframes glitch-b {
  0%, 90%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
  92% { opacity: .8; transform: translate(4px, -1px); clip-path: inset(55% 0 12% 0); }
  95% { opacity: .8; transform: translate(-3px, 1px); clip-path: inset(12% 0 60% 0); }
  98% { opacity: .7; transform: translate(2px, 0); clip-path: inset(40% 0 30% 0); }
}
@keyframes glitch-fast-a {
  0%, 100% { opacity: .9; transform: translate(-3px, 0); clip-path: inset(10% 0 60% 0); }
  25% { transform: translate(3px, 1px); clip-path: inset(55% 0 15% 0); }
  50% { transform: translate(-2px, -1px); clip-path: inset(30% 0 40% 0); }
  75% { transform: translate(4px, 0); clip-path: inset(70% 0 5% 0); }
}
@keyframes glitch-fast-b {
  0%, 100% { opacity: .8; transform: translate(3px, 0); clip-path: inset(60% 0 10% 0); }
  25% { transform: translate(-3px, -1px); clip-path: inset(15% 0 55% 0); }
  50% { transform: translate(2px, 1px); clip-path: inset(42% 0 28% 0); }
  75% { transform: translate(-4px, 0); clip-path: inset(5% 0 72% 0); }
}

/* ---------- INTRO ---------- */
#intro .draw { stroke-dasharray: var(--len, 700); stroke-dashoffset: var(--len, 700); }
#intro .rose-fill { opacity: 0; fill: rgba(139, 26, 43, .55); }
#intro.step-draw .draw { animation: draw 1.5s ease forwards; animation-delay: var(--d, 0s); }
#intro.step-draw .rose-fill { animation: fadeIn 1.1s ease 1.3s forwards; }
#intro.step-burst .intro-rose { animation: bloom .9s var(--ease); }

.intro-hello, .intro-name { opacity: 0; transform: translateY(10px); transition: opacity .7s ease, transform .7s ease; }
#intro.step-type .intro-hello, #intro.step-type .intro-name { opacity: 1; transform: none; }
.intro-name .caret { animation: blink .9s steps(1) infinite; }
#intro.step-type .intro-name.glitch::before { animation: glitch-fast-a .45s steps(1) infinite; }
#intro.step-type .intro-name.glitch::after  { animation: glitch-fast-b .45s steps(1) infinite; }
#intro.step-calm .intro-name.glitch::before { animation: glitch-a 3.2s infinite; }
#intro.step-calm .intro-name.glitch::after  { animation: glitch-b 3.2s infinite; }

.intro-enter { opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .6s ease, transform .6s ease; }
#intro.step-enter .intro-enter { opacity: 1; transform: none; pointer-events: auto; animation: pulse 1.8s ease-in-out .6s infinite; }
.intro-skip { opacity: 0; animation: fadeIn .6s ease .4s forwards; }

#intro.leaving { opacity: 0; transform: scale(1.08); filter: blur(12px); pointer-events: none; transition: opacity .8s ease, transform .8s ease, filter .8s ease; }

.burst-petal {
  position: absolute; left: 0; top: 0; width: var(--sz, 14px); height: calc(var(--sz, 14px) * 1.4);
  border-radius: 70% 30% 70% 30% / 60% 40% 60% 40%; background: var(--c, #d94f70); opacity: 0;
  animation: burst var(--dur, 2.4s) cubic-bezier(.15, .7, .3, 1) forwards; animation-delay: var(--delay, 0s);
}

/* ---------- PREFERS-REDUCED-MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; transition-delay: 0s !important;
  }
  .reveal { opacity: 1; translate: none; }
  [data-tilt] { transform: none; }
  .skill-fill { transform: scaleX(var(--lvl, 0)); }
  .trail-petal, .burst-petal { display: none; }
  .disc { animation: none; }
}
