/* ==========================================================
   Animasi & efek hidup — Masjid Cendikia
   Semua efek dimatikan bila pengguna memilih "kurangi gerakan".
   ========================================================== */

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

  /* Transisi halus antarhalaman (browser yang mendukung) */
  @view-transition { navigation: auto; }
  /* Elemen yang meluncur dari samping tidak boleh memicu gulir horizontal */
  html, body { overflow-x: clip; }

  /* ---------- Pola geometri Islami bergerak (hero, judul halaman, CTA) ---------- */
  .hero, .phero, .cta, .section--dark { position: relative; overflow: hidden; isolation: isolate; }
  .hero > .wrap, .phero > .wrap, .cta > .wrap, .section--dark > .wrap { position: relative; z-index: 2; }
  .hero::before, .phero::before, .cta::before, .section--dark::before {
    content: ""; position: absolute; inset: -80px; z-index: 0; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23f0cf85' stroke-width='1'%3E%3Cpath d='M40 16L64 40L40 64L16 40Z'/%3E%3Cpath d='M23 23H57V57H23Z'/%3E%3Ccircle cx='40' cy='40' r='6'/%3E%3Cpath d='M0 0L23 23M80 0L57 23M0 80L23 57M80 80L57 57'/%3E%3C/g%3E%3C/svg%3E");
    opacity: .09;
    -webkit-mask-image: radial-gradient(70% 80% at 80% 30%, #000, transparent 75%);
            mask-image: radial-gradient(70% 80% at 80% 30%, #000, transparent 75%);
    animation: m-drift 40s linear infinite;
  }
  @keyframes m-drift { to { transform: translate(80px, 80px); } }

  /* Bintang delapan besar berputar perlahan di hero */
  .hero::after {
    content: ""; position: absolute; z-index: 0; pointer-events: none;
    width: min(720px, 90vw); aspect-ratio: 1; right: -18%; top: -22%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23d6a84a' stroke-width='.6'%3E%3Cpath d='M100 6L194 100L100 194L6 100Z'/%3E%3Cpath d='M33.5 33.5H166.5V166.5H33.5Z'/%3E%3Ccircle cx='100' cy='100' r='66'/%3E%3Ccircle cx='100' cy='100' r='47'/%3E%3Cpath d='M100 53L133 100L100 147L67 100Z'/%3E%3Cpath d='M53 100L100 67L147 100L100 133Z'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
    opacity: .22;
    animation: m-spin 120s linear infinite;
  }
  @keyframes m-spin { to { transform: rotate(360deg); } }

  /* Kanvas partikel cahaya (dibuat oleh motion.js) */
  .m-sparkle { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

  /* ---------- Masuknya hero ---------- */
  .hero__in > * { animation: m-rise .9s cubic-bezier(.2,.7,.2,1) both; }
  .hero__in > :nth-child(1) { animation-delay: .15s; }
  .hero__in > :nth-child(2) { animation-delay: .3s; }
  .hero__in > :nth-child(3) { animation-delay: .45s; }
  .hero__in > :nth-child(4) { animation-delay: .6s; }
  .hero__in > :nth-child(5) { animation-delay: .75s; }
  @keyframes m-rise { from { opacity: 0; transform: translateY(28px); filter: blur(6px); } }

  .hero__img { animation: m-zoom 1.3s cubic-bezier(.2,.7,.2,1) both; }
  @keyframes m-zoom { from { opacity: 0; transform: scale(.92); } }
  .hero__img img { animation: m-float 7s ease-in-out 1.3s infinite; translate: var(--px, 0) var(--py, 0); transition: translate .4s ease-out; }
  @keyframes m-float { 50% { transform: translateY(-12px); } }
  @media (min-width: 861px) {
    .hero__img { position: relative; }
    .hero__img::before {
      content: ""; position: absolute; inset: -14px; z-index: -1; border-radius: 40px 40px 160px 160px / 40px 40px 110px 110px;
      background: conic-gradient(from var(--m-a, 0deg), transparent 0 60%, rgba(240,207,133,.7) 75%, transparent 90%);
      filter: blur(18px); opacity: .55; animation: m-orbit 8s linear infinite;
    }
  }
  @property --m-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
  @keyframes m-orbit { to { --m-a: 360deg; } }

  /* Judul "Masjid Cendikia" berkilau emas */
  .hero h1 {
    background: linear-gradient(100deg, #fff 0 38%, var(--gold-2) 46%, #fff8e6 50%, var(--gold-2) 54%, #fff 62% 100%);
    background-size: 250% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: m-rise .9s cubic-bezier(.2,.7,.2,1) .45s both, m-shine 6s ease-in-out 1.6s infinite;
  }
  @keyframes m-shine { 0% { background-position: 100% 0; } 45%, 100% { background-position: -50% 0; } }
  .hero__ayat { text-shadow: 0 0 22px rgba(240,207,133,.35); }

  /* Judul halaman dalam */
  .phero .crumbs, .phero h1, .phero__lead { animation: m-rise .8s cubic-bezier(.2,.7,.2,1) both; }
  .phero h1 { animation-delay: .12s; }
  .phero__lead { animation-delay: .24s; }

  /* ---------- Bilah progres gulir ---------- */
  .m-progress {
    position: fixed; inset: 0 0 auto; height: 3px; z-index: 60; pointer-events: none;
    background: linear-gradient(90deg, var(--gold), var(--gold-2), var(--gold));
    transform-origin: 0 50%; transform: scaleX(var(--p, 0));
    box-shadow: 0 0 10px rgba(214,168,74,.7);
  }

  /* ---------- Menu ---------- */
  @media (min-width: 1001px) {
    .menu a:not(.btn) { position: relative; }
    .menu a:not(.btn)::after {
      content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; border-radius: 2px;
      background: var(--gold); transform: scaleX(0); transform-origin: right; transition: transform .3s cubic-bezier(.2,.7,.2,1);
    }
    .menu a:not(.btn):hover::after { transform: scaleX(1); transform-origin: left; }
  }
  @media (max-width: 1000px) {
    .menu.is-open { animation: m-drop .3s cubic-bezier(.2,.7,.2,1); }
    .menu.is-open > * { animation: m-rise .4s cubic-bezier(.2,.7,.2,1) both; }
    .menu.is-open > :nth-child(2) { animation-delay: .03s; }
    .menu.is-open > :nth-child(3) { animation-delay: .06s; }
    .menu.is-open > :nth-child(4) { animation-delay: .09s; }
    .menu.is-open > :nth-child(5) { animation-delay: .12s; }
    .menu.is-open > :nth-child(6) { animation-delay: .15s; }
    .menu.is-open > :nth-child(7) { animation-delay: .18s; }
    .menu.is-open > :nth-child(8) { animation-delay: .21s; }
  }
  @keyframes m-drop { from { opacity: 0; transform: translateY(-10px); } }
  .brand img { transition: transform .6s cubic-bezier(.2,.7,.2,1); }
  .brand:hover img { transform: rotate(-8deg) scale(1.08); }

  /* ---------- Tombol: kilau menyapu ---------- */
  .btn { position: relative; overflow: hidden; isolation: isolate; }
  .btn--gold::after, .btn--primary::after, .btn--wa::after {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%);
    transform: translateX(-120%); animation: m-sweep 4.5s ease-in-out infinite;
  }
  .btn--primary::after, .btn--wa::after { background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.22) 50%, transparent 70%); animation-delay: 1.5s; }
  @keyframes m-sweep { 0%, 60% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
  .btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -10px rgba(42,11,27,.55); }
  .btn:active { transform: translateY(0) scale(.97); }

  /* ---------- Muncul saat digulir ---------- */
  .rv { opacity: 0; translate: 0 34px; transition: opacity .8s cubic-bezier(.2,.7,.2,1), translate .8s cubic-bezier(.2,.7,.2,1), scale .8s cubic-bezier(.2,.7,.2,1), clip-path 1.1s cubic-bezier(.7,0,.2,1), transform .25s, box-shadow .25s; }
  .rv--left  { translate: -40px 0; }
  .rv--right { translate: 40px 0; }
  .rv--zoom  { translate: none; scale: .9; }
  .rv--img   { translate: none; opacity: 1; clip-path: inset(0 0 100% 0 round var(--radius)); }
  .rv.in { opacity: 1; translate: none; scale: none; clip-path: inset(0 0 0 0 round var(--radius)); }

  /* Garis emas tumbuh di depan eyebrow */
  .eyebrow::before { content: ""; display: inline-block; vertical-align: middle; width: 0; height: 2px; margin-right: 0; border-radius: 2px; background: currentColor; transition: width .7s cubic-bezier(.2,.7,.2,1) .25s, margin .7s cubic-bezier(.2,.7,.2,1) .25s; }
  .eyebrow.is-seen::before { width: 26px; margin-right: 10px; }

  /* ---------- Kartu: miring 3D + cahaya mengikuti kursor ---------- */
  .card--link, .post, .partner, .person, .event { position: relative; }
  .card--link, .person, .event { overflow: hidden; }
  .m-tilt { transform-style: preserve-3d; will-change: transform; }
  .m-tilt::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; opacity: 0; transition: opacity .3s;
    background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), rgba(240,207,133,.28), transparent 60%);
  }
  .m-tilt:hover::after { opacity: 1; }
  .m-tilt:hover { transform: perspective(900px) translateY(-6px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); box-shadow: 0 24px 44px -22px rgba(74,20,48,.45); }
  .card__icon { transition: transform .5s cubic-bezier(.3,1.6,.5,1), background .3s; }
  .card--link:hover .card__icon { transform: rotate(-8deg) scale(1.12); background: var(--maroon-2); }
  .post__img { overflow: hidden; display: block; }
  .post__img img { transition: transform .7s cubic-bezier(.2,.7,.2,1); }
  .post:hover .post__img img { transform: scale(1.07); }
  .pillars li { transition: transform .3s, box-shadow .3s, border-color .3s; }
  .pillars li:hover { transform: translateX(6px); box-shadow: var(--shadow); border-left-color: var(--maroon-2); }
  .event__date { transition: transform .4s cubic-bezier(.3,1.6,.5,1); }
  .event:hover .event__date { transform: rotate(-4deg) scale(1.06); }

  /* Gambar split: zoom halus saat hover */
  .split__img { overflow: hidden; border-radius: var(--radius); }
  .split__img img { transition: transform 1.2s cubic-bezier(.2,.7,.2,1); }
  .split__img:hover img { transform: scale(1.05); }

  /* ---------- Jadwal salat ---------- */
  .times li { transition: background .3s, color .3s, transform .3s; }
  .times li:hover { transform: translateY(-3px); }
  .times li.is-next { position: relative; animation: m-pulse 2.2s ease-out infinite; }
  @keyframes m-pulse { 0% { box-shadow: 0 0 0 0 rgba(214,168,74,.65); } 80%, 100% { box-shadow: 0 0 0 14px rgba(214,168,74,0); } }
  .next { position: relative; overflow: hidden; }
  .next::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 35%, rgba(255,255,255,.15) 50%, transparent 65%); transform: translateX(-100%); animation: m-sweep 5s ease-in-out infinite; }
  .next__count.tick { animation: m-tick .35s ease-out; }
  @keyframes m-tick { from { opacity: .55; transform: translateY(-3px); } }
  .next__count { display: inline-block; }

  /* ---------- Logo mitra ---------- */
  .mitra__logos img { filter: grayscale(1); opacity: .7; transition: filter .4s, opacity .4s, transform .4s cubic-bezier(.3,1.6,.5,1); }
  .mitra__logos img:hover { filter: none; opacity: 1; transform: translateY(-4px) scale(1.08); }

  /* ---------- Galeri ---------- */
  .gallery__item img { transition: transform .8s cubic-bezier(.2,.7,.2,1), filter .5s; }
  .gallery__item:hover img { transform: scale(1.09); filter: saturate(1.15); }
  .gallery__item span { transition: padding .4s; }
  .gallery__item:hover span { padding-bottom: 20px; }
  .lightbox[open] { animation: m-zoom .35s cubic-bezier(.2,.7,.2,1); }

  /* ---------- Sosial ---------- */
  .socials a { transition: background .2s, transform .35s cubic-bezier(.3,1.6,.5,1); }
  .socials a:hover { transform: translateY(-4px) rotate(-6deg); }

  /* ---------- QRIS bercahaya ---------- */
  .qris__img { animation: m-glow 3.5s ease-in-out infinite; }
  @keyframes m-glow { 50% { box-shadow: 0 0 0 6px rgba(214,168,74,.25), 0 18px 50px -14px rgba(214,168,74,.55); } }

  /* ---------- Tombol kembali ke atas ---------- */
  .m-top {
    position: fixed; right: 18px; bottom: 18px; z-index: 55; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--maroon); color: var(--gold-2); display: grid; place-items: center;
    box-shadow: 0 10px 24px -10px rgba(42,11,27,.7);
    opacity: 0; transform: translateY(20px) scale(.8); pointer-events: none;
    transition: opacity .3s, transform .4s cubic-bezier(.3,1.6,.5,1), background .2s;
  }
  .m-top.show { opacity: 1; transform: none; pointer-events: auto; }
  .m-top:hover { background: var(--maroon-2); transform: translateY(-3px); }
  .m-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
  .m-top circle { stroke: var(--gold); stroke-width: 2.5; fill: none; }
}

@media (prefers-reduced-motion: reduce) {
  .m-sparkle, .m-progress, .m-top { display: none !important; }
}
