/* ==========================================================================
   Halaman depan (index.php) — lapisan animasi
   Dimuat SETELAH pages/index.css. Menghidupkan kembali animasi latar hero
   yang sebelumnya dimatikan, plus animasi masuk, scroll reveal, hitung
   angka, parallax kartu, dan kilau tombol. Semua dimatikan otomatis bila
   perangkat meminta "kurangi gerakan" (prefers-reduced-motion).
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {

  /* ---------- 1. Latar hero hidup ---------- */
  #homePage .hero-orb-a   { animation: imOrbA 11s ease-in-out infinite !important; opacity: .55; }
  #homePage .hero-orb-b   { animation: imOrbB 9s 1s ease-in-out infinite !important; opacity: .5; }
  #homePage .hero-orb-c   { animation: imOrbC 14s ease-in-out infinite !important; opacity: .45; }
  #homePage .hero-glow-ring { animation: imRing 7s ease-in-out infinite !important; }
  #homePage .hero-star    { animation: imTwinkle 3.6s ease-in-out infinite !important; }
  #homePage .hero-star.s2 { animation-delay: .9s !important; }
  #homePage .hero-star.s3 { animation-delay: 1.8s !important; }
  #homePage .hero-star.s4 { animation-delay: 2.6s !important; }
  #homePage .hero-shimmer { display: block !important; animation: imShimmer 7s ease-in-out infinite !important; }
  #homePage .hero-school-logo { animation: imLogo 5s ease-in-out infinite !important; }
  #homePage .hero-note .dot { animation: imPulseDot 2.2s ease-in-out infinite !important; }

  /* Partikel halus yang naik perlahan (dibuat oleh index-motion.js) */
  .im-particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
  .im-particles i {
    position: absolute; bottom: -12px;
    width: var(--s, 6px); height: var(--s, 6px); border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.95), rgba(255,255,255,0) 70%);
    opacity: 0;
    animation: imRise var(--d, 12s) linear var(--delay, 0s) infinite;
  }
  html.theme-dark .im-particles i { background: radial-gradient(circle, rgba(147,197,253,.9), rgba(147,197,253,0) 70%); }

  /* ---------- 2. Animasi masuk hero (bertahap) ---------- */
  .im-ready #homePage .hero-left > *,
  .im-ready #homePage .hero-brand { opacity: 0; }
  #homePage.im-go .hero-brand        { animation: imUp .7s cubic-bezier(.2,.8,.2,1) .05s both; }
  #homePage.im-go .hero-left h1      { animation: imUp .8s cubic-bezier(.2,.8,.2,1) .15s both; }
  #homePage.im-go .hero-copy         { animation: imUp .8s cubic-bezier(.2,.8,.2,1) .3s both; }
  #homePage.im-go .hero-actions      { animation: imUp .8s cubic-bezier(.2,.8,.2,1) .42s both; }
  #homePage.im-go .hero-note         { animation: imUp .8s cubic-bezier(.2,.8,.2,1) .55s both; }
  #homePage.im-go .dashboard-card    { animation: imCardIn 1s cubic-bezier(.2,.8,.2,1) .25s both, imFloat 6s ease-in-out 1.4s infinite !important; }

  /* Judul: kata per kata naik, bagian <em> berkilau gradasi */
  #homePage .im-word { display: inline-block; opacity: 0; transform: translateY(.55em) rotate(2deg); }
  #homePage.im-go .im-word { animation: imWord .7s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(.2s + var(--i) * .06s); }
  #homePage .hero-left h1 em {
    background: linear-gradient(90deg, currentColor 0%, #7cc4ff 35%, #ffffff 50%, #7cc4ff 65%, currentColor 100%);
    background-size: 250% 100%;
    -webkit-background-clip: text; background-clip: text;
    animation: imTextShine 6s ease-in-out 1.6s infinite;
  }
  #homePage .hero-left h1 em .im-word { -webkit-text-fill-color: transparent; background: inherit; -webkit-background-clip: text; background-clip: text; }

  /* Bar statistik tumbuh setelah kartu masuk */
  #homePage.im-go .bar-fill { transform-origin: left center; animation: imBar 1.4s cubic-bezier(.2,.8,.2,1) both !important; }
  #homePage.im-go .bar-row:nth-child(1) .bar-fill { animation-delay: .9s !important; }
  #homePage.im-go .bar-row:nth-child(2) .bar-fill { animation-delay: 1.05s !important; }
  #homePage.im-go .bar-row:nth-child(3) .bar-fill { animation-delay: 1.2s !important; }

  /* ---------- 3. Scroll reveal ---------- */
  #homePage .im-reveal { opacity: 0 !important; transform: translateY(26px) scale(.985) !important; transition: opacity .7s cubic-bezier(.2,.8,.2,1), transform .7s cubic-bezier(.2,.8,.2,1) !important; transition-delay: calc(var(--i, 0) * 70ms) !important; }
  #homePage .im-reveal.im-in { opacity: 1 !important; transform: none !important; }
  #homePage .section-top.im-reveal { transform: translateY(18px) !important; }

  /* ---------- 4. Interaksi ---------- */
  #homePage .btn-primary { position: relative; overflow: hidden; }
  #homePage .btn-primary::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent);
    transform: skewX(-18deg);
    animation: imBtnShine 4.5s ease-in-out 2s infinite;
    pointer-events: none;
  }
  #homePage .portal-card { transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s, border-color .35s !important; }
  #homePage .portal-card:hover { transform: translateY(-5px) !important; box-shadow: 0 18px 36px rgba(15,35,65,.12) !important; }
  #homePage .portal-card:hover .p-icon { animation: imWiggle .6s ease both !important; }
  #homePage .portal-card .p-go { transition: transform .3s ease; }
  #homePage .portal-card:hover .p-go { transform: translateX(4px); }
  #homePage .service-card { transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s !important; }
  #homePage .service-card:hover { transform: translateY(-6px) !important; box-shadow: 0 22px 44px rgba(15,35,65,.12) !important; }
  #homePage .highlight .hi-icon { transition: transform .4s cubic-bezier(.2,.8,.2,1); }
  #homePage .highlight:hover .hi-icon { transform: rotate(-8deg) scale(1.12); }
  #homePage .dashboard-card.im-tilt { transition: rotate .3s ease-out; }
  #homePage .cta { background-size: 200% 200% !important; animation: imGradient 10s ease infinite; }
}

/* ---------- Keyframes ---------- */
@keyframes imOrbA { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(-40px,34px,0) scale(1.12); } }
@keyframes imOrbB { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(46px,-30px,0) scale(1.08); } }
@keyframes imOrbC { 0%,100% { transform: translate3d(0,0,0); } 33% { transform: translate3d(-50px,20px,0); } 66% { transform: translate3d(30px,-24px,0); } }
@keyframes imRing { 0%,100% { transform: scale(.94); opacity: .5; } 50% { transform: scale(1.06); opacity: 1; } }
@keyframes imTwinkle { 0%,100% { opacity: .2; transform: scale(.7) rotate(0); } 50% { opacity: 1; transform: scale(1.2) rotate(20deg); } }
@keyframes imShimmer { 0% { left: -45%; opacity: 0; } 15% { opacity: .85; } 50% { left: 118%; opacity: .6; } 60%,100% { left: 118%; opacity: 0; } }
@keyframes imLogo { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes imPulseDot { 0%,100% { box-shadow: 0 0 0 0 rgba(89,255,172,.55); } 70% { box-shadow: 0 0 0 9px rgba(89,255,172,0); } }
@keyframes imRise { 0% { transform: translateY(0) translateX(0); opacity: 0; } 10% { opacity: var(--o, .7); } 90% { opacity: var(--o, .7); } 100% { transform: translateY(var(--h, -520px)) translateX(var(--x, 30px)); opacity: 0; } }
@keyframes imUp { from { opacity: 0; transform: translateY(24px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes imWord { to { opacity: 1; transform: none; } }
@keyframes imCardIn { from { opacity: 0; transform: translateX(48px) rotate(2deg) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes imFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes imTextShine { 0%,100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
@keyframes imBar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes imBtnShine { 0% { left: -60%; } 30%,100% { left: 130%; } }
@keyframes imWiggle { 0%,100% { transform: rotate(0) scale(1); } 30% { transform: rotate(-10deg) scale(1.1); } 60% { transform: rotate(6deg) scale(1.08); } }
@keyframes imGradient { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
