/* 상단 헤더 스타일 - 기본 상태 (투명) */
.top-header:not(.white):not(.scrolled) {
    background-color: transparent !important;  /* 투명 배경 (white나 scrolled 클래스가 없을 때만) */
    padding: 1rem 0;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1490px;
    max-width: 1490px;
    z-index: 1003; /* 메뉴(1002) 위에 항상 표시되도록 */
    box-shadow: none !important;  /* 투명이니까 그림자 제거 */
    transition: background-color 0.4s ease, box-shadow 0.4s ease;  /* 그림자도 애니메이션 */
}

/* 기본 헤더 스타일 (위치, 크기 등 공통) */
.top-header {
    padding: 1rem 0;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1490px;
    max-width: 1490px;
    z-index: 1003; /* 메뉴(1002) 위에 항상 표시되도록 */
    transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

/* 기본 상태 배경 투명 (명시적으로) */
.top-header:not(.scrolled):not(.white) {
    background-color: transparent !important;
    box-shadow: none !important;
}

/* 헤더 container 반응형 */
.top-header .container {
    width: 100%;
    max-width: 1490px;
    margin: 0 auto !important;
    padding-left: 15px;
    padding-right: 15px;
    box-sizing: border-box;
    position: relative;
    background-color: transparent !important; /* 명시적으로 투명 설정 */
}

/* 헤더가 스크롤됐을 때만 container도 흰색 배경 */
.top-header.scrolled .container {
    background-color: transparent !important; /* container는 항상 투명 (헤더만 배경색 변경) */
}

/* 스크롤 시 헤더 스타일 (우선순위 높음) */
.top-header.scrolled {
    background-color: #ffffff !important;
    box-shadow: none !important; /* 그림자 제거 */
    width: 100vw !important; /* 화면 좌우로 꽉 차게 */
    left: 50% !important;
    transform: translateX(-50%) !important;
    max-width: none !important;
}

/* 메뉴가 열렸을 때 헤더도 흰색으로 (스크롤이 최상단일 때만) */
.top-header.white:not(.scrolled) {
    background-color: #ffffff !important;
    box-shadow: none !important; /* 그림자 제거 */
    left: 50%;
    transform: translateX(-50%);
    width: 1490px;
    max-width: 1490px;
}

/* 메뉴가 열렸을 때도 스크롤 위치에 따라 배경색 결정 */
.top-header.white.scrolled {
    background-color: #ffffff !important;
    box-shadow: none !important; /* 그림자 제거 */
}

.top-header.scrolled .logo-text {
    color: #333;
}

.top-header.scrolled .center-nav a {
    color: #333;
}

/* 이 규칙은 위의 active 규칙으로 대체됨 */

.top-header.scrolled .menu-btn-icon {
    filter: brightness(0) invert(0);  /* 검은색으로 변환 */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    background-color: transparent !important; /* 명시적으로 투명 설정 */
}

/* 로고 스타일 */
.logo {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'KbizHanmaumGothic', sans-serif;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.8rem;  /* 이미지와 텍스트 간격 */
}

.logo img {
    display: block;
    width: 52px;
    height: 38px;
    object-fit: contain;  /* 비율 유지 */
}

.logo-text {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'KbizHanmaumGothic', sans-serif;
    transition: color 0.4s ease;
}

.logo:hover {
    opacity: 0.9;
}

/* 헤더가 흰색일 때 로고 색상 */
.top-header.white .logo {
    color: #333;
}

.top-header.white .logo-text {
    color: #333;
}

/* 가운데 메뉴 네비게이션 (오른쪽 정렬) */
.center-nav {
    position: absolute;
    right: 0;
    display: flex;
    gap: 1rem;  /* 메뉴 간격 (4rem의 절반) */
    align-items: flex-end;  /* 하단 정렬 (구분선과 함께) */
    margin-right: 80px;
    width: fit-content;  /* 내용에 맞게 width 설정 */
}

.center-nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 195px;  /* 고정 크기 */
    min-width: 195px;
    max-width: 195px;
}

.center-nav a {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    text-decoration: none;
    font-size: 17px;
    font-weight: 700;
    font-family: 'Noto Sans KR', 'Droid Sans', sans-serif;
}

.center-nav a:hover {
    /* background-color: rgba(255, 255, 255, 0.2); */  /* 나중에 필요하면 주석 해제 */
    transform: translateY(-2px);
}

/* 헤더 메뉴 아래 구분선 (top-header.white 그림자 위치와 동일) */
.header-menu-line {
    position: absolute;
    bottom: -18px;  /* top-header.white의 box-shadow y 오프셋(2px)과 동일 */
    height: 3px;
    background-color: rgba(255, 255, 255, 0.3);  /* 기본: 반투명 흰색 */
    transition: opacity 0.4s ease, visibility 0.4s ease, background-color 0.4s ease;
    opacity: 0;  /* 기본적으로 숨김 */
    visibility: hidden;
}

/* 헤더가 흰색일 때 구분선 표시 (active 클래스가 있는 것만) */
.top-header.white .header-menu-line.active,
.top-header.scrolled .header-menu-line.active {
    opacity: 1;
    visibility: visible;
    background-color: #000000;  /* 검은색 */
}

/* active 클래스가 없는 라인은 숨김 */
.top-header.white .header-menu-line:not(.active),
.top-header.scrolled .header-menu-line:not(.active) {
    opacity: 0;
    visibility: hidden;
}

.header-menu-line.line-black-01 {
    width: 93px;
}

.header-menu-line.line-black-02 {
    width: 114px;
}

.header-menu-line.line-black-03 {
    width: 114px;
}

.header-menu-line.line-black-04 {
    width: 114px;
}

.header-menu-line.line-black-05 {
    width: 150px;
}


/* 헤더가 흰색일 때 가운데 메뉴 색상 */
.top-header.white .center-nav a {
    color: #333;
}

/* 메뉴 버튼 (이미지 사용) */
.menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1004; /* top-header(1003) 위에 표시되도록 */
}

.menu-btn-icon {
    display: block;
    width: auto;
    height: auto;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    filter: brightness(0) invert(1);  /* 흰색으로 변환 */
}

/* 닫기 버튼 (X 모양) */
.menu-btn-close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 23px;
    height: 23px;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.menu-btn-close-icon span {
    display: block;
    width: 23px;
    height: 2px;
    background-color: #333;
    position: absolute;
    transition: all 0.3s ease;
}

.menu-btn-close-icon span:nth-child(1) {
    transform: rotate(45deg);
}

.menu-btn-close-icon span:nth-child(2) {
    transform: rotate(-45deg);
}

/* 메뉴 버튼 활성화 상태 (닫기 버튼 표시) */
.menu-btn.active .menu-btn-icon {
    opacity: 0;
    visibility: hidden;
}

.menu-btn.active .menu-btn-close-icon {
    display: flex;
}

/* 헤더가 흰색일 때 메뉴 버튼 색상 */
.top-header.white .menu-btn-icon {
    filter: brightness(0) invert(0);  /* 검은색으로 변환 */
}

/* 전체 메뉴 오버레이 */
.full-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    background-color: rgba(255, 255, 255, 0);  /* 투명 시작 (흰색) */
    overflow: hidden;
    z-index: 1002; /* 헤더(1000)와 배너(999) 위에 표시되도록 */
    transition: height 0.4s ease, background-color 0.4s ease;
}

/* 메뉴가 열릴 때 배경 딤드 효과 */
.full-menu::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0);
    z-index: -1;
    transition: background-color 0.4s ease;
    pointer-events: none;
}

.full-menu.open::before {
    background-color: rgba(0, 0, 0, 0.5);  /* 반투명 검은색 배경 */
}

/* 메뉴가 열렸을 때 */
.full-menu.open {
    height: 340px;  /* Figma 디자인: 340px */
    background-color: transparent;  /* 투명하게 변경 (메뉴 컨테이너에 배경 적용) */
}

/* 메뉴 컨테이너 */
.menu-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    height: 100%;
    padding-top: 80px;
    max-width: 1490px;
    margin: 0 auto;
    position: relative;
    z-index: 1;  /* 딤드 위에 표시 */
    background-color: #ffffff;  /* 흰색 배경 추가 */
}

/* 메뉴 컨텐츠 */
.menu-content {
    width: 100%;
    max-width: 1490px;
    padding: 0;
    box-sizing: border-box;
    position: relative;
    z-index: 1;  /* 딤드 위에 표시 */
}

/* 메인 메뉴 네비게이션 (오른쪽 정렬) */
.main-menu-nav {
    position: absolute;
    right: 0;
    display: flex;
    gap: 1rem;  /* 아이템 간격 (4rem의 절반) */
    align-items: flex-start;
    margin-right: 90px;
    z-index: 1;  /* 딤드 위에 표시 */
    width: fit-content;  /* 내용에 맞게 width 설정 */
}

/* 메인 메뉴 아이템 (195px 고정 크기) */
.main-menu-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;  /* center-nav-item과 동일하게 중앙 정렬 */
    width: 195px;  /* 고정 크기 */
    min-width: 195px;
    max-width: 195px;
}


/* 서브메뉴 */
.sub-menu {
    display: flex;
    flex-direction: column;
    align-items: center;  /* center-nav-item과 동일하게 중앙 정렬 */
    gap: 22px;  /* 서브메뉴 간격 */
    margin-top: 19px;  /* 메인 메뉴와 서브메뉴 사이 간격 (header-menu-line 아래) */
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1;  /* 딤드 위에 표시 */
}

/* 서브메뉴는 각 main-menu-item 내부에서 자동으로 중앙 정렬됨 (center-nav-item과 동일) */

/* 메뉴가 열렸을 때 서브메뉴 표시 */
.full-menu.open .sub-menu {
    opacity: 1;
    transform: translateY(0);
}

.full-menu.open .main-menu-item:nth-child(1) .sub-menu { transition-delay: 0.1s; }
.full-menu.open .main-menu-item:nth-child(2) .sub-menu { transition-delay: 0.2s; }
.full-menu.open .main-menu-item:nth-child(3) .sub-menu { transition-delay: 0.3s; }

.sub-menu a {
    color: #000000;
    text-decoration: none;
    font-size: 17px;
    font-weight: 700;
    font-family: 'Noto Sans KR', 'Droid Sans', sans-serif;
    transition: all 0.3s ease;
    padding: 0;
    white-space: nowrap;
    text-align: center;  /* center-nav-item과 동일하게 중앙 정렬 */
    z-index: 1;  /* 딤드 위에 표시 */
}

.sub-menu a:hover {
    color: #666;
}

/* 메인 컨텐츠에 상단 여백 추가 (헤더 고정 때문에) */
main {
    margin-top: 80px;
}

/* 반응형 미디어 쿼리 */

/* 태블릿 (768px ~ 1489px) */
@media (min-width: 768px) and (max-width: 1489px) {
    .top-header {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
    }
    
    .top-header.white {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
    }
    
    .top-header.scrolled {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
    }
    
    .center-nav {
        display: flex;  /* 태블릿에서는 표시 */
        gap: 2rem;
    }
    
    .center-nav a {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .logo img {
        width: 45px;
        height: 33px;
    }
    
    .logo-text {
        font-size: 1.3rem;
    }
    
    .menu-nav a {
        font-size: 1.5rem;
    }
}

/* 모바일 (767px 이하) */
@media (max-width: 767px) {
    .top-header {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        padding: 0.75rem 0;
    }
    
    .top-header.white {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
    }
    
    /* 모바일에서는 항상 scrolled 상태로 표시 */
    .top-header {
        background-color: #ffffff !important;
        box-shadow: none !important;
    }
    
    .top-header.scrolled {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        background-color: #ffffff !important;
    }
    
    .top-header .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .center-nav {
        display: none;  /* 모바일에서는 중앙 메뉴 숨김 */
    }
    
    .logo {
        font-size: 1.1rem;
    }
    
    .logo img {
        width: 40px;
        height: 29px;
    }
    
    .logo-text {
        font-size: 1.1rem;
        color: #333 !important; /* 모바일에서는 항상 검은색 */
    }
    
    .menu-btn {
        width: 35px;
        height: 30px;
        padding: 8px;
        z-index: 1004 !important; /* 메뉴 버튼이 항상 클릭 가능하도록 */
    }
    
    /* 모바일에서는 항상 메뉴 버튼 아이콘이 검은색으로 표시 */
    .menu-btn-icon {
        filter: brightness(0) invert(0) !important; /* 검은색으로 변환 */
    }
    
    .menu-btn span {
        width: 25px;
        height: 2.5px;
    }
    
    .full-menu.open {
        height: 100vh;  /* 모바일에서는 전체 화면 */
    }
    
    .menu-container {
        padding-top: 100px;
    }
    
    /* 모바일에서 메인 메뉴 네비게이션 세로 정렬 */
    .main-menu-nav {
        position: relative;
        left: auto;
        transform: none;
        flex-direction: column;  /* 세로 정렬 */
        gap: 2rem;  /* 모바일에서는 간격 줄임 */
        align-items: center;  /* 중앙 정렬 */
        width: 100%;
        padding-top: 0;
    }
    
    /* 모바일에서 메인 메뉴 아이템 */
    .main-menu-item {
        width: 100%;
        max-width: 300px;
        align-items: center;
    }
    
    /* 모바일에서 서브메뉴 */
    .sub-menu {
        margin-top: 1rem;
        gap: 1rem;  /* 모바일에서는 간격 줄임 */
        width: 100%;
    }
    
    .sub-menu a {
        font-size: 16px;
        padding: 0.5rem 0;
    }
    
    .menu-nav li {
        margin: 1.5rem 0;
    }
    
    .menu-nav a {
        font-size: 1.5rem;
        padding: 0.5rem 1.5rem;
    }
    
    main {
        margin-top: 70px;
    }
}
