/* タイピング練習コース /typing/（ハブ＋教材ページ）のページ固有スタイル。
   css/style.css → css/learn.css の後に読む。
   ページ枠・サブナビ・白カード・表の基本・つぎの一歩・ハブ見出し・ボタンは css/learn.css の共通部品
   （learn-page / learn-subnav / learn-section / learn-cta / learn-hero / btn-learn）を使い、ここには
   キーボード図・ローマ字表・章カード・学年カード・ミッション・段位表・記録用紙・印刷だけを置く。
   色は :root のトークンを使う。タイピング固有なのは「キーの強調」の赤と「段」の紫の2つだけ */

.typing-page {
  --typing-accent: #C0392B;   /* 押すキー・目標の強調。学ぶ導線の緑と混ざらないよう赤 */
  --typing-dan: #8E44AD;      /* 段位表で「段」を「級」と見分ける */
}
.typing-page .learn-lead b, .typing-page b { color: var(--typing-accent); font-weight: 700; }
.typing-page .note { color: var(--text-sub); font-size: 0.88rem; line-height: 1.7; margin: 0.6rem 0 0; }
.typing-page kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.35em;
  margin: 0 0.08em;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.88em;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
}
.typing-page code { background: var(--brand-tint); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.9em; }

/* ---- 箇条書きの変種 ---- */
.check-list { list-style: none; padding-left: 0.2rem; }
.check-list li { padding-left: 0.2rem; }
.steps-list li { padding-left: 0.2rem; }
.steps-list li::marker { color: var(--brand); font-weight: 700; }

/* ---- 表の変種（基本の罫線・見出し地は learn.css の .learn-page table） ---- */
.table-wrap { overflow-x: auto; margin: 0.5rem 0; }
.typing-page thead th { white-space: nowrap; }
.ex-table td:nth-child(2) { font-family: var(--font-mono); white-space: nowrap; }
.data-table td:first-child { white-space: nowrap; }
.data-table small { color: var(--text-weak); }
.goal-table td:first-child, .conv-table td:first-child { white-space: nowrap; font-weight: 700; color: var(--brand-dark); }
.ng-table td:first-child { white-space: nowrap; }
.ng-table small { color: var(--text-weak); font-weight: 400; }
.plan-table td:first-child { white-space: nowrap; font-weight: 700; text-align: center; color: var(--brand-dark); background: var(--bg); }

/* ---- キーボード図（指ごとに色分け） ---- */
.kbd-figure { margin: 0.8rem 0; text-align: center; }
.kbd-row { display: flex; justify-content: center; gap: 4px; margin: 4px 0; }
.kbd-row-1 { padding-left: 1.4rem; }
.kbd-row-2 { padding-left: 2.4rem; }
.kbd-row-3 { padding-left: 3.2rem; }
.kbd-figure .key {
  position: relative;
  min-width: 2.2rem;
  height: 2.2rem;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-bottom-width: 3px;
  border-radius: 6px;
  color: var(--text);
}
.kbd-figure .key.is-home { border: 2.5px solid var(--text); border-bottom-width: 4px; }
.kbd-figure .key.is-bump::after {
  content: "●";
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5rem;
  color: var(--typing-accent);
}
.kbd-figure .key-space { min-width: 14rem; font-size: 0.75rem; }
.kbd-figure figcaption { font-size: 0.8rem; color: var(--text-weak); margin-top: 0.5rem; }
.kbd-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem 0.8rem; margin-top: 0.4rem; font-size: 0.78rem; color: var(--text-sub); }
.legend-item { white-space: nowrap; }
.swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border-radius: 3px;
  margin-right: 0.3em;
  vertical-align: -0.05em;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
/* 指の色（左右で対になるよう同系色を使う）。
   .typing-page kbd の白背景（詳細度 0,1,1）に負けないよう .kbd-figure を前置する */
.kbd-figure .f-lp, .swatch.f-lp { background: #FFD1D1; }
.kbd-figure .f-lr, .swatch.f-lr { background: #FFE2B8; }
.kbd-figure .f-lm, .swatch.f-lm { background: #FFF5B0; }
.kbd-figure .f-li, .swatch.f-li { background: #CDEFC8; }
.kbd-figure .f-ri, .swatch.f-ri { background: #C8E8F5; }
.kbd-figure .f-rm, .swatch.f-rm { background: #D9D4F7; }
.kbd-figure .f-rr, .swatch.f-rr { background: #F5CFEA; }
.kbd-figure .f-rp, .swatch.f-rp { background: #E4E4E4; }
.kbd-figure .f-th, .swatch.f-th { background: #F5F0E6; }
.finger-table td:first-child { white-space: nowrap; font-weight: 700; }
.finger-table kbd { margin: 0.1em 0.15em; }
@media (max-width: 480px) {
  .kbd-figure .key { min-width: 1.75rem; height: 1.9rem; font-size: 0.72rem; }
  .kbd-row { gap: 3px; }
  .kbd-row-1 { padding-left: 0.9rem; }
  .kbd-row-2 { padding-left: 1.6rem; }
  .kbd-row-3 { padding-left: 2.2rem; }
  .kbd-figure .key-space { min-width: 10rem; }
}

/* ---- ローマ字表 ---- */
.romaji-table th[scope="row"] { white-space: nowrap; width: 3.2em; text-align: center; }
.romaji-table td { text-align: center; padding: 0.35rem 0.3rem; min-width: 3.6em; }
.romaji-table td.empty { background: var(--bg); }
.romaji-table .rk { display: block; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.romaji-table .rr { display: block; font-family: var(--font-mono); font-size: 1rem; font-weight: 700; color: var(--typing-accent); }
.romaji-table .ra { display: block; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-weak); }
.romaji-pairs td, .romaji-list td { text-align: left; }
.romaji-pairs .rk-cell, .romaji-list .rk-cell { font-weight: 700; white-space: nowrap; }
.romaji-pairs .rr, .romaji-pairs .ra { display: inline; margin-right: 0.5em; }
.print-row { text-align: center; margin: 0 0 1rem; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.btn-print { font-size: 0.95rem; padding: 0.55rem 1.4rem; }

/* ---- 例（小さい文字ページ） ---- */
.ex-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin: 0.6rem 0;
}
.ex-grid li {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  margin: 0;
  line-height: 1.5;
}
.ex-kana { display: block; font-weight: 700; }
.ex-romaji { display: block; font-family: var(--font-mono); font-size: 0.95rem; color: var(--text-sub); }
@media (max-width: 480px) { .ex-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---- FAQ・関連 ---- */
.faq-item h3 { font-size: 0.98rem; margin: 0.9rem 0 0.3rem; }
.faq-item:first-of-type h3 { margin-top: 0.3rem; }
.faq-item p { margin: 0; line-height: 1.8; }
.related-list { list-style: none; padding-left: 0; }
.related-list li { padding: 0.35rem 0; border-bottom: 1px dashed var(--line-soft); }
.related-list li:last-child { border-bottom: 0; }
.related-list a { font-weight: 700; color: var(--brand-dark); }

/* ---- ハブ: 「つづきから」（学習記録がある人だけ JS で表示）。
   前回の続きが最優先で、1-1 は「最初からやり直す」に下げる ---- */
.hero-resume { margin: 0 0 0.6rem; }
.hero-resume .hero-note { margin-top: 0.45rem; }
.btn-resume { background: var(--brand); }
.btn-resume:hover { background: var(--brand-dark); }
.hero-resume-done { font-size: 1rem; font-weight: 700; color: var(--learn); margin: 0; }
.hero-resume-done a { color: var(--learn); }
.btn-restart {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand-dark);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.45rem 1.1rem;
  text-decoration: none;
}
.btn-restart:hover { background: var(--brand-tint); }

.tenets { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin: 0.4rem 0 0; }
.tenets li {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  line-height: 1.6;
}
.tenet-icon { font-size: 1.6rem; }
.tenets strong { color: var(--text); font-size: 1rem; }
.tenets span:last-child { font-size: 0.86rem; color: var(--text-sub); }
@media (max-width: 768px) { .tenets { grid-template-columns: 1fr; } }

.ch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin: 0.8rem 0 0.4rem; }
.ch-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.ch-head { display: flex; justify-content: space-between; align-items: center; }
.ch-no { font-size: 0.78rem; font-weight: 700; color: #fff; background: var(--brand); border-radius: var(--radius-pill); padding: 0.05rem 0.55rem; }
.ch-stars { font-size: 0.8rem; color: #E6B422; letter-spacing: 0.05em; min-height: 1em; }
.ch-card .ch-name { font-size: 1rem; margin: 0.2rem 0 0; color: var(--text); }
.ch-blurb { font-size: 0.83rem; color: var(--text-sub); margin: 0; line-height: 1.6; flex: 1; }
.ch-start {
  align-self: flex-end;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--learn);
  background: var(--learn-tint);
  border: 1px solid var(--learn-border);
  border-radius: var(--radius-pill);
  padding: 0.2rem 0.75rem;
}
.ch-start:hover { background: var(--learn); color: #fff; }
@media (max-width: 768px) { .ch-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .ch-grid { grid-template-columns: 1fr; } }

.measure-box { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.measure-text { flex: 1 1 320px; }
.goal-mini { width: auto; font-size: 0.9rem; margin: 0.4rem 0; }
.goal-mini th { white-space: nowrap; }
.measure-section .btn-primary { flex: 0 0 auto; }

/* ゲームカードは共通 .games-grid を使うが、ハブ内では余白を詰める */
.typing-games { padding: 0.6rem 0 0.2rem; gap: 0.9rem; }
.typing-games .game-card-title { font-size: 1rem; }
.game-card-sub { display: block; font-size: 0.75rem; color: var(--text-weak); font-weight: 400; }
@media (min-width: 768px) { .typing-games { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .typing-games { grid-template-columns: repeat(3, 1fr); } }

/* ---- 学年切りかえ（ハブの見出しと学年別ページの上部で共通）。
   「自分の学年」を1タップで選べるように pill 型。現在の学年は塗りつぶし ---- */
.grade-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 1rem 0 0;
}
.typing-page > .grade-pills { justify-content: flex-start; margin: -0.4rem 0 1.2rem; }
.grade-pills-label { font-size: 0.85rem; font-weight: 700; color: var(--text-sub); margin-right: 0.2rem; }
.grade-pill {
  display: inline-block;
  padding: 0.4rem 0.95rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  line-height: 1.4;
}
.grade-pill:hover { background: var(--brand-tint); }
.grade-pill.is-current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---- 学年別カード（ハブ #grades）---- */
.grade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-top: 0.8rem; }
.grade-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 0.9rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--bg);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
}
.grade-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(230, 126, 34, 0.15); }
.grade-icon { font-size: 1.6rem; line-height: 1; }
.grade-name { font-weight: 700; color: var(--text); font-size: 1.02rem; }
.grade-goal { font-size: 0.82rem; color: var(--text-sub); line-height: 1.5; }
.grade-more { margin-top: auto; padding-top: 0.3rem; font-size: 0.82rem; color: var(--brand-dark); font-weight: 700; }
@media (max-width: 768px) { .grade-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---- きょうのミッション（ハブ #mission）。達成は JS が .is-done を足す ---- */
.mission-section { background: linear-gradient(135deg, var(--surface), var(--brand-tint)); }
.mission-lead { margin: 0 0 0.6rem; color: var(--text-sub); font-size: 0.92rem; }
.mission-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.mission-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 700;
  line-height: 1.4;
}
.mission-item a { color: var(--text); text-decoration: none; }
.mission-item a:hover { text-decoration: underline; }
.mi-check {
  flex: 0 0 auto;
  width: 1.3em;
  height: 1.3em;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}
.mission-item.is-done { background: var(--learn-tint); border-color: var(--learn-border); }
.mission-item.is-done a { color: var(--learn); text-decoration: line-through; }
.mission-item.is-done .mi-check { background: var(--learn); border-color: var(--learn); position: relative; }
.mission-item.is-done .mi-check::after {
  content: '';
  position: absolute;
  left: 0.32em; top: 0.08em;
  width: 0.35em; height: 0.7em;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.mission-streak { display: flex; align-items: center; flex-wrap: wrap; gap: 0.7rem; margin-top: 0.8rem; }
.streak-days { font-weight: 700; color: var(--typing-accent); }
.streak-dots { display: inline-flex; gap: 0.3rem; }
.streak-dots .dot { width: 0.85em; height: 0.85em; border-radius: 50%; background: var(--line-soft); }
.streak-dots .dot.is-on { background: var(--brand); }
.streak-dots .dot.is-today { box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--brand); }
.mission-msg { font-weight: 700; color: var(--learn); }
@media (max-width: 768px) { .mission-list { grid-template-columns: 1fr; } }

/* ---- 段位表（/typing/rank/）。国の目標にあたる段位と「段」を色で区別 ---- */
.rank-table td:first-child { font-weight: 700; color: var(--text); }
.rank-table tr.is-goal td { background: var(--brand-tint); }
.rank-table tr.is-goal td:first-child { color: var(--typing-accent); }
.rank-table tr.is-dan td:first-child { color: var(--typing-dan); }
.formula {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 1.02rem;
  color: var(--text);
}

.material-list { list-style: none; padding: 0; }
.material-list li { padding: 0.5rem 0; border-bottom: 1px dashed var(--line-soft); line-height: 1.6; }
.material-list li:last-child { border-bottom: 0; }
.material-list a { color: var(--brand-dark); }
.mat-desc { display: block; font-size: 0.82rem; color: var(--text-weak); }
.teachers-section .btn-secondary { font-size: 0.95rem; }

/* ---- 先生向け: 記録用紙（印刷して配る紙なので黒い罫線のまま） ---- */
.record-sheet {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin: 0.8rem 0;
  color: #222;
}
.record-sheet h3 { text-align: center; font-size: 1.2rem; margin: 0 0 0.6rem; color: #222; }
.record-sheet .rs-meta, .record-sheet .rs-goal { margin: 0.3rem 0; font-size: 0.92rem; }
.record-sheet .rs-blank { display: inline-block; min-width: 3em; border-bottom: 1px solid #222; }
.rs-table { font-size: 0.9rem; margin-top: 0.6rem; }
.rs-table th, .rs-table td { border: 1px solid #555; padding: 0.35rem 0.5rem; height: 2.1em; }
.rs-table thead th { background: #F3F3F3; color: #222; }
.rs-table tbody tr:nth-child(even) { background: #fff; }
.rs-table td:nth-child(5) { width: 45%; }
.record-sheet .rs-note { margin: 0.6rem 0 0.2rem; font-size: 0.85rem; }
.record-sheet .rs-credit { margin: 0; font-size: 0.75rem; color: var(--text-weak); text-align: right; }

/* ---- 印刷 ----
   ボタンから印刷したとき（body[data-print]）は対象だけを紙に出す。
   Ctrl+P の通常印刷ではページ全体（ヘッダー・ナビ・広告は省く。共通分は learn.css） */
@media print {
  .print-row, .grade-pills { display: none !important; }
  body[data-print="tables"] .typing-page > :not(.print-keep) { display: none !important; }
  body[data-print="tables"] .typing-page > h1 { display: block !important; font-size: 1.2rem; }
  body[data-print="tables"] .print-keep .note { display: none; }
  body[data-print="tables"] .romaji-table td { padding: 0.2rem 0.25rem; }
  body[data-print="tables"] .romaji-table .rk { font-size: 0.95rem; }
  body[data-print="tables"] .romaji-table .rr { font-size: 0.9rem; color: #000; }
  body[data-print="record-sheet"] .typing-page > * { display: none !important; }
  body[data-print="record-sheet"] .typing-page > .learn-section:has(#record-sheet) { display: block !important; }
  body[data-print="record-sheet"] .learn-section:has(#record-sheet) > :not(.record-sheet) { display: none !important; }
  .record-sheet { border: 0; padding: 0; }
  .rs-table th, .rs-table td { height: 2.4em; }
}
