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

/* WordPress管理バーがある場合に高さを設定 */
body:has(#wpadminbar) {
  --admin-bar-height: 32px;
}

.header {
  position: fixed;
  top: var(--header-top-offset-mobile);
  left: 0;
  z-index: 999;
  width: 100%;

  @media (min-width: 880px) {
    top: var(--header-top-offset-desktop);
  }
}

/* WordPress管理バーがある場合に高さを設定 */
body:has(#wpadminbar) .header {
  @media screen and (min-width: 783px) and (max-width: 1023px) {
    top: calc(var(--header-top-offset-mobile) + var(--admin-bar-height));
  }

  @media screen and (min-width: 1024px) {
    top: calc(var(--header-top-offset-desktop) + var(--admin-bar-height));
  }
}

body:has(#wpadminbar) .header__logo-wrapper {
  @media screen and (min-width: 783px) {
    margin-top: var(--admin-bar-height);
  }
}

body:has(#wpadminbar) .site-logo {
  @media screen and (min-width: 783px) {
    top: calc(24px + var(--admin-bar-height));
  }
}

/* ============================================================
 * Site Logo (headerタグの外側、追従しない)
 * ============================================================ */

.site-logo {
  position: absolute;
  top: 24px;
  left: 16px;
  z-index: 50;

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

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

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

.site-logo__icon[data-color="white"] {
  fill: var(--color-white);
}

.site-logo__icon[data-color="orange"] {
  fill: var(--color-orange-primary);
}

/* ============================================================
 * Site Logo Spacer (ロゴ用余白)
 * ============================================================ */

.site-logo-spacer {
  height: 80px;
  background-color: var(--color-white);
}

.site-logo-spacer[data-color="orange"] {
  background-color: var(--color-orange-primary);
}

.site-logo-spacer[data-color="white"] {
  background-color: var(--color-white);
}

/* ============================================================
 * 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[data-visible="false"] {
    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;
    transition: opacity 0.3s ease;

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

  .header__menu-backdrop[data-visible="true"] {
    opacity: 1;
    pointer-events: auto;
  }

  .header__menu-backdrop[data-visible="false"] {
    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;
    }
  }

  @media (min-width: 880px) {
    .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;
    -ms-overflow-style: none;

    &::-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__menu-container[data-visible="false"] {
    opacity: 0;
  }

  .header__logo-wrapper[data-visible="false"] {
    opacity: 0;
  }

  /* ============================================================
   * Logo (メニューオーバーレイ内)
   * ============================================================ */

  .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;
    padding: 12px 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;
    padding: 12px 0;
  }

  /* ============================================================
   * Menu Item Component
   * ============================================================ */
  .c-header-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-decoration: none;
    padding: 12px 0;

    &:hover .c-header-item__icon {
      @media (min-width: 880px) {
        transform: translateX(4px);
      }
    }

    &:hover .c-header-item__text {
      color: var(--color-orange-primary);
    }

    &:hover .c-header-item__text[data-color="orange"] {
      color: var(--color-black-primary);
    }
  }

  .c-header-item__text {
    font-size: 16px;
    font-weight: 500;
    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);
    }
  }

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

  /* ============================================================
   * Menu Accordion Component
   * ============================================================ */
  .c-header-accordion {
    width: 100%;
  }

  .c-header-accordion__toggle {
    /* buttonタグのリセット */
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    text-align: inherit;
    -webkit-appearance: none;
    appearance: none;

    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 0;
    cursor: pointer;

    &:hover .c-header-accordion__plus {
      @media (min-width: 880px) {
        transform: translateX(4px);
      }
    }

    &:hover .c-header-accordion__text {
      color: var(--color-black-primary);
    }
  }

  .c-header-accordion__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;
  }

  .c-header-accordion__plus {
    position: relative;
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-right: 6px;
  }

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

  .c-header-accordion__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;
  }

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

  .c-header-accordion__content {
    overflow: hidden;
    height: 0;
    opacity: 0;
    will-change: height, opacity;
    transition:
      height 0.3s ease,
      opacity 0.3s ease;
  }

  /* 折りたたみ時 */
  .c-header-accordion__content[data-expanded="false"] {
    height: 0;
    opacity: 0;
  }

  /* 展開時 */
  .c-header-accordion__content[data-expanded="true"] {
    opacity: 1;
  }

  .c-header-accordion__children {
    display: flex;
    flex-direction: column;
    padding-bottom: 8px;
  }

  .c-header-accordion__child-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-decoration: none;
    padding: 6px 0;

    &:hover .c-header-accordion__child-icon {
      @media (min-width: 880px) {
        transform: translateX(4px);
      }
    }

    &:hover .c-header-accordion__child-text {
      color: var(--color-orange-primary);
    }
  }

  .c-header-accordion__child-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-black-primary);
    letter-spacing: 0.1em;
    line-height: 1.5;
  }

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

  /* ============================================================
   * SNS Section
   * ============================================================ */

  .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 Section
   * ============================================================ */

  .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);
    }
  }
}
