/* ==========================================================================
   グローバルヘッダー（ワンソース化）
   - HTMLは1系統。PC(横並びメガメニュー) / SP(右ドロワー＋アコーディオン) は
     メディアクエリ(境界 1025px)のみで切り替える。
   - 既存の style.css / sp.css とクラス名が衝突しないよう .gh- 接頭辞で統一。
   ========================================================================== */

:root {
  --gh-accent: #011774;
  --gh-accent-sub: #3181b4;
  --gh-text: #000;
  --gh-line: #ccc;
  --gh-cta: #c2410c;       /* 白文字とのコントラスト比 4.5:1 以上(WCAG AA) */
  --gh-cta-hover: #9a3412;
  --gh-bar-h: 56px;
}

/* ---------- 共通 ---------- */
.gh {
  background-color: #fff;
  z-index: 9999;
  position: sticky;
  top: 0;
  width: 100%;
}
.gh#index { position: fixed; }

.gh ul,
.gh li { list-style: none; margin: 0; padding: 0; }
.gh a { text-decoration: none; }

.gh-logo { display: flex; align-items: center; }
.gh-logo a { display: block; width: 100%; }
.gh-logo img { display: block; width: 100%; height: auto; }

.gh-toggle { display: none; }
.gh-backdrop { display: none; }
.gh-acc { display: none; }

.gh-lock { overflow: hidden; }

/* キーボード操作時のフォーカス表示 */
.gh a:focus-visible,
.gh button:focus-visible {
  outline: 3px solid var(--gh-accent-sub);
  outline-offset: 2px;
}
.gh-panel a:focus-visible,
.gh-panel button:focus-visible { outline-color: #fff; }

/* Esc で閉じたメガメニュー/ドロップダウン(PC) */
@media screen and (min-width: 1025px) {
  .gh.is-esc .gh-menu > .gh-item > .gh-sub { display: none !important; }
}

/* 動きを減らす設定のユーザー向け */
@media (prefers-reduced-motion: reduce) {
  .gh *,
  .gh *::before,
  .gh *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ボタン化した親項目(リンク先なし) */
.gh-link--btn {
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ==========================================================================
   PC (>= 1025px) : 横並びメガメニュー
   ========================================================================== */
@media screen and (min-width: 1025px) {
  .gh-inner {
    display: grid;
    grid-template-columns: minmax(240px, 400px) 1fr;
    grid-template-areas: "logo util" "menu menu";
    column-gap: 30px;
    align-items: center;
  }
  .gh-logo { grid-area: logo; }
  .gh-panel { display: contents; }

  .gh-utility {
    grid-area: util;
    justify-self: end;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    padding: 1em 1em 1em 0;
    white-space: nowrap;
  }
  .gh-group-link { color: var(--gh-text); }
  /* ラッパーを無効化し、検索フォームを旧 .top-group-info-wrap の直接の子と同じ扱いにする(高さを旧と一致させる) */
  .gh-search { display: contents; }

  .gh-nav { grid-area: menu; margin-top: 10px; } /* 旧 .mt_10 相当 */
  .gh-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0 40px;
    padding-right: calc(20px + 1em) !important;
  }
  .gh-menu > .gh-item { position: relative; }
  .gh-menu > .gh-item--mega { position: static; } /* パネル基準をヘッダーにする */

  /* 高さは旧ヘッダー(.gr-nav > li > a)と同一: height 3em / padding-bottom 1em */
  .gh-menu > .gh-item > .gh-link {
    position: relative;
    display: block;
    width: 100%;
    height: 3em;
    padding-bottom: 1em;
    text-align: center;
    color: var(--gh-text);
  }
  .gh-menu > .gh-item > .gh-link > span { position: relative; display: inline-block; }
  .gh-menu > .gh-item > .gh-link > span::before,
  .gh-menu > .gh-item > .gh-link > span::after {
    content: "";
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--gh-line);
  }
  .gh-menu > .gh-item > .gh-link > span::before { left: -20px; }
  .gh-menu > .gh-item > .gh-link > span::after { right: -21px; }
  .gh-menu > .gh-item--parent > .gh-link > span::after { display: none; }

  .gh-menu > .gh-item > .gh-link::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: .5em;
    width: 100%;
    height: 2px;
    border-radius: 10px;
    background-color: #fff;
    transition: .4s;
  }
  .gh-menu > .gh-item:hover > .gh-link::before,
  .gh-menu > .gh-item:focus-within > .gh-link::before,
  .gh-menu > .gh-item.is-tap-open > .gh-link::before { background-color: var(--gh-accent); }

  .gh-menu > .gh-item--parent > .gh-link { padding-right: 1em; }
  .gh-menu > .gh-item--parent > .gh-link::after {
    content: "";
    position: absolute;
    top: 1em;
    right: -.4em;
    width: 12px;
    aspect-ratio: 1 / 1;
    background: url(../images/nav-arrow-1.png) center / contain no-repeat;
    transform: translateY(-50%);
  }

  /* --- ドロップダウン / メガメニュー共通 --- */
  .gh-sub { display: none; }
  .gh-menu > .gh-item:hover > .gh-sub,
  .gh-menu > .gh-item:focus-within > .gh-sub,
  .gh-menu > .gh-item.is-tap-open > .gh-sub { /* is-tap-open: タッチ端末(タブレット横向き等)で1回目のタップで開いた状態 */
    display: block;
    animation: ghSubIn .2s forwards;
  }
  @keyframes ghSubIn { from { opacity: 0; } to { opacity: 1; } }

  .gh-sub--l1 {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 40px);
    padding: 1em !important;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  }
  /* 通常のドロップダウン(導入・保守 / ダウンロード等)は旧 .sub-menu と同じ見た目 */
  .gh-sub--l1 > .gh-item { margin-block: 1em; }
  .gh-sub--l1 > .gh-item:first-of-type { margin-top: 0; }
  .gh-sub--l1 > .gh-item:last-of-type { margin-bottom: 0; }
  .gh-sub a { display: flex; flex-direction: column; width: 100%; color: #000; font-size: .9em; text-align: left; }
  .gh-sub a:hover { color: var(--gh-accent); }
  /* 第2階層以降はつねに表示(第1階層のパネルと一緒に開閉される) */
  .gh-sub .gh-sub { display: block; }
  /* --- メガメニュー(ハードウェア / 取扱ソフトウェア 共通デザイン) --- */
  .gh-sub--mega {
    width: min(1120px, calc(100vw - 40px));
    padding: 1.6em 2em 1.8em !important; /* .gh-sub--l1 の !important より後に書いて上書き */
  }
  .gh-menu > .gh-item--mega:hover > .gh-sub--mega,
  .gh-menu > .gh-item--mega:focus-within > .gh-sub--mega,
  .gh-menu > .gh-item--mega.is-tap-open > .gh-sub--mega {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.2em 2.4em;
    align-items: start;
  }
  .gh-sub--mega > .gh-item { margin: 0 !important; }

  /* リンク: どちらのメニューも同じ見た目(先頭に「-」、ホバーで薄い背景) */
  .gh-sub--mega a,
  .gh-sub--mega .gh-link {
    position: relative;
    display: block;
    width: 100%;
    text-align: left;
    padding: .4em .5em .4em 1.4em;
    font-size: .9em;
    line-height: 1.5;
    border-radius: 3px;
  }
  .gh-sub--mega a::before { content: "-"; position: absolute; left: .5em; }
  .gh-sub--mega a:hover { background: #f3f6fb; }

  /* 見出し(子を持つ項目): 紺色の太字 + 下線 */
  .gh-sub--mega > .gh-item--parent > .gh-link {
    margin-bottom: .4em;
    padding: 0 0 .5em;
    border-bottom: 2px solid var(--gh-accent);
    border-radius: 0;
    font-size: .95em;
    font-weight: 700;
    color: var(--gh-accent);
  }
  .gh-sub--mega > .gh-item--parent > .gh-link::before { content: none; }
  .gh-sub--mega > .gh-item--parent > .gh-link--btn { cursor: default; }
  .gh-sub--mega > .gh-item--parent > a.gh-link:hover { background: none; }

  /* 項目数の多いグループは 2 列に分けて表示 */
  .gh-sub--mega .gh-item--wide { grid-column: span 3; }
  .gh-sub--mega .gh-sub--cols { column-count: 2; column-gap: 2.4em; }
  .gh-sub--mega .gh-sub--cols > .gh-item { break-inside: avoid; }

  /* 見出しを持たない一覧型(取扱ソフトウェア): 最長の文字数に合わせて幅・列幅を詰める */
  .gh-sub--mega.gh-sub--flat { width: max-content; max-width: calc(100vw - 40px); }
  .gh-sub--flat a,
  .gh-sub--flat .gh-link { white-space: nowrap; }
  .gh-menu > .gh-item--mega:hover > .gh-sub--mega.gh-sub--flat,
  .gh-menu > .gh-item--mega:focus-within > .gh-sub--mega.gh-sub--flat,
  .gh-menu > .gh-item--mega.is-tap-open > .gh-sub--mega.gh-sub--flat {
    grid-template-columns: repeat(3, auto);
    justify-content: start;
    gap: .2em 1.6em;
  }

  .gh-cta-bar { display: none; }
  .gh-panel .sp-nav-contactbox { display: none; } /* SPドロワー専用(電話/フォーム画像) */
}

@media screen and (min-width: 1200px) {
  .gh-menu > .gh-item--mega:hover > .gh-sub--mega,
  .gh-menu > .gh-item--mega:focus-within > .gh-sub--mega,
  .gh-menu > .gh-item--mega.is-tap-open > .gh-sub--mega {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .gh-menu > .gh-item--mega:hover > .gh-sub--mega.gh-sub--flat,
  .gh-menu > .gh-item--mega:focus-within > .gh-sub--mega.gh-sub--flat,
  .gh-menu > .gh-item--mega.is-tap-open > .gh-sub--mega.gh-sub--flat {
    grid-template-columns: repeat(4, auto);
  }
}

/* ==========================================================================
   SP / タブレット (<= 1024px) : 右ドロワー + アコーディオン + 下部固定CTA
   ========================================================================== */
@media screen and (max-width: 1024px) {
  .gh-inner { display: flex; justify-content: space-between; align-items: center; }
  .gh-logo { max-width: 245px; }

  .gh-toggle {
    display: block;
    position: relative;
    z-index: 5;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 100vh;
    background: #fff;
    cursor: pointer;
    transition: .5s;
  }
  .gh-toggle span {
    position: absolute;
    left: 50%;
    width: 25px;
    height: 2px;
    background: #000;
    transform: translate(-50%, -50%);
    transition: .5s;
  }
  .gh-toggle span:nth-child(1) { top: 25px; }
  .gh-toggle span:nth-child(2) { top: 35px; }
  .gh-toggle[aria-expanded="true"] span { background: var(--gh-accent); }
  .gh-toggle[aria-expanded="true"] span:nth-child(1) { top: 30px; transform: translate(-50%, -50%) rotate(45deg); }
  .gh-toggle[aria-expanded="true"] span:nth-child(2) { top: 30px; transform: translate(-50%, -50%) rotate(-45deg); }

  /* 旧SPナビ(nav.nav)と同じ見た目: 背景オーバーレイなし */
  .gh-backdrop { display: none; }

  .gh-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 3;
    display: block;
    width: 100%;
    max-width: 670px;
    height: 100dvh;
    overflow-y: auto;
    padding: 6rem 2rem 0 2rem;
    background: var(--gh-accent);
    font-size: 1rem;
    color: #fff;
    font-weight: 700;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .5s cubic-bezier(.17, .46, 0, .99), visibility 0s .5s;
  }
  .gh.is-open .gh-panel { transform: none; visibility: visible; transition-delay: 0s; }

  .gh-utility { display: contents; }
  /* 旧SPドロワーには無かった要素(グループ企業情報・ヘッダーのお問い合わせボタン)はSPでは非表示 */
  .gh-utility .gh-group-link,
  .gh-utility .top-group-contact { display: none !important; }

  /* 旧SPと同じく、ドロワーを開いてもヘッダー(ロゴ+閉じるボタンの白帯)は最前面に残す */
  .gh::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    background: #fff;
  }
  .gh-logo { position: relative; z-index: 5; }

  /* 旧 nav.nav 配下のスタイルをそのまま再現(アコーディオンなし・サブメニューは常時展開) */
  /* アコーディオン: 子メニューを持つ項目は最初は折りたたみ、右端の矢印(または見出しタップ)で開閉 */
  .gh-panel ul li.gh-item--parent { position: relative; }
  .gh-panel ul li.gh-item--parent > .gh-sub { display: none; }
  .gh-panel ul li.gh-item--parent.is-open > .gh-sub { display: block; }

  /* 矢印アイコン: 白い円形 + メニュー背景色(#011774)の矢印。右端をすべて揃え、縦位置は各行の1行目の文字の中央 */
  .gh-acc,
  .gh-panel ul li .gh-link--btn::after {
    --gh-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%23011774' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff var(--gh-chev) center / 24px 24px no-repeat;
    transition: transform .3s;
  }
  .gh-acc {
    display: block;
    position: absolute;
    top: calc(.8em - 12px); /* 親リンクの文字(行の高さ 1.6em)の中央 */
    right: 0;
    padding: 0;
    border: 0;
    font-size: inherit;
    cursor: pointer;
  }
  .gh-acc::before { content: ""; position: absolute; inset: -10px; } /* タップ領域を拡大 */
  .gh-panel ul li .gh-sub > li > .gh-acc { top: calc(.64em - 12px); } /* 下位階層のリンクは文字が .8em のため */
  .gh-panel ul li .gh-link--btn::after {
    content: "";
    position: absolute;
    top: calc(.8em - 12px); /* ボタン自身の文字の中央 */
    right: 0;
  }
  .gh-panel ul li.is-open > .gh-acc,
  .gh-panel ul li.is-open > .gh-link--btn::after { transform: rotate(180deg); }
  .gh-panel ul li.gh-item--parent > a.gh-link,
  .gh-panel ul li.gh-item--parent > .gh-link--btn { padding-right: 40px; }

  .gh-panel ul li {
    font-size: 1.4em;
    margin-bottom: 0.5em;
  }
  .gh-panel ul li a,
  .gh-panel ul li .gh-link--btn {
    position: relative;
    display: block;
    width: 100%;
    padding: 0 0 0.5em;
    color: #fff;
    text-align: left;
    text-decoration: none;
    transition: 0s;
  }
  .gh-panel ul li a:hover { opacity: 0.9; }
  .gh-panel ul li .gh-sub {
    display: block;
    font-size: 0.6em;
    font-weight: normal;
    margin: 0.5em 0 1.5em 2em;
  }
  .gh-panel ul li .gh-sub li a,
  .gh-panel ul li .gh-sub li .gh-link--btn { position: relative; font-size: 0.8em; font-weight: inherit; }
  .gh-panel ul li .gh-sub li a:before,
  .gh-panel ul li .gh-sub li .gh-link--btn:before {
    content: "";
    position: absolute;
    top: 50%;
    left: -1.5em;
    width: 1em;
    height: 1px;
    background-color: #fff;
    transform: translateY(-0.25em);
  }

  /* 下部固定の「お問い合わせ・資料請求」バー */
  .gh-cta-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    display: flex;
    height: calc(var(--gh-bar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .2);
  }
  .gh-cta-bar a {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .95rem;
    color: #fff;
  }
  .gh-cta-tel { background: var(--gh-accent); }
  .gh-cta-form { flex: 1.4 1 0 !important; background: var(--gh-cta); }

  /* 固定バーがコピーライト行を隠さないよう、フッター最下部(黒帯)にバーの高さ分の余白を足す。
     body への padding はインラインの body{padding:0} に上書きされるため使わない */
  .ft #copy { padding-bottom: calc(8px + var(--gh-bar-h) + env(safe-area-inset-bottom, 0px)); }

  /* メニュー内の検索窓の文字サイズは標準(16px)に */
  .gh-panel .sp-nav-searchbox .search-form input { font-size: 16px; }
}
