/*
 * 주소모음 전용 Responsive Header
 * 대상: /theme/basic/head.php
 * 기본 default.css를 직접 수정하지 않고 이 파일에서 Header만 독립적으로 재정의한다.
 */

#jm_header {
    position: relative;
    z-index: 1000;
    width: 100%;
    background: #fff;
    border-top: 1px solid #303846;
    border-bottom: 1px solid #e5e9ef;
}

#jm_header * {
    box-sizing: border-box;
}

#jm_header .jm_header_inner {
    display: flex;
    align-items: center;
    width: 1100px;
    height: 66px;
    margin: 0 auto;
}

#jm_header .jm_brand {
    flex: 0 0 auto;
    width: 255px;
}

#jm_header .jm_brand_link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

#jm_header .jm_brand_logo {
    display: block;
    max-width: 185px;
    max-height: 40px;
    width: auto;
    height: auto;
}

#jm_header .jm_nav {
    flex: 1 1 auto;
    height: 100%;
}

#jm_header .jm_nav_list {
    display: flex;
    align-items: stretch;
    justify-content: center;
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

#jm_header .jm_nav_item {
    position: relative;
    display: flex;
    align-items: stretch;
}

#jm_header .jm_nav_link {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding: 0 17px;
    border-radius: 7px;
    color: #39465a;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .16s ease, color .16s ease;
}

#jm_header .jm_nav_item:hover > .jm_nav_link,
#jm_header .jm_nav_item:focus-within > .jm_nav_link {
    color: #26374f;
    background: #f4f6f9;
}

#jm_header .jm_nav_arrow {
    margin-top: 1px;
    color: #718096;
    font-size: 11px;
    transition: transform .16s ease;
}

#jm_header .jm_nav_item:hover .jm_nav_arrow,
#jm_header .jm_nav_item:focus-within .jm_nav_arrow {
    transform: rotate(180deg);
}

#jm_header .jm_nav_empty {
    display: flex;
    align-items: center;
    color: #7b8797;
    font-size: 13px;
}

#jm_header .jm_nav_empty a {
    margin-left: 8px;
    color: #405de6;
}

/* 2차 메뉴 */
#jm_header .jm_dropdown {
    position: absolute;
    top: 52px;
    left: 50%;
    width: 240px;
    padding-top: 14px;
    visibility: hidden;
    opacity: 0;
    transform: translate(-50%, 8px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}

#jm_header .jm_nav_item:hover > .jm_dropdown,
#jm_header .jm_nav_item:focus-within > .jm_dropdown {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}

#jm_header .jm_dropdown_list {
    margin: 0;
    padding: 12px;
    list-style: none;
    background: #fff;
    border: 1px solid #dfe4ea;
    border-radius: 15px;
    box-shadow: 0 12px 28px rgba(26, 39, 56, .14);
}

#jm_header .jm_dropdown_item {
    margin: 0;
    padding: 0;
}

#jm_header .jm_dropdown_link {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    color: #4a586d;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color .14s ease, color .14s ease;
}

#jm_header .jm_dropdown_link:hover,
#jm_header .jm_dropdown_link:focus {
    color: #24364e;
    background: #f4f6f9;
}

#jm_header .jm_dropdown_name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 우측 전체메뉴 버튼 */
#jm_header .jm_header_actions {
    display: flex;
    flex: 0 0 70px;
    justify-content: flex-end;
    align-items: center;
}

#jm_header .jm_allmenu_btn,
#jm_header .jm_allmenu_close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    padding: 0;
    background: transparent;
    color: #3d4a5e;
    cursor: pointer;
}

#jm_header .jm_allmenu_btn {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    font-size: 17px;
    transition: background-color .14s ease;
}

#jm_header .jm_allmenu_btn:hover,
#jm_header .jm_allmenu_btn:focus {
    background: #f3f5f8;
}

#jm_header .jm_allmenu {
    position: absolute;
    top: 66px;
    left: 50%;
    z-index: 1002;
    width: 1100px;
    max-height: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid transparent;
    border-radius: 0 0 14px 14px;
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, max-height .22s ease;
}

#jm_header .jm_allmenu.is-open {
    max-height: 620px;
    border-color: #e1e6ec;
    box-shadow: 0 14px 34px rgba(22, 34, 49, .14);
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

#jm_header .jm_allmenu_inner {
    padding: 22px 26px 28px;
}

#jm_header .jm_allmenu_head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid #edf0f4;
}

#jm_header .jm_allmenu_head strong {
    color: #27364c;
    font-size: 16px;
}

#jm_header .jm_allmenu_close {
    width: 36px;
    height: 36px;
    border-radius: 7px;
    font-size: 16px;
}

#jm_header .jm_allmenu_close:hover,
#jm_header .jm_allmenu_close:focus {
    background: #f3f5f8;
}

#jm_header .jm_allmenu_grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 26px;
    margin: 0;
    padding: 22px 0 0;
    list-style: none;
}

#jm_header .jm_allmenu_title {
    display: block;
    margin-bottom: 10px;
    color: #28384f;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

#jm_header .jm_allmenu_sub {
    margin: 0;
    padding: 0;
    list-style: none;
}

#jm_header .jm_allmenu_sub li + li {
    margin-top: 7px;
}

#jm_header .jm_allmenu_sub a {
    color: #778397;
    font-size: 13px;
    text-decoration: none;
}

#jm_header .jm_allmenu_sub a:hover,
#jm_header .jm_allmenu_sub a:focus {
    color: #30445f;
}

#jm_header .jm_allmenu_bg {
    display: none;
    position: fixed;
    z-index: 1001;
    inset: 0;
    background: rgba(18, 28, 41, .18);
}

#jm_header .jm_allmenu_bg.is-open {
    display: block;
}

body.jm_allmenu_open {
    overflow: hidden;
}

/* 기존 basic theme Header 스타일과 충돌 방지 */
#jm_header + hr {
    display: none;
}


/* =========================================================
   Responsive Header
   ========================================================= */

#jm_header .jm_allmenu_sections {
    display: none;
}

@media (max-width: 1180px) {
    #jm_header .jm_header_inner {
        width: calc(100% - 40px);
    }

    #jm_header .jm_brand {
        width: 190px;
    }

    #jm_header .jm_nav_link {
        padding-left: 10px;
        padding-right: 10px;
        font-size: 13px;
    }

    #jm_header .jm_allmenu {
        width: calc(100% - 40px);
    }

    #jm_header .jm_allmenu_grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    #jm_header {
        min-width: 0;
    }

    #jm_header .jm_header_inner {
        width: 100%;
        height: 58px;
        padding: 0 16px;
    }

    #jm_header .jm_brand {
        width: auto;
        flex: 1 1 auto;
    }

    #jm_header .jm_brand_logo {
        max-width: 142px;
        max-height: 34px;
    }

    /* 모바일에서는 긴 Desktop 메뉴를 숨기고 Hamburger Drawer로 통합한다. */
    #jm_header .jm_nav {
        display: none;
    }

    #jm_header .jm_header_actions {
        flex: 0 0 auto;
    }

    #jm_header .jm_allmenu_btn {
        width: 40px;
        height: 40px;
        font-size: 19px;
    }

    #jm_header .jm_allmenu {
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        width: min(88vw, 390px);
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
        opacity: 0;
        transform: translateX(100%);
        overflow-y: auto;
        overscroll-behavior: contain;
        box-shadow: -18px 0 45px rgba(20, 34, 50, .16);
        transition: opacity .2s ease, transform .22s ease;
    }

    #jm_header .jm_allmenu.is-open {
        max-height: none;
        border: 0;
        opacity: 1;
        transform: translateX(0);
    }

    #jm_header .jm_allmenu_inner {
        min-height: 100%;
        padding: 20px 18px 30px;
    }

    #jm_header .jm_allmenu_head {
        position: sticky;
        top: -20px;
        z-index: 3;
        margin: -20px -18px 0;
        padding: 18px 18px 15px;
        background: rgba(255,255,255,.97);
        backdrop-filter: blur(8px);
    }

    #jm_header .jm_allmenu_head strong {
        font-size: 18px;
    }

    #jm_header .jm_allmenu_sections {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 18px 0 6px;
    }

    #jm_header .jm_allmenu_sections a {
        display: flex;
        align-items: center;
        min-height: 42px;
        padding: 0 12px;
        border: 1px solid #e6eaef;
        border-radius: 10px;
        background: #f8fafb;
        color: #3b4b61;
        font-size: 13px;
        font-weight: 700;
        text-decoration: none;
    }

    #jm_header .jm_allmenu_sections a:hover,
    #jm_header .jm_allmenu_sections a:focus {
        border-color: #bde8e2;
        background: #effdfa;
        color: #008f7d;
    }

    #jm_header .jm_allmenu_grid {
        grid-template-columns: 1fr;
        gap: 0;
        padding-top: 12px;
    }

    #jm_header .jm_allmenu_group {
        padding: 15px 0;
        border-bottom: 1px solid #edf0f3;
    }

    #jm_header .jm_allmenu_title {
        margin-bottom: 9px;
        font-size: 15px;
    }

    #jm_header .jm_allmenu_sub {
        display: flex;
        flex-wrap: wrap;
        gap: 7px 12px;
    }

    #jm_header .jm_allmenu_sub li + li {
        margin-top: 0;
    }

    #jm_header .jm_allmenu_sub a {
        display: inline-flex;
        padding: 5px 0;
        font-size: 13px;
    }

    #jm_header .jm_allmenu_bg {
        z-index: 1001;
        background: rgba(15, 27, 43, .38);
    }
}

@media (max-width: 420px) {
    #jm_header .jm_header_inner {
        padding-left: 13px;
        padding-right: 10px;
    }

    #jm_header .jm_brand_logo {
        max-width: 128px;
    }

    #jm_header .jm_allmenu {
        width: 92vw;
    }
}
