/* 政府統計データ可視化サイト
 *
 * 依存なしの手書き CSS。ライト／ダークは自動反転ではなく、それぞれ選んだ値を持つ。
 * グラフの色（--series-1 など）は検証済みのカラーパレットから取っており、
 * ライト面・ダーク面それぞれで別のステップを選んである（単純な反転ではない）。
 */

:root {
  color-scheme: light dark;

  --surface-0: #ffffff;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ee;
  --border: #dedcd6;

  --text-primary: #16150f;
  --text-secondary: #52514e;
  --text-muted: #75736c;

  --link: #1a5fb4;
  --link-hover: #123f78;

  /* データビジュアライゼーション用のトークン */
  --series-1: #2a78d6;
  --viz-grid: #e4e2dc;
  --viz-axis-text: #52514e;

  --max-width: 44rem;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --border: #35342f;

    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;

    --link: #7fb2f0;
    --link-hover: #a9cbf6;

    /* ダーク面用に選び直した値（ライトの色をそのまま使うと沈む） */
    --series-1: #3987e5;
    --viz-grid: #33322d;
    --viz-axis-text: #c3c2b7;
  }
}

:root[data-theme="dark"] {
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --border: #35342f;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #9a998f;
  --link: #7fb2f0;
  --link-hover: #a9cbf6;
  --series-1: #3987e5;
  --viz-grid: #33322d;
  --viz-axis-text: #c3c2b7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 17px;
  line-height: 1.85;
  /* 日本語は単語区切りが無いので、句読点前後で折り返す指定を入れる */
  word-break: normal;
  overflow-wrap: anywhere;
  line-break: strict;
}

.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }

.skip-link {
  position: absolute; left: -9999px;
  background: var(--surface-2); padding: .5rem 1rem;
}
.skip-link:focus { left: 1rem; top: 1rem; z-index: 10; }

/* ---- ヘッダ / フッタ ---- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  padding: .75rem 0;
  margin-bottom: 2rem;
}
.site-title { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--text-primary); }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .35rem; font-size: .85rem; }
.site-nav a { color: var(--text-secondary); text-decoration: none; }
.site-nav a:hover { color: var(--link); text-decoration: underline; }

.site-footer {
  margin-top: 4rem; padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  font-size: .85rem; color: var(--text-secondary);
}
.site-footer .disclaimer { margin-top: 0; }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.copyright { color: var(--text-muted); }

/* ---- 見出し ---- */
h1 { font-size: 1.6rem; line-height: 1.5; margin: 0 0 .75rem; }
h2 { font-size: 1.25rem; margin: 2.5rem 0 .75rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }

.lede { color: var(--text-secondary); }

/* ---- 記事 ---- */
.breadcrumb { font-size: .8rem; color: var(--text-muted); margin: 0 0 .5rem; }
.article-header { margin-bottom: 1.5rem; }

.article-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: .35rem 1rem; margin: 1rem 0; padding: .85rem 1rem;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .85rem;
}
.article-meta div { display: flex; gap: .5rem; }
.article-meta dt { color: var(--text-muted); flex: 0 0 auto; }
.article-meta dd { margin: 0; color: var(--text-primary); }

.article-body ul { padding-left: 1.25rem; }
.article-body li { margin: .3rem 0; }

.toc {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .5rem 1.25rem 1rem; font-size: .9rem;
}
.toc h2 { font-size: .95rem; border: none; margin: .75rem 0 .25rem; padding: 0; }
.toc ul { list-style: none; padding-left: 0; margin: 0; }
.toc .toc-l3 { padding-left: 1rem; }

.faq-item { margin: 1rem 0; }
.faq dt { font-weight: 600; }
.faq dd { margin: .25rem 0 0; color: var(--text-secondary); }

.source { font-size: .9rem; color: var(--text-secondary); }

/* ---- カード一覧 ---- */
.card-list { list-style: none; padding: 0; display: grid; gap: 1rem; }
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; background: var(--surface-1);
}
.card > a { font-weight: 600; text-decoration: none; }
.card > a:hover { text-decoration: underline; }
.card-meta { margin: .25rem 0 .5rem; font-size: .8rem; color: var(--text-muted); }
.card-excerpt { margin: 0; font-size: .9rem; color: var(--text-secondary); }

.field-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.field-list .count { color: var(--text-muted); font-size: .8rem; }

/* ---- グラフ ---- */
.viz-figure {
  margin: 2rem 0; padding: 1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-1);
}
.viz-chart { display: block; width: 100%; height: auto; }

/* 線は 2px、端は丸。塗りは持たない（面グラフにすると軸を切った影響が誇張される） */
.viz-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* 点は面と同色のリングを持たせ、線と重なっても輪郭が消えないようにする */
.viz-dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
/* 軸ラベルと値ラベルは系列色ではなくテキスト色を着る */
.viz-axis-label { fill: var(--viz-axis-text); font-size: 11px; font-family: inherit; }
.viz-value-label { fill: var(--text-primary); font-size: 12px; font-weight: 600; font-family: inherit; }

.viz-caption { margin-top: .5rem; font-size: .8rem; color: var(--text-muted); }

.viz-table { margin-top: .75rem; font-size: .85rem; }
.viz-table summary { cursor: pointer; color: var(--text-secondary); }
.viz-table table { border-collapse: collapse; margin-top: .5rem; width: 100%; }
.viz-table th, .viz-table td { border: 1px solid var(--border); padding: .3rem .6rem; text-align: left; }
.viz-table td { text-align: right; font-variant-numeric: tabular-nums; }
.viz-table thead th { background: var(--surface-2); }

/* 強制カラーモード（ハイコントラスト）では系統色が失われるので輪郭で見せる */
@media (forced-colors: active) {
  .viz-line { stroke: CanvasText; }
  .viz-dot { fill: CanvasText; stroke: Canvas; }
}

/* ---- 広告枠 ---- */
/* 最小高さを確保して、広告の読み込みで本文が飛ばないようにする（CLS 対策）。
   広告が配信されない場合でも枠が潰れるだけで崩れない。 */
.ad-slot { margin: 2rem 0; min-height: 100px; }
.ad-slot--middle { margin: 2.5rem 0; }
.ad-label {
  display: block; font-size: .7rem; color: var(--text-muted);
  letter-spacing: .05em; margin-bottom: .25rem;
}

/* ---- プレビュー（レビュー用） ---- */
.preview-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 2rem 0; background: var(--surface-1);
}
.alert { border-left: 3px solid var(--border); padding: .5rem .75rem; font-size: .85rem; }
.alert--ng { border-left-color: #e34948; }
.alert--warn { border-left-color: #eda100; }
.preview-meta-description { font-size: .85rem; color: var(--text-secondary); }

@media (max-width: 32rem) {
  body { font-size: 16px; }
  h1 { font-size: 1.35rem; }
}

/* ---- 運営者情報 ---- */
.operator {
  display: grid; gap: .35rem 1rem; margin: 1rem 0; padding: .85rem 1rem;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .9rem;
}
.operator div { display: flex; gap: .75rem; flex-wrap: wrap; }
.operator dt { color: var(--text-muted); flex: 0 0 6.5rem; }
.operator dd { margin: 0; }
