/* 執筆記事（article/ 以下）の共通レイアウト。
   site.css の後に読み込む。デザイン基準は docs/naito/design-ref-article.md。
   旧テンプレートのDOM構造（#site-box/#index-contents/.gist/#title 等）を
   変えずに見た目だけ統一するため、既存class/id名を対象にした上書きが中心。 */

:root {
    --art-text-sub: var(--color-theme);
    --art-border: var(--color-border);
    --art-surface: var(--color-surface);
    --art-gap-s: 8px;
    --art-gap-m: 16px;
    --art-gap-l: 24px;
    --art-gap-xl: 40px;
}

a { text-underline-offset: 3px; }
:focus-visible { outline: 3px solid #4d7fd1; outline-offset: 2px; }

/* ヘッダーは /header/header.css のまま触らない（トップと同一見た目） */

/* ==== パンくず（.topicpath）：#index-contents 内の先頭に移動済み。
   小さく・控えめに。構造はそのまま ==== */
.topicpath {
    margin: var(--art-gap-l) 0 0;
    font-size: .8125rem;
    color: var(--art-text-sub);
    line-height: 1.6;
}
.topicpath a { color: var(--color-brand); }

/* ==== 本文コンテナ：旧固定幅（#site-box:1200px / #index-contents:980px）を解除 ==== */
#site-box { width: auto; margin: 0; }
#index-contents {
    width: min(calc(100% - 2rem), 1100px) !important;
    margin-inline: auto !important;
    padding-bottom: var(--art-gap-xl);
    /* 長いURL等の連続文字列が本文幅を突き抜けるのを防ぐ
       （継承するプロパティなので下層のテキスト全体に効く） */
    overflow-wrap: anywhere;
}
/* 記事詳細ページは読みやすさ優先で 800px に絞る */
#index-contents.article-detail {
    width: min(calc(100% - 2rem), 800px) !important;
}
#index-contents .gist { width: auto !important; float: none !important; }
#index-contents .photo { width: auto !important; float: none !important; max-width: 100%; }

/* ==== ページタイトル（h3#title）：site.cssの.page-titleと同じ左線スタイル ==== */
/* 詳細ページはインライン style で font-size が書かれているため !important で統一 */
#index-contents .gist h3#title,
#index-contents .gist h3#title[style] {
    border-left: 10px solid var(--color-brand);
    border-bottom: none;
    padding-left: 1rem;
    margin: var(--art-gap-l) 0 var(--art-gap-m);
    font-size: clamp(1.75rem, 3vw, 2.25rem) !important;
    font-weight: 600;
    line-height: 1.4 !important;
}
/* 詳細ページの #title はやや小さめ */
#index-contents.article-detail .gist h3#title,
#index-contents.article-detail .gist h3#title[style] {
    margin: var(--art-gap-l) 0 var(--art-gap-s);
    font-size: clamp(1.5rem, 3vw, 2rem) !important;
}

.gist > p { margin: 0 0 var(--art-gap-m); font-size: 1rem !important; line-height: 1.8 !important; }

/* ==== 記事カテゴリ一覧（table#articleList）：2列テーブルをグリッド化 ====
   tbody/tr/td の構造を維持したまま grid 化する（common/css/mobile.css と同じ手法）。 */
#articleList { display: block; width: 100%; border-collapse: collapse; margin-top: var(--art-gap-l); }
#articleList tbody { display: block; }
#articleList tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--art-gap-l);
    margin-bottom: var(--art-gap-l);
}
#articleList td {
    width: auto;
    padding: 0;
    border-top: 3px solid var(--color-brand);
    padding-top: var(--art-gap-m);
    vertical-align: top;
}
/* 項目数が奇数で最終行が1列になる場合は全幅に広げる */
#articleList td:only-child { grid-column: 1 / -1; }
#articleList td h4 {
    border: none;
    margin: 0 0 var(--art-gap-s);
    padding: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.5;
}
#articleList td h4 a {
    color: var(--color-brand);
    text-decoration: none;
}
#articleList td h4 a::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
}
#articleList td h4 a:hover,
#articleList td h4 a:focus-visible { text-decoration: underline; color: var(--color-theme-hover); }
#articleList td p {
    margin: 0;
    padding: 0;
    font-size: .875rem;
    color: var(--art-text-sub);
    line-height: 1.75;
}

/* ==== 記事一覧アイテム（.box.row）：サムネイル＋日付＋タイトル＋著者 ====
   旧Bootstrapグリッド（.row .col-2 .col-5 .col-7）は flex で再構成。
   Bootstrap自体は読み込まない。 */
.box.row {
    display: flex;
    gap: var(--art-gap-m);
    align-items: flex-start;
    padding: var(--art-gap-m) 0;
    border-bottom: 1px solid var(--art-border);
    margin: 0;
}
.box.row > img[class*="col-"] {
    flex: 0 0 96px;
    width: 96px !important;
    height: 5rem !important;
    object-fit: cover;
    margin: 4px 0 0;
}
.box.row > div[class*="col-"] {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
}
/* 日付：小さく・等幅数字・控えめ色 */
.box.row .data {
    margin: 0;
    font-size: .8125rem;
    color: var(--art-text-sub);
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
}
/* 記事タイトルリンク：やや太字・下線はhover時 */
.box.row > div[class*="col-"] > a {
    display: inline-block;
    margin-top: 2px;
    color: var(--color-brand);
    font-weight: 600;
    text-decoration: none;
    line-height: 1.55;
}
.box.row > div[class*="col-"] > a:hover,
.box.row > div[class*="col-"] > a:focus-visible {
    color: var(--color-theme-hover);
    text-decoration: underline;
}
/* 著者名：日付よりさらに小さく */
.box.row .name {
    margin: 4px 0 0 !important;
    font-size: .75rem !important;
    color: var(--art-text-sub);
}

/* ==== 記事詳細：メタ行・本文・図版 ==== */
/* 「最終更新日」の右揃え <p> に下罫線を足して記事ヘッダーと本文を分ける */
.gist p[style*="text-align: end"],
.gist p[style*="text-align:end"],
.gist p.art-updated {
    color: var(--art-text-sub);
    font-size: .8125rem !important;
    margin: 0 0 var(--art-gap-l);
    padding-bottom: var(--art-gap-m);
    border-bottom: 1px solid var(--art-border);
}
#index-contents .gist p { margin: 0 0 var(--art-gap-m); font-size: 1rem; }
/* 空divのスペーサー（旧来の余白目的）は潰し、余白はCSSで管理 */
#index-contents .gist div[style*="height: 2rem"],
#index-contents .gist div[style*="height:2rem"],
#index-contents .gist div.art-spacer { display: none; }

/* 図版（中央揃えdiv＋キャプション）：余白で区切る */
#index-contents .gist div[style*="text-align:center"],
#index-contents .gist div[style*="text-align: center"],
#index-contents .gist div.art-caption {
    margin: var(--art-gap-l) auto;
    font-size: .8125rem !important;
    color: var(--art-text-sub);
    line-height: 1.6;
}
#index-contents .gist div[style*="text-align:center"] img,
#index-contents .gist div[style*="text-align: center"] img,
#index-contents .gist div.art-caption img {
    display: block;
    margin: 0 auto var(--art-gap-s);
    max-width: 100%;
    height: auto;
}

/* ==== 記事中の見出し（h3#title以外）：セクションタイトル相当 ==== */
#index-contents .gist h3:not(#title) {
    border-left: 8px solid var(--color-brand);
    padding-left: .8rem;
    margin: var(--art-gap-xl) 0 var(--art-gap-m);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}
#index-contents .gist h4 {
    margin: var(--art-gap-l) 0 var(--art-gap-s);
    font-size: 1.0625rem;
    font-weight: 600;
}

/* ==== 区切り線・リスト・脚注 ==== */
#index-contents .gist hr {
    border: none;
    border-top: 1px solid var(--art-border);
    height: auto;
    margin: var(--art-gap-xl) 0;
}
#index-contents .gist ul {
    margin: 0 0 var(--art-gap-m) 1.4em;
    padding: 0;
    list-style: disc;
}
#index-contents .gist ol {
    margin: 0 0 var(--art-gap-m) 1.4em;
    padding: 0;
}
#index-contents .gist li { margin-bottom: var(--art-gap-s); }
#index-contents .gist dd { margin-left: 1.5em; }

/* ==== ページ先頭へ戻る：旧リンクは隠し、共通フローティングボタンに統一 ==== */
.pagetop { display: none; }

body > footer.site-footer { margin-top: 0; }

@media (max-width: 768px) {
    #articleList tr { grid-template-columns: 1fr; gap: 0; }
    #articleList td { padding-bottom: var(--art-gap-l); }
    /* site.css が #index-contents table に掛ける横スクロール化を
       #articleList には効かせない（グリッドなので潰れて見える） */
    #index-contents #articleList {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }
    .box.row > img[class*="col-"] { flex-basis: 80px; width: 80px !important; height: 4.5rem !important; }
}
