/* =========================================================
 * header.css（完成版・基準）
 * - 横スクロール防止
 * - グローバルナビ（2階層 / 3階層 / メガ）安定
 * - ヘッダー内リンクはすべて下線なし
 * - サブメニューありに ▼ 表示
 * - トップ / サブメニューでホバー背景を統一
 * ======================================================= */


/* =========================================================
 * 1) Header base
 * ======================================================= */
.site-header{
  border-bottom: 1px solid #e0e0e0;
  font-size: 14px;
  color: #333;
  background: #fff;
  max-width: 100%;
}

.site-header.fixed-top{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 2000;
}

body{
  padding-top: var(--site-header-offset, 0px);
}

.site-header *,
.site-header *::before,
.site-header *::after{
  box-sizing: border-box;
}


/* =========================================================
 * 2) Layout container
 * ======================================================= */
.header-inner{
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.header-menus{
  flex: 1 1 auto;
  min-width: 0;
}

.header-mobile-actions{
  display: none;
}


/* =========================================================
 * 3) Logo
 * ======================================================= */
.site-logo{
  display: block;
  width: 316.5px;
  max-width: min(316.5px, 100%);
  text-decoration: none;
  color: inherit;
}

.site-logo picture{
  display: block;
}

.site-logo-image{
  display: block;
  width: 100%;
  max-width: 316.5px;
  height: auto;
  aspect-ratio: 316.5 / 52.39;
  object-fit: contain;
}

.logo-text{
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  text-align: center;
}


/* =========================================================
 * 4) Top row（上段リンク / 検索）
 * ======================================================= */
.header-top{
  padding: 12px 0 8px;
  width: 100%;
}

.header-top-right{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  min-width: 0;
}

/* Search button */
.header-search-link{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 18px 2px 16px;
  border-radius: 999px;
  background: #000;
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  white-space: nowrap;
}

.header-search-link:hover{
  background: #555;
}

.header-search-icon{
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  position: relative;
}

.header-search-icon::after{
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  transform: rotate(45deg);
  right: -5px;
  bottom: -2px;
}

/* Top links（アクセス・医療関係の方など） */
.top-links ul{
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.top-links li{
  display: inline-flex;
  align-items: center;
}

.top-links li + li::before{
  content: "|";
  color: #535353;
  margin: 0 8px;
}

.top-links a{
  font-size: 15px;
  font-weight: 500;
  color: #535353;
  padding: 6px 8px;
  border-radius: 6px;
}

.top-links a:hover{
  color: #004b8d;
}


/* =========================================================
 * 5) Global nav base（メインナビ）
 * ======================================================= */
.header-main{
  width: 100%;
  border-top: none;
}

.header-main-inner{
  display: flex;
  width: 100%;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 18px;
}

.global-nav{
  flex: 1 auto;
  min-width: 0;
}

.global-nav > ul{
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  row-gap: 0px;
  column-gap: 18px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* メインリンク */
.global-nav > ul > li > a{
  display: inline-block;
  padding: 10px 8px;
  font-size: 18px;
  font-weight: 500;
  color: #2F2F2F;
  white-space: nowrap;
  border-radius: 6px;
}

.global-nav > ul > li > a:hover{
  color: #004b8d;
}


/* =========================================================
 * 6) Dropdown（2階層）
 * ======================================================= */
.global-nav > ul > li{
  position: relative;
}

/* パネル */
.global-nav .sub-menu{
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  min-width: 225px;
  max-width: calc(100vw - 32px);
  margin-top: 0;
  padding: 8px 0;
  list-style: none;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,.15);
  display: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: .22s ease;
}

.global-nav > ul > li:hover > .sub-menu,
.global-nav > ul > li:focus-within > .sub-menu{
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* サブメニュー項目 */
.global-nav .sub-menu a{
  display: block;
  padding: 6px 16px;
  font-size: 16px;
  color: #333;
}

.global-nav .sub-menu a:hover{
  background: #f0f5fb;
  color: #004b8d;
}


/* =========================================================
 * 診療科・部門（2番目メニュー）：サブメニュー幅を調整
 * ======================================================= */
.global-nav > ul > li:nth-child(2) > .sub-menu{
  min-width: 160px;
}


/* =========================================================
 * 7) 3階層（孫メニュー）
 * ======================================================= */

/* 矢印（▶） */
.global-nav .sub-menu > li.menu-item-has-children > a{
  position: relative;
  padding-right: 34px;
}

.global-nav .sub-menu > li.menu-item-has-children > a::after{
  content: "▶";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: .7;
}

/* 孫パネル */
.global-nav .sub-menu .sub-menu{
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: 6px;
  min-width: 240px;
  max-width: calc(100vw - 32px);
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(6px);
}

.global-nav .sub-menu > li:hover > .sub-menu,
.global-nav .sub-menu > li:focus-within > .sub-menu{
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Hover bridge（子→孫で消えない対策） */
.global-nav .sub-menu > li{
  position: relative;
}

.global-nav .sub-menu > li::after{
  content: "";
  position: absolute;
  top: 0;
  right: -10px;
  width: 12px;
  height: 100%;
  background: transparent;
}


/* =========================================================
 * 8) Mega menu
 * ======================================================= */
/* 支援部門（3列孫メニュー）を限界まで詰める */
.global-nav .is-mega-3col > .sub-menu{
  width: min(540px, 90vw);
  column-count: 3;
  column-width: 175px;
  column-gap: 1px;
}

.global-nav .is-mega-2col > .sub-menu{
  width: min(480px, 90vw);
  column-count: 2;
  column-gap: 12px;
  padding: 0px;
}

.global-nav .is-mega-3col > .sub-menu > li,
.global-nav .is-mega-2col > .sub-menu > li{
  break-inside: avoid;
}

.global-nav .is-mega-3col > .sub-menu a,
.global-nav .is-mega-2col > .sub-menu a{
  white-space: normal;
}


/* =========================================================
 * 9) Responsive / overflow
 * ======================================================= */
@media (max-width: 768px){
  .header-inner{
    padding: 0 var(--gutter);
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .global-nav > ul{
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .header-main-inner{
    flex-wrap: wrap;
    gap: 12px;
  }
}

@media (min-width: 769px){
  .header-inner{
    flex-wrap: nowrap;
  }

  .global-nav > ul{
    justify-content: flex-end;
    margin-left: 0px;
  }
}

/* 横スクロール防止 */
.header-main{
  overflow-x: clip;
}

@supports not (overflow-x: clip){
  .header-main{
    overflow-x: hidden;
  }
}


/* =========================================================
 * 10) Header 内リンク：下線を完全に無効化
 * - common.css の a:hover underline 対策
 * ======================================================= */
.site-header a,
.site-header a:hover,
.site-header a:focus,
.site-header a:active,
.site-header a:visited{
  text-decoration: none !important;
}


/* =========================================================
 * 11) SP menu（1024px以下）
 * ======================================================= */
.sp-menu-overlay[hidden]{
  display: none !important;
}

@media (max-width: 1024px){
  .site-header{
    min-height: 60px;
  }

  .site-header.fixed-top{
    z-index: 4000;
  }

  .header-inner{
    max-width: none;
    min-height: 60px;
    padding: 0 16px;
    gap: 12px;
    flex-wrap: nowrap;
    align-items: center;
  }

  .site-logo{
    width: 190px;
    max-width: calc(100% - 108px);
    flex: 0 1 auto;
  }

  .site-logo-image{
    max-width: none;
    aspect-ratio: auto;
  }

  .header-menus{
    display: none;
  }

  .header-mobile-actions{
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-left: auto;
    flex: 0 0 auto;
  }

  .header-search-link--mobile{
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    gap: 0;
    justify-content: center;
    border-radius: 50%;
    background: #2F2F2F;
  }

  .header-search-link--mobile:hover{
    background: #2F2F2F;
  }

  .header-search-link--mobile .header-search-text{
    display: none;
  }

  .header-search-link--mobile .header-search-icon{
    width: 14px;
    height: 14px;
  }

  .sp-menu-toggle{
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #1759A5;
    cursor: pointer;
    appearance: none;
  }

  .sp-menu-toggle__line{
    position: absolute;
    left: 10px;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
    transition: transform .2s ease, opacity .2s ease, top .2s ease;
  }

  .sp-menu-toggle__line:nth-child(1){
    top: 12px;
  }

  .sp-menu-toggle__line:nth-child(2){
    top: 19px;
  }

  .sp-menu-toggle__line:nth-child(3){
    top: 26px;
  }

  .sp-menu-toggle.is-open .sp-menu-toggle__line:nth-child(1){
    top: 19px;
    transform: rotate(45deg);
  }

  .sp-menu-toggle.is-open .sp-menu-toggle__line:nth-child(2){
    opacity: 0;
  }

  .sp-menu-toggle.is-open .sp-menu-toggle__line:nth-child(3){
    top: 19px;
    transform: rotate(-45deg);
  }

  .sp-menu-overlay{
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4100;
    background: #fff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sp-menu-panel{
    width: 100%;
    background: #fff;
  }

  .sp-menu-list{
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid #D8E0E3;
  }

  .sp-menu-item{
    margin: 0;
    padding: 0;
  }

  .sp-menu-link{
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    padding: 0 16px 0 24px;
    border-bottom: 1px solid #D8E0E3;
    background: #fff;
    color: #2F2F2F;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
  }

  .sp-menu-link__label{
    display: block;
    padding-right: 16px;
  }

  .sp-menu-link__arrow{
    position: relative;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1759A5;
  }

  .sp-menu-link__arrow::before{
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    border-top: 2px solid #fff;
    border-right: 2px solid #fff;
    transform: translate(-62%, -50%) rotate(45deg);
  }

  body.is-sp-menu-open{
    overflow: hidden;
  }
}

@media (min-width: 1025px){
  .sp-menu-overlay{
    display: none !important;
  }
}