/* =====================================================================
   modern テーマ: pages.css — ホーム・お問い合わせ以外のページ固有スタイル
   対象: サービス / リフォーム・お客様別 / 設備工事・リフォーム一覧 / 事例一覧・詳細 / お知らせ / 会社概要 /
         施工の流れ / プライバシーポリシー / 404・500（Docs/redesign-proposal.md §5.2〜§5.10）
   担当: 2段階(テンプレート)。共通部品は base.css、枠は layout.css を編集しない（必要なら相談）。
   読み込み: partials/top.ejs が home・contact 以外のページで読む。
   ===================================================================== */

/* ---------- 本文（modern ブロック出力: src/lib/render/blocks.js renderBlocksModern） ---------- */
/* 見出しは 1 段上げて出力される（h3→h2, h4→h3）。見た目は §3（h2 相当は茶色 + 下線） */
.m-article h2 {
  font-size: var(--fs-h3); color: var(--c-earth); margin-top: var(--sp-8); padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--c-line);
}
.m-article h3 { font-size: var(--fs-h4); color: var(--c-ink); margin-top: var(--sp-6); margin-bottom: var(--sp-3); border: 0; padding: 0; }
.m-article > h2:first-child, .m-article > h3:first-child { margin-top: 0; }
.m-article h2[id], .m-article h3[id] { scroll-margin-top: calc(var(--header-h) + 16px); }
@media (min-width: 1024px) { .m-article h2[id], .m-article h3[id] { scroll-margin-top: calc(var(--header-h-lg) + 16px); } }
.m-article--narrow { max-width: 720px; }
.m-article .m-list li::marker { color: var(--c-brand); }
.m-figure { margin: 0 0 var(--sp-5); }
.m-figure img { border-radius: var(--radius); }

/* 写真グリッド（photoRow）: クリックで拡大 */
/* 빠른 정리(2026-12-04): 사진은 3:2로 통일, 장수에 따라 칸 수를 정해 혼자 남는 사진이 없게 한다.
   1장=본문 폭 / 2장=2열 / 3장=3열 / 4장=2×2 / 5장 이상=3열. 휴대폰은 2장 이상이면 2열(홀수면 첫 장을 크게). */
.m-photos { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); margin: var(--sp-5) 0 var(--sp-6); align-items: start; }
.m-photos--1 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) {
  .m-photos { gap: var(--sp-5); }
  .m-photos--3, .m-photos--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 599.98px) {
  .m-photos--3 > .m-photo:first-child, .m-photos--5 > .m-photo:first-child { grid-column: 1 / -1; }
  .m-photos .m-photo__title { font-size: 15px !important; }
  .m-photos .m-photo__cap { font-size: 13px; }
}

/* 글 + 사진 1장 좌우 배치(renderBlocksModern 이 「문단 → 사진 1장」을 묶는다) */
.m-split { display: grid; gap: var(--sp-4); margin: 0 0 var(--sp-6); align-items: start; }
.m-split__text > :last-child { margin-bottom: 0; }
.m-split__media .m-photo { margin: 0; }
@media (min-width: 768px) {
  .m-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-6); }
  .m-split--left .m-split__media { order: -1; }
}

/* 본문은 칸 전체를 쓴다(기존 사이트처럼). 760px 로 묶으면 오른쪽이 비어 본문이 가운데에 오지 않는다 */
.m-article { --measure: none; }
.m-service__main.m-article, .m-prose.m-article:not(.m-article--narrow) { max-width: none; }
/* 카드 목록이 있는 페이지는 카드가 좁아지지 않게 칸 전체를 쓴다 */
.m-service__main.m-article:has(.m-cards), .m-prose.m-article:has(.m-cards) { max-width: none; }
.m-article h2, .m-article h3, .m-cards .m-card__title { word-break: auto-phrase; text-wrap: balance; }
.m-photo { margin: 0; min-width: 0; }
.m-photo__title { font-size: 17px !important; margin: 0 0 var(--sp-2) !important; color: var(--c-ink) !important; border: 0 !important; padding: 0 !important; }
.m-photo__cap { color: var(--c-muted); font-size: 15px; margin: 0 0 var(--sp-2); max-width: none; }
figcaption.m-photo__cap { margin: var(--sp-2) 0 0; }
.m-photo__link { display: block; position: relative; border-radius: var(--radius); overflow: hidden; background: var(--c-bg-warm); cursor: zoom-in; }
.m-photo__link img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 0; transition: transform 300ms ease; }
.m-photo__link:hover img { transform: scale(1.03); }
.m-photo__link:focus-visible { outline-offset: 3px; }

/* カード（cards ブロック・一覧） */
.m-cards { list-style: none; padding: 0; margin: var(--sp-5) 0 var(--sp-6); }
.m-cards > li { display: flex; min-width: 0; max-width: none; margin: 0; }
.m-cards > li > .m-card { flex: 1; }
.m-cards .m-card__media img { border-radius: 0; }
.m-cards .m-card__title { color: var(--c-ink); font-size: var(--fs-h4) !important; margin: 0 !important; padding: 0 !important; border: 0 !important; }
.m-cards .m-card__text { display: block; -webkit-line-clamp: unset; overflow: visible; max-width: none; } /* 설명을 자르지 않는다 */
.m-cards .m-card__media { aspect-ratio: 2 / 1; } /* 카드 사진 원본은 640×320(2:1) */
.m-listing .m-cards { margin-top: 0; }

/* 表（table / infoTable） */
.m-table-wrap { overflow-x: auto; margin: 0 0 var(--sp-5); }
.m-table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 0 0 var(--sp-5); }
.m-table-wrap .m-table { margin: 0; }
.m-table th, .m-table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-line); text-align: left; vertical-align: top; }
.m-table tr:first-child > * { border-top: 1px solid var(--c-line); }
.m-table th { background: var(--c-bg-warm); font-weight: 700; white-space: nowrap; width: 9em; }
.m-table td ul { margin: var(--sp-1) 0 var(--sp-2); }
.m-table td li { max-width: none; }
@media (max-width: 599.98px) {
  .m-table--info tr { display: grid; }
  .m-table--info th { width: auto; white-space: normal; border-bottom: 0; }
  .m-table--info tr:not(:first-child) th { border-top: 1px solid var(--c-line); }
  .m-table--info th:empty, .m-table--info th:has(> br:only-child) { display: none; }
}
.m-infotable { display: grid; gap: var(--sp-5); margin: 0 0 var(--sp-6); align-items: start; }
.m-infotable .m-table { margin: 0; }
.m-infotable__media img { width: 100%; border-radius: var(--radius); }
@media (min-width: 1024px) { .m-infotable { grid-template-columns: 1.6fr 1fr; gap: var(--sp-6); } }

/* ---------- 위지윅 본문（CKEditor 5 출력: src/lib/render/html-body.js renderHtmlBody, Docs/wysiwyg-dev-spec.md §4） ---------- */
/* 사진 좌/우 글 감싸기: PC(≥768px)는 폭 45%·3:2, 모바일은 감싸지 않고 100% */
.m-wfig { margin: var(--sp-2) 0 var(--sp-5); }
@media (min-width: 768px) {
  .m-wfig { width: 45%; margin-top: var(--sp-1); }
  .m-wfig--right { float: right; margin-left: var(--sp-6); }
  .m-wfig--left { float: left; margin-right: var(--sp-6); }
}
/* 감싸기 사진이 다음 절·사진 묶음·표까지 내려오지 않게 */
.m-article :is(h2, .m-photos, .m-table-wrap, .m-infotable, .m-cards, .m-anshin, hr, .m-callout) { clear: both; }
.m-article::after { content: ""; display: table; clear: both; }
/* 강조 상자（Style 플러그인 「強調ボックス」: p.m-callout / div.m-callout） 1종 */
.m-callout { margin: var(--sp-5) 0 var(--sp-6); padding: var(--sp-5) var(--sp-5); background: var(--c-brand-tint); border-left: 4px solid var(--c-brand); border-radius: var(--radius); max-width: none; }
div.m-callout > :first-child { margin-top: 0; }
div.m-callout > :last-child { margin-bottom: 0; }
.m-article blockquote { margin: var(--sp-5) 0; padding: var(--sp-1) 0 var(--sp-1) var(--sp-5); border-left: 3px solid var(--c-line); color: var(--c-muted); }

/* ---------- サービス・リフォーム・お客様別（§5.2・§5.3） ---------- */
.m-service__grid { display: grid; gap: var(--sp-6); }
.m-service__main { min-width: 0; }
.m-service__side { display: flex; flex-direction: column; gap: var(--sp-5); }
@media (min-width: 1024px) {
  .m-service__grid { grid-template-columns: 260px minmax(0, 1fr); gap: var(--sp-7); align-items: start; }
  .m-service__side { position: sticky; top: calc(var(--header-h-lg) + var(--sp-5)); max-height: calc(100vh - var(--header-h-lg) - var(--sp-6)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 2px; }
}
@media (max-width: 1023.98px) {
  .m-service__side { order: 2; }
  .m-toc--side, .m-contactbox { display: none; } /* モバイル: 目次は本文上の折りたたみ、連絡は下部固定バー */
}

/* 目次 */
.m-toc__title { font-weight: 700; font-size: var(--fs-small); color: var(--c-muted); letter-spacing: .1em; margin: 0 0 var(--sp-2); }
.m-toc__list, .m-toc__list ol { list-style: none; margin: 0; padding: 0; }
.m-toc__list a { display: block; padding: 6px 0 6px var(--sp-3); border-left: 2px solid var(--c-line); color: var(--c-ink); text-decoration: none; font-size: 15px; line-height: 1.5; }
.m-toc__list a:hover { color: var(--c-brand); border-left-color: var(--c-brand); }
.m-toc__list ol a { padding-left: var(--sp-5); font-size: 14px; color: var(--c-muted); }
.m-toc__list li { max-width: none; margin: 0 !important; }
.m-toc--mobile { margin-bottom: var(--sp-5); border: 1px solid var(--c-line); border-radius: var(--radius); background: #fff; }
.m-toc--mobile summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 var(--sp-4); font-weight: 700; cursor: pointer; list-style: none; }
.m-toc--mobile summary::-webkit-details-marker { display: none; }
.m-toc--mobile[open] .m-toc__caret { transform: rotate(180deg); }
.m-toc--mobile .m-toc__list { padding: 0 var(--sp-4) var(--sp-4); }
@media (min-width: 1024px) { .m-toc--mobile { display: none; } }
.m-toc--inline { margin: 0 0 var(--sp-6); padding: var(--sp-5); background: var(--c-bg-warm); border-radius: var(--radius); }

/* 連絡ボックス・関連サービス（サイド） */
.m-contactbox { padding: var(--sp-5); border-radius: var(--radius); background: var(--c-brand-tint); }
.m-contactbox__title { font-weight: 700; color: var(--c-brand-dark); margin: 0 0 var(--sp-2); }
.m-contactbox__tel { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--c-ink); font-weight: 700; font-size: 20px; letter-spacing: .04em; text-decoration: none; }
.m-contactbox__tel:hover { color: var(--c-brand-dark); }
.m-contactbox__hours { font-size: 13px; color: var(--c-muted); margin: 0 0 var(--sp-3); }
.m-contactbox .m-btn { margin-top: var(--sp-3); }
.m-related__title { font-weight: 700; font-size: var(--fs-small); color: var(--c-muted); letter-spacing: .1em; margin: 0 0 var(--sp-2); }
.m-related ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--c-line); }
.m-related a { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: var(--sp-2) var(--sp-1); border-bottom: 1px solid var(--c-line); color: var(--c-ink); text-decoration: none; font-weight: 700; font-size: 15px; }
.m-related a:hover { color: var(--c-brand); }

/* 賃貸オーナー様 / 個人のお客様 の切り替え */
.m-tabs { margin: 0 0 var(--sp-5); }
@media (max-width: 599.98px) { .m-tabs ul { display: grid; width: 100%; } }
.m-tabs ul { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 100%; gap: var(--sp-1); list-style: none; margin: 0; padding: var(--sp-1); background: var(--c-bg-warm); border-radius: 999px; }
.m-tabs a { display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.4; min-height: 44px; padding: var(--sp-1) var(--sp-4); border-radius: 999px; color: var(--c-ink); font-weight: 700; text-decoration: none; }
.m-tabs a:hover { color: var(--c-brand); }
.m-tabs a[aria-current] { background: #fff; color: var(--c-brand-dark); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }

/* ---------- 会社概要（§5.7） ---------- */
.m-body--company .m-article { max-width: none; }
.m-anshin { margin: var(--sp-8) 0; }
.m-anshin h2 { margin-top: 0; }
.m-anshin__list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-5); }
@media (min-width: 768px) { .m-anshin__list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.m-anshin__item { max-width: none !important; margin: 0 !important; padding: var(--sp-6); background: var(--c-brand-tint); border-radius: var(--radius); border-top: 4px solid var(--c-brand); }
.m-anshin__item h3 { margin: 0 0 var(--sp-3); color: var(--c-brand-dark); }
.m-anshin__item p { margin: 0; }
.m-access { margin-top: var(--sp-8); }
.m-access .m-embed { max-width: 960px; margin-bottom: var(--sp-4); }
.m-access__addr { font-weight: 700; }

/* ---------- 一覧（カテゴリ・事例）（§5.3・§5.4） ---------- */
.m-tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; }
.m-tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--c-bg-warm); color: var(--c-muted); font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.m-case-card__media { position: relative; aspect-ratio: 3 / 2; }
.m-case-card__badge { position: absolute; top: var(--sp-3); right: var(--sp-3); padding: 2px 10px; border-radius: 999px; background: rgba(34, 34, 34, .78); color: #fff; font-size: 13px; font-weight: 700; }
.m-case-card__text { -webkit-line-clamp: 2 !important; }

/* ---------- 事例詳細（§5.5） ---------- */
.m-case__visual img { width: 100%; border-radius: var(--radius); aspect-ratio: 16 / 9; object-fit: cover; }
.m-case__grid { display: grid; gap: var(--sp-6); }
.m-case__main { min-width: 0; }
.m-case__intro p { max-width: var(--measure); }
.m-case__side { display: flex; flex-direction: column; gap: var(--sp-4); }
/* モバイル: 360°/写真 → 概要（Client 等）→ 本文。PC: 左に 360°・本文、右に概要（sticky） */
.m-case__grid { grid-template-areas: "media" "side" "main"; }
.m-case__media { grid-area: media; margin: 0; }
.m-case__main { grid-area: main; }
.m-case__side { grid-area: side; }
@media (min-width: 1024px) {
  .m-case__grid { grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "media side" "main side"; gap: var(--sp-6) var(--sp-7); align-items: start; }
  .m-case__side { position: sticky; top: calc(var(--header-h-lg) + var(--sp-5)); }
}
.m-facts { margin: 0; border-top: 1px solid var(--c-line); }
.m-facts > div { padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-line); }
.m-facts dt { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--c-muted); }
.m-facts dd { margin: 0; font-weight: 700; }
.m-case__gallery { margin-top: var(--sp-7); }
.m-case__gallery h2 { font-size: var(--fs-h3); color: var(--c-earth); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--c-line); }
.m-gallery { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .m-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); } }
.m-gallery li:first-child { grid-column: 1 / -1; }
.m-gallery .m-photo__link img { aspect-ratio: 3 / 2; }
.m-gallery li:first-child .m-photo__link img { aspect-ratio: 16 / 9; }
.m-case__back, .m-back { margin-top: var(--sp-7); }

/* ---------- お知らせ（§5.6） ---------- */
.m-newslist { list-style: none; padding: 0; margin: 0 0 var(--sp-6); border-top: 1px solid var(--c-line); }
.m-newslist li { max-width: none; margin: 0 !important; }
.m-newslist__link { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-2) var(--sp-5); align-items: baseline; padding: var(--sp-4) var(--sp-1); border-bottom: 1px solid var(--c-line); color: var(--c-ink); text-decoration: none; }
.m-newslist__link time { color: var(--c-muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.m-newslist__title { font-weight: 700; }
.m-newslist__arrow { color: var(--c-brand); }
.m-newslist__link:hover .m-newslist__title { color: var(--c-brand); text-decoration: underline; }
@media (max-width: 599.98px) {
  .m-newslist__link { grid-template-columns: 1fr auto; }
  .m-newslist__link time { grid-column: 1 / -1; }
}
.m-pager ul { display: flex; flex-wrap: wrap; gap: var(--sp-2); list-style: none; padding: 0; margin: 0 0 var(--sp-2); }
.m-pager li { margin: 0 !important; }
.m-pager a, .m-pager span[aria-current] { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 var(--sp-3); border: 1px solid var(--c-line); border-radius: var(--radius-btn); text-decoration: none; }
.m-pager span[aria-current] { background: var(--c-brand); border-color: var(--c-brand); color: #fff; font-weight: 700; }
.m-pager__count { color: var(--c-muted); font-size: var(--fs-small); }
.m-news-article__date { color: var(--c-muted); font-variant-numeric: tabular-nums; }

/* ---------- 404・500 ---------- */
.m-errorlinks { list-style: none; padding: 0; margin: var(--sp-5) 0 var(--sp-6); display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }
.m-errorlinks li { max-width: none; margin: 0 !important; }
.m-errorlinks a { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--c-line); border-radius: var(--radius); color: var(--c-ink); font-weight: 700; text-decoration: none; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.m-errorlinks a:hover { border-color: var(--c-brand); color: var(--c-brand); box-shadow: var(--shadow-hover); }

/* ---------- ライトボックス（js/lightbox.js, <dialog>） ---------- */
.m-lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(17, 17, 17, .94); color: #fff; overflow: hidden; }
.m-lightbox::backdrop { background: rgba(17, 17, 17, .6); }
.m-lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.m-lightbox__bar { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-2) var(--sp-3); }
.m-lightbox__count { margin: 0; padding-left: var(--sp-2); font-size: var(--fs-small); color: #ddd; font-variant-numeric: tabular-nums; }
.m-lightbox__figure { margin: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; gap: var(--sp-3); padding: 0 var(--sp-3) var(--sp-5); min-height: 0; }
.m-lightbox__img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; user-select: none; touch-action: pan-y pinch-zoom; }
.m-lightbox__cap { margin: 0; color: #eee; font-size: 15px; text-align: center; }
.m-lightbox__btn { display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; transition: background-color var(--t-fast); }
.m-lightbox__btn:hover { background: rgba(255, 255, 255, .28); }
.m-lightbox__btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.m-lightbox__prev, .m-lightbox__next { position: absolute; top: 50%; transform: translateY(-50%); }
.m-lightbox__prev { left: var(--sp-3); }
.m-lightbox__next { right: var(--sp-3); }
@media (min-width: 1024px) {
  .m-lightbox__figure { padding: 0 96px var(--sp-6); }
  .m-lightbox__prev { left: var(--sp-5); }
  .m-lightbox__next { right: var(--sp-5); }
}
/* .m-prose の li + li 余白を一覧部品では打ち消す */
.m-prose .m-cards > li, .m-prose .m-photos li, .m-prose .m-toc__list li { margin-top: 0; }

.m-nowrap { white-space: nowrap; }
/* 위지윅 본문: 사진 1장(가운데)·会社表 옆 사진은 원래 비율(블록 출력의 image 블록·infoTable 사진과 같게) */
.m-photos--1 .m-photo__link img, .m-infotable__media .m-photo__link img { aspect-ratio: auto; }
.m-infotable__media .m-photos { margin: 0; }
/* 카드(제목 → 사진 → 설명): 설명은 사진 아래 */
.m-photo__link + .m-photo__cap { margin: var(--sp-2) 0 0; }

/* ── 기존 사이트(Joomla) 본문 배치 (2026-12-04: 「사진·콘텐츠 배치는 기존과 같게」) ──
   본문 HTML 이 원본 기사의 Bootstrap 3 격자(.row > .col-md-6 …, .thumbnail, .well)를 그대로 쓴다.
   격자·카드·버튼의 기본은 base.css 「prose」(Joomla 유래 클래스). 여기서는 위지윅 사진(.m-photo)과 어울리게만 맞춘다.
   사진은 원본 비율 그대로(잘라내지 않는다). 편집기(src/admin-assets/editor-content.css)도 같은 배치 */
.m-article .row .m-photo { margin: 0; }
.m-article .row .m-photo__link img { aspect-ratio: auto; height: auto; }
.m-article .row > [class*="col-"] > .m-photo + p, .m-article .row > [class*="col-"] > p + .m-photo { margin-top: var(--sp-3); }
.m-article .thumbnail > .m-photo .m-photo__link { border-radius: 0; }
.m-article .thumbnail .caption h3 { color: var(--c-earth); }
.m-article .well { padding: var(--sp-5); background: var(--c-bg-warm); border-radius: var(--radius); }
.m-article .well blockquote { margin: 0 0 var(--sp-5); padding: 0 0 0 var(--sp-4); border-left: 4px solid var(--c-brand); color: var(--c-ink); font-style: normal; }
.m-article .well blockquote:last-child { margin-bottom: 0; }
.m-article .well blockquote h4 { margin-top: 0; }
.m-article .row .m-table-wrap { margin: 0; }
/* 좁은 화면(열이 세로로 쌓일 때): 「글 | 사진」 줄도 사진이 먼저 오게(施工の流れ 등 좌우 번갈아 배치) */
@media (max-width: 1023.98px) {
  .m-article .row > [class*="col-"]:has(> .m-photo:only-child) { order: -1; }
}
