/* =========================
   Header 右侧菜单容器
   把包住 menu-en / menu-ja 的父容器强制改为横向
   ========================= */
header .wp-block-group.is-content-justification-right.wp-block-group-is-layout-flex {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0 !important;
}

/* =========================
   默认导航本体
   ========================= */
header .menu-en.wp-block-navigation,
header .menu-ja.wp-block-navigation {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
}

/* 导航内部 ul */
header .menu-en .wp-block-navigation__container,
header .menu-ja .wp-block-navigation__container {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 1.2rem !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 每个菜单项不许被压缩 */
header .menu-en .wp-block-navigation-item,
header .menu-ja .wp-block-navigation-item {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;
}

/* 链接与文字保持横排 */
header .menu-en .wp-block-navigation-item__content,
header .menu-ja .wp-block-navigation-item__content,
header .menu-en .wp-block-navigation-item__label,
header .menu-ja .wp-block-navigation-item__label {
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
}

/* 子菜单按钮也保持横排 */
header .menu-en .wp-block-navigation-submenu__toggle,
header .menu-ja .wp-block-navigation-submenu__toggle {
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
}

/* 日文菜单上若带有 space-between 类，覆盖掉 */
header .menu-ja.items-justified-space-between,
header .menu-ja.is-content-justification-space-between,
header .menu-ja .wp-block-navigation__container.items-justified-space-between {
    justify-content: flex-end !important;
}

/* =========================
   语言切换：只让当前语言菜单显示
   下面两组规则保留常见写法，命中其一即可
   ========================= */

/* 日文页：隐藏英文菜单，显示日文菜单 */
html[lang^="ja"] header .menu-en,
body.lang-ja header .menu-en,
body[class*="lang-ja"] header .menu-en {
    display: none !important;
}

html[lang^="ja"] header .menu-ja,
body.lang-ja header .menu-ja,
body[class*="lang-ja"] header .menu-ja {
    display: flex !important;
}

/* 英文页：隐藏日文菜单，显示英文菜单 */
html[lang^="en"] header .menu-ja,
body.lang-en header .menu-ja,
body[class*="lang-en"] header .menu-ja {
    display: none !important;
}

html[lang^="en"] header .menu-en,
body.lang-en header .menu-en,
body[class*="lang-en"] header .menu-en {
    display: flex !important;
}

/* =========================
   小屏幕下交给汉堡菜单
   ========================= */
@media (max-width: 991px) {

    header .menu-en .wp-block-navigation__container,
    header .menu-ja .wp-block-navigation__container {
        gap: 0.9rem !important;
    }
}

/* 默认先隐藏英文 */
.footer-en {
    display: none;
}

/* 日文页显示日文 footer */
html[lang^="ja"] .footer-ja,
body.lang-ja .footer-ja,
body[class*="lang-ja"] .footer-ja {
    display: block !important;
}

html[lang^="ja"] .footer-en,
body.lang-ja .footer-en,
body[class*="lang-ja"] .footer-en {
    display: none !important;
}

/* 英文页显示英文 footer */
html[lang^="en"] .footer-en,
body.lang-en .footer-en,
body[class*="lang-en"] .footer-en {
    display: block !important;
}

html[lang^="en"] .footer-ja,
body.lang-en .footer-ja,
body[class*="lang-en"] .footer-ja {
    display: none !important;
}

.lang-switch {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-switch a {
    text-decoration: none;
    color: inherit;
}

.lang-switch a:hover {
    opacity: 0.7;
}

.menu-ja {
    display: none;
}

html[lang="ja"] .menu-ja {
    display: block;
}

html[lang="ja"] .menu-en {
    display: none;
}

html[lang="en"] .menu-en {
    display: block;
}

html[lang="ja"] .lang-switch a[href*="/ja"] {
    font-weight: 600;
}

html[lang="en"] .lang-switch a[href*="/en"] {
    font-weight: 600;
}