/* 2027共通ヘッダー。本文・追従ボタンとは独立して管理する。 */
.c-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1100;
  color: var(--header-text);
  background: var(--color-white);
  font-size: 14px;
  line-height: 1.6;
  isolation: isolate;

  @media screen and (min-width: 1251px) {
    inset: 20px auto 20px 0;
    width: var(--header-sidebar-width);
    border-radius: 0 10px 10px 0;
    box-shadow: 1px 1px 7px rgb(0 0 0 / 25%);
  }
}

.c-header [hidden] {
  display: none !important;
}

.c-header.is-menu-open {
  height: 100dvh;
}

/* SPメニューの開閉。旧ヘッダーと同じく左からスライドさせる。閉じる時はheader.jsがis-menu-closingを付け、終了後に非表示にする */
@keyframes c-header-nav-in {
  from {
    transform: translateX(-110%);
  }
}

@keyframes c-header-nav-out {
  to {
    transform: translateX(-110%);
  }
}

@media screen and (max-width: 1250px) {
  /* スライド中に後ろが白く残らないよう、背景はバーとパネル側に持たせる */
  .c-header {
    background: transparent;
  }

  .c-header__nav {
    min-height: calc(100dvh - var(--header-mobile-height));
    background: var(--color-white);
  }

  .c-header.is-menu-open .c-header__nav {
    animation: c-header-nav-in .8s cubic-bezier(0.215, 0.61, 0.355, 1);
  }

  .c-header.is-menu-closing .c-header__nav {
    animation: c-header-nav-out .4s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
  }
}

.c-header a,
.c-header button {
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s ease, color .18s ease, opacity .18s ease;
}

.c-header :is(a, button):focus-visible {
  outline: 2px solid var(--header-blue);
  outline-offset: -3px;
}

.c-header__scroll {
  max-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;

  @media screen and (min-width: 1251px) {
    max-height: calc(100dvh - 40px);
    border-radius: inherit;
  }
}

.c-header__bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-mobile-height);
  box-shadow: inset 0 -1px var(--header-border);
  background: var(--color-white);

  @media screen and (min-width: 1251px) {
    position: static;
    justify-content: center;
    min-height: 132px;
    box-shadow: none;
    padding: 40px 10px 28px;
  }
}

.c-header__logo {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  min-width: 0;

  @media screen and (min-width: 1251px) {
    padding: 0;
  }
}

.c-header__logo img {
  display: block;
  width: 206px;
  max-width: 100%;
  height: 40px;
  object-fit: contain;

  @media screen and (min-width: 1251px) {
    height: 44px;
  }
}

.c-header__toggle {
  flex: 0 0 var(--header-mobile-height);
  width: var(--header-mobile-height);
  height: var(--header-mobile-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  padding: 0;
  background: var(--header-accent);
  color: var(--color-white);
  cursor: pointer;

  @media screen and (min-width: 1251px) {
    display: none;
  }
}

.c-header__toggle-icon {
  position: relative;
  width: 18px;
  height: 12px;
  margin-block-start: 4px;
  border-block: 1.5px solid currentColor;

  &::before {
    content: '';
    position: absolute;
    inset: 50% 0 auto;
    border-top: 1.5px solid currentColor;
    transform: translateY(-50%);
  }
}

.c-header__toggle-label {
  font-family: var(--font-family-line-seed);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
}

.c-header__languages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 17px 10px;
  margin: 0;
  list-style: none;

  a {
    display: block;
    width: 76px;
    padding: 3px 0;
    border: 1px solid var(--header-border);
    border-radius: 4px;
    color: #555;
    background: var(--color-white);
    font: 700 12px/1.5 var(--font-family-base);
    text-align: center;
  }

  a[aria-current], a:hover {
    border-color: var(--header-blue);
    color: var(--header-blue);
  }

  @media screen and (min-width: 1251px) {
    padding: 8px 10px 20px;
    a {
      width: 82px;
    }
  }
}

.c-header__menu,
.c-header__submenu {
  margin: 0;
  padding: 0;
  list-style: none;
}

.c-header__item {
  border-top: 1px solid var(--header-border);

  &:last-child {
    border-bottom: 1px solid var(--header-border);
  }

  @media screen and (min-width: 1251px) {
    border-color: var(--color-white);
    &:last-child {
      border-color: var(--color-white);
    }
  }
}

.c-header__link {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 11px 12px;
  margin: 0;
  border: 0;
  background: var(--header-menu-bg);
  color: var(--header-text);
  font: inherit;
  font-size: 12px;
  line-height: 1.65;
  text-align: left;
  text-decoration: none;
  cursor: pointer;

  &:hover,
  &:focus-visible {
    background: var(--header-menu-hover);
  }

  @media screen and (min-width: 1251px) {
    min-height: 45px;
    padding: 11px 10px;
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    gap: 8px;
  }
}

.c-header__item.is-open > .c-header__link {
  @media screen and (min-width: 1251px) {
    background: var(--header-menu-hover);
  }
}

.c-header__icon {
  display: block;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: var(--header-accent);
}

.c-header__arrow,
.c-header__indicator {
  display: block;
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--header-accent);
  color: var(--color-white);
  flex: 0 0 16px;
}

.c-header__arrow::before {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  top: 50%;
  left: 5px;
  transform: translateY(-50%) rotate(45deg);
}

.c-header__indicator {
  &::before, &::after {
    content: '';
    position: absolute;
    inset: 7px 4px auto;
    border-top: 1.5px solid currentColor;
  }
  &::after {
    transform: rotate(90deg);
  }

  @media screen and (min-width: 1251px) {
    &::before {
      width: 5px;
      height: 5px;
      inset: 50% auto auto 5px;
      border-top: 1.5px solid currentColor;
      border-right: 1.5px solid currentColor;
      transform: translateY(-50%) rotate(45deg);
    }
    &::after {
      display: none;
    }
  }
}

.c-header__link[aria-expanded="true"] .c-header__indicator::after {
  display: none;
}

.c-header__submenu {
  background: var(--header-menu-hover);
  color: var(--header-text);

  a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 36px;
    padding: 9px 12px 9px 37px;
    border-bottom: 1px solid var(--color-white);
    color: inherit;
    font-size: 12px;
    line-height: 1.6;
    text-decoration: none;
  }
  li:last-child a {
    border-bottom: 0;
  }
  a:hover, a:focus-visible {
    background: rgb(0 0 0 / 8%);
  }

  @media screen and (min-width: 1251px) {
    /* Fixed position escapes the sidebar's scroll area. JS aligns it with its trigger. */
    position: fixed;
    z-index: 1;
    width: 240px;
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    border-radius: 0 3px 3px 0;
    background: var(--header-submenu-bg);
    color: var(--color-white);

    a {
      padding: 11px 12px;
      border-color: #777;
    }
    .c-header__arrow {
      background: var(--color-white);
      color: var(--header-submenu-bg);
    }
  }
}

.c-header__extras {
  display: grid;
  gap: 10px;
  padding-block: 20px;
  padding-inline: 15px;

  @media screen and (min-width: 1251px) {
    padding-inline: 20px;
  }
}

.c-header__banners {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;

  a {
    display: block;
    overflow: hidden;
    background: var(--color-white);
  }
  img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 217 / 100;
    object-fit: contain;
  }
  a:hover {
    opacity: .7;
  }

  @media screen and (min-width: 1251px) {
    grid-template-columns: 1fr;
  }
}

.c-header__action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 8px;
  border: 1px solid var(--header-accent);
  border-radius: 4px;
  color: var(--header-accent);
  background: var(--color-white);
  font-size: 13px;
  line-height: 1.5;
  text-decoration: none;

  &:hover {
    background: var(--header-menu-hover);
  }
  .c-header__icon {
    color: currentColor;
  }
}

.c-header__action--contact {
  color: var(--color-white);
  background: var(--header-accent);

  &:hover {
    background: var(--header-accent-hover);
    border-color: var(--header-accent-hover);
  }
}

body.header-menu-open {
  position: fixed;
  top: var(--header-scroll-offset, 0px);
  left: 0;
  right: 0;
  overflow: hidden;
}

/* Only offset pages with this header; preserve the existing desktop content gutter. */
body:has(.c-header) #main {
  @media screen and (max-width: 1250px) {
    padding-top: var(--header-mobile-height);
  }
}

body:has(.c-header) #idx_mainvisual .mainvisual_bg {
  @media screen and (max-width: 1250px) {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .c-header a, .c-header button {
    transition: none;
  }
  .c-header .c-header__nav {
    animation: none !important;
  }
}
