/* ==========================================================================
   光る会サイト 共通スタイル
   モバイルファースト。ベースはスマホ幅、min-width:900px でPC向けに拡張。
   配色は CSS変数で管理し、prefers-color-scheme:dark で切り替える。
   ========================================================================== */

:root {
  /* 基調色（既存HTMLの紺〜青系を踏襲） */
  --navy-900: #0d1b2a;
  --navy-700: #1b3a5c;
  --navy-500: #23557f;
  --blue-200: #9fc4e8;

  /* ライトテーマ */
  --bg: #ffffff;
  --bg-alt: #f2f6fa;
  --text: #1c2733;
  --text-muted: #55677a;
  --line: #d8e2ec;
  --link: #1b5a94;
  --card: #ffffff;
  --card-border: #d8e2ec;
  --header-bg: #0d1b2a;
  --header-text: #eaf2fa;
  --hero-bg-1: #0d1b2a;
  --hero-bg-2: #1b3a5c;
  --hero-text: #f2f7fc;
  --hero-sub: #b9d3ec;
  --accent: #23557f;
  --accent-strong: #1b3a5c;
  --accent-soft: #e5eef7;
  --quote-border: #9fc4e8;
  --btn-bg: #23557f;
  --btn-text: #ffffff;
  --focus: #1b5a94;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141e;
    --bg-alt: #101c29;
    --text: #dce6f1;
    --text-muted: #9fb2c5;
    --line: #263a4f;
    --link: #8fc1ee;
    --card: #12202f;
    --card-border: #263a4f;
    --header-bg: #0a1420;
    --header-text: #e6eff8;
    --hero-bg-1: #0a1420;
    --hero-bg-2: #14293f;
    --hero-text: #edf4fb;
    --hero-sub: #a9c6e4;
    --accent: #9fc4e8;
    --accent-strong: #bcd7ef;
    --accent-soft: #16283a;
    --quote-border: #3f6a94;
    --btn-bg: #2e6ca3;
    --btn-text: #f2f7fc;
    --focus: #8fc1ee;
  }
}

/* --------------------------------------------------------------------------
   リセットとベース
   -------------------------------------------------------------------------- */
* , *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic Medium", "游ゴシック Medium", YuGothic, "Yu Gothic",
    "游ゴシック体", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", sans-serif;
  font-size: 16.5px;
  line-height: 2.0;
  /* 日本語の禁則・折り返し */
  line-break: strict;
  word-break: normal;
  overflow-wrap: break-word;
}

/* ドロワー展開中は背面をスクロールさせない */
html.nav-open, html.nav-open body { overflow: hidden; }

h1, h2, h3, h4 { line-height: 1.6; margin: 0 0 0.6em; }
p { margin: 0 0 1.2em; }
ul, ol { margin: 0 0 1.2em; padding-left: 1.4em; }
li { margin-bottom: 0.55em; }

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

strong { color: var(--accent-strong); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 本文へスキップ */
.skip-link {
  position: absolute;
  left: 8px; top: -72px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 0 0 6px 6px;
  transition: top 0.15s ease-out;
}
.skip-link:focus { top: 0; }

/* --------------------------------------------------------------------------
   ヘッダーとナビゲーション
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  color: var(--header-text);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
html.nav-open .site-header { z-index: 70; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  min-height: 58px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--header-text);
  text-decoration: none;
  padding: 6px 0;
  min-height: 44px;
  align-items: center;
}
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.08em; }
.brand-sub { font-size: 0.78rem; color: var(--hero-sub); letter-spacing: 0.06em; }

/* ハンバーガーボタン（900px未満のみ表示） */
.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--header-text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
html.nav-open .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
html.nav-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
html.nav-open .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ドロワー（右からスライドイン） */
.site-nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  width: min(78vw, 320px);
  background: var(--header-bg);
  padding: 76px 8px 24px;
  padding-right: calc(8px + env(safe-area-inset-right));
  overflow-y: auto;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
html.nav-open .site-nav {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.25s ease;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav li { margin: 0; }
.site-nav a {
  display: block;
  padding: 12px 18px;
  min-height: 44px;
  color: var(--header-text);
  text-decoration: none;
  font-size: 1.02rem;
  border-radius: 8px;
}
.site-nav a:hover { background: rgba(159, 196, 232, 0.14); }
.site-nav a[aria-current="page"] {
  background: rgba(159, 196, 232, 0.2);
  font-weight: 700;
}

/* 暗幕 */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 10, 16, 0.55);
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  cursor: pointer;
}
.nav-backdrop[hidden] { display: none; }

/* --------------------------------------------------------------------------
   ヒーロー
   -------------------------------------------------------------------------- */
.hero {
  background: linear-gradient(150deg, var(--hero-bg-1) 0%, var(--hero-bg-2) 100%);
  color: var(--hero-text);
  padding: 44px 20px 48px;
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
}
.hero-inner { max-width: 880px; margin: 0 auto; }
.hero-eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  color: var(--hero-sub);
  margin-bottom: 1.1em;
}
.hero h1 {
  font-size: clamp(1.7rem, 6.4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.5;
  margin-bottom: 0.5em;
}
.hero-lead {
  font-size: 1.02rem;
  color: var(--hero-sub);
  margin-bottom: 1.4em;
}
.hero-promise {
  border: 1px solid rgba(159, 196, 232, 0.45);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 0 0 1.6em;
  background: rgba(13, 27, 42, 0.35);
}
.hero-promise p { margin: 0 0 0.4em; }
.hero-promise p:last-child { margin-bottom: 0; }
.hero-promise .promise-head {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--hero-sub);
}

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 22px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.btn-primary { background: var(--blue-200); color: #0d1b2a; }
.btn-ghost {
  border: 1px solid rgba(159, 196, 232, 0.6);
  color: var(--hero-text);
}

/* --------------------------------------------------------------------------
   セクション共通
   -------------------------------------------------------------------------- */
main {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.section {
  padding: 44px 20px;
}
.section-alt { background: var(--bg-alt); }
.section-inner { max-width: 880px; margin: 0 auto; }

.section-label {
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.3em;
}
.section h2 {
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.35em;
  margin-bottom: 1em;
}
.section h3 { font-size: 1.12rem; margin-top: 1.6em; }

.tagline {
  background: var(--navy-700);
  color: #eaf2fa;
  text-align: center;
  padding: 26px 20px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.tagline p { margin: 0; max-width: 880px; margin-inline: auto; }

/* カード類 */
.cards { display: grid; gap: 16px; grid-template-columns: 1fr; margin: 0 0 1.4em; }
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 18px 18px 8px;
}
.card h3 { margin-top: 0; }
.card-tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 8px;
  margin-bottom: 0.5em;
}
.card-tag-strong {
  background: var(--accent);
  color: var(--bg);
}

/* 数値カード */
.stat-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin-bottom: 1.4em; }
.stat {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 16px 14px;
  text-align: center;
}
.stat-value {
  display: block;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-strong);
  line-height: 1.3;
}
.stat-label { display: block; margin-top: 0.4em; font-size: 0.88rem; line-height: 1.7; }
.stat-source {
  display: block;
  margin-top: 0.5em;
  font-size: 0.74rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* 強調ボックス（定義文など） */
.emphasis-box {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 16px 18px;
  margin: 0 0 1.4em;
}
.emphasis-box p { margin: 0; }

/* 引用（会記など） */
.quote {
  border-left: 4px solid var(--quote-border);
  margin: 0 0 1.4em;
  padding: 4px 0 4px 16px;
}
.quote p { margin: 0 0 0.4em; }
.quote p:last-child { margin-bottom: 0; }
.quote-src {
  font-size: 0.82rem;
  color: var(--text-muted);
}

blockquote {
  border-left: 4px solid var(--quote-border);
  background: var(--bg-alt);
  margin: 0 0 1.4em;
  padding: 14px 16px;
  border-radius: 0 8px 8px 0;
}
blockquote p { margin-bottom: 0.9em; }
blockquote p:last-child { margin-bottom: 0; }

/* 表 */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 0.5em;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}
.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 0.92rem;
  line-height: 1.8;
}
.table-scroll caption {
  text-align: left;
  font-weight: 700;
  padding: 10px 12px 4px;
}
.table-scroll th, .table-scroll td {
  border-top: 1px solid var(--card-border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.table-scroll thead th {
  border-top: 0;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
/* 1列目（見出し列）が1文字ずつ折り返されないように列幅を確保する */
.table-scroll th[scope="row"],
.table-scroll td:first-child,
.table-scroll th:first-child {
  min-width: 9em;
}
.table-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1.4em;
}

/* ページ送りリンク */
.next-link { margin-top: 1.6em; }
.next-link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   読み物
   -------------------------------------------------------------------------- */
.article {
  max-width: 680px;
  margin: 0 auto;
  padding: 36px 20px 20px;
}
.series-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.3em;
}
.part-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.2em;
}
.article h1 {
  font-size: 1.55rem;
  line-height: 1.6;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5em;
  margin-bottom: 1.2em;
}
.article h1 .ep-sub {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 0.3em;
}

/* 場面転換の区切り */
.scene-break {
  text-align: center;
  color: var(--text-muted);
  letter-spacing: 0.8em;
  padding-left: 0.8em; /* letter-spacing の右ズレ補正 */
  margin: 2.2em 0;
  font-size: 1rem;
}

/* 現代への視線・出典 */
.article section h2 {
  font-size: 1.08rem;
  margin-top: 2.4em;
  border-left: 4px solid var(--accent);
  border-bottom: 1px solid var(--line);
  padding: 0.15em 0 0.3em 0.6em;
}
.article .modern-note h2::before { content: "◆ "; color: var(--accent); }
.article .sources { font-size: 0.83rem; line-height: 1.85; color: var(--text-muted); }
.article .sources h2 { color: var(--text); }
.article .sources ul { padding-left: 1.3em; }

/* 各話下部ナビ */
.ep-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin: 2.6em 0 0.6em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line);
}
.ep-nav a, .ep-nav span.ep-nav-empty {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 8px;
}
.ep-nav .ep-nav-prev { margin-right: auto; }
.ep-nav .ep-nav-next { margin-left: auto; }

/* 読み物目次 */
.toc-part {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 18px 18px 14px;
  margin-bottom: 20px;
}
.toc-part h2 {
  border-bottom: 1px solid var(--line);
  font-size: 1.2rem;
  padding-bottom: 0.4em;
}
.toc-part ol {
  list-style: none;
  margin: 0 0 0.8em;
  padding: 0;
}
.toc-part ol a {
  display: block;
  padding: 9px 6px;
  min-height: 44px;
  text-decoration: none;
  border-radius: 6px;
}
.toc-part ol a:hover { background: var(--accent-soft); }
.toc-ep-no { font-weight: 700; color: var(--accent); margin-right: 0.6em; }
.toc-ep-sub { display: block; font-size: 0.84rem; color: var(--text-muted); margin-left: 3.4em; }
.toc-pdf { font-size: 0.9rem; margin: 0; }
.toc-note {
  font-size: 0.84rem;
  color: var(--text-muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

/* --------------------------------------------------------------------------
   フッター・上へ戻る
   -------------------------------------------------------------------------- */
.site-footer {
  background: var(--navy-900);
  color: #d5e4f2;
  text-align: center;
  padding: 34px 20px;
  padding-bottom: calc(34px + env(safe-area-inset-bottom));
  margin-top: 48px;
}
.footer-slogan {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.5em;
}
.footer-copy { font-size: 0.8rem; color: #9db4ca; margin: 0; }

.to-top {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.to-top[hidden] { display: none; }

/* --------------------------------------------------------------------------
   PC向け拡張（900px以上）
   -------------------------------------------------------------------------- */
@media (min-width: 900px) {
  .nav-toggle { display: none; }

  .site-nav {
    position: static;
    width: auto;
    padding: 0;
    background: transparent;
    transform: none;
    visibility: visible;
    overflow: visible;
    transition: none;
    box-shadow: none;
  }
  .site-nav ul { display: flex; gap: 2px; }
  .site-nav a { padding: 10px 14px; font-size: 0.95rem; }
  .nav-backdrop { display: none !important; }

  .hero { padding: 84px 24px 88px; }
  .hero-lead { font-size: 1.15rem; }

  .section { padding: 64px 24px; }
  .section h2 { font-size: 1.65rem; }

  .cards { grid-template-columns: repeat(3, 1fr); }
  .cards-2 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-value { font-size: 1.9rem; }

  .table-note { display: none; }
  .table-scroll table { font-size: 0.95rem; }

  .article { padding-top: 56px; }
  .article h1 { font-size: 1.8rem; }
}

/* --------------------------------------------------------------------------
   アニメーション抑制
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
}
