/*
 * Learning Index スタイル
 * 雑誌の目次を模した1カラム構成。依存ライブラリなし。
 * 配色はライト/ダーク両対応で、本文テキストはコントラスト比AA以上を確保する。
 */

:root {
  /* 紙面を思わせる暖色系のライトテーマ */
  --paper: #faf6ef;
  --ink: #211d18;
  --ink-soft: #5c554b;
  --rule: #d8d0c2;
  --leader: #b9af9d;
  --accent: #a03a15;
  --chip-edge: rgba(33, 29, 24, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1712;
    --ink: #ece5d8;
    --ink-soft: #b3a795;
    --rule: #3a352c;
    --leader: #55503f;
    --accent: #de7f4e;
    --chip-edge: rgba(236, 229, 216, 0.3);
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  border-top: 6px solid var(--ink);
}

/* 見出し類は明朝体で組み、誌面らしい表情をつける */
.masthead-title,
.masthead-sub,
.chapter-no,
h2 {
  font-family: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho",
    YuMincho, "Noto Serif JP", "Times New Roman", serif;
}

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px 72px;
}

a {
  color: inherit;
}

/* ---------- ヘッダー ---------- */

.masthead {
  padding: 64px 0 40px;
  border-bottom: 1px solid var(--ink);
}

.masthead-overline {
  font-size: 13px;
  letter-spacing: 0.35em;
  color: var(--accent);
  margin-bottom: 18px;
}

.masthead-title {
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.masthead-sub {
  margin-top: 10px;
  font-size: 15px;
  letter-spacing: 0.5em;
  color: var(--ink-soft);
}

.masthead-lede {
  margin-top: 28px;
  max-width: 40em;
  color: var(--ink);
}

.masthead-meta {
  margin-top: 20px;
  padding-top: 10px;
  display: inline-block;
  border-top: 3px solid var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

/* ---------- 章（セクション） ---------- */

.chapter {
  margin-top: 72px;
}

.chapter-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  column-gap: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink);
}

.chapter-no {
  font-size: 56px;
  line-height: 0.9;
  color: var(--accent);
  font-weight: 500;
}

.chapter-titles h2 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.chapter-lede {
  margin-top: 8px;
  max-width: 38em;
  font-size: 14px;
  color: var(--ink-soft);
}

.chapter-count {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------- 目次の行 ---------- */

.entries {
  list-style: none;
}

.entries > li {
  border-bottom: 1px solid var(--rule);
}

.entry {
  display: block;
  padding: 18px 4px;
  text-decoration: none;
}

.entry-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 言語ごとの識別色を示す小さな面 */
.chip {
  flex: none;
  width: 12px;
  height: 12px;
  background: var(--c, var(--ink-soft));
  border: 1px solid var(--chip-edge);
}

.entry-name {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.02em;
}

/* 目次らしい点線のリーダー罫 */
.leader {
  flex: 1 1 auto;
  min-width: 24px;
  border-bottom: 1px dotted var(--leader);
  margin: 0 6px;
  transform: translateY(0.2em);
}

/* バッジと矢印をひとまとまりにして、折り返し時も一体で動かす */
.entry-tail {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.badge {
  flex: none;
  font-size: 11px;
  letter-spacing: 0.12em;
  line-height: 1;
  padding: 5px 9px;
  border: 1px solid var(--ink-soft);
  border-radius: 2px;
  color: var(--ink-soft);
}

.badge-planned {
  border-style: dashed;
  border-color: var(--accent);
  color: var(--accent);
}

.arrow {
  flex: none;
  color: var(--ink-soft);
  font-size: 15px;
  transition: transform 0.15s ease, color 0.15s ease;
}

.entry-desc {
  display: block;
  margin: 6px 0 0 22px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-soft);
}

/* ホバー時はアクセント色の下線で示す */
a.entry:hover .entry-name,
a.entry:focus-visible .entry-name {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

a.entry:hover .arrow,
a.entry:focus-visible .arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

a.entry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* 準備中の行は色を落とすが、AAを満たす濃さは保つ */
.is-planned .entry-name {
  color: var(--ink-soft);
  font-weight: 500;
}

.is-planned .chip {
  opacity: 0.45;
}

/* ---------- フッター ---------- */

.colophon {
  margin-top: 88px;
  padding-top: 20px;
  border-top: 1px solid var(--ink);
  font-size: 14px;
  color: var(--ink-soft);
}

.colophon a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.colophon a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.colophon-note {
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 0.14em;
}

/* ---------- モバイル ---------- */

@media (max-width: 600px) {
  .masthead {
    padding-top: 48px;
  }

  .chapter {
    margin-top: 56px;
  }

  .chapter-head {
    grid-template-columns: auto 1fr;
    row-gap: 8px;
  }

  .chapter-no {
    font-size: 40px;
  }

  .chapter-count {
    grid-column: 2;
    justify-self: start;
  }

  .leader {
    display: none;
  }

  .entry-main {
    flex-wrap: wrap;
  }

  .entry-tail,
  .entry-main > .badge {
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arrow {
    transition: none;
  }
}
