/* =========================================
   1. 기본 태그 초기화 및 공통 스타일
========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
ul, li { list-style: none; }
a { text-decoration: none; color: inherit; }
body {  background-color: black; }

/* =========================================
   2. 헤더 기본 상태 (투명 & 좌우 80px 여백)
========================================= */
.header {
    position: fixed; top: 0; left: 0; width: 100%; height: 80px;
    background: transparent; border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000; transition: all 0.3s ease;
}
.header-inner { display: flex; align-items: center; width: 100%; padding: 0 80px; height: 80px; }

/* =========================================
   3. 💻 PC 화면 전용 레이아웃 (1023px 이상에서만 작동)
========================================= */
@media screen and (min-width: 1023px) {
    .logo-wrap { flex: 1; display: flex; justify-content: flex-start; }
    .logo-color { display: none; }
    .logo-white { display: block; height: 40px; }

    .main-menu { flex: 0 0 900px; display: flex; justify-content: space-between; }
    .main-menu > li { flex: 1; text-align: center; position: relative; }
    .main-link {
        display: flex; align-items: center; justify-content: center;
        height: 80px; font-size: 17px; font-weight: 700; color: #fff; transition: color 0.3s;
    }

    .lang-wrap { flex: 1; display: flex; justify-content: flex-end; align-items: center; gap: 20px; }
    .lang-wrap a { font-size: 14px; font-weight: 600; color: #fff; transition: color 0.3s; }
    .lang-wrap a:hover { color: #8cc63f; }

    .header:hover, .header.is-scrolled { background: #fff; border-bottom: 1px solid #ddd; }
    .header:hover .main-link, .header.is-scrolled .main-link { color: #111; }
    .header:hover .logo-white, .header.is-scrolled .logo-white { display: none; }
    .header:hover .logo-color, .header.is-scrolled .logo-color { display: block; height: 40px; }
    .header:hover .lang-wrap a, .header.is-scrolled .lang-wrap a { color: #333; }
    .header:hover .lang-wrap a:hover, .header.is-scrolled .lang-wrap a:hover { color: #0d5ea6; }

    .sub-bg {
        position: absolute; top: 80px; left: 0; width: 100%; height: 0;
        background: #fff; z-index: 10; transition: height 0.3s ease;
    }
    .header:hover .sub-bg { height: 280px; border-bottom: 1px solid #ddd; }

    .sub-menu {
        position: absolute; top: 80px; left: 0; width: 100%; height: 280px;
        padding: 20px 0; opacity: 0; visibility: hidden; z-index: 20; transition: opacity 0.3s, background 0.2s;
    }
    .header:hover .sub-menu { opacity: 1; visibility: visible; }
    .sub-menu li a { display: block; padding: 10px 0; font-size: 15px; color: #555; transition: font-weight 0.2s; }
    .sub-menu li a:hover { font-weight: bold; }

    .main-menu > li:hover .main-link { background: #0d5ea6 !important; color: #fff !important; }
    .main-menu > li:hover .sub-menu { background: #0d5ea6; }
    .main-menu > li:hover .sub-menu li a { color: #fff; }

    .sub-menu::before {
        content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 3px;
        background: #dd0000; transform: scaleX(0); transform-origin: center;
    }
    .main-menu > li:hover .sub-menu::before { transform: scaleX(1); transition: transform 0.3s ease-out; }

    .header:hover .mobile-btn span, .header.is-scrolled .mobile-btn span { background: #111; }
}

/* =========================================
   4. 📱 모바일 전용 요소 기본 세팅
========================================= */
.mobile-btn {
    display: none; padding: 0; background: transparent; border: none;
    cursor: pointer; width: 30px; height: 20px; z-index: 2000;
}
.mobile-btn span {
    display: block; width: 100%; height: 3px; background: #fff; margin-bottom: 5px;
    transition: all 0.25s ease-in-out;
}
.mobile-btn span:last-child { margin-bottom: 0; }

.mobile-menu-wrap {
    position: fixed; top: -100%; left: 0; width: 100%; height: 100vh;
    background: #fff; z-index: 3000; transition: top 0.4s ease-in-out;
    display: flex; flex-direction: column; overflow-y: auto;
}
.mobile-menu-wrap.open { top: 0; }

.mobile-menu-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; border-bottom: 1px solid #eee;
}
.m-logo img { height: 40px; }
.mobile-close-btn {
    background: transparent; border: none; font-size: 28px; cursor: pointer; color: #333; padding: 0;
}

/* =========================================
   📱 모바일 메뉴 아코디언 기본 베이스 수정
========================================= */
.mobile-nav > li { border-bottom: 1px solid #eee; }
.m-main-link { display: block; padding: 20px; font-size: 16px; font-weight: 500; color: #333; }

/* 🚨 [모션 교정] 원래 숨겨져 있을 때 높이를 0으로 닫고 트랜지션을 줍니다. */
.m-sub-menu {
    display: block !important; /* 스크립트 블록 간섭 배제 */
    max-height: 0;            /* 평소엔 높이 0으로 완벽 폐쇄 */
    overflow: hidden;         /* 흘러넘치는 자식 요소 숨김 */
    background: #f4f6f8;
    padding: 0;               /* 열리기 전엔 여백도 0 */
    border-top: 0 solid #eee;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease; /* 스르륵 롤링 모션 엔진 */
}
.m-sub-menu li a { display: block; padding: 12px 20px; font-size: 14px; color: #666; }

/* =========================================
   5. 📱 모바일 및 태블릿 전용 반응형 레이아웃 교정 (1022px 이하)
========================================= */
@media screen and (max-width: 1022px) {
    .header {
        position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 80px !important;
        background: #ffffff !important; border-bottom: 1px solid #ddd !important; z-index: 999999 !important;
    }
    .header-inner {
        display: flex !important; align-items: center !important; justify-content: space-between !important;
        height: 80px !important; padding: 0 20px !important;
    }
    .main-menu, .sub-bg, .sub-menu { display: none !important; }

    .logo-white { display: none !important; }
    .logo-color { display: block !important; height: 40px !important; }

    .lang-wrap {
        display: flex !important; position: absolute !important; right: 70px !important; top: 50% !important;
        transform: translateY(-50%) !important; gap: 10px !important;
    }
    .lang-wrap a { color: #111111 !important; font-size: 13px !important; }

    .mobile-menu-wrap {
        position: fixed !important; top: -100vh !important; left: 0 !important; width: 100% !important;
        height: calc(100vh - 80px) !important; background: #ffffff !important; z-index: 99998 !important;
        padding-top: 0 !important; transition: all 0.4s ease-in-out !important;
    }
    .mobile-menu-wrap.open { top: 80px !important; }
    .mobile-menu-header { display: none !important; }

    /* 🚨 [모션 교정] 대메뉴 클릭하여 활성화(.active) 되었을 때, 하위 높이를 부드럽게 개방 */
    .mobile-nav > li.active .m-sub-menu {
        max-height: 300px;         /* 메뉴가 스르륵 펼쳐질 최대 리미트 높이 */
        padding: 10px 0;           /* 활성화 시 부드럽게 위아래 안쪽 여백 부여 */
        border-top: 1px solid #eee;
    }
    .mobile-nav > li.active .m-main-link { color: #0d5ea6; font-weight: bold; background: #fafafa; }

    /* -----------------------------------------
       ⚡ 모바일 버튼 ✕자 체인징 정밀 레이아웃
    ----------------------------------------- */
    .mobile-btn {
        display: block !important; position: absolute !important; right: 20px !important; top: 50% !important;
        transform: translateY(-50%) !important; width: 30px !important; height: 20px !important; padding: 0 !important;
        background: transparent !important; border: none !important; z-index: 9999999 !important;
    }
    .mobile-btn span {
        display: block !important; width: 100% !important; height: 3px !important; background: #111111 !important;
        opacity: 1 !important; transform: none !important; transition: all 0.25s ease-in-out !important;
    }
    .mobile-btn span:nth-child(1) { margin-top: 0 !important; margin-bottom: 5px !important; }
    .mobile-btn span:nth-child(2) { margin-top: 0 !important; margin-bottom: 5px !important; }
    .mobile-btn span:nth-child(3) { margin-top: 0 !important; margin-bottom: 0 !important; }

    html body .mobile-btn.open span:nth-child(1) {
        transform: translateY(8px) rotate(45deg) !important;
    }
    html body .mobile-btn.open span:nth-child(2) {
        opacity: 0 !important;
    }
    html body .mobile-btn.open span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg) !important;
    }
}