/* ============================================================
 * NORMA NEWS — PWA Install Banner & Splash (pwa-install.css)
 * ------------------------------------------------------------
 * Aman untuk CSS website yang sudah ada:
 *   - HANYA memakai class berprefix .pwa-install-* / .pwa-splash-*
 *   - TIDAK ada selector global (button, body, div, dll.)
 *   - Mobile-first, responsif, ringan (~5 KB)
 * ============================================================ */

/* ---------- Banner Install (slide-down dari atas) ---------- */

.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2147483000;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    transform: translateY(-110%);
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.5s ease;
    opacity: 0;
    will-change: transform;
    pointer-events: none;
}

.pwa-install-banner.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 520px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 10px 40px rgba(26, 26, 46, 0.18),
                0 2px 8px rgba(26, 26, 46, 0.08);
    border: 1px solid rgba(65, 105, 225, 0.14);
}

.pwa-install-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 3px 10px rgba(65, 105, 225, 0.25);
    background: #4169E1;
}

.pwa-install-text {
    flex: 1 1 auto;
    min-width: 0;
}

.pwa-install-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.35;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pwa-install-subtitle {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
    margin: 2px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pwa-install-subtitle strong {
    color: #4169E1;
    font-weight: 700;
}

.pwa-install-button {
    flex: 0 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #ffffff;
    background: linear-gradient(135deg, #4169E1 0%, #3457C5 100%);
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(65, 105, 225, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    text-transform: uppercase;
}

.pwa-install-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(65, 105, 225, 0.45);
}

.pwa-install-button:active {
    transform: translateY(0);
    opacity: 0.9;
}

.pwa-install-button:focus-visible {
    outline: 3px solid rgba(65, 105, 225, 0.4);
    outline-offset: 2px;
}

.pwa-install-close {
    flex: 0 0 auto;
    position: absolute;
    top: 4px;
    right: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 18px;
    line-height: 1;
    color: #9ca3af;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.pwa-install-close:hover {
    color: #4b5563;
    background: rgba(26, 26, 46, 0.06);
}

.pwa-install-close:focus-visible {
    outline: 2px solid rgba(65, 105, 225, 0.4);
    outline-offset: 1px;
}

/* ---------- Petunjuk instalasi manual (iOS / browser tanpa prompt) ---------- */

.pwa-install-instructions {
    max-width: 520px;
    margin: 10px auto 0;
    background: #f0f4ff;
    border: 1px solid rgba(65, 105, 225, 0.25);
    border-radius: 14px;
    padding: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.6;
    color: #1a1a2e;
    text-align: left;
    animation: pwaFadeIn 0.3s ease;
}

.pwa-install-instructions strong { color: #3457C5; }

.pwa-install-instructions ol {
    margin: 6px 0 0;
    padding-left: 20px;
}

.pwa-install-instructions li { margin: 3px 0; }

/* ---------- Toast konfirmasi setelah terinstall ---------- */

.pwa-toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(20px);
    z-index: 2147483000;
    background: #1a1a2e;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(26, 26, 46, 0.35);
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    max-width: calc(100vw - 32px);
    text-align: center;
}

.pwa-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- Splash screen (khusus iOS standalone) ---------- */

.pwa-splash-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147482999;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    opacity: 1;
    transition: opacity 0.35s ease;
}

.pwa-splash-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.pwa-splash-icon {
    width: 96px;
    height: 96px;
    border-radius: 24px;
    box-shadow: 0 12px 32px rgba(65, 105, 225, 0.28);
}

.pwa-splash-name {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #1a1a2e;
}

/* ---------- Animasi ---------- */

@keyframes pwaFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Hormati preferensi pengguna: kurangi gerakan */
@media (prefers-reduced-motion: reduce) {
    .pwa-install-banner,
    .pwa-toast,
    .pwa-splash-overlay,
    .pwa-install-instructions {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- Desktop (≥768px): kartu ringkas terpusat ---------- */

@media (min-width: 768px) {
    .pwa-install-banner {
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }
    .pwa-install-content {
        padding: 14px 18px;
        border-radius: 18px;
    }
    .pwa-install-icon { width: 52px; height: 52px; border-radius: 14px; }
    .pwa-install-title { font-size: 15px; }
    .pwa-install-subtitle { font-size: 13px; }
    .pwa-install-button {
        font-size: 13px;
        padding: 10px 22px;
    }
}
