/* ==========================================================================
   ハンバーガーメニュー（カスタムオーバーレイ）のスタイル
   ========================================================================== */

/* 左上のMENUタイトルとウィジェットタイトルを非表示 */
body #sp_menu .c-widget__title {
    display: none !important;
}

/* 全体の背景色・テキスト色の上書き */
body #sp_menu .p-spMenu__inner {
    background-color: #0c4394;
    color: #fff;
}

body #sp_menu .p-spMenu__inner::before {
    background-color: #0c4394;
    background: #0c4394;
    opacity: 1;
}

body #sp_menu .p-spMenu__body {
    background-color: transparent;
    color: #fff;
}

/* 閉じるボタン（×ボタン）の色を白に */
body #sp_menu .p-spMenu__closeBtn .c-iconBtn {
    color: #fff;
}

/* SWELLデフォルトの不要なメニューエリアを非表示（ウィジェットのみ使用するため） */
#sp_menu .p-spMenu__nav {
    display: none;
}

/* ==========================================================================
   PC用メガメニュースタイル (960px以上)
   ========================================================================== */
@media screen and (min-width: 960px) {

    /* PC表示時、ハンバーガーが開かれたらヘッダー下にメガメニューとして全幅表示する */
    body #sp_menu {
        display: block;
        /* body #sp_menu (111) で SWELLの .p-spMenu (10) を上書き */
        position: fixed;
        top: var(--custom-header-height, 118px);
        /* ヘッダー＋インフォバーの高さ（JSで動的計算） */
        left: 0;
        width: 100vw;
        height: auto;
        bottom: auto;
        z-index: 99;
        /* ヘッダー(z-index: 100)の後ろに配置 */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease, visibility 0.4s;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    }

    html[data-spmenu="opened"] body #sp_menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* PC時のオーバーレイの位置調整 */
    body #sp_menu .p-spMenu__overlay {
        position: fixed;
        top: var(--custom-header-height, 118px);
        height: calc(100vh - var(--custom-header-height, 118px));
    }

    body #sp_menu .p-spMenu__inner,
    html[data-spmenu="opened"] body #sp_menu .p-spMenu__inner {
        width: 100%;
        max-width: none;
        height: auto;
        padding-top: 0;
        background-color: #0c4394;
        transform: none;
        -webkit-transform: none;
        transition: none;
    }

    body #sp_menu .p-spMenu__body {
        padding: 0;
        /* SWELLのデフォルトpaddingをリセット */
    }

    /* PCでは右上の閉じるボタンを隠す（ヘッダーのハンバーガーボタンで閉じるため） */
    body #sp_menu .p-spMenu__closeBtn {
        display: none;
    }

    #sp_menu_bottom {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        align-items: start;
        /* カラムを上揃えにする */
        gap: 32px;
        padding: 40px 60px;
        max-width: 1200px;
        /* コンテンツ最大幅 */
        margin: 0 auto;
    }
}

/* ==========================================================================
   スマホ用スタイル (959px以下)
   ========================================================================== */
@media screen and (max-width: 959px) {

    /* SPドロワーを開いた時もヘッダーを前面にアクティブ表示する */
    body #sp_menu {
        z-index: 99 !important; /* ヘッダー(100)の背面に配置 */
        top: var(--custom-header-height, 118px) !important; /* ヘッダーの下から開始 */
        height: calc(100vh - var(--custom-header-height, 118px)) !important;
    }

    body #sp_menu .p-spMenu__overlay {
        top: 0 !important;
        height: 100% !important;
    }

    /* SWELLの左右設定に関わらず右からスライドするように強制（幅 390px） */
    body #sp_menu .p-spMenu__inner {
        top: 0 !important;
        height: 100% !important;
        left: auto !important;
        right: 0 !important;
        width: 390px !important;
        transform: translateX(390px) !important;
        -webkit-transform: translateX(390px) !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
    }

    /* メニュー本体を上揃えにする */
    body #sp_menu .p-spMenu__body {
        margin-top: 0 !important;
        margin-bottom: auto !important;
    }

    html[data-spmenu="opened"] body #sp_menu .p-spMenu__inner {
        transform: translateX(0) !important;
        -webkit-transform: translateX(0) !important;
    }

    /* ヘッダーのハンバーガーボタンが操作可能なため、内部の閉じるボタンは不要 */
    body #sp_menu .p-spMenu__closeBtn {
        display: none !important;
    }

    #sp_menu_bottom {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 24px 20px;
    }
}

/* スマホサイズ（480px以下）の時は横幅100%にする */
@media screen and (max-width: 480px) {
    body #sp_menu .p-spMenu__inner {
        width: 100% !important;
        transform: translateX(100%) !important;
        -webkit-transform: translateX(100%) !important;
    }

    html[data-spmenu="opened"] body #sp_menu .p-spMenu__inner {
        transform: translateX(0) !important;
        -webkit-transform: translateX(0) !important;
    }
}

/* ==========================================================================
   ドロワーのスクロールバー制御（SP）
   ========================================================================== */
@media screen and (max-width: 959px) {
    /* 必要な時だけスクロールバーを表示 */
    body #sp_menu .p-spMenu__inner {
        overflow-y: auto !important;
        /* Firefox: 細いスクロールバー */
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
    }

    /* Chrome / Safari: スクロールバーを細くカスタマイズ */
    body #sp_menu .p-spMenu__inner::-webkit-scrollbar {
        width: 4px;
    }

    body #sp_menu .p-spMenu__inner::-webkit-scrollbar-track {
        background: transparent;
    }

    body #sp_menu .p-spMenu__inner::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.4);
        border-radius: 2px;
    }

    body #sp_menu .p-spMenu__inner::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.7);
    }
}

/* ==========================================================================
   SWELLのデフォルトウィジェットスタイル（.c-listMenu）のリセット
   ========================================================================== */
/* メニューボトムコンテナの上余白をリセット */
body #sp_menu .p-spMenu__bottom {
    margin-top: 0 !important;
}

#sp_menu_bottom .c-widget {
    margin-top: 0 !important;
}

#sp_menu_bottom .c-listMenu {
    border: none !important;
}

#sp_menu_bottom .c-listMenu>ul>li {
    border: none !important;
}

#sp_menu_bottom .c-listMenu a {
    padding: 0 !important;
    border: none !important;
}

#sp_menu_bottom .c-listMenu a::after {
    content: none !important;
    /* SWELLの右矢印アイコンを消す */
}

/* ウィジェットメニュー共通スタイル */
#sp_menu_bottom .widget_nav_menu {
    margin-bottom: 0;
    /* SWELLデフォルトのマージンをリセット */
}

#sp_menu_bottom .menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* メニューの各項目 */
#sp_menu_bottom .menu>li {
    display: flex;
    flex-direction: column;
    gap: 0; /* サブメニューの開閉に合わせてSPのgapはJSクラスで制御 */
    position: relative;
}

#sp_menu_bottom .menu>li>a {
    color: #fff !important;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0.05em;
    text-decoration: none;
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 16px !important;
    /* ハイフン用の余白 */
    cursor: pointer;
    transition: opacity 0.3s ease;
}

/* 擬似要素でハイフンを追加 */
#sp_menu_bottom .menu>li>a::before {
    content: "-";
    position: absolute;
    left: 0;
    color: #fff;
}

@media (hover: hover) {

    #sp_menu_bottom .menu>li>a:hover,
    #sp_menu_bottom .menu>li>a:focus-visible {
        opacity: 0.75;
    }
}

#sp_menu_bottom .menu>li>a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* 階層がある場合の親メニュー（アコーディオンのトグルボタン） */
#sp_menu_bottom .menu-item-has-children>a {
    justify-content: space-between;
    width: 100%;
}

/* SP時のアコーディオン用矢印アイコン */
#sp_menu_bottom .menu>li.menu-item-has-children>a::after {
    content: "" !important;
    display: inline-block !important;
    width: 8px !important;
    height: 8px !important;
    border-right: 2px solid #fff !important;
    border-bottom: 2px solid #fff !important;
    transform: rotate(45deg) !important;
    transition: transform 0.3s ease !important;
    margin-right: 4px !important;
    flex-shrink: 0 !important;
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
}

#sp_menu_bottom .menu>li.menu-item-has-children.is-open>a::after {
    transform: rotate(-135deg) !important;
}

/* 親テーマ由来のホバー背景色をリセット */
body #sp_menu #sp_menu_bottom .menu > li > a:hover,
body #sp_menu #sp_menu_bottom .menu > li > a:focus,
body #sp_menu #sp_menu_bottom .sub-menu > li > a:hover,
body #sp_menu #sp_menu_bottom .sub-menu > li > a:focus {
    background-color: transparent !important;
}

/* サブメニュー（階層下） */
#sp_menu_bottom .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0 0 0 24px;
    /* 子項目をインデント */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#sp_menu_bottom .sub-menu>li>a {
    color: #fff !important;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0.04em;
    text-decoration: none;
    padding-left: 0 !important;
    transition: opacity 0.3s ease;
}

#sp_menu_bottom .sub-menu>li>a::before {
    content: none;
    /* 子要素にはハイフンをつけない */
}

@media (hover: hover) {

    #sp_menu_bottom .sub-menu>li>a:hover,
    #sp_menu_bottom .sub-menu>li>a:focus-visible {
        opacity: 0.75;
    }
}

#sp_menu_bottom .sub-menu>li>a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* アコーディオンの開閉挙動 (SP: max-height トランジション) */
@media screen and (max-width: 959px) {
    /* デフォルトは折りたたんだ状態 */
    #sp_menu_bottom .sub-menu {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        padding-top: 0;
        gap: 0;
        transition:
            max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.25s ease,
            padding-top 0.35s ease,
            gap 0.35s ease;
    }

    /* .is-open で展開 */
    #sp_menu_bottom .menu-item-has-children.is-open > .sub-menu {
        max-height: 800px;
        opacity: 1;
        padding-top: 8px;
        gap: 16px;
    }
}

/* PCでは常に展開表示（メガメニュー） */
@media screen and (min-width: 960px) {
    #sp_menu_bottom .sub-menu {
        display: flex;
    }

    /* PC横並び表示では親メニューと子メニューの間に16pxの余白 */
    #sp_menu_bottom .menu>li {
        gap: 16px;
    }

    /* PC時は矢印を非表示 */
    #sp_menu_bottom .menu>li.menu-item-has-children>a::after {
        content: none !important;
        display: none !important;
    }
}
