/* ===== Mobile Responsive Enhancements (shared) ===== */

/* Hamburger button */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 0;
    margin-left: auto;
    z-index: 1100;
}
.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--ok-brown, #181C28);
    transition: transform 0.28s ease, opacity 0.2s ease;
    border-radius: 2px;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

body.nav-open { overflow: hidden; }

/* ===== <= 900px : tablet & mobile ===== */
@media (max-width: 900px) {
    .hamburger { display: flex; }

    .navbar .container {
        flex-wrap: nowrap !important;
        padding: 12px 16px !important;
        gap: 10px !important;
        min-width: 0;
    }
    .brand-wrap {
        flex-shrink: 0 !important;
        min-width: 0;
        max-width: calc(100% - 56px);
        overflow: hidden;
    }
    .logo-link { flex-shrink: 0 !important; }
    .logo-img {
        height: 36px !important;
        width: auto !important;
        max-width: none !important;
        flex-shrink: 0 !important;
    }
    /* 모바일에서는 로고만 노출하고 부가 텍스트는 숨김 */
    .brand-text { display: none !important; }
    .brand-subtitle { display: none !important; }

    /* 햄버거 — 항상 최우측 */
    .hamburger {
        order: 3 !important;
        margin-left: auto !important;
    }

    /* 언어 토글 — 모바일 드로어 메뉴 내부로 이동 (JS가 .nav-links 안으로 옮김) */
    .nav-links .lang-switcher-mobile {
        display: block;
        margin: 16px 6px 4px !important;
        padding-top: 16px !important;
        border-top: 1px solid var(--ok-gray-100, #F1F3F5);
    }
    .nav-links .lang-switcher-mobile .lang-switcher {
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
    .nav-links .lang-switcher-mobile .ls-options {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        bottom: auto !important;
        left: 0 !important;
        right: auto !important;
    }
    /* 모바일에선 헤더의 원본 lang-switcher 숨김 */
    .navbar > .container > .lang-switcher {
        display: none !important;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: rgba(255,255,255,0.98);
        backdrop-filter: blur(20px);
        flex-direction: column !important;
        gap: 0 !important;
        padding: 12px 20px 24px !important;
        margin: 0;
        list-style: none;
        border-bottom: 1px solid var(--ok-gray-200, #C8CBD2);
        box-shadow: 0 12px 24px rgba(24,28,40,0.10);
        max-height: 100vh;
        overflow-y: auto;
        transform: translateY(-110%);
        transition: transform 0.28s ease, top 0s linear 0.28s, max-height 0s linear 0.28s;
        z-index: 999;
        visibility: hidden;
    }
    .nav-links.active {
        top: var(--nav-h, 64px);
        max-height: calc(100vh - var(--nav-h, 64px));
        transform: translateY(0);
        visibility: visible;
        transition: transform 0.28s ease, top 0s linear 0s, max-height 0s linear 0s;
    }
    .nav-links li {
        width: 100%;
        border-bottom: 1px solid var(--ok-gray-100, #F1F3F5);
    }
    .nav-links li:last-child { border-bottom: none; }
    .nav-links a {
        display: block !important;
        padding: 14px 6px !important;
        width: 100%;
        font-size: 1rem !important;
    }
    .nav-links a::after { display: none !important; }
    .nav-links a.compro-link,
    .nav-links a.marketplace-link {
        display: inline-block !important;
        margin: 8px 0 4px !important;
        padding: 10px 16px !important;
        width: auto !important;
    }

    /* Dropdown: 모바일 아코디언 (탭하면 펼쳐짐) */
    .dropdown-menu {
        position: static !important;
        box-shadow: none !important;
        border: none !important;
        background: var(--ok-gray-50, #F7F7F9) !important;
        border-radius: 10px !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.28s ease, margin 0.28s ease, padding 0.28s ease;
    }
    .nav-links li.open > .dropdown-menu {
        max-height: 600px;
        margin: 4px 0 8px !important;
        padding: 6px 0 !important;
    }
    .dropdown-menu a {
        padding: 12px 18px !important;
        font-size: 0.92rem !important;
    }
    /* 부모 링크에 셰브론 표시 */
    .nav-links li:has(.dropdown-menu) > a {
        position: relative;
        padding-right: 36px !important;
    }
    .nav-links li:has(.dropdown-menu) > a::before {
        content: "";
        position: absolute;
        right: 12px;
        top: 50%;
        width: 8px;
        height: 8px;
        border-right: 2px solid var(--ok-brown, #181C28);
        border-bottom: 2px solid var(--ok-brown, #181C28);
        transform: translateY(-70%) rotate(45deg);
        transition: transform 0.25s ease;
    }
    .nav-links li.open:has(.dropdown-menu) > a::before {
        transform: translateY(-30%) rotate(-135deg);
    }

    /* Sticky offsets 모바일 보정 */
    .filter-sticky-wrapper,
    .filter-sticky,
    .wbs-section,
    .wbs-sticky,
    .sticky-aside { top: var(--nav-h, 64px) !important; }

    /* ===== Filter bar 모바일 렌더링 정리 ===== */
    .filter-sticky-wrapper {
        margin-bottom: 16px !important;
    }
    .filter-bar {
        border-radius: 22px !important;
    }
    .filter-sticky-wrapper.panel-open .filter-bar {
        border-radius: 22px 22px 0 0 !important;
    }
    .filter-bar .filter-inner {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 10px 12px !important;
    }
    /* 칩 그룹 — 가로 스크롤 + 우측 페이드 그라디언트로 스크롤 가능 표시 */
    .filter-chips-wrap,
    .filter-bar .filter-inner > .filter-chips {
        position: relative;
    }
    .filter-chips {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px !important;
        padding: 2px 24px 4px 2px !important;
        margin: 0 -2px !important;
        scroll-snap-type: x proximity;
        mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    }
    .filter-chips::-webkit-scrollbar { display: none; }
    .chip-filter {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 6px 12px !important;
        font-size: 0.78rem !important;
        line-height: 1.2 !important;
        scroll-snap-align: start;
    }
    .advanced-filter-toggle,
    .sort-select {
        font-size: 0.82rem !important;
        padding: 7px 14px !important;
        white-space: nowrap;
    }
    /* Filter 버튼 + Sort select 한 줄에 두기 */
    .filter-bar .filter-inner > .advanced-filter-toggle,
    .filter-bar .filter-inner > .sort-select {
        align-self: flex-start;
    }

    .result-info {
        margin: 4px 6px 16px !important;
        font-size: 0.9rem !important;
        gap: 8px !important;
    }
    .result-info strong { color: var(--ok-orange, #FF571F); }

    /* ===== Footer 정렬 통일 (mobile) ===== */
    footer .footer-grid {
        gap: 28px !important;
        text-align: left !important;
    }
    footer .footer-grid > div { text-align: left !important; }
    footer .footer-grid > div:last-child { text-align: left !important; }
    footer .footer-logo { justify-content: flex-start !important; }
    footer .footer-description {
        text-align: left !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    footer .logo-wrapper-vertical { align-items: flex-start !important; }
    footer .footer-grid > div:last-child .logo-wrapper-vertical {
        align-items: flex-start !important;
    }
    footer h4 { text-align: left !important; }
    footer .footer-copy {
        text-align: center !important;
        padding-top: 16px;
    }

    /* Table 가로 스크롤 */
    .table-compare,
    .comparison-table,
    table.responsive-table,
    .table-wrapper > table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        max-width: 100%;
    }

    /* 카드 이미지 비율 고정 (썸네일 갤러리 .thumb 는 별도 처리) */
    .card-img,
    .asset-img {
        aspect-ratio: 4 / 3;
        height: auto !important;
    }

    /* ===== detail_asset: 썸네일 갤러리 가로 스크롤 ===== */
    .thumb-grid {
        display: flex !important;
        grid-template-columns: none !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px !important;
        padding: 12px !important;
        scroll-snap-type: x mandatory;
    }
    .thumb-grid::-webkit-scrollbar { display: none; }
    .thumb {
        flex: 0 0 88px !important;
        width: 88px !important;
        height: 64px !important;
        aspect-ratio: auto !important;
        border-radius: 10px !important;
        scroll-snap-align: start;
    }

    /* 메인 갤러리 이미지 비율 안정화 */
    .gallery-img {
        height: auto !important;
        aspect-ratio: 16 / 10 !important;
        min-height: 220px;
    }
    .gallery-main { border-radius: 16px !important; overflow: hidden; }

    /* 모달 모바일 보정 */
    .modal-content,
    .modal-body {
        padding: 24px !important;
        max-height: 90vh;
        overflow-y: auto;
        width: min(100%, 540px) !important;
    }

    .container { padding: 0 20px !important; }
}

/* ===== <= 600px : small phones ===== */
@media (max-width: 600px) {
    .hero-content,
    .hero-cari .hero-content,
    .hero .hero-content,
    .hero-contact .hero-content,
    .hero-panduan .hero-content,
    .hero-katalog .hero-content {
        grid-template-columns: 1fr !important;
        padding: 60px 22px 64px !important;
        gap: 20px !important;
        min-height: auto !important;
    }
    .hero-copy { padding-left: 0 !important; }
    .hero-cari,
    .hero,
    .hero-contact,
    .hero-panduan,
    .hero-katalog {
        margin-bottom: 36px !important;
        border-radius: 0 0 24px 24px !important;
    }
    .stats-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    h1 { font-size: clamp(1.55rem, 6vw, 2.1rem) !important; }
    h2 { font-size: clamp(1.3rem, 5vw, 1.7rem) !important; }
    .container { padding: 0 16px !important; }
    .cta-group { flex-direction: column; align-items: stretch; }
    .cta-group .btn-primary,
    .cta-group .btn-outline { justify-content: center; }
}
