/* ============================================================
   OH3 統計ページ共通スタイル（ranking/ ・ muni/）
   lp.html (2026-09 刷新版) と同じ設計言語。
   白地・一色のアクセント・装飾なし。数字と表で語る。

   ⚠ ガイドページの oh3-static.css（Dark Cartographic）とは別系統。
     統計ページは「読ませる表」なので、LP と同じ白地に合わせている。
     ここを触ると ranking/*.html と muni/*.html の全ページが変わる。
     HTML 側は scripts/stats/build-muni-rankings.mjs ・ build-muni-pages.mjs が生成する。
   ============================================================ */

:root {
    --bg: #ffffff;
    --bg-alt: #f5f6f8;
    --line: #dfe3e8;
    --line-strong: #c5ccd4;
    --text: #1f2933;
    --text-sub: #52606d;
    --text-muted: #7b8794;
    --accent: #2f5fa8;          /* 公開自治体の青（LP・地図と共通） */
    --accent-dark: #244c88;
    --accent-soft: #e8eef8;
    --primary: #475569;         /* OH3 プライマリ（スレート） */
    --primary-dark: #334155;

    --font: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Helvetica Neue", Arial, sans-serif;
    --maxw: 1120px;
    --gutter: 32px;
    --radius: 6px;

    color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-padding-top: 72px; }
html, body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 16px;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body { overflow-x: hidden; }
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
strong { font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
/* 表が主役のページは、行が横に伸びすぎないよう少し狭く */
.wrap--narrow { max-width: 900px; }
.num { font-variant-numeric: tabular-nums; }

/* ============ Top bar ============ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(180%) blur(6px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 24px;
}
.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand small { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.header-links {
    display: flex;
    align-items: center;
    gap: 22px;
    font-size: 14px;
}
.header-links a { color: var(--text-sub); }
.header-links a:hover { color: var(--text); text-decoration: none; }
.header-links a.current { color: var(--text); font-weight: 700; }
.nav-cta {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    border-radius: var(--radius);
}
.nav-cta:hover { background: var(--primary-dark); text-decoration: none; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 22px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.3;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--bg-alt); }

/* ============ Breadcrumb ============ */
.crumb {
    font-size: 12.5px;
    color: var(--text-muted);
    padding: 16px 0 0;
    line-height: 1.7;
}
.crumb a { color: var(--text-sub); }
.crumb span { margin: 0 6px; color: var(--line-strong); }

/* ============ Page head ============ */
.page-head { padding: 24px 0 36px; border-bottom: 1px solid var(--line); }
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 14px;
}
.eyebrow::before {
    content: "";
    width: 10px; height: 10px;
    background: var(--accent);
    border-radius: 2px;
}
.eyebrow .dim { color: var(--text-muted); font-weight: 400; }
.page-head h1 {
    font-size: clamp(25px, 3.1vw, 34px);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: 0.01em;
    margin-bottom: 16px;
    text-wrap: pretty;
}
.lede {
    font-size: 15.5px;
    color: var(--text-sub);
    max-width: 52em;
}
.lede strong { color: var(--text); }

/* 母数・年・中央値などの数字帯。LP のヒーロー統計と同じ形 */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    margin-top: 26px;
}
.stat-strip > div { padding: 16px 20px; border-right: 1px solid var(--line); }
.stat-strip > div:last-child { border-right: none; }
.stat-num {
    font-size: 27px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.stat-num small { font-size: 14px; font-weight: 500; color: var(--text-sub); margin-left: 3px; }
.stat-label { font-size: 12.5px; color: var(--text-sub); margin-top: 6px; line-height: 1.5; }

/* ============ Section ============ */
section { padding: 44px 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: none; }
section > h2 {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 6px;
    text-wrap: pretty;
}
.section-sub { color: var(--text-sub); font-size: 14.5px; margin-bottom: 22px; }
section > h2 + .table-wrap,
section > h2 + table,
section > h2 + .grid,
section > h2 + p { margin-top: 18px; }

.prose p { color: var(--text-sub); font-size: 15.5px; max-width: 52em; }
.prose p + p { margin-top: 14px; }

/* ============ Table ============ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
    background: #fff;
}
th, td {
    border: 1px solid var(--line);
    padding: 9px 14px;
    text-align: left;
    vertical-align: middle;
    line-height: 1.6;
}
thead th {
    background: var(--bg-alt);
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    font-size: 13.5px;
}
/* ⚠ thead を position:sticky にしない。.table-wrap の overflow-x:auto が
   スクロールコンテナになるため、見出しが表の途中に貼り付いて1行目を隠す。 */
tbody tr:hover td { background: #fafbfc; }
td { color: var(--text-sub); }
td a { color: var(--accent); }
td.rank {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 4.6em;
    color: var(--text-muted);
    font-size: 13.5px;
}
td.rank b { font-size: 16px; color: var(--text); font-weight: 700; }
/* 自治体名は折り返さない。狭い画面で「音威子府村」が3行に割れて読めなくなる */
td.name { color: var(--text); font-weight: 500; white-space: nowrap; }
td.pref { color: var(--text-muted); font-size: 13.5px; white-space: nowrap; width: 7em; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); font-weight: 500; }
thead th.num { text-align: right; }

/* 上位3件だけ、青の下地で目線を止める（メダル等の装飾はしない） */
tbody tr.is-top td { background: var(--accent-soft); }
tbody tr.is-top:hover td { background: #dee8f6; }

/* ============ Card grid ============ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
}
.grid a {
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 15px 17px;
    line-height: 1.6;
    color: var(--text);
}
.grid a:hover { border-color: var(--line-strong); background: var(--bg-alt); text-decoration: none; }
.grid a strong { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.grid a span { display: block; font-size: 12.5px; color: var(--text-sub); margin-top: 3px; }

/* 都道府県リンクのように短い項目を並べるとき */
/* 47都道府県を並べる。スマホで1列にすると縦に長すぎるので2列に収まる幅にする */
.grid--tight { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid--tight a { padding: 11px 14px; }
.grid--tight a strong { font-size: 14px; }

/* ============ 指標カード（市区町村の個票ページ） ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 16px 18px 12px;
}
.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.card-label { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.card-value { font-size: 14px; font-weight: 700; color: var(--text-sub); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* ▲▼は「全国で高いほうに外れている／低いほうに外れている」の印。
   赤緑ではなく、LPの青と、それと釣り合う落ち着いた赤茶で示す */
.dir { font-size: 11px; line-height: 1; }
.dir.high { color: #a4553f; }
.dir.low { color: var(--accent); }
.rank { display: flex; align-items: baseline; gap: 2px; }
.rank-num { font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; color: var(--text); font-variant-numeric: tabular-nums; }
.rank-unit { font-size: 14px; font-weight: 700; color: var(--text); }
.rank-total { font-size: 12.5px; color: var(--text-muted); margin-left: 6px; }
.sub { font-size: 12.5px; color: var(--text-sub); line-height: 1.75; }
.year { text-align: right; font-size: 11.5px; color: var(--text-muted); }
.card .caveat { margin: 10px 0 4px; padding: 8px 12px; font-size: 12.5px; line-height: 1.7; }

/* 類型（「◯◯なまち」） */
.type { padding: 13px 0; border-bottom: 1px solid var(--line); }
.type:first-child { padding-top: 0; }
.type:last-child { border-bottom: none; padding-bottom: 0; }
.type strong { display: block; font-size: 15.5px; }
.type span { font-size: 13.5px; color: var(--text-sub); }

/* 読みどころ（AIが書いた本文） */
.comment {
    margin: 0;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    background: var(--bg-alt);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 15.5px;
    line-height: 1.95;
    color: var(--text);
}

/* Wikimedia Commons の写真 */
.photo { margin: 0; }
.photo img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.photo figcaption { font-size: 12px; color: var(--text-muted); margin-top: 8px; line-height: 1.7; }

/* ============ Notes / caveats ============ */
.note { font-size: 13px; color: var(--text-muted); line-height: 1.85; max-width: 60em; }
.note + .note { margin-top: 10px; }
.caveat {
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    background: var(--bg-alt);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 12px 16px;
    margin: 18px 0;
    font-size: 13.5px;
    color: var(--text-sub);
    line-height: 1.8;
    max-width: 60em;
}

/* ============ CTA band ============ */
.cta-band { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 44px 0; }
.cta-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    flex-wrap: wrap;
}
.cta-band h2 { font-size: clamp(20px, 2.4vw, 25px); font-weight: 700; line-height: 1.45; }
.cta-band p { color: var(--text-sub); margin-top: 8px; font-size: 14.5px; max-width: 46em; }
.cta-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ============ Footer ============ */
.footer { padding: 40px 0 32px; font-size: 13.5px; color: var(--text-sub); }
.footer h5 { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.footer-legal { font-size: 12px; color: var(--text-muted); margin-top: 12px; max-width: 62em; line-height: 1.8; }
.footer-nav-line { line-height: 2.1; margin-top: 16px; }
.footer-nav-line a { color: var(--text-sub); }
.footer-base {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-muted);
}
.footer-base a { color: var(--text-muted); }

/* ============ Responsive ============ */
@media (max-width: 1080px) {
    .topbar { position: static; }
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 10px; }
    .header-links { order: 3; width: 100%; gap: 14px; flex-wrap: wrap; }
    .nav-cta { order: 2; margin-left: auto; }
}
@media (max-width: 720px) {
    :root { --gutter: 18px; }
    html, body { font-size: 15.5px; }
    .page-head { padding: 18px 0 28px; }
    section { padding: 34px 0; }
    /* 2列に割れると「1,184.7万 / 円」のように数字が折り返す。縦積みにする */
    .stat-strip { grid-template-columns: 1fr; }
    .stat-strip > div { border-right: none; border-bottom: 1px solid var(--line); }
    .stat-num { font-size: 25px; }
    .stat-strip > div:last-child { border-bottom: none; }
    table { font-size: 13.5px; }
    th, td { padding: 8px 9px; }
    td.pref { width: auto; }
    /* 見出しを nowrap のままにすると「課税対象所得（納税義務者1人当たり）」で表が
       画面幅を超え、肝心の数値が右に隠れる。スマホでは見出しだけ折り返させる */
    thead th { white-space: normal; }
    td.rank { width: 3.2em; }
    .footer-base { flex-direction: column; }
    .btn { width: 100%; }
    .cta-actions { width: 100%; }
}
