/*
 * ui-motion.css — ikon menu, animasi kemunculan, dan transisi tema.
 * Ringan: hanya opacity/transform, tanpa library. Dimatikan untuk
 * pengguna yang memilih "kurangi gerakan" (prefers-reduced-motion).
 */

/* ---------- Ikon menu ---------- */
.am-nav-ico {
    display: inline-block;
    width: 1.1em;
    text-align: center;
    font-size: 0.92em;
    color: #145614; /* brand-dark */
    opacity: 0.85;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease, color 0.2s ease;
}

.dark .am-nav-ico {
    color: #87E64B; /* brand-green */
}

.group:hover > .am-nav-ico,
a:hover > .am-nav-ico,
a:focus-visible > .am-nav-ico {
    transform: translateY(-2px) scale(1.12);
    opacity: 1;
}

/* Menu desktop baru cukup lebar untuk ikon mulai 1280px (lebar kontainer maksimal).
   Di bawahnya ikon disembunyikan agar label tidak patah baris. */
@media (max-width: 1279.98px) {
    .am-nav-ico--desk {
        display: none;
    }
}

@media (min-width: 1280px) {
    ul.am-nav-list > li > a {
        white-space: nowrap;
    }

    /* Jarak antar-menu 24px → 20px untuk memberi ruang ikon */
    ul.am-nav-list > li:not([hidden]) ~ li:not([hidden]) {
        margin-left: 20px;
        margin-right: 0;
    }
}

/* Ikon menu HP selebar sama agar teks sejajar */
#mobileSidebar ul > li a > i:first-child {
    width: 1.25em;
    text-align: center;
}

/* ---------- Dropdown menu desktop & sidebar HP ---------- */
/* Animasi otomatis diputar ulang setiap kali menu berubah dari display:none ke tampil */
.nav-dropdown-menu > * {
    transform-origin: top center;
    animation: am-drop-in 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes am-drop-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

#mobileSidebar.is-open > div > ul > li {
    animation: am-slide-in 0.35s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    animation-delay: calc(var(--i, 0) * 35ms + 60ms);
}

@keyframes am-slide-in {
    from { opacity: 0; transform: translateX(-14px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Animasi kemunculan saat digulir ---------- */
html.motion-ready .am-reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
    transition-delay: var(--am-delay, 0ms);
    will-change: opacity, transform;
}

html.motion-ready .am-reveal.is-in {
    opacity: 1;
    transform: none;
}

/* ---------- Tombol tema: ikon bulan/matahari berputar ---------- */
.dark-mode-toggle i:not(.hidden) {
    display: inline-block;
}

html.theme-anim .dark-mode-toggle i:not(.hidden) {
    animation: am-icon-swap 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes am-icon-swap {
    from { opacity: 0; transform: rotate(-120deg) scale(0.4); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Kurangi gerakan ---------- */
@media (prefers-reduced-motion: reduce) {
    html.motion-ready .am-reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .nav-dropdown-menu > *,
    #mobileSidebar.is-open > div > ul > li,
    html.theme-anim .dark-mode-toggle i:not(.hidden) {
        animation: none;
    }

    .am-nav-ico {
        transition: none;
    }
}
