/**
 * CSS File: header.css
 * 2026-07-07 | Structured Mobile-First Header Optimization
 */

/* -------------------------------------------------------------------------
 * 1. スマートフォン縦向き環境（デフォルトスタイル）
 * ------------------------------------------------------------------------- */
.p-header {
  position: fixed;
  top: 0; /* 💡 固定位置は0のまま動かさない */
  left: 0;
  width: 100%;
  height: 60px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #eee;
  z-index: var(--z_200-header);
  display: flex;
  align-items: center;

  /* 💡 topアニメーションを廃止し、transformで制御（will-changeを正しく活かす） */
  transform: translateY(-100%) translateZ(0);
  will-change: transform;
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

/* 💡 表示クラス：transformで定位置（0）へ戻す */
.p-header.is-show {
  transform: translateY(0) translateZ(0);
}

.p-header__inner {
  width: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  gap: 25px;
}

.p-header__logo img {
  height: 28px;
  width: auto;
  display: block;
}

.p-header__trigger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
}

.p-header__trigger span {
  width: 100%;
  height: 2px;
  background-color: #4a5568;
  transition: all 0.3s;
  display: block;
}

.p-header__trigger.is-active span:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.p-header__trigger.is-active span:nth-child(2) {
  opacity: 0;
}

.p-header__trigger.is-active span:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

.p-header__trigger.is-submenu-open span:nth-child(1) {
  width: 18px;
  margin-left: auto;
  transform: translateX(-10px) translateY(15px) rotate(-45deg);
}

.p-header__trigger.is-submenu-open span:nth-child(2) {
  opacity: 0;
}

.p-header__trigger.is-submenu-open span:nth-child(3) {
  width: 18px;
  margin-left: auto;
  transform: translateX(3px) translateY(-2px) rotate(45deg);
}

.p-header__nav {
  display: none;
  flex-direction: column;
  position: fixed;
  top: 60px;
  left: 0;
  width: 100%;
  height: calc(100vh - 60px);
  background-color: rgba(255, 255, 255, 0.9);
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

.p-header__nav.is-open {
  display: flex;
}

.p-header__nav-item {
  width: 100%;
  padding: 15px 0;
  border-bottom: 1px solid #f7f7f7;
  color: #4a5568;
  text-decoration: none;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9375rem;
}

.p-header__mega-menu {
  position: fixed;
  top: 60px;
  left: 0;
  width: 100%;
  height: calc(100vh - 60px);
  background: #fff;
  display: none;
  overflow-y: auto;
}

.p-header__mega-menu.is-active {
  display: block;
}

.p-header__mega-menu-inner {
  padding: 20px;
  display: block;
  column-count: 1;
}

.p-header__mega-menu-item {
  color: var(
    --upper-color-1
  ); /* 💡 修正: 旧サーモンピンクからメインのネイビーへ */
  font-weight: bold;
}

.p-header__mega-menu-item a {
  display: block;
  padding: 15px 0;
  color: #4a5568;
  text-decoration: none;
  border-bottom: 1px solid #f0f0f0;
  font-weight: 700;
  font-size: 0.9375rem;
}

.p-header__mega-menu-item--sub {
  padding-left: 1.2rem;
}

.p-header__mega-menu-item--sub a {
  font-weight: 500;
  color: #555555;
  font-size: 0.875rem;
}

.p-header__icon-arrow::before {
  content: "∨";
  font-size: 0.625rem;
  margin-left: 4px;
}

.icon-external::before {
  content: "↗";
  font-size: 0.75rem;
  margin-left: 4px;
}

/* -------------------------------------------------------------------------
 * 2. レスポンシブ対応：横向きスマホ等（特殊幅）
 * ------------------------------------------------------------------------- */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .p-header__nav,
  .p-header__mega-menu {
    height: calc(100vh - 60px);
  }
}

/* -------------------------------------------------------------------------
 * 3. レスポンシブ対応：タブレットサイズ以上
 * ------------------------------------------------------------------------- */
@media screen and (min-width: 768px) and (min-height: 501px) {
  .p-header {
    height: 75px;
  }

  .p-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
  }

  .p-header__logo img {
    height: 36px;
  }

  .p-header__trigger {
    display: none;
  }

  .p-header__nav {
    display: flex;
    position: static;
    flex-direction: row;
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    gap: 14px;
    margin-left: auto; /* ナビゲーション全体を右側に押しやり、TOPの左側に余白を強制確保 */
    overflow: visible;
  }

  .p-header__nav-item {
    position: relative;
    display: inline-block;
    width: auto;
    padding: 0;
    border: none;
    font-size: 0.8125rem;
    white-space: nowrap;
    letter-spacing: -0.02em;
  }

  /* 💡 修正: パターンA 滞在ページをゴールドにして黒系から完全に脱却 */
  .p-header__nav-item.is-current {
    color: var(--lower-color-5);
    pointer-events: auto;
  }

  /* 💡 修正: 滞在ページの下線も同じゴールドで統一 */
  .p-header__nav-item.is-current::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--lower-color-5);
  }

  /* 💡 修正: メメニュー展開中の太下線もゴールドに */
  .p-header__nav-item.is-active::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--lower-color-5);
  }

  .p-header__mega-menu {
    position: fixed;
    top: 75px;
    left: 0;
    height: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-top: 1px solid #eee;
    display: block;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.4s ease;
  }

  .p-header__mega-menu.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .p-header__mega-menu-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 50px;
    display: grid;
    grid-template-rows: repeat(3, auto);
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    justify-content: center;
    gap: 0 80px;
  }

  .p-header__mega-menu-item {
    break-inside: avoid;
  }

  .p-header__mega-menu-item a {
    border-bottom: 1px solid #f7f7f7;
    padding: 10px 0;
    padding-right: 20px;
    transition: color 0.3s;
    white-space: nowrap;
  }

  /* 💡 修正: メガメニュー内ホバー時のテキストをディープネイビーに */
  .p-header__mega-menu-item a:hover {
    color: var(--upper-color-1);
  }
}

/* -------------------------------------------------------------------------
 * 4. レスポンシブ対応：PCサイズ以上
 * ------------------------------------------------------------------------- */
@media screen and (min-width: 1024px) and (min-height: 501px) {
  .p-header__nav {
    gap: 24px;
  }

  .p-header__nav-item {
    font-size: 0.9375rem;
    letter-spacing: 0.02em;
  }
}

/* メガメニュー全体のインナークローザー */
.p-header__mega-menu-inner {
  display: flex;
  flex-direction: column;
  padding: 30px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  max-width: 1200px;
  margin: 0 auto;
}

/* TOPリンク（共通） */
.p-header__mega-menu-item--top {
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 20px;
  font-weight: bold;
}

/* 💡 修正: メガメニュー内のTOPリンクをディープネイビーにして統一感アップ */
.p-header__mega-menu-item--top a {
  color: var(--upper-color-1);
  font-size: 1.1rem;
}

/* BPO専用：左右を強制的に50%ずつに割る横並びコンテナ */
.p-header__mega-menu-bpo-container {
  display: flex;
  width: 100%;
  gap: 60px; /* 左右の部屋の間の余白 */
  position: relative;
}

/* 左右の部屋の境界線（真ん中のセパレーター） */
.p-header__mega-menu-bpo-container::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background-color: #e0e0e0; /* 真ん中のうすい区切り線 */
  transform: translateX(-50%);
}

/* 左右それぞれの独立した縦並びカラム */
.p-header__mega-menu-bpo-col {
  display: flex;
  flex-direction: column; /* 上から下へ強制的に並べる */
  gap: 12px;
  width: calc(50% - 30px); /* セパレーターを挟んで綺麗に半分 */
}

/* グループ大見出し（事務一括支援 / 業務プロセス支援） */
.p-header__mega-menu-item--group-title {
  font-weight: bold;
  font-size: 1.05rem;
  color: #333;
  padding-bottom: 6px;
  /* 💡 修正: 見出しの下線をディープネイビーにして新パレットに調和 */
  border-bottom: 2px solid var(--upper-color-1);
  margin-bottom: 6px;
}

/* 子メニュー（インデント＋左側に薄い縦線の束） */
.p-header__mega-menu-item--sub {
  font-size: 0.9rem;
  padding-left: 15px;
  position: relative;
}
.p-header__mega-menu-item--sub::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background-color: #f0f0f0;
}
.p-header__mega-menu-item--sub a {
  color: #555;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s ease;
}

/* 💡 修正: BPO内リンクホバー時もディープネイビーに変更 */
.p-header__mega-menu-item--sub a:hover {
  color: var(--upper-color-1);
  transform: translateX(3px);
}

/* BPO以外の通常のメニュー（派遣・ITなど）が壊れないための縦並び維持 */
#id-mega-menu-0 .p-header__mega-menu-item,
#id-mega-menu-2 .p-header__mega-menu-item,
#id-mega-menu-3 .p-header__mega-menu-item,
#id-mega-menu-4 .p-header__mega-menu-item {
  width: 100%;
  margin-bottom: 10px;
}
