/**
 * Frontend mobile & touch — navigasi, layout, dan komponen responsif.
 * Semua override layout utama dibatasi media query agar desktop (>992px) tidak terpengaruh.
 */

:root {
    --site-header-mobile-h: 58px;
    --safe-inline: max(16px, env(safe-area-inset-left, 0px));
    --safe-inline-end: max(16px, env(safe-area-inset-right, 0px));
}

/* ── Mobile nav toggle (hidden on desktop) ── */
.nav-mobile-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid #ececec;
    border-radius: 10px;
    background: #fff;
    color: #333;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 36;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nav-mobile-toggle__bars {
    display: grid;
    gap: 5px;
    width: 18px;
}

.nav-mobile-toggle__bars span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

body.site-nav-open .nav-mobile-toggle__bars span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

body.site-nav-open .nav-mobile-toggle__bars span:nth-child(2) {
    opacity: 0;
}

body.site-nav-open .nav-mobile-toggle__bars span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-mobile-overlay {
    display: none;
}

/* ── Tablet & mobile ── */
@media (max-width: 992px) {
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    html,
    body {
        overflow-x: hidden;
    }

    .site-frame {
        overflow-x: visible;
    }

    .site-frame img,
    .site-frame video {
        max-width: 100%;
    }

    .site-header .brand-copy {
        min-width: 0;
    }

    .site-header .brand-copy p,
    .site-header .brand-copy span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .container {
        width: min(1320px, calc(100vw - var(--safe-inline) - var(--safe-inline-end)));
    }

    .nav-mobile-toggle {
        display: inline-flex;
    }

    .nav-mobile-overlay {
        display: block;
        position: fixed;
        top: var(--site-header-mobile-h);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        background: rgba(15, 18, 28, 0.48);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.22s ease, visibility 0.22s ease;
    }

    body.site-nav-open .nav-mobile-overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .site-header {
        z-index: 50;
        overflow: visible;
    }

    .nav-shell {
        flex-wrap: nowrap;
        height: var(--site-header-mobile-h);
        padding: 6px 0;
        gap: 10px;
        overflow: visible;
    }

    .brand {
        flex: 1 1 auto;
        min-width: 0;
    }

    .brand p {
        font-size: 18px;
    }

    .brand span {
        font-size: 9px;
    }

    .nav-actions {
        flex-shrink: 0;
        gap: 8px;
        position: relative;
        z-index: 36;
        margin-left: auto;
    }

    .language-switcher {
        max-width: 118px;
        font-size: 11px;
        padding: 0 8px;
    }

    .btn-login {
        width: 44px;
        height: 44px;
    }

    .nav-menu {
        position: fixed;
        top: var(--site-header-mobile-h);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 41;
        display: flex;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 10px max(var(--safe-inline), 16px) calc(24px + env(safe-area-inset-bottom, 0px));
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 4px;
        background: #fff;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        border-top: 1px solid #f0f0f0;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-6px);
        transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
    }

    .nav-mobile-overlay[hidden] {
        display: none !important;
    }

    body.site-nav-open {
        overflow: hidden;
        overscroll-behavior: none;
    }

    body.site-nav-open .nav-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .nav-menu > a,
    .nav-menu .nav-dropdown {
        width: 100%;
    }

    .nav-menu > a {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 10px 14px;
        border-radius: 10px;
        font-size: 15px;
        white-space: normal;
    }

    .nav-menu > a:active,
    .nav-menu .dropdown-menu a:active {
        background: #fff3f4;
    }

    .nav-menu a.active::after {
        display: none;
    }

    .nav-menu > a.active,
    .nav-menu .dropdown-toggle.active {
        background: #fff5f5;
    }

    .nav-menu .nav-dropdown {
        border-bottom: 1px solid #f4f4f4;
    }

    .nav-menu .dropdown-toggle {
        width: 100%;
        min-height: 48px;
        justify-content: space-between;
        padding: 10px 14px;
        border-radius: 10px;
        font-size: 15px;
        white-space: normal;
    }

    .nav-menu .dropdown-menu {
        position: static;
        transform: none;
        width: 100%;
        min-width: 0;
        box-shadow: none;
        border: 0;
        margin: 0 0 8px;
        padding: 0 0 4px 12px;
        background: transparent;
    }

    .nav-menu .nav-dropdown:not(.open) .dropdown-menu {
        display: none;
    }

    .nav-menu .dropdown-menu a {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    .nav-actions .language-switcher {
        display: none;
    }

    .nav-menu .language-switcher {
        display: block;
        width: 100%;
        max-width: none;
        min-height: 44px;
        margin-top: 12px;
        font-size: 14px;
        padding: 0 12px;
    }

    .prokum-page,
    .prokum-detail-page,
    .profil-page,
    .kontak-page,
    .stat-page,
    .news-page {
        width: min(1320px, calc(100vw - var(--safe-inline) - var(--safe-inline-end)));
    }

    .prokum-breadcrumb,
    .prokum-detail-breadcrumb,
    .profil-breadcrumb,
    .kontak-breadcrumb,
    .stat-breadcrumb,
    .berita-detail-breadcrumb {
        overflow-wrap: anywhere;
    }

    .prokum-hero,
    .profil-hero,
    .kontak-hero,
    .stat-hero {
        padding: 20px 16px;
        min-height: 140px;
        border-radius: 0 0 0 18px;
    }

    .prokum-doc-title,
    .prokum-page .result-item h3,
    .berita-article-title {
        overflow-wrap: anywhere;
    }

    .prokum-doc-actions,
    .prokum-header-top {
        flex-wrap: wrap;
    }

    .prokum-meta-table,
    .team-table,
    .stat-table {
        width: 100%;
    }

    .team-table-wrap,
    .stat-table-wrap,
    .stat-chart-canvas-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .stat-chart-head,
    .stat-section-head,
    .stat-hero-row {
        flex-wrap: wrap;
        gap: 10px;
    }

    .kontak-map-wrap iframe {
        width: 100%;
        min-height: 220px;
    }

    /* Hero & search */
    .hero {
        min-height: 320px;
        border-radius: 0 0 0 18px;
    }

    .hero-wrap {
        padding: 28px 0 36px;
    }

    .hero-copy {
        max-width: 100%;
    }

    .hero-copy h1 {
        font-size: clamp(1.75rem, 7vw, 2.35rem);
        line-height: 1.12;
    }

    .hero-copy p {
        font-size: 14px;
        line-height: 1.55;
    }

    .hero-btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .search-panel {
        padding: 14px;
    }

    .search-form {
        grid-template-columns: 1fr;
    }

    .search-form input,
    .search-form select,
    .search-form button {
        min-height: 44px;
        font-size: 15px;
    }

    .tags {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .tags::-webkit-scrollbar {
        display: none;
    }

    .tags a {
        flex-shrink: 0;
    }

    .section-head h2 {
        font-size: clamp(1.25rem, 4.5vw, 1.5rem);
    }

    .quick-grid,
    .product-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .external-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .footer-brand-col {
        padding-bottom: 4px;
    }

    .footer-desc {
        max-width: none;
        font-size: 13px;
    }

    .socials {
        gap: 12px;
    }

    .site-footer h4 {
        margin-top: 4px;
        padding-top: 12px;
        border-top: 1px solid rgba(255, 255, 255, 0.14);
    }

    .footer-brand-col + div h4 {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    .wa-float {
        width: 84px;
        height: 84px;
        right: max(8px, env(safe-area-inset-right, 0px));
        bottom: max(10px, env(safe-area-inset-bottom, 0px));
    }

    .a11y-widget {
        right: max(8px, env(safe-area-inset-right, 0px));
        bottom: calc(108px + env(safe-area-inset-bottom, 0px));
    }

    .a11y-toggle {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 768px) {
    .external-slider {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 0;
        padding: 0;
        border: 0;
        background: transparent;
        scrollbar-width: none;
    }

    .external-slider::-webkit-scrollbar {
        display: none;
    }

    .external-slider .external-track {
        transform: none !important;
        width: max-content;
        min-width: 100%;
        padding-inline: 0;
        gap: 12px;
    }

    .external-slider .external-card {
        flex: 0 0 min(260px, calc(100vw - 56px));
        scroll-snap-align: start;
        padding: 16px 14px;
        box-shadow: 0 4px 14px rgba(15, 24, 44, 0.06);
    }

    .external-slider .external-card .icon {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .doc-thumb.doc-thumb-mockup {
        display: none;
    }

    .doc-card,
    .prokum-page .result-item {
        grid-template-columns: 1fr auto;
        align-items: start;
    }

    /* Home — stats bar (5 KPI) */
    .stats-info {
        gap: 12px;
    }

    .stats-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 10px;
        border-radius: 14px;
    }

    .stats-bar article {
        display: flex;
        align-items: center;
        gap: 10px;
        text-align: left;
        padding: 12px 10px;
        border-right: 0;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.1);
        min-height: 68px;
    }

    .stats-bar article:nth-child(5) {
        grid-column: 1 / -1;
        justify-content: center;
        max-width: none;
        margin-inline: 0;
        width: auto;
    }

    .stats-bar i {
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        display: grid;
        place-items: center;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.16);
        font-size: 15px;
    }

    .stats-bar h3 {
        margin: 0;
        font-size: clamp(1.15rem, 4.5vw, 1.35rem);
        line-height: 1.1;
    }

    .stats-bar p {
        margin: 3px 0 0;
        font-size: 11px;
        line-height: 1.3;
        opacity: 0.92;
    }

    .integrity-box {
        padding: 16px;
    }

    .integrity-box h3 {
        font-size: 17px;
    }
}

@media (max-width: 640px) {
    .nav-actions .language-switcher {
        display: none;
    }

    .hero {
        min-height: 280px;
    }

    .hero-media::after {
        background: linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.96) 0%,
            rgba(255, 255, 255, 0.88) 45%,
            rgba(255, 255, 255, 0.55) 100%
        );
    }

    .quick-grid,
    .product-grid {
        grid-template-columns: 1fr;
    }

    .external-slider .external-card {
        flex: 0 0 min(240px, calc(100vw - 48px));
        max-width: none;
    }

    .doc-card {
        padding: 14px;
    }

    .consult-visitor-grid,
    .info-grid,
    .help-wide {
        gap: 12px;
    }

    .site-popup-banner__dialog {
        width: min(560px, calc(100vw - 24px));
        border-radius: 12px;
    }
}

@media (max-width: 380px) {
    .brand-logos img {
        width: 30px;
        height: 30px;
    }

    .brand p {
        font-size: 16px;
    }
}

@media (min-width: 993px) {
    .nav-mobile-overlay {
        display: none !important;
    }

    body.site-nav-open {
        overflow: auto;
    }

    .nav-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        overflow: visible;
        box-shadow: none;
        border-top: 0;
        padding: 0;
        flex-direction: row;
        width: auto;
        height: auto;
        margin-left: auto;
        margin-right: 0;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        z-index: auto;
        background: transparent;
    }

    .site-header .nav-actions {
        margin-left: 12px;
    }

    .doc-thumb.doc-thumb-mockup {
        display: flex;
    }

    .stats-bar {
        grid-template-columns: repeat(5, 1fr);
        gap: 0;
        padding: 0;
        border-radius: 12px;
    }

    .stats-bar article {
        display: block;
        text-align: center;
        padding: 13px 6px;
        border-right: 1px solid rgba(255, 255, 255, 0.16);
        border-radius: 0;
        background: transparent;
        min-height: 0;
    }

    .stats-bar article:nth-child(5) {
        grid-column: auto;
        justify-content: unset;
        max-width: none;
        margin-inline: 0;
        width: auto;
    }

    .stats-bar article:last-child {
        border-right: 0;
    }

    .stats-bar i {
        width: auto;
        height: auto;
        display: inline;
        border-radius: 0;
        background: transparent;
        font-size: 14px;
    }

    .stats-bar h3 {
        margin: 6px 0 0;
        font-size: 24px;
        line-height: normal;
    }

    .stats-bar p {
        margin: 4px 0 0;
        font-size: 12px;
    }
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
    .hero-btn,
    .search-form button,
    .doc-card .doc-btn,
    .quick-card,
    .product-card {
        -webkit-tap-highlight-color: transparent;
    }
}
