/* =========================
   변수
   ========================= */
:root {
  --header-top-height: 40px;
  --header-main-height: 50px;
  --header-nav-height: 40px;
  --header-total-height: calc(
    var(--header-top-height) + var(--header-main-height) + var(--header-nav-height)
  );
  --admin-bar-height: 0px;
}

/* =========================
   WP admin bar 대응
   ========================= */
body.admin-bar {
  --admin-bar-height: 32px;
}

@media (max-width: 782px) {
  body.admin-bar {
    --admin-bar-height: 46px;
  }
}

/* モバイル：header-top を非表示にするため、
   高さ変数を 0 に再定義（各ページ hero の padding-top 計算が正しく動くように）。
   admin-bar 有無に関わらず確実に効くよう、--header-total-height も明示的に再計算する。 */
@media (max-width: 768px) {
  :root {
    --header-top-height: 0px;
    --header-nav-height: 0px;
    --header-total-height: var(--header-main-height);
  }
}

/* =========================
   Header 기본
   ========================= */
.site-header {
  position: fixed;
  top: var(--admin-bar-height);
  left: 0;
  width: 100%;
  z-index: 999;
  background: #fff;
  /* border-bottom: 1px solid #ddd; */
  transition:
    background 0.3s ease,
    border-color 0.3s ease;
}

/* トップページ：初期は透明 */
body.home .site-header {
  background: transparent;
  border-bottom-color: transparent;
}

body.is-recruit-page .site-header {
  background: transparent;
  border-bottom-color: transparent;
}

body.is-brand-page .site-header {
  background: transparent;
  border-bottom-color: transparent;
}

body.is-education-page .site-header {
  background: #fff !important;
  background-image: none !important;
  border-bottom-color: transparent;
}

body.home .site-header .main-navigation {
  background: transparent;
  padding-bottom: 12px;
}

body.is-recruit-page .site-header .main-navigation {
  background: transparent;
  padding-bottom: 12px;
}

body.is-brand-page .site-header .main-navigation {
  background: transparent;
  padding-bottom: 12px;
}

body.is-education-page .site-header .main-navigation {
  background: #fff !important;
  background-image: none !important;
}

body.is-education-page .site-header .site-logo img {
  filter: none;
}

body.is-education-page .site-header .main-navigation > ul > li > a {
  color: #333;
}

body.is-education-page .site-header .menu-toggle span {
  background: #333;
}

body.home .site-header .main-navigation > ul > li > a {
  color: #fff;
}

body.is-recruit-page .site-header .site-logo img {
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

body.is-recruit-page .site-header .header-top > span {
  color: #dce8f4;
}

body.home .site-header .main-navigation .sub-menu a {
  color: #333;
}

body.home .site-header .site-logo img {
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

body.home .site-header .header-top {
  color: #fff;
}

body.home .site-header .header-top a {
  color: #fff;
}

body.home .site-header .header-top.is-mobile-clone .service-list {
  display: none;
}

.service-list {
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: clamp(300px, 30vw, 360px);
  min-height: 28px;
  padding: 3px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
}

.service-list::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc((100% - 6px) / 2);
  height: calc(100% - 6px);
  background: #e4e7eb;
  border-radius: 999px;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.service-list:has(.service-list__item:nth-child(2).is-active)::before {
  transform: translateX(100%);
}

@media (hover: hover) {
  .service-list:has(.service-list__item:nth-child(1):hover)::before {
    transform: translateX(0);
  }

  .service-list:has(.service-list__item:nth-child(2):hover)::before {
    transform: translateX(100%);
  }
}

.service-list__item {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  display: inline-flex;
  flex: 1 1 50%;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  color: #8a9299 !important;
  font-family: var(--font-ja);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition:
    color 0.2s ease,
    opacity 0.2s ease;
}

.service-list__item.is-active {
  color: #1f2933 !important;
}

.service-list__item:not(.is-active):hover {
  color: #5f6870 !important;
}

@media (hover: hover) {
  .service-list:has(.service-list__item:hover) .service-list__item {
    color: #8a9299 !important;
  }

  .service-list:has(.service-list__item:nth-child(1):hover) .service-list__item:nth-child(1),
  .service-list:has(.service-list__item:nth-child(2):hover) .service-list__item:nth-child(2) {
    color: #1f2933 !important;
  }
}

/* モバイルメニュー展開時：白背景に強制（即時切替） */
body.home .site-header:has(.main-navigation.is-open) {
  background: #fff;
  border-bottom-color: #ddd;
  transition: none;
}

body.is-recruit-page .site-header:has(.main-navigation.is-open) {
  background: #fff;
  border-bottom-color: #ddd;
  transition: none;
}

body.is-brand-page .site-header:has(.main-navigation.is-open) {
  background: #fff;
  border-bottom-color: #ddd;
  transition: none;
}

body.home .site-header:has(.main-navigation.is-open) .site-logo img {
  filter: none;
  transition: none;
}

body.is-recruit-page .site-header:has(.main-navigation.is-open) .site-logo img {
  filter: none;
  transition: none;
}

body.is-brand-page .site-header:has(.main-navigation.is-open) .site-logo img {
  filter: none;
  transition: none;
}

body.home .site-header:has(.main-navigation.is-open) .menu-toggle span {
  background: #333;
  transition:
    transform 0.3s,
    opacity 0.3s;
}

body.is-recruit-page .site-header:has(.main-navigation.is-open) .menu-toggle span {
  background: #333;
  transition:
    transform 0.3s,
    opacity 0.3s;
}

body.is-brand-page .site-header:has(.main-navigation.is-open) .menu-toggle span {
  background: #333;
  transition:
    transform 0.3s,
    opacity 0.3s;
}

body.home .site-header:has(.main-navigation.is-open) .main-navigation {
  background: #fff;
}

body.is-recruit-page .site-header:has(.main-navigation.is-open) .main-navigation {
  background: #fff;
}

body.is-brand-page .site-header:has(.main-navigation.is-open) .main-navigation {
  background: #fff;
}

body.home .site-header:has(.main-navigation.is-open) .main-navigation > ul > li > a {
  color: #333;
}

body.is-brand-page .site-header:has(.main-navigation.is-open) .main-navigation > ul > li > a {
  color: #333;
}

body.is-recruit-page .site-header:has(.main-navigation.is-open) .header-top > span {
  color: #111;
}

body.is-brand-page .site-header:has(.main-navigation.is-open) .header-top,
body.is-brand-page .site-header:has(.main-navigation.is-open) .header-top a,
body.is-brand-page .site-header:has(.main-navigation.is-open) .header-top > span {
  color: #111;
}

/* ページ最上部を離れたら：白背景に */
body.home .site-header.is-not-top {
  background: #fff;
  border-bottom-color: #ddd;
}

body.is-recruit-page .site-header.is-not-top {
  background: #fff;
  border-bottom-color: #ddd;
}

body.is-brand-page .site-header.is-not-top {
  background: #fff;
  border-bottom-color: #ddd;
}

body.home .site-header.is-not-top .main-navigation {
  /* background: #fff; */
}

body.home .site-header.is-not-top .main-navigation > ul > li > a {
  color: #333;
}

body.home .site-header.is-not-top .site-logo img {
  filter: none;
}

body.is-recruit-page .site-header.is-not-top .site-logo img {
  filter: none;
}

body.home .site-header.is-not-top .header-top {
  color: inherit;
}

body.home .site-header.is-not-top .header-top a {
  color: inherit;
}

body.is-recruit-page .site-header.is-not-top .header-top > span {
  color: inherit;
}

/* WP admin-bar がある場合でも html に margin-top: 32px が自動付与されるため、
   body padding には --admin-bar-height を含めない（二重計算になる）。 */
body {
  padding-top: var(--header-total-height);
}

/* =========================
   Header Layout
   ========================= */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--gutter-width);
  font-size: 12px;
  max-width: var(--max-width);
  margin: 0 auto;
  height: var(--header-top-height);
  max-height: var(--header-top-height);
  opacity: 1;
  overflow: visible;
  transition:
    max-height 0.3s ease,
    opacity 0.3s ease,
    padding 0.3s ease;
}

.site-header.is-scrolled .header-top {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* スクロール時：ロゴ・CTAボタンを縮小 */
.site-header.is-scrolled .site-logo img {
  max-height: 30px;
  transition: max-height 0.3s ease;
}

.site-header.is-scrolled .header-cta a {
  padding: 6px 12px;
  font-size: 13px;
  transition:
    padding 0.3s ease,
    font-size 0.3s ease;
}

.site-header.is-scrolled .header-inner {
  height: 56px;
  transition: height 0.3s ease;
}

.header-inner {
  height: var(--header-main-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter-width);
  max-width: var(--max-width);
  margin: 0 auto;
  transition: height 0.3s ease;
}

.site-branding,
.site-logo {
  display: flex;
  align-items: center;
}

.site-logo img {
  display: block;
  max-height: 40px;
  height: auto;
  width: auto;
  transition: max-height 0.3s ease;
}

.header-cta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-cta a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(-76deg, #145393 0%, #3c75ac 100%);
  color: #fff;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 3px;
  white-space: nowrap;
  transition:
    padding 0.3s ease,
    font-size 0.3s ease;
}

/* Download Button Container */
.header-cta a.download {
  background: linear-gradient(315deg, #1d4055 15.14%, #2a5c7a 84.58%);
  box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.08);
}

/* =========================
   Desktop Nav
   ========================= */
.main-navigation {
  background: #fff;
  padding: 0 calc(var(--gutter-width) + 4px) 12px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.main-navigation ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 30px;
  list-style: none;
  margin: 0;
}

.main-navigation li {
  position: relative;
}

.main-navigation a {
  text-decoration: none;
  color: #333;
}

/* 데스크톱: 서브메뉴 아이콘 */
@media (min-width: 769px) {
  .menu-item-has-children > a::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg);
    margin-left: 6px;
    position: relative;
    top: -3px;
    transition:
      transform 0.2s ease,
      top 0.2s ease;
  }

  .menu-item-has-children:hover > a::after {
    top: 0;
    transform: rotate(225deg);
  }

  .submenu-toggle {
    display: none !important;
  }

  .main-navigation .sub-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    display: block;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 0;
    margin: 0;
    z-index: 20;
    box-shadow: 0 12px 28px rgba(20, 35, 50, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transform-origin: top left;
    transition:
      opacity 0.18s ease,
      transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0.18s ease;
  }

  .main-navigation .sub-menu::before {
    content: '';
    position: absolute;
    top: -16px;
    left: 0;
    width: 100%;
    height: 16px;
  }

  .main-navigation .sub-menu li {
    border-bottom: 0;
  }

  .main-navigation .sub-menu a {
    position: relative;
    display: block;
    padding: 10px 18px;
    white-space: nowrap;
    transition:
      background 0.18s ease,
      color 0.18s ease,
      padding 0.18s ease;
  }

  .main-navigation .sub-menu a::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 8px;
    width: 3px;
    height: 0;
    background: #145393;
    border-radius: 999px;
    transform: translateY(-50%);
    transition: height 0.18s ease;
  }

  .main-navigation .sub-menu a:hover,
  .main-navigation .sub-menu a:focus-visible {
    background: #f4f7fa;
    color: #145393;
    padding-left: 22px;
    outline: none;
  }

  .main-navigation .sub-menu a:hover::before,
  .main-navigation .sub-menu a:focus-visible::before {
    height: 18px;
  }

  .menu-item-has-children:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .mobile-extra {
    display: none;
  }
}

/* =========================
   햄버거 버튼
   ========================= */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px 0;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 1px;
  background: #333;
  transition:
    transform 0.3s,
    opacity 0.3s,
    background 0.3s;
}

/* トップページ透明時：ハンバーガー白 */
body.home .site-header:not(.is-not-top) .menu-toggle span {
  background: #fff;
}

body.is-recruit-page .site-header:not(.is-not-top) .menu-toggle span {
  background: #fff;
}

.menu-toggle.is-open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.menu-toggle.is-open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.menu-toggle.is-open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.mobile-service-list {
  display: none;
}

/* =========================
   Mobile
   ========================= */
@media (max-width: 768px) {
  /* 원본 헤더 상단/CTA 숨김 */
  .site-header > .header-top,
  .site-header > .header-inner .header-cta {
    display: none;
  }

  .site-logo img {
    height: 30px;
  }

  .menu-toggle {
    display: flex;
    flex-shrink: 0;
  }

  /* 모바일 메뉴 오버레이 */
  .main-navigation {
    display: none;
    position: fixed;
    top: calc(var(--admin-bar-height) + var(--header-main-height));
    left: 0;
    width: 100%;
    height: calc(100dvh - var(--admin-bar-height) - var(--header-main-height));
    background: #fff;
    z-index: 998;
    overflow-y: auto;
    border-top: 1px solid #eee;
  }

  /* スクロール時はヘッダー高さが 56px に縮小されるため、メニュー位置を合わせて公白を防ぐ */
  .site-header.is-scrolled .main-navigation {
    top: calc(var(--admin-bar-height) + 56px);
    height: calc(100dvh - var(--admin-bar-height) - 56px);
  }

  .main-navigation.is-open {
    display: block;
  }

  .mobile-service-list {
    position: relative;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: none;
    min-height: 34px;
    font-size: 12px;
    margin: 24px auto 12px;
    padding: 3px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
  }

  .mobile-service-list::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc((100% - 6px) / 2);
    height: calc(100% - 6px);
    background: #e4e7eb;
    border-radius: 999px;
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .mobile-service-list:has(.mobile-service-list__item:nth-child(2).is-active)::before {
    transform: translateX(100%);
  }

  .mobile-service-list__item {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    display: inline-flex;
    flex: 1 1 50%;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    color: #8a9299;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
  }

  .mobile-service-list__item.is-active {
    color: #1f2933;
  }

  /* 모바일 클론 영역 */
  .mobile-extra {
    padding: 0 0 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .main-navigation .mobile-extra .header-top {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
    font-size: 12px;
    border-bottom: 0;
    display: none;
  }

  .main-navigation .mobile-extra .header-cta {
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 0;
  }

  .main-navigation .mobile-extra .header-cta a {
    width: calc(50% - 6px);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 16px;
    font-size: 14px;
  }

  /* 메뉴 리스트 */
  #primary-menu {
    display: block !important;
    margin: 0;
    padding: 0;
  }

  #primary-menu > li {
    position: relative;
    border-bottom: 1px solid #eee;
  }

  #primary-menu > li > a {
    display: block;
    padding: 16px 0;
    line-height: 1.5;
    font-size: 14px;
  }

  /* 모바일에서는 데스크톱 화살표 숨김 */
  .menu-item-has-children > a::after {
    display: none !important;
  }

  /* + / - 버튼
     아이콘의 중심 위치는 그대로 두고 탭 영역만 24px → 48px 로 확대 */
  .submenu-toggle {
    position: absolute;
    right: 4px;
    top: 4px;
    transform: none;
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    z-index: 2;
  }

  .submenu-toggle::before,
  .submenu-toggle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    background: #333;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s ease;
  }

  .submenu-toggle::before {
    width: 14px;
    height: 1px;
  }

  .submenu-toggle::after {
    width: 1px;
    height: 14px;
  }

  .submenu-toggle.is-open::after {
    opacity: 0;
  }

  /* 모바일 서브메뉴 */
  .main-navigation .sub-menu {
    display: none;
    position: static;
    border-top: 1px solid #eee;
    background: #fafafa;
    margin: 0;
    padding: 0;
  }

  .main-navigation .sub-menu.is-open {
    display: block;
  }

  .main-navigation .sub-menu li {
    border-bottom: 1px solid #eee;
  }

  .main-navigation .sub-menu li:last-child {
    border-bottom: none;
  }

  .main-navigation .sub-menu a {
    display: block;
    padding: 12px 20px 12px 16px;
    line-height: 1.5;
    font-size: 14px;
  }
}
