/* assets/css/mobile-app.css
   Tampilan ala aplikasi HP untuk halaman publik (layar < 1024px):
   bar navigasi bawah, bottom-sheet menu, safe-area (notch), kartu geser, daftar berita ringkas.
   Desktop (>= 1024px) tidak berubah. */

:root { --m-nav-h: 64px; --m-safe-t: env(safe-area-inset-top, 0px); --m-safe-b: 0px; }
@supports (padding: env(safe-area-inset-bottom)) { :root { --m-safe-b: env(safe-area-inset-bottom, 0px); } }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(76px + var(--m-safe-t)); }
body { -webkit-tap-highlight-color: transparent; }
a, button, [role="button"], input, select, textarea, label { touch-action: manipulation; }
[x-cloak] { display: none !important; }
.m-app { display: none; }

@media (max-width: 1023.98px) {
    html, body { overflow-x: hidden; }
    html.m-lock, html.m-lock body { overflow: hidden; }

    /* Bar atas: ikut area aman (notch) */
    body { padding-top: calc(68px + var(--m-safe-t)) !important; }
    nav.fixed.top-0::before { content: ""; display: block; height: var(--m-safe-t); } /* ruang notch tanpa mengubah padding asli */
    #scrollProgress { top: var(--m-safe-t); }

    /* Footer memberi ruang untuk bar bawah */
    footer { padding-bottom: calc(var(--m-nav-h) + var(--m-safe-b)); }

    /* Tombol "kembali ke atas" naik di atas bar bawah */
    #backToTop { bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 14px) !important; right: 14px !important; width: 44px !important; height: 44px !important; }

    /* Input 16px agar iOS tidak zoom otomatis; target sentuh nyaman */
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
    select, textarea { font-size: 16px !important; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select { min-height: 46px; }

    .article-body { font-size: 1rem; }
    .article-body table { display: block; overflow-x: auto; max-width: 100%; }
    .article-body iframe, .article-body video { max-width: 100%; }

    /* ===== Bar navigasi bawah ===== */
    .m-app { display: block; }
    .m-appnav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
        height: calc(var(--m-nav-h) + var(--m-safe-b)); padding: 0 6px var(--m-safe-b);
        display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
        background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
        border-top: 1px solid #e2e8f0; box-shadow: 0 -6px 24px rgba(15, 23, 42, .07);
    }
    .m-tab {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        background: none; border: 0; padding: 6px 2px 4px; color: #64748b; font: 600 10.5px/1.1 Poppins, system-ui, sans-serif;
        text-decoration: none; cursor: pointer; transition: color .15s, transform .12s;
    }
    .m-tab i { font-size: 21px; line-height: 1; }
    .m-tab:active { transform: scale(.92); }
    .m-tab.is-active { color: #059669; }
    .m-tab.is-active::before {
        content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 4px 4px;
        background: linear-gradient(90deg, #10b981, #3b82f6);
    }
    /* Tombol tengah (PPDB) menonjol */
    .m-tab-cta { color: #475569; }
    .m-fab {
        width: 52px; height: 52px; margin-top: -26px; border-radius: 9999px; display: flex; align-items: center; justify-content: center;
        background: linear-gradient(135deg, #10b981, #3b82f6); color: #fff; font-size: 22px;
        box-shadow: 0 8px 20px rgba(16, 185, 129, .4); border: 4px solid #fff; transition: transform .12s;
    }
    .m-tab-cta:active .m-fab { transform: scale(.92); }
    .m-tab-cta > span:last-child { margin-top: 1px; }
    html.m-kb .m-appnav { display: none; } /* sembunyi saat keyboard terbuka */

    /* ===== Bottom sheet "Menu" ===== */
    .m-sheet-ov {
        position: fixed; inset: 0; z-index: 70; background: rgba(15, 23, 42, .5);
        opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
    }
    .m-sheet-ov.is-open { opacity: 1; visibility: visible; }
    .m-sheet {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; max-height: 86vh; max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain;
        background: #fff; border-radius: 24px 24px 0 0; padding: 10px 16px calc(18px + var(--m-safe-b));
        transform: translateY(105%); visibility: hidden; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility .3s;
        box-shadow: 0 -12px 40px rgba(15, 23, 42, .2);
    }
    .m-sheet.is-open { transform: translateY(0); visibility: visible; }
    .m-grab { width: 42px; height: 5px; border-radius: 9999px; background: #cbd5e1; margin: 0 auto 12px; }
    .m-sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
    .m-sheet-head img { height: 38px; width: auto; }
    .m-sheet-title { font-weight: 800; color: #0f172a; font-size: 1rem; line-height: 1.15; }
    .m-sheet-sub { font-size: .75rem; color: #94a3b8; }
    .m-sheet-close { margin-left: auto; width: 38px; height: 38px; border-radius: 9999px; border: 0; background: #f1f5f9; color: #475569; font-size: 1rem; }
    .m-sheet h4 { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #10b981; margin: 14px 4px 6px; }
    .m-list { background: #f8fafc; border-radius: 16px; overflow: hidden; }
    .m-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; color: #1e293b; text-decoration: none; font-size: .92rem; font-weight: 500; border-bottom: 1px solid #eef2f7; }
    .m-item:last-child { border-bottom: 0; }
    .m-item:active { background: #eef2f7; }
    .m-item .m-ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; color: #10b981; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); flex: 0 0 auto; }
    .m-item .m-chev { margin-left: auto; color: #94a3b8; font-size: .8rem; }
    .m-item.is-danger, .m-item.is-danger .m-ico { color: #dc2626; }
    .m-wa { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; padding: 13px; border-radius: 9999px; background: #25D366; color: #fff; font-weight: 700; text-decoration: none; }
}

/* ===== Layar HP (< 640px) ===== */
@media (max-width: 639.98px) {
    .py-20 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
    .pt-20 { padding-top: 3rem !important; }
    .pb-20 { padding-bottom: 3rem !important; }
    .py-14 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .mb-14 { margin-bottom: 1.75rem !important; }
    .mb-16 { margin-bottom: 2rem !important; }
    .mt-16 { margin-top: 2rem !important; }

    /* Hero pas satu layar (di antara bar atas & bawah) */
    .h-\[90vh\] {
        height: calc(100vh - 140px - var(--m-safe-t) - var(--m-safe-b)) !important;
        height: calc(100svh - 140px - var(--m-safe-t) - var(--m-safe-b)) !important;
        min-height: 440px !important; max-height: none !important;
    }
    .hero-prev, .hero-next, .scroll-down { display: none !important; } /* diganti geser jari */
    .hero-indicators { bottom: 1.25rem !important; }
    .hero-cta { width: 100%; }
    .hero-cta a { width: min(100%, 320px); justify-content: center; }

    /* Kartu geser horizontal (snap) seperti aplikasi */
    .m-snap {
        display: flex !important; gap: 14px !important; overflow-x: auto; scroll-snap-type: x mandatory;
        margin-left: -1rem; margin-right: -1rem; padding: 6px 1rem 18px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .m-snap::-webkit-scrollbar { display: none; }
    .m-snap > * { flex: 0 0 80%; scroll-snap-align: center; transition: transform .12s; }
    .m-snap > *:active { transform: scale(.98); }

    /* Daftar berita ringkas: foto kecil di kiri, judul di kanan */
    .m-newslist { gap: .75rem !important; }
    .m-newslist > div { position: relative; display: flex; gap: .8rem; padding: .6rem !important; border-radius: 1.1rem !important; transition: transform .12s; }
    .m-newslist > div:active { transform: scale(.985); }
    .m-newslist > div > div:first-child { flex: 0 0 96px; margin: 0 !important; border-radius: .9rem !important; }
    .m-newslist > div > div:first-child img { height: 96px !important; }
    .m-newslist > div > div:first-child .absolute { top: .35rem !important; right: .35rem !important; padding: .15rem .45rem !important; font-size: .62rem !important; border-radius: .45rem !important; }
    .m-newslist > div > div:last-child { flex: 1; min-width: 0; padding: 0 !important; display: flex; flex-direction: column; justify-content: space-between; }
    .m-newslist h5 { height: auto !important; margin-bottom: .35rem !important; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    .m-newslist h5 a::after { content: ""; position: absolute; inset: 0; }   /* seluruh kartu bisa diketuk */
    .m-newslist a.block, .m-newslist .bg-blue-50 { display: none !important; }
    .m-newslist .flex.items-center.justify-between { margin-bottom: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
    .m-sheet, .m-sheet-ov, .m-tab, .m-fab { transition: none !important; }
}
@media print { .m-app { display: none !important; } }
