/* ==========================================================
   WordPress のテーマ側の幅制限・見出し装飾・余白を打ち消す（body.jaf-page 限定）
   ----------------------------------------------------------
   親テーマ（Lightning 等）のCSSはこちらより後に読み込まれ、同じ詳細度ならテーマが勝つ。
   新しい要素で崩れたら、まずここに足す。:where() を使って詳細度を上げすぎない。
   body.jaf-page は functions.php の body_class フィルターで付く。
   ========================================================== */

body.jaf-page :is(
  #page, #wrapper, #container, #content, #primary, #main, #site-content,
  .site, .site-content, .site-main, .content-area, .main-content,
  .container, .container-fluid, .l-container, .l-content, .l-main, .inner, .wrap, .wrapper,
  .entry, .entry-content, .page-content, .post-content, .post, .page,
  .wp-site-blocks, .wp-block-post-content, .is-layout-constrained, .is-layout-flow,
  .has-global-padding, .alignwide, .alignfull
) {
  max-width: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Gutenberg の constrained レイアウト：直下の子に content-size の max-width がかかる */
body.jaf-page .is-layout-constrained > *,
body.jaf-page .wp-block-post-content > * {
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* 本文の上下の余白や、テーマ側のパンくず・タイトルなど */
body.jaf-page .entry-header,
body.jaf-page .page-header,
body.jaf-page .entry-title,
body.jaf-page .breadcrumbs,
body.jaf-page .wp-block-post-title {
  display: none !important;
}
body.jaf-page :is(.site-content, .entry-content, .page-content, .wp-block-post-content, main) {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* 横に少しはみ出しても横スクロールを出さない（overflow:hidden ではなく clip：position:sticky を壊さない） */
body.jaf-page {
  overflow-x: clip;
}

/* テーマ（Lightning）が html / body に付けるフォント・文字サイズ・行間を、common.css の body と同じ値に戻す
   テーマの `body,html { font-family: Lato,… ; font-size: var(--vk-size-text) }`（SPは ×0.875＝14px）がこちらの body（0,0,1）より後に読まれて勝ち、
   本文の行間が 28.8px → 27.2px、SPメニューが 16px → 14px になっていた（2026-11-30）。値は common.css の body と必ずそろえる */
html:has(> body.jaf-page) {
  font-size: 100%;
}
body.jaf-page {
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0.05em;
}

/* テーマが p・見出しに直接付ける行間と、見出しの上下余白を、手元（テーマなし）と同じにする
   テーマ：`p { line-height: var(--vk-line-height) }`・`h1…h6 { margin-top:0; margin-bottom: var(--vk-margin-headding-bottom); line-height: var(--vk-line-height-low) }`
   → 行間は親から引き継ぐ（body の 1.8）、見出しの余白はブラウザ標準に戻す（revert）。
   詳細度（0,0,2）：テーマ（0,0,1）より高く、こちらのクラス指定（0,1,0）より低い（自分で指定した行間・余白はそのまま） */
html :where(body.jaf-page) :is(p, h1, h2, h3, h4, h5, h6) {
  line-height: inherit;
}
html :where(body.jaf-page) :is(h1, h2, h3, h4, h5, h6) {
  margin-top: revert;
  margin-bottom: revert;
}

/* テーマ（Lightning）が h2 / h3 に自動で付ける罫線・余白を消す
   ・h2：上に太線＋下に細線（border-top / border-bottom / padding）
   ・h3：下に細線（border-bottom / padding）
   :where() で除外しているので詳細度は上がらず、独自の罫線を持つ要素（.jaf-keep-border を付ける）は
   自分のCSSがそのまま効く。 */
/* 詳細度は (0,0,2)：テーマの h2/h3:where(…)（0,0,1）には勝ち、自分のクラス（.top__plan-name など 0,1,0）には負ける。
   以前の body.jaf-page :is(h2,h3)（0,1,2）は自分のクラスの padding・角丸・枠線まで消していた（2026-11-30 TOPのプラン名・プランページの見出し） */
html :where(body.jaf-page) :is(h2, h3):where(:not(.jaf-keep-border)) {
  border: 0;
  border-radius: 0;
  padding: 0;
}

/* テーマ／WordPress標準のスタイルがリンク全体に付ける下線を消す
   カード全体が <a> のため、カード内の文字すべてに下線が入っていた。
   下線を残したいリンクには .jaf-keep-underline を付ける。:where() は詳細度を上げない */
body.jaf-page a:where(:not(.jaf-keep-underline)),
body.jaf-page a:where(:not(.jaf-keep-underline)):is(:hover, :focus, :active) {
  text-decoration: none;
}

/* テーマ（Lightning）が h2 / h3 の ::after で付ける青い短い線を消す
   （h3:where(:not(.wp-block-post-title))::after … 幅30%・下に1pxのメインカラー線） */
html :where(body.jaf-page) :is(h2, h3):where(:not(.jaf-own-after))::after {
  content: none;
  /* テーマの h3::after の残りの指定（position:absolute・width:30% など）も戻す。自分で ::after を作った見出し（.plan__more-title など）に混ざると、
     飾りが絶対配置になって見出しの高さが縮んでいた（2026-11-30）。自分のクラスの ::after（0,1,1）で指定した値はそのまま */
  position: revert;
  bottom: revert;
  width: revert;
  display: revert;
  overflow: revert;
  line-height: revert;
  border-bottom: revert;
}

/* テーマ（Lightning）が h4 に自動で付ける灰色の背景・余白・角丸を消す */
html :where(body.jaf-page) h4 {   /* (0,0,2)：テーマの h4:where(…)（0,0,1）にだけ勝つ */
  background: none;
  border-radius: 0;
  padding: 0;
}
/* 色を「親から引き継ぐ」リンク（common.css の `a { color: inherit }`）は、テーマの `a { color: var(--vk-color-text-link) }`（0,0,1）に負けて灰色・青になる。
   ・クラスなしのリンク → 下の body.jaf-page a:not([class])
   ・クラス付きのリンク → (0,0,2) で引き継ぐ。自分のクラスで色を指定していれば（0,1,0）そちらが勝つ
   ※ 以前は .common_header__logo を (0,2,1) で inherit にしていて、ロゴの緑（.common_header__logo の color）まで消していた（2026-11-30） */
body.jaf-page a:not([class]) {
  color: inherit;
}
html :where(body.jaf-page) a:where([class]) {
  color: inherit;
}

/* ホバーで文字が青くなるのを防ぐ */
/* テーマの a:hover（0,1,1・青）が、クラス付きリンクのホバー時の色を上書きする（2026-11-30 右の固定ボタン・電話番号など）。
   ・色を親から引き継ぐリンク → 下の (0,1,2) でホバー時も引き継ぐ
   ・クラスで色を指定しているリンク → そのクラスのルールに `.xxx:hover` も並べて書く（0,2,0 で勝つ。例：.common_side__btn, .common_side__btn:hover）
   ・ホバーで色を変えたいときは、各CSSで .xxx:hover { color: … } と書けばよい（0,2,0 > 0,1,2） */
body:where(.jaf-page) a:where([class]):hover {
  color: inherit;
}

/* プラグイン（VK All in One Expansion Unit）の「ページトップへ」ボタンを消す
   プラグイン側は .scrolled .page_top_btn { display:block } で出すため、ID指定で確実に上書きする */
body.jaf-page #page_top {
  display: none !important;
}

/* テーマ（Lightning）が p / ul / ol / dl / blockquote / iframe に付ける下の余白を消す
   `.wp-block-table, blockquote, dl, iframe, ol, p, ul { margin-bottom: var(--vk-margin-element-bottom) }` への対策。
   詳細度は、テーマ（0,0,1）より高く、こちらのクラス指定（0,1,0）より低い（0,0,2）にしている。
   → こちらのCSSで margin を指定している要素はその値のまま、指定のない要素だけ余白が0になる */
html :where(body.jaf-page) :is(p, ul, ol, dl, blockquote, iframe) {
  margin-bottom: 0;
}

/* テーマが ul / ol / li / 表 / dt・dd に付ける指定を、手元（common.css のリセット＋ブラウザ標準）と同じに戻す
   テーマ：`:is(ul,ol):where(…) { padding-left:1.5em }`・`li { margin:.5em 0 }`・`table td, table th { padding:.5rem 1rem }`＋罫線・`dt { font-weight:700; margin-bottom:.5em }`・`dd { margin-left:0 }`
   common.css の `ul, ol { margin:0; padding:0; list-style:none }` はテーマと同じ詳細度で先に読まれるため負けていた
   （2026-11-30：SPヘッダーの「お急ぎの方」が7px下がる、メニュー・フッターが24px右に寄る、斎場の表に罫線）。
   詳細度（0,0,3）：テーマ（〜0,0,2）より高く、こちらのクラス指定（0,1,0）より低い → 自分で指定した値はそのまま */
html body:where(.jaf-page) :is(ul, ol) {
  margin: 0;
  padding: 0;
  list-style: none;
}
html body:where(.jaf-page) li {
  margin-top: 0;
  margin-bottom: 0;
}
html body:where(.jaf-page) :is(table, th, td) {
  border: revert;
  padding: revert;
  font-size: revert;   /* テーマ `:where(…) > table :is(th,td) { font-size: var(--vk-size-text-sm) }`（14px）→ 親から引き継ぐ */
}
html body:where(.jaf-page) dt {
  font-weight: revert;
  margin-bottom: revert;
}
html body:where(.jaf-page) dd {
  margin-left: revert;
}

/* 注意：上の「main の余白を消す」!important は、固定ヘッダー分の上余白まで消し、パンくずがヘッダーの下に隠れる。
   各ページのCSSで確保する：body.jaf-page main.ページ名 { padding-top: 80px !important }（SP 60px） */
