/* ==========================================
   크몽 스타일 확장형 네비게이션
   ========================================== */

/* 기본 넧비게이션 바 재정의 */
.top-nav-bar {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%);
    padding: 15px 20px;
    border-radius: 0 0 24px 24px;
    margin-bottom: 25px;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    overflow: visible;
}

/* 네비게이션 컨테이너 */
.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

/* 햄버거 메뉴 버튼 */
.hamburger-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 45px;
    height: 45px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.hamburger-btn:active {
    transform: scale(0.95);
}

.hamburger-line {
    width: 24px;
    height: 2.5px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translateY(10px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translateY(-10px);
}

/* 상단 로우 (로고만) */
.nav-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 로고 스타일 */
.nav-logo {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    font-family: 'Noto Serif KR', serif;
    font-size: 1.4rem;
    font-weight: 700;
}

.nav-logo-icon {
    font-size: 2rem;
    margin-right: 10px;
}

/* 햄버거 버튼 숨김 */
.hamburger-btn {
    display: none !important;
}

/* 카테고리 래퍼 */
.nav-categories-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    width: 100%;
    max-height: none;
    opacity: 1;
    overflow: visible;
    transition: all 0.3s ease;
}

/* 확장 시 2줄 레이아웃 강제 */
.nav-categories-wrapper.expanded {
    gap: 15px 12px;
    display: grid;
    grid-template-columns: repeat(10, 85px);
    justify-content: center;
    max-width: 100%;
    margin: 0 auto;
}

/* 모든 촰목 크기 통일 */
.nav-categories-wrapper.expanded .nav-link,
.nav-categories-wrapper.expanded .view-all-btn {
    width: 85px;
    height: auto;
    padding: 8px 12px !important;
    box-sizing: border-box;
}

/* 네비게이션 메뉴 (래퍼만 역할) */
.nav-menu {
    display: contents;
}

/* 카테고리 링크 */
.nav-link {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px !important;
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s ease;
    min-width: 75px;
    text-align: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: translateY(-3px) !important;
}

.nav-link.active {
    background: white !important;
    color: #6366F1 !important;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
}

/* 아이콘 */
.nav-icon {
    font-size: 1.5rem !important;
    margin-bottom: 4px;
    display: block;
}

/* 텍스트 */
.nav-text {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.2;
}

/* 숨겨진 카테고리 (데스크톱에서만 숨김) */
@media (min-width: 769px) {
    .nav-link.hidden-category {
        display: none !important;
    }

    .nav-categories-wrapper.expanded .nav-link.hidden-category {
        display: flex !important;
    }
}

/* 전체보기 버튼 */
.view-all-btn {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 75px;
    font-family: inherit;
    flex-shrink: 0;
}

.view-all-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-3px) !important;
}

.view-all-btn .nav-icon {
    font-size: 1.5rem !important;
    margin-bottom: 4px;
    transition: transform 0.3s ease;
}

.view-all-btn .nav-text {
    font-size: 0.75rem;
    font-weight: 600;
}

/* 확장 시 아이콘 회전 */
.nav-categories-wrapper.expanded .view-all-btn .nav-icon {
    transform: rotate(180deg);
}

/* 애니메이션 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 태블릿 반응형 (1024px 이하) */
@media (max-width: 1024px) {
    .nav-menu {
        gap: 10px;
    }

    .nav-link,
    .view-all-btn {
        min-width: 75px;
        padding: 8px 12px !important;
    }

    .nav-icon {
        font-size: 2rem;
    }

    .nav-text {
        font-size: 0.75rem;
    }
}

/* 모바일 반응형 (768px 이하) */
@media (max-width: 768px) {
    .top-nav-bar {
        padding: 12px 15px;
        border-radius: 0 0 20px 20px;
    }

    .nav-container {
        gap: 12px;
    }

    .nav-logo {
        font-size: 1.2rem;
    }

    .nav-logo-icon {
        font-size: 1.7rem;
    }

    .nav-categories-wrapper {
        gap: 8px;
        justify-content: center;
    }

    .nav-link,
    .view-all-btn {
        min-width: 70px;
        padding: 10px 12px !important;
    }

    .nav-icon {
        font-size: 1.5rem !important;
        margin-bottom: 4px;
    }

    .nav-text {
        font-size: 0.7rem;
    }
}

/* 작은 모바일 (480px 이하) */
@media (max-width: 480px) {
    .top-nav-bar {
        padding: 10px 12px;
        border-radius: 0 0 16px 16px;
    }

    .nav-container {
        gap: 10px;
    }

    .nav-logo {
        font-size: 1.1rem;
    }

    .nav-logo-icon {
        font-size: 1.5rem;
        margin-right: 8px;
    }

    .nav-categories-wrapper {
        gap: 6px;
        justify-content: center;
    }

    .nav-link,
    .view-all-btn {
        min-width: 62px;
        padding: 8px 10px !important;
    }

    .nav-icon {
        font-size: 1.6rem;
        margin-bottom: 3px;
    }

    .nav-text {
        font-size: 0.65rem;
    }
}

/* 매우 작은 모바일 (360px 이하) */
@media (max-width: 360px) {
    .top-nav-bar {
        padding: 8px 10px;
    }

    .nav-categories-wrapper {
        gap: 5px;
    }

    .nav-link,
    .view-all-btn {
        min-width: 56px;
        padding: 7px 8px !important;
    }

    .nav-icon {
        font-size: 1.4rem;
        margin-bottom: 2px;
    }

    .nav-text {
        font-size: 0.6rem;
    }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {

    .nav-link,
    .view-all-btn {
    /* 터치 영역 확대 */
        min-height: 48px;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    }

    .nav-link:active,
    .view-all-btn:active {
        background: rgba(255, 255, 255, 0.3) !important;
        transform: scale(0.95) !important;
    }

    /* 호버 효과 제거 (터치 디바이스에서는 불필요) */
    .nav-link:hover,
    .view-all-btn:hover {
        transform: none !important;
    }
}

/* 초기 로딩 시 확장 상태 강제 (깜빡임 방지) */
html.nav-expanded-init .nav-categories-wrapper {
    max-height: none !important;
}

html.nav-expanded-init .nav-categories-wrapper .nav-link.hidden-category {
    display: flex !important;
}

/* ===== 모바일 반응형 (768px 이하) ===== */
@media (max-width: 768px) {
    .top-nav-bar {
        padding: 10px 15px;
    }

    .nav-container {
        gap: 12px;
    }

    .nav-top-row {
        width: 100%;
    }

    .hamburger-btn {
        display: flex !important;
    }

    .nav-logo-text {
        display: none;
    }

    .nav-categories-wrapper {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        padding: 0;
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(139, 92, 246, 0.95));
        border-radius: 12px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
    }

    .nav-categories-wrapper.active {
        max-height: 100vh !important;
        opacity: 1 !important;
        overflow-y: auto !important;
        padding: 6px !important;
    }

    .nav-menu {
        display: contents !important;
        width: 100%;
    }

    /* 전체보기 버튼 숨김 (모바일에서는 불필요) */
    .view-all-btn {
        display: none !important;
    }

    .nav-link {
        width: calc(25% - 3.75px);
        min-width: unset;
        padding: 6px 5px !important;
        text-align: center;
        flex-direction: column;
        gap: 3px;
        border-radius: 8px;
    }

    .nav-icon {
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .nav-text {
        font-size: 0.65rem;
        flex: 1;
        line-height: 1.1;
    }

    /* 모바일에서는 숨겨진 카테고리도 모두 표시 */
    .nav-link.hidden-category,
    .nav-categories-wrapper .nav-link.hidden-category,
    .nav-categories-wrapper.active .nav-link.hidden-category {
        display: flex !important;
    }

    .nav-link.active {
        background: white !important;
        color: #6366F1 !important;
    }
}

/* 작은 모바일 (480px 이하) */
@media (max-width: 480px) {
    .top-nav-bar {
        padding: 10px 12px;
        border-radius: 0 0 16px 16px;
        margin-bottom: 20px;
    }

    .nav-container {
        gap: 10px;
    }

    .nav-logo {
        font-size: 1.1rem;
    }

    .nav-logo-icon {
        font-size: 1.4rem;
        margin-right: 8px;
    }

    .hamburger-btn {
        width: 40px;
        height: 40px;
        padding: 6px 8px;
    }

    .hamburger-line {
        width: 20px;
        height: 2px;
    }

    .nav-categories-wrapper {
        gap: 4px;
    }

    .nav-categories-wrapper.active {
        max-height: 400px;
        padding: 5px !important;
    }

    .nav-link {
        width: calc(25% - 3px);
        padding: 5px 3px !important;
        gap: 2px;
    }

    .nav-icon {
        font-size: 1.4rem;
    }

    .nav-text {
        font-size: 0.6rem;
        line-height: 1.1;
    }

    /* 터치 디바이스 - 클릭 영역 확대 */
    .hamburger-btn {
        min-height: 48px;
    }
}

/* 매우 작은 모바일 (360px 이하) - 모든 메뉴 표시 */
@media (max-width: 360px) {
    .nav-link.hidden-category {
        display: flex !important;
    }
}