/**
 * Header Styles (Vanilla CSS with BEM)
 *
 * TODO: 暫定対応 - 全ページリニューアル後、このファイルを削除してTailwindに統合
 *
 * 目的：
 * - トップページ（Vite環境）と旧環境の両方で動作するヘッダー
 * - 旧環境のスタイルと競合しないよう、独立したスタイルとして管理
 */

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

.header {
  position: fixed;
  top: 16px;
  left: 0;
  z-index: 999;
  width: 100%;

  @media (min-width: 880px) {
    top: 24px;
  }
}

/* WordPress管理バー対応 */
body:has(#wpadminbar) .header {
  top: 16px;
}

@media screen and (min-width: 783px) {
  body:has(#wpadminbar) .header {
    top: calc(32px + 16px);
  }

  body:has(#wpadminbar) .header__logo-wrapper {
    margin-top: 32px;
  }

  /* body:has(#wpadminbar) .header__menu-container {
    padding-top: 32px;
  } */
}

@media screen and (min-width: 1024px) {
  body:has(#wpadminbar) .header {
    top: calc(32px + 24px);
  }

  body:has(#wpadminbar) .header__logo-wrapper {
    margin-top: 32px;
  }

  /* body:has(#wpadminbar) .header__menu-container {
    padding-top: 32px;
  } */
}

/* ============================================================
 * Menu Button
 * ============================================================ */

#header-2026 {
  .header__menu-button {
    position: absolute;
    right: 16px;
    top: 0px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--color-white);
    padding: 10px 24px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    opacity: 1;
    transform: translateY(0);
    transition:
      background-color 0.3s ease,
      opacity 0.3s ease,
      transform 0.3s ease;

    @media (min-width: 880px) {
      right: 24px;
    }
  }

  /* スクロール時の表示/非表示アニメーション */
  .header__menu-button--visible {
    opacity: 1;
    transform: translateY(0);
  }

  .header__menu-button--hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
  }

  .header__menu-button {
    /* ホバー時：閉じている時は背景がオレンジに、開いている時は文字色がオレンジに */
    &:hover:not([data-menu-open="true"]) {
      background-color: var(--color-orange-primary);
    }

    &:hover:not([data-menu-open="true"]) .header__menu-text {
      color: var(--color-white);
    }

    &:hover:not([data-menu-open="true"]) .header__menu-line {
      background-color: var(--color-white);
    }

    /* バツボタン時のホバー：文字色とアイコンがオレンジに */
    &:hover[data-menu-open="true"] .header__menu-text {
      color: var(--color-orange-primary);
    }

    &:hover[data-menu-open="true"] .header__menu-line {
      background-color: var(--color-orange-primary);
    }
  }

  .header__menu-text {
    font-family: var(--font-m-plus, "M PLUS 1", sans-serif);
    font-weight: 400;
    color: var(--color-black-primary);
    font-size: 16px;
    line-height: 1;
    letter-spacing: normal;
    transition: color 0.3s ease;
  }

  .header__menu-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 16px;
    height: 16px;
  }

  .header__menu-line {
    display: block;
    background-color: var(--color-black-primary);
    width: 16px;
    height: 2px;
    transform: scaleY(0.5);
    transform-origin: center;
    transition: all 0.3s ease;
  }

  /* メニュー展開時：二本線をバツに変形 */
  .header__menu-button[data-menu-open="true"] .header__menu-line:first-child {
    transform: translateY(4px) rotate(45deg) scaleY(0.5);
  }

  .header__menu-button[data-menu-open="true"] .header__menu-line:last-child {
    transform: translateY(-4px) rotate(-45deg) scaleY(0.5);
  }

  /* ============================================================
   * Menu Overlay
   * ============================================================ */

  /* 背景オーバーレイ（PC時の左側クリック領域） */
  .header__menu-backdrop {
    position: fixed;
    inset: 0;
    background-color: transparent;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;

    /* PC時のみ表示 */
    @media (min-width: 880px) {
      display: block;
    }
  }

  .header__menu-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
  }

  .header__menu-backdrop--hidden {
    opacity: 0;
    pointer-events: none;
  }

  .header__menu-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--color-white);
    overflow-y: auto;
    transform: translateX(100%);
    z-index: 2;

    @media (min-width: 880px) {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      min-height: 100vh;
    }
  }

  .header__menu-overlay--hidden {
    display: none;
  }

  @media (min-width: 880px) {
    /* lg breakpoint */
    .header__menu-overlay {
      left: auto;
      width: 660px;
    }
  }

  .header__menu-container {
    display: flex;
    flex-direction: column;
    padding: 32px;
    padding-top: 0px;
    min-height: 100vh;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    opacity: 0;

    /* WebKit browsers (Chrome, Safari) */
    &::-webkit-scrollbar {
      display: none;
    }

    @media (min-width: 880px) {
      display: flex;
      flex: 1;
      flex-direction: column;
      justify-content: space-between;
      padding: 0px 64px 40px;
      min-height: auto;
    }
  }

  .header__logo-wrapper {
    opacity: 0;
  }

  /* ============================================================
   * Logo
   * ============================================================ */

  .header__logo-main-wrapper {
    position: absolute;
    top: 0px;
    left: 16px;
    z-index: 999;

    @media (min-width: 880px) {
      left: 32px;
    }
  }

  .header__logo-main {
    fill: var(--color-white);
    width: 120px;
    height: 18px;

    @media (min-width: 880px) {
      width: 188px;
      height: 30px;
    }
  }

  .header__logo-wrapper {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    padding: 24px 32px;
    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-gray-secondary);

    @media (min-width: 880px) {
      position: static;
      padding: 30px 64px;
    }
  }

  .header__logo {
    fill: var(--color-orange-primary);
    width: 120px;
    height: 18px;

    @media (min-width: 880px) {
      width: 167px;
      height: 25px;
    }
  }

  /* ============================================================
   * Menu Items
   * ============================================================ */

  .header__menu-list {
    display: flex;
    flex-direction: column;
    margin-bottom: 40px;

    @media (min-width: 880px) {
      flex-direction: row;
      gap: 40px;
    }
  }

  .header__menu-list-item {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 0;
    border-bottom: 1px solid var(--color-gray-secondary);

    @media (min-width: 880px) {
      min-width: 240px;
    }
  }

  .header__menu-list-item-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-black-primary);
    letter-spacing: 0.1em;
    line-height: 1.5;
  }

  /* Menu Item（通常リンク） */
  .header__menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-decoration: none;

    /* ホバー時：矢印アイコンが右にスライド */
    &:hover .header__menu-item-icon {
      @media (min-width: 880px) {
        transform: translateX(4px);
      }
    }

    /* オレンジリンクのホバー時：色が少し濃くなる */
    &:hover .header__menu-item-text[data-color="orange"] {
      color: var(--color-orange-dark);
    }
  }

  .header__menu-item-text {
    font-size: 16px;
    font-weight: 500; /* font-bold */
    color: var(--color-black-primary);
    letter-spacing: 0.1em;
    line-height: 1.5;
    transition: color 0.3s ease;

    &[data-color="orange"] {
      color: var(--color-orange-primary);
    }
  }

  .header__menu-item-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: var(--color-black-primary);
    transition: transform 0.3s ease;
  }

  /* Menu Item（展開可能） */
  .header__menu-expandable {
    width: 100%;
  }

  .header__menu-expandable-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    cursor: pointer;

    /* ホバー時：プラスアイコンが右にスライド、テキストが濃くなる */
    &:hover .header__menu-expandable-plus {
      @media (min-width: 880px) {
        transform: translateX(4px);
      }
    }

    &:hover .header__menu-expandable-text {
      color: var(--color-orange-dark);
    }
  }

  .header__menu-expandable-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-orange-primary);
    letter-spacing: 0.1em;
    line-height: 1.5;
    transition: color 0.3s ease;
  }

  /* +アイコン */
  .header__menu-expandable-plus {
    position: relative;
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-right: 6px;
  }

  .header__menu-expandable-plus-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-black-primary);
    transform: translateY(-50%);
  }

  .header__menu-expandable-plus-line--vertical {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background-color: var(--color-black-primary);
    transform: translateX(-50%);
    transform-origin: center;
    transition: transform 0.3s ease;
  }

  /* 展開時に縦線を回転してマイナスに */
  .header__menu-expandable-toggle[data-expanded="true"] .header__menu-expandable-plus-line--vertical {
    transform: translateX(-50%) rotate(90deg);
  }

  /* 子要素コンテンツ */
  .header__menu-expandable-content {
    overflow: hidden;
    height: 0;
    opacity: 0;
    transition:
      height 0.3s ease,
      opacity 0.3s ease;
  }

  /* 折りたたみ時 */
  .header__menu-expandable-content[data-expanded="false"] {
    height: 0;
    opacity: 0;
  }

  /* 展開時 */
  .header__menu-expandable-content[data-expanded="true"] {
    opacity: 1;
  }

  .header__menu-expandable-children {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
  }

  /* 子要素のリンク */
  .header__menu-expandable-child-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-decoration: none;

    /* ホバー時：矢印が右にスライド */
    &:hover .header__menu-expandable-child-icon {
      @media (min-width: 880px) {
        transform: translateX(4px);
      }
    }
  }

  .header__menu-expandable-child-text {
    font-size: 12px;
    font-weight: 500; /* font-medium */
    color: var(--color-black-primary);
    letter-spacing: 0.1em;
    line-height: 1.5;
  }

  .header__menu-expandable-child-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: var(--color-black-primary);
    transition: transform 0.3s ease;
  }

  /* ============================================================
   * SNS Links
   * ============================================================ */

  .header__sns-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-gray-secondary);

    @media (min-width: 880px) {
      justify-content: flex-start;
      gap: 64px;
    }
  }

  .header__sns-title {
    font-weight: 400;
    color: var(--color-black);
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: 0.1em;
  }

  .header__sns-links {
    display: flex;
    gap: 24px;
  }

  .header__sns-link {
    display: block;
    width: 29px;
    height: 30px;

    svg {
      width: 100%;
      height: 100%;
      fill: var(--color-orange-primary);
    }
  }

  /* ============================================================
   * Footer Links (in menu)
   * ============================================================ */

  .header__footer-links {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-top: 24px;

    @media (min-width: 880px) {
      flex-direction: row;
      flex-wrap: wrap;
      column-gap: 32px;
      row-gap: 16px;
    }
  }

  .header__footer-link {
    font-weight: 400;
    color: var(--color-black-primary);
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: 0.1em;
    text-decoration: none;
    transition: color 0.2s;

    &:hover {
      color: var(--color-orange-primary);
    }
  }
}
