/* =============================================================
   Saya Merah Putih — Optimasi Responsif (modul lanjutan)
   Dimuat setelah style.css. Fokus: kerapian di tablet & ponsel,
   cegah overflow horizontal, target sentuh nyaman.
   ============================================================= */

/* ---------- Pengaman global ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, iframe, table { max-width: 100%; }
* { min-width: 0; }

/* ---------- Tablet besar ---------- */
@media (max-width: 1024px) {
    :root { --wrap: 960px; }
    .section { padding: 62px 0; }
    .berita-utama .ph-img { min-height: 260px; }
}

/* ---------- Tablet ---------- */
@media (max-width: 820px) {
    .galeri-grid { grid-template-columns: repeat(3, 1fr); }
    .berita-grid { grid-template-columns: repeat(2, 1fr); }
    .panel { padding: 22px; }
    .form-card { padding: 26px; }
    .berita-utama h2 { font-size: 1.6rem; }
}

/* ---------- Ponsel besar ---------- */
@media (max-width: 640px) {
    .wrap { width: min(100% - 30px, var(--wrap)); }
    .section { padding: 48px 0; }

    /* Aksi hero jadi lebar penuh & mudah disentuh */
    .hero-actions { width: 100%; }
    .hero-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* Pencarian berita membungkus rapi */
    .berita-search { flex-wrap: wrap; }
    .berita-search .bs-input { flex: 1 1 100%; }
    .berita-search .btn { flex: 1; justify-content: center; }

    /* Header ringkas */
    .page-hero { padding: 44px 0 34px; }
    .map-embed iframe { height: 260px; }

    /* Kartu & panel lebih padat */
    .berita-utama .bu-body { padding: 22px; }
    .side-card { padding: 18px; }
    .zona-body p, .berita-card p { font-size: .84rem; }

    /* Momen pilihan galeri: tinggi lebih pas di ponsel */
    .feat-main .ph-img, .feat-card .ph-img { min-height: 230px; }
}

/* ---------- Ponsel ---------- */
@media (max-width: 480px) {
    .wrap { width: min(100% - 26px, var(--wrap)); }

    /* Navbar & brand */
    .navbar { padding: 8px 12px 8px 14px; }
    .brand-logo { width: 40px; height: 40px; }
    .brand-text .b2 { font-size: 1.5rem; }

    /* Statistik: tetap 2 kolom tapi lebih ringkas */
    .stat-bar { padding: 16px; gap: 8px; }
    .stat { gap: 10px; padding: 4px; }
    .stat-ico { width: 40px; height: 40px; border-radius: 12px; }
    .stat-ico .icon { width: 20px; height: 20px; }
    .stat b { font-size: 1.45rem; }
    .stat span { font-size: .74rem; }

    /* Tombol & filter */
    .btn { padding: 12px 20px; font-size: .9rem; }
    .filter-bar { gap: 8px; }
    .filter-btn { padding: 9px 15px; font-size: .82rem; }

    /* Judul hero sedikit dikecilkan bayangannya */
    .hero-title { text-shadow: 1px 2px 0 rgba(255,255,255,.6); }

    /* Galeri mini 2 kolom agar tak terlalu kecil */
    .galeri-mini { grid-template-columns: repeat(2, 1fr); }

    /* Ornament & heading */
    .section-head { margin-bottom: 34px; }
}

/* ---------- Ponsel kecil ---------- */
@media (max-width: 360px) {
    .stat-bar { grid-template-columns: 1fr; }
    .stat:nth-child(odd) { border-right: none; }
    .stat { border-bottom: 1px solid var(--garis); padding-bottom: 12px; }
    .stat:last-child { border-bottom: none; }
    .galeri-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Lightbox galeri ---------- */
.lightbox {
    position: fixed; inset: 0; z-index: 200; display: none;
    align-items: center; justify-content: center; gap: 8px; padding: 24px;
    background: rgba(30, 8, 8, 0.92); backdrop-filter: blur(4px);
}
.lightbox.open { display: flex; }
.lb-figure { margin: 0; max-width: min(1000px, 92vw); text-align: center; }
.lb-img {
    max-width: 100%; max-height: 82vh; border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5); background: #fff;
}
.lb-cap { color: #fff; margin-top: 12px; font-size: .95rem; font-weight: 500; }
.lb-close {
    position: absolute; top: 18px; right: 22px; width: 44px; height: 44px;
    font-size: 30px; line-height: 1; color: #fff; background: rgba(255,255,255,.12);
    border-radius: 50%; transition: .2s;
}
.lb-close:hover { background: var(--merah); }
.lb-nav {
    flex-shrink: 0; width: 50px; height: 50px; border-radius: 50%; font-size: 22px;
    color: #fff; background: rgba(255,255,255,.12); transition: .2s;
}
.lb-nav:hover { background: var(--merah); }
@media (max-width: 560px) {
    .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); }
    .lb-prev { left: 12px; } .lb-next { right: 12px; }
}

/* ---------- Aksesibilitas: fokus keyboard & skip-link ---------- */
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 300;
    background: var(--merah); color: #fff; padding: 10px 18px;
    border-radius: 0 0 10px 10px; font-weight: 600; font-size: .9rem;
    transition: top .2s;
}
.skip-link:focus { top: 0; }

:focus-visible {
    outline: 2px solid var(--merah);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---------- Aksesibilitas: kurangi animasi ---------- */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
    [data-reveal] { opacity: 1 !important; transform: none !important; }
}
