/* ========================================
   ABC Dental 共通ヘッダー CSS
   ----------------------------------------
   additional.css L21-27 の #masthead { position: fixed }
   および L357-378 / L438-464 / L466-475 の
   ヘッダー関連スタイルが自前ヘッダーにもそのまま当たる前提。

   Phase A Phase 2.5b (2026/04/19): ロゴ二重表示の抑止。
   header.html では PC ロゴ（a.custom-logo-link）とモバイルロゴ
   （a.custom-mobile-logo-link）を同じ .site-logo-img 内に並べて出力している。
   Astra のブレークポイント 922px に合わせて、
   - 922px 以上 → PC ロゴのみ表示、モバイルロゴ非表示
   - 921.98px 以下 → モバイルロゴのみ表示、PC ロゴ非表示
   の切替を CSS のみで行う。
   ======================================== */

@media (min-width: 922px) {
    #masthead .custom-mobile-logo-link {
        display: none;
    }
}

@media (max-width: 921.98px) {
    #masthead .site-logo-img .custom-logo-link {
        display: none;
    }
    #masthead .site-logo-img .custom-mobile-logo-link {
        display: inline-block;
    }
}


/* ================================================================
   Phase A Phase 2.5c (2026/04/19): ロゴサイズ制限

   Astra は本来 .ast-header-break-point body クラス配下で
   .custom-mobile-logo-link img { max-width:150px } を適用していたが、
   初期ロード時 (ast-desktop 付与状態) ではこのルールが効かないため、
   元画像サイズ 800px のまま表示される症状がある (JS で body class が
   切り替わるまでの間)。

   body クラスに依存せず @media クエリだけで判定する自前ルールを追加し、
   初期ロード時点から正しいサイズになるようにする。
   ================================================================ */

/* 全画面幅共通: ロゴ画像は常に max-width:150px */
#masthead .site-logo-img img {
    max-width: 150px;
    width: auto;
    height: auto;
}

/* デスクトップ: PC ロゴに明示サイズ指定 */
@media (min-width: 922px) {
    #masthead .site-logo-img .custom-logo-link img {
        max-width: 150px;
        width: 150px;
    }
}

/* モバイル/タブレット: モバイルロゴに明示サイズ指定 */
@media (max-width: 921.98px) {
    #masthead .site-logo-img .custom-mobile-logo-link img {
        max-width: 150px;
        width: 150px;
    }
}


/* ================================================================
   Phase A Phase 2.5c (2026/04/19): Above Header 3カラムレイアウト補完

   Astra Header Builder が出力していた grid-template-columns 相当の
   レイアウト指定が自前ヘッダーに適用されないため、
   ハンバーガー・ロゴ・CTA が中央寄りになる症状を解消する。

   デスクトップでは左/中央/右を 1fr / auto / 1fr で等間隔分配、
   モバイル/タブレットでは Astra デフォルトと同じ grid レイアウトに
   切り替える。
   ================================================================ */

/* デスクトップ: 3 カラム等間隔分配 */
@media (min-width: 922px) {
    #masthead .ast-builder-grid-row.ast-grid-center-col-layout {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 20px;
        width: 100%;
    }
    #masthead .site-header-above-section-left {
        justify-self: start;
        align-items: center;
    }
    #masthead .site-header-above-section-center {
        justify-self: center;
        align-items: center;
    }
    #masthead .site-header-above-section-right {
        justify-self: end;
        align-items: center;
    }
}

/* モバイル/タブレット: 3 カラム grid (中央配置) */
@media (max-width: 921.98px) {
    #masthead .ast-builder-grid-row.ast-grid-center-col-layout {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 12px;
        width: 100%;
    }
    #masthead .site-header-above-section-left {
        justify-self: start;
        align-items: center;
    }
    #masthead .site-header-above-section-center {
        justify-self: center;
        align-items: center;
    }
    #masthead .site-header-above-section-right {
        justify-self: end;
        align-items: center;
    }
}

/* Above Header Bar の垂直パディング
   (Astra デフォルト相当の余白を確保) */
#masthead .ast-above-header-bar {
    padding-top: 10px;
    padding-bottom: 10px;
}


/* ================================================================
   Phase A Phase 2.5c-fix (2026/04/19): body クラス切替副作用の抑止

   Astra のインライン CSS には以下のルールが存在する:
     @media (max-width:921px){
         .ast-header-break-point .ast-above-header-bar { display: grid; }
     }
   body クラスが JS で ast-desktop → ast-header-break-point に切り替わった
   瞬間、.ast-above-header-bar が display:grid に変わり、内部の
   .site-above-header-wrap が grid の子要素として内容幅に縮む結果、
   自前の 3カラム grid (.ast-builder-grid-row レベル) の 1fr 空き領域が
   消失し、ハンバーガー・ロゴ・CTA が中央に寄って見える。

   .ast-above-header-bar を display:block に固定して副作用を抑止する。
   内部 3要素の grid レイアウトは .ast-builder-grid-row レベルで
   制御されるので影響を受けない。

   !important は Astra インライン CSS のセレクタ特異性
   (.ast-header-break-point ...) を上書きするため必要。
   ================================================================ */

@media (max-width: 921.98px) {
    #masthead .ast-above-header-bar {
        /* !important: Astra の .ast-header-break-point 由来のインライン CSS を上書き */
        display: block !important;
    }
}


/* ================================================================
   Phase B-a (2026/04/19): 右上CTA（初めての方）スタイル移管

   _additional-css/additional.css から MMM 非依存の CTA 関連ルールを
   ヘッダー自前化に合わせて本ファイルへ移管。
   元位置:
     - 基本スタイル: additional.css L358-L379
     - 544px 以下:   additional.css L441-L450（統合メディアクエリ内）
     - 374px 以下:   additional.css L467-L476（統合メディアクエリ内）
   H1 / medical-post-meta は MMM 非依存ではあるが CTA とは独立領域のため、
   additional.css 側に残置する。
   ================================================================ */

/* 右上CTA（初めての方）- C. グラデーション下線スタイル */
/* デスクトップ・タブレット共通 */
#masthead .ast-header-button-1 .ast-custom-button {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1em;
    line-height: 1;
    color: #2a2a2a;
    background: transparent;
    border: none;
    border-bottom: 2px solid;
    border-image: linear-gradient(90deg, #c5a059, #d4b36a, #c5a059) 1;
    border-radius: 0;
    padding: 10px 10px 7px;
    transition: all 0.3s ease;
}

#masthead .ast-header-button-1 .ast-custom-button:hover,
#masthead .ast-header-button-1 .ast-custom-button:focus-visible {
    color: #1a1a1a;
    background: rgba(197, 160, 89, 0.08);
}

/* スマホ（544px以下）: CTA 縮小 */
@media (max-width: 544px) {
    #masthead .ast-header-button-1 .ast-custom-button {
        font-size: 12px !important;
        font-weight: 600;
        padding: 8px 8px 5px !important;
        letter-spacing: 0.06em;
        white-space: nowrap;
        line-height: 1.2;
        min-width: auto !important;
    }
}

/* 極小画面（374px以下）: CTA さらに縮小 */
@media (max-width: 374px) {
    #masthead .ast-header-button-1 .ast-custom-button {
        font-size: 11px !important;
        font-weight: 600;
        padding: 6px 6px 4px !important;
        letter-spacing: 0.04em;
    }
}


/* ================================================================
   Phase B-b2 (2026/04/20): 自前ハンバーガーメニュー（INDEX パネル化）
   nav を #masthead 右上に絶対配置、スクロール連動でネイビー→白にフェード。
   ================================================================ */

/* nav は通常フローに戻す（トグルのみ絶対配置で右上に固定） */
#masthead .abc-header__nav {
    display: block;
    margin: 0;
    padding: 0;
}

/* トグルボタン: 70×70 正方形、#masthead 右上に絶対配置
   背景色は層 5（スクロール連動）で制御 */
.abc-header__toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-sizing: border-box;
    z-index: 10060;
    transition: background 0.35s ease;
}

/* 3 本線: 22×2px、ネイビー、線間は flex gap: 6px で統一 */
.abc-header__toggle-line {
    display: block;
    width: 22px;
    height: 2px;
    background: #1A2A4A;
    margin: 0;
    padding: 0;
    transition: background 0.35s ease, transform 0.25s ease, opacity 0.25s ease;
}

/* INDEX ラベル: セリフ体、11px、letter-spacing 2px、ネイビー */
.abc-header__toggle-label {
    display: block;
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif;
    font-size: 11px;
    letter-spacing: 2px;
    color: #1A2A4A;
    line-height: 1;
    transition: color 0.35s ease, opacity 0.2s ease;
}

/* メニュー開放時: INDEX ラベル非表示、3 本線が X に変形 */
body.abc-nav-open .abc-header__toggle-label {
    opacity: 0;
}
body.abc-nav-open .abc-header__toggle-line--1 {
    transform: translateY(8px) rotate(45deg);
}
body.abc-nav-open .abc-header__toggle-line--2 {
    opacity: 0;
}
body.abc-nav-open .abc-header__toggle-line--3 {
    transform: translateY(-8px) rotate(-45deg);
}

/* Astra ヘッダー既存 CTA ボタンを非表示（下部固定 CTA バーへ機能移設） */
#masthead .ast-header-button-1,
#masthead .ast-custom-button,
#masthead .ast-header-button-1 .ast-custom-button {
    display: none !important;
}

/* =========================================
   メニューパネル（全画面オーバーレイ）
   ========================================= */

.abc-header__panel {
    /* !important: 旧 B-b1 実装の position: absolute を確実に上書き */
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #F5F0E8;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0s 0.35s;
    z-index: 10045;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    writing-mode: horizontal-tb;
}

.abc-header__panel[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.35s ease;
}

/* 全子孫要素に横書きを強制（縦書き化バグの保険） */
.abc-header__panel,
.abc-header__panel * {
    writing-mode: horizontal-tb;
}

/* パネル内コンテンツコンテナ: 上寄せ、CTA バーと干渉しない下余白 */
.abc-header__panel-inner {
    width: 100%;
    min-height: 100%;
    padding: 100px 30px 80px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 0;
}

/* ヘッダーブロック（ロゴ + タグライン）: メニューとの間に余白 */
.abc-header__panel-header {
    text-align: center;
    margin-bottom: 48px;
}
.abc-header__panel-brand {
    display: block;
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif;
    font-size: 22px;
    color: #1A2A4A;
    letter-spacing: 1px;
    font-weight: 500;
    line-height: 1.2;
}
.abc-header__panel-tagline {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif;
    font-size: 11px;
    color: #1A2A4A;
    letter-spacing: 3px;
    margin-top: 10px;
    line-height: 1;
}
.abc-header__panel-tagline::before,
.abc-header__panel-tagline::after {
    content: '';
    flex: 0 0 40px;
    height: 0;
    border-top: 1px solid #1A2A4A;
    margin: 0 12px;
}

/* メニュー本体 */
.abc-header__menu {
    width: 100%;
}
.abc-header__menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}
.abc-header__menu li {
    margin: 0;
    padding: 0;
}
/* Item 4 (Phase B 2026/04/20): 現在閲覧中のページを subtle gold 表示（JS が動的にクラス付与） */
.abc-header__menu-item--current .abc-header__menu-link {
    color: #C9A96E;
    pointer-events: none;
    position: relative;
}
.abc-header__menu-item--current .abc-header__menu-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 1px;
    background: #C9A96E;
}
.abc-header__menu-link {
    display: inline-block;
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif;
    font-size: 20px;
    color: #1A2A4A;
    letter-spacing: 2px;
    /* !important: Astra テーマの a { text-decoration: underline } を上書きするため必要 */
    text-decoration: none !important;
    line-height: 1;
    padding: 4px 8px;
    transition: color 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}
.abc-header__menu-link:hover,
.abc-header__menu-link:focus-visible {
    color: #C9A96E;
    text-decoration: none !important;
    box-shadow: 0 1px 0 #C9A96E;
}

/* ================================================================
   Phase B (2026/04/20): Item 5 (fade-in) + Item 6 (/flow/ 強調)
   Item 2 は footer-cta-bar.css、Item 3/4 は上の hover / current ブロックで対応済
   ================================================================ */

/* Item 6: 初診の流れ（/flow/）を中推奨 CTA として強調（navy 1px 枠 + hover 反転） */
.abc-header__menu-link[href="/flow/"] {
    border: 1px solid #1A2A4A;
    padding: 11px 28px;
}
.abc-header__menu-link[href="/flow/"]:hover,
.abc-header__menu-link[href="/flow/"]:focus-visible {
    background: #1A2A4A;
    color: #F5F0E8;
    /* Item 3a の gold 下線を打ち消し（反転表示中は下線不要） */
    box-shadow: none;
}

/* Item 5: メニュー項目のカスケード fade-in（各 li の style="--i:N" を遅延係数として使用） */
@keyframes abc-menu-item-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
body.abc-nav-open .abc-header__menu li {
    animation: abc-menu-item-in 0.35s ease both;
    animation-delay: calc(var(--i, 0) * 60ms + 200ms);
}

/* ==============================
   INDEX トグル色バグ対策（5 層）v2 ベージュ統一版
   Safari タップハイライト / focus 残留 / user-select ハイライト を完全排除
   ============================== */

/* 層 1: Safari タップハイライト透明化 */
.abc-header__toggle {
    -webkit-tap-highlight-color: transparent;
}

/* 層 2: ブラウザデフォルト外観を無効化（iOS/Safari の青系グラデ等を排除） */
.abc-header__toggle {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-clip: padding-box;
}

/* 層 3: ユーザー選択によるハイライト排除 */
.abc-header__toggle,
.abc-header__toggle * {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* 層 4: :focus の outline を排除し、:focus-visible のみキーボード用 outline を出す */
.abc-header__toggle:focus {
    outline: none;
}
.abc-header__toggle:focus-visible {
    outline: 2px solid #1A2A4A;
    outline-offset: 2px;
}

/* 層 5: 状態別背景色を !important で固定（記述順 = 優先順）
   1. 初期（ベージュ）→ 2. スクロール後（白）→ 3. nav-open（ベージュ・最優先） */

/* ---- 1. 初期状態: ベージュ */
.abc-header__toggle,
.abc-header__toggle:hover,
.abc-header__toggle:active,
.abc-header__toggle:focus {
    background-color: #F5F0E8 !important;
}

/* ---- 2. スクロール後: 白（nav-open 以外） */
body.abc-header-scrolled .abc-header__toggle,
body.abc-header-scrolled .abc-header__toggle:hover,
body.abc-header-scrolled .abc-header__toggle:active,
body.abc-header-scrolled .abc-header__toggle:focus {
    background-color: #fff !important;
}

/* ---- 3. nav-open 時: ベージュ（スクロール状態を上書き・最優先） */
body.abc-nav-open .abc-header__toggle,
body.abc-nav-open .abc-header__toggle:hover,
body.abc-nav-open .abc-header__toggle:active,
body.abc-nav-open .abc-header__toggle:focus {
    background-color: #F5F0E8 !important;
}

/* =========================================
   メニュー開放中はページ本体スクロール固定
   ========================================= */
body.abc-nav-open {
    overflow: hidden;
}
