/* 令和7年国勢調査 都道府県別の人口 — 図表ページ
   外部の書体・ライブラリを読まない（オフラインでも同じ表示）。色の組合せはすべてコントラスト比 4.5:1 以上 */

:root {
  --bg: #fafbfc;
  --surface: #fff;
  --fg: #15161e;
  --fg-2: #4d4f5c;
  --fg-3: #5f6170;
  --rule: rgba(21, 22, 30, 0.12);
  --rule-strong: rgba(21, 22, 30, 0.24);
  --accent: #3f52d4;
  --accent-soft: #e3e6fd;
  --focus: #3f52d4;
  /* 増減率の 5 段階（増加は青、減少は減り方が大きいほど濃い橙） */
  --r0: #3f52d4;
  --r1: #fdebd3;
  --r2: #f8c98f;
  --r3: #e98a3c;
  --r4: #a8460f;
  --bar: #5266eb;
  --bar-neg: #c2601b;
  --font: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Yu Gothic', 'Meiryo', system-ui, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 16px; line-height: 1.8; letter-spacing: 0.02em;
  font-feature-settings: 'palt' 0;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 8px 14px; background: var(--fg); color: #fff; border-radius: 6px; }
.skip:focus { top: 12px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* 制作例であることの表示（実際の納品では外す） */
.sample { background: #15161e; color: #ededf3; font-size: 13px; }
.sample .wrap { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; padding-top: 8px; padding-bottom: 8px; }
.sample a { color: #c5cbff; }

.top { border-bottom: 1px solid var(--rule); background: var(--surface); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.top__title { margin: 0; font-size: 15px; font-weight: 600; }
.top__lang { font-size: 14px; }

main { padding-bottom: 96px; }
.intro { padding: 56px 0 32px; }
.intro__kicker { margin: 0; font-size: 14px; color: var(--fg-2); }
h1 { margin: 6px 0 0; font-size: clamp(28px, 4.4vw, 42px); line-height: 1.35; font-weight: 700; letter-spacing: 0.01em; }
.intro__lead { margin: 18px 0 0; max-width: 46em; font-size: 17px; color: var(--fg-2); }
.intro__lead strong { color: var(--fg); }

.figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 32px 0 0; padding: 0; }
.figs div { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; }
.figs dt { font-size: 13px; color: var(--fg-2); }
.figs dd { margin: 4px 0 0; font-size: clamp(20px, 2.4vw, 26px); font-weight: 700; line-height: 1.3; }
.figs dd small { font-size: 13px; font-weight: 400; color: var(--fg-2); margin-left: 2px; }
@media (max-width: 760px) { .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.toc { margin: 28px 0 0; padding: 14px 18px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.toc h2 { margin: 0; font-size: 14px; color: var(--fg-2); }
.toc ol { margin: 4px 0 0; padding-left: 1.4em; display: flex; flex-wrap: wrap; gap: 0 28px; }

section.block { margin-top: 64px; }
.block > h2 { margin: 0; font-size: clamp(21px, 2.6vw, 26px); line-height: 1.45; }
.block__lead { margin: 8px 0 0; color: var(--fg-2); max-width: 46em; }

figure { margin: 20px 0 0; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: clamp(16px, 2.4vw, 28px); }
figcaption { font-size: 14px; color: var(--fg-2); margin-top: 12px; }
.fig__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.fig__title { margin: 0; font-size: 16px; font-weight: 600; }

/* 切り替えボタン */
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 999px; padding: 3px; gap: 2px; background: var(--bg); }
.seg button {
  font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--fg); padding: 6px 14px;
  border-radius: 999px; cursor: pointer; min-height: 36px;
}
.seg button[aria-pressed='true'] { background: var(--fg); color: #fff; }
.seg button:hover:not([aria-pressed='true']) { background: var(--accent-soft); }

/* 図1 棒グラフ */
.bars { margin-top: 16px; }
.bars svg { width: 100%; height: auto; overflow: visible; }
.bars text { font-family: var(--font); fill: var(--fg); }
.bars .lab { font-size: 13px; }
.bars .val { font-size: 12px; fill: var(--fg-2); font-variant-numeric: tabular-nums; }
.bars .axis { stroke: var(--rule-strong); }
.bars .grid { stroke: var(--rule); }
.bars .tick { font-size: 11px; fill: var(--fg-3); }
.bars rect { transition: y 0.5s cubic-bezier(0.2, 1, 0.4, 1), width 0.5s cubic-bezier(0.2, 1, 0.4, 1), x 0.5s cubic-bezier(0.2, 1, 0.4, 1); }
.bars g.row { transition: transform 0.5s cubic-bezier(0.2, 1, 0.4, 1); }
.bars g.row.is-hl .lab { font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .bars rect, .bars g.row { transition: none; } }

/* 図2 タイルグリッド地図 */
.mapwrap { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr); gap: 24px; align-items: start; margin-top: 16px; }
@media (max-width: 860px) { .mapwrap { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); grid-template-rows: repeat(12, auto); gap: 4px; }
.tile {
  font: inherit; aspect-ratio: 1; border: 1px solid rgba(21, 22, 30, 0.08); border-radius: 6px; padding: 2px; cursor: pointer;
  display: grid; place-content: center; text-align: center; line-height: 1.15; color: var(--fg); min-width: 0;
}
.tile span { display: block; font-size: clamp(8px, 1.05vw, 12px); white-space: nowrap; letter-spacing: -0.04em; }
.tile span.is-long { letter-spacing: -0.1em; font-size: clamp(7px, 0.95vw, 11px); }
.tile b { display: block; font-size: clamp(8px, 1vw, 11px); font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 1px; }
.tile[data-bin='0'] { background: var(--r0); color: #fff; }
.tile[data-bin='1'] { background: var(--r1); }
.tile[data-bin='2'] { background: var(--r2); }
.tile[data-bin='3'] { background: var(--r3); color: #15161e; }
.tile[data-bin='4'] { background: var(--r4); color: #fff; }
.tile[aria-pressed='true'] { outline: 3px solid var(--fg); outline-offset: 1px; }
.tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; z-index: 1; }
@media (max-width: 520px) { .tile b { display: none; } .tiles { gap: 3px; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--fg-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(21, 22, 30, 0.12); }

.detail { border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; background: var(--bg); }
.detail h3 { margin: 0; font-size: 20px; }
.detail dl { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 14px; }
.detail dt { color: var(--fg-2); }
.detail dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail p { margin: 12px 0 0; font-size: 14px; }
.detail .hint { color: var(--fg-2); }

/* 図3 市区町村 */
.muni__ctl { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; margin-top: 16px; }
.muni__ctl label { display: grid; gap: 4px; font-size: 14px; color: var(--fg-2); }
select {
  font: inherit; font-size: 16px; min-height: 44px; padding: 6px 36px 6px 12px; border-radius: 8px; border: 1px solid var(--rule-strong);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2315161e' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none; color: var(--fg);
}
.muni__sum { margin: 12px 0 0; font-size: 14px; color: var(--fg-2); }
.muni__list { margin-top: 12px; max-height: 560px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.muni__list table { margin: 0; }
.muni__list thead th { position: sticky; top: 0; z-index: 1; }
.spark { display: inline-block; height: 10px; border-radius: 2px; vertical-align: middle; }
.spark--pos { background: var(--bar); }
.spark--neg { background: var(--bar-neg); }
.sparkcell { width: 34%; }
.sparkcell div { position: relative; height: 14px; }
.sparkcell .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--rule-strong); }
.sparkcell .spark { position: absolute; top: 2px; }

/* 表 */
.tablewrap { margin-top: 16px; overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
caption { text-align: left; padding: 14px 16px 6px; font-weight: 600; font-size: 15px; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
thead th { background: #f1f2f6; font-weight: 600; text-align: right; vertical-align: bottom; font-size: 13px; line-height: 1.4; }
thead th:first-child, thead th.l { text-align: left; }
tbody th { text-align: left; font-weight: 500; }
td { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f6f7fb; }
tr.total th, tr.total td { font-weight: 700; background: #f6f7fb; border-top: 2px solid var(--rule-strong); }
.neg { color: #a33f00; }
.sortbtn { font: inherit; font-weight: 600; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: inherit; }
.sortbtn::after { content: ''; display: inline-block; width: 0.9em; }
th[aria-sort='descending'] .sortbtn::after { content: ' ▼'; }
th[aria-sort='ascending'] .sortbtn::after { content: ' ▲'; }

.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 16px 0 0; padding: 0; list-style: none; }
.dl a { display: block; height: 100%; padding: 16px 18px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--fg); }
.dl a:hover { border-color: var(--accent); }
.dl b { display: block; color: var(--accent); }
.dl span { display: block; font-size: 13px; color: var(--fg-2); margin-top: 2px; }

.notes { margin: 12px 0 0; padding-left: 1.4em; font-size: 14px; color: var(--fg-2); }
.notes li + li { margin-top: 4px; }
.source { margin-top: 16px; padding: 16px 18px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); font-size: 14px; }
.source p { margin: 0; }
.source p + p { margin-top: 6px; }

.tip {
  position: fixed; z-index: 20; pointer-events: none; background: #15161e; color: #fff; font-size: 13px; line-height: 1.5;
  padding: 8px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); opacity: 0; transition: opacity 0.12s;
  font-variant-numeric: tabular-nums; max-width: 240px;
}
.tip.on { opacity: 1; }

.foot { border-top: 1px solid var(--rule); padding: 28px 0 40px; font-size: 13px; color: var(--fg-2); }
.foot p { margin: 0; }

@media print {
  .sample, .skip, .seg, .top__lang, .tip { display: none !important; }
  body { background: #fff; }
  .card, .tablewrap { break-inside: avoid; }
  .muni__list { max-height: none; overflow: visible; }
}
