/**
 * カルテ共通スタイル — セクション見出し・sticky・wrap 色（viewport 条件なし）
 *
 * - PC / モバイル共通で適用される見出し帯・トーン色。メディアクエリは含まない。
 * - 読み込み順: common-form.css の次（ファイル名ソート）。
 */

/* セクション見出し（stickyバーと同じデザイン） */
#kh-karte .kh-karte__sectionTitle {
    margin: 40px 0 0;
    padding: 12px 20px;
    border: 1px solid var(--kh-section-border, rgba(30, 58, 138, 0.18)) !important;
    border-bottom: none !important;
    background-color: var(--kh-section-bg, #fff7ed) !important;
    background-image: none !important;
    border-radius: 12px 12px 0 0;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 800;
    color: var(--kh-section-text, var(--karte-main-dark)) !important;
    box-shadow: none;
    transition: background-color 0.12s ease-out, box-shadow 0.12s ease-out, border-left-color 0.12s ease-out;
}

/* セクション別クラス（3パターンでループ・少し分かりやすく） */
#kh-karte .kh-karte__sectionTitle.section_a { background-color: #fef9c3 !important; border-color: rgba(133, 77, 14, 0.32) !important; color: #713f12 !important; background-image: none !important; }
#kh-karte .kh-karte__sectionTitle.section_b { background-color: #e7f3ff !important; border-color: rgba(30, 64, 175, 0.24) !important; color: #1e40af !important; background-image: none !important; }
#kh-karte .kh-karte__sectionTitle.section_c { background-color: #fee2e2 !important; border-color: rgba(185, 28, 28, 0.38) !important; color: #991b1b !important; background-image: none !important; }
#kh-karte .kh-karte__sectionTitle.section_d { background-color: #ede9fe !important; border-color: rgba(91, 33, 168, 0.28) !important; color: #5b21a8 !important; background-image: none !important; }

/* 現在の大枠を示すアクティブ表示 */
#kh-karte .kh-karte__sectionTitle.is-active {
    outline: 2px solid var(--kh-section-outline, rgba(30, 58, 138, 0.28));
    outline-offset: 0;
}

/* セクションごとの色（最大3色でループ） */
#kh-karte .kh-karte__sectionWrap {
    --kh-section-bg: #fff7ed;
    --kh-section-border: rgba(124, 45, 18, 0.22);
    --kh-section-outline: rgba(124, 45, 18, 0.28);
    --kh-section-text: var(--karte-main-dark);
}

#kh-karte .kh-karte__sectionWrap--tone1 {
    --kh-section-bg: #fef9c3;
    --kh-section-border: rgba(133, 77, 14, 0.32);
    --kh-section-outline: rgba(133, 77, 14, 0.4);
    --kh-section-text: #713f12;
}

#kh-karte .kh-karte__sectionWrap--tone2 {
    --kh-section-bg: #e7f3ff;
    --kh-section-border: rgba(30, 64, 175, 0.24);
    --kh-section-outline: rgba(30, 64, 175, 0.32);
    --kh-section-text: #1e40af;
}

#kh-karte .kh-karte__sectionWrap--tone3 {
    --kh-section-bg: #fee2e2;
    --kh-section-border: rgba(185, 28, 28, 0.38);
    --kh-section-outline: rgba(185, 28, 28, 0.46);
    --kh-section-text: #991b1b;
}

#kh-karte .kh-karte__sectionWrap--tone4 {
    --kh-section-bg: #ede9fe;
    --kh-section-border: rgba(91, 33, 168, 0.28);
    --kh-section-outline: rgba(91, 33, 168, 0.36);
    --kh-section-text: #5b21a8;
}

/* セクション境界（ここより下は追従セクション外・レイアウトに影響させない） */
#kh-karte .kh-karte__sectionBoundary { margin: 0; padding: 0; height: 0; overflow: hidden; }

/* 既存のユーティリティ（mb10）で隙間が出ないように固定 */
#kh-karte .kh-karte__sectionTitle.kh-karte__mb10 {
    margin-bottom: 0 !important;
}

/* セクション丸ごと枠で囲む（見出し〜次の見出し手前） */
#kh-karte .kh-karte__sectionWrap {
    display: flow-root;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#kh-karte .kh-karte__sectionWrap.is-active {
    border: none;
    outline: 2px solid var(--kh-section-outline, rgba(30, 58, 138, 0.28));
    border-radius: 16px;
    padding: 0;
    background: color-mix(in srgb, var(--kh-section-bg, #fff7ed) 70%, #ffffff 30%);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
}

/* セクション見出し直下のテーブル上端を角丸なしにして密着 */
#kh-karte .kh-karte__sectionWrap > .kh-karte__table:first-of-type {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    margin-top: 0 !important;
}

/* スクロール追従見出しバー（共通）※サイトヘッダー 88px の下に表示 */
#kh-karte .kh-karte__stickySectionBar {
    position: fixed;
    top: 88px;
    left: 0;
    right: auto;
    width: 100%;
    z-index: 1000;
    padding: 12px 20px;
    border: 1px solid rgba(30, 58, 138, 0.18);
    border-bottom: none;
    background-color: #fff7ed;
    color: var(--karte-main-dark);
    font-size: 18px;
    line-height: 1.4;
    font-weight: 800;
    box-shadow: none;
    border-radius: 12px 12px 0 0;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.08s ease-out;
    pointer-events: none;
}

#kh-karte .kh-karte__stickySectionBar.is-visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    /* 色は JS で「現在の見出し」から同期する */
}

/* 見出しの赤テキストだけを追従バーで赤太字 */
#kh-karte .kh-karte__stickyBarDanger {
    color: var(--karte-danger) !important;
    font-weight: 900 !important;
}

/* 事業目的：最後に自動追加される文言（グレー表示のみ） */
#kh-karte .kh-karte__purposeAutoAppendText {
    color: #6b7280;
    font-size: 14px;
}

