/* 共通スタイル：全ページで読み込む。教材ごとの装飾は各lesson.cssに書く */

/* Zen Maru Gothic（SIL OFL。assets/fonts/OFL.txt）。
   英数・かな・記号・JIS第1水準漢字に絞ったサブセット。それ以外の字はフォールバックで出る */
@font-face {
  font-family: "Zen Maru Gothic";
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ZenMaruGothic-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "Zen Maru Gothic";
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/ZenMaruGothic-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Zen Maru Gothic";
  font-weight: 900;
  font-display: swap;
  src: url("../fonts/ZenMaruGothic-Black.woff2") format("woff2");
}

:root {
  --bg: #fffaf0;
  --ink: #2b2b3a;
  --muted: #5a5a70;
  --card: #ffffff;
  --line: #e6dfcf;
  --primary: #ff8a3d;      /* ヘッダー・番号の丸・アクセント（上の文字は --ink） */
  --btn: #c24e0a;          /* 主ボタン（白文字） */
  --btn-shadow: #8f3706;
  --blue: #1f6fe0;         /* 小数の枠 */
  --blue-ink: #1659b8;     /* 小数の文字 */
  --green: #12804a;        /* 分数の文字・枠 */
  --red: #e5484d;
  --yellow: #ffd54a;
  --tint-blue: #eef4ff;
  --tint-green: #e8f7ef;
  --tint-yellow: #fff6df;
  --radius: 24px;
  --shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
  --tap: 52px; /* 指で押しやすい最小サイズ */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "BIZ UDPGothic", "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.7;
  /* 分かち書きなので、ことばの途中ではなく空白の位置で折り返す */
  word-break: keep-all;
  overflow-wrap: break-word;
}

button { font-family: inherit; }

.site-header {
  background: var(--primary);
  color: var(--ink);
  padding: 14px 40px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.site-header a { color: var(--ink); text-decoration: none; }
.site-header .logo { font-size: 22px; font-weight: 900; }
.site-header .crumb { font-size: 15px; font-weight: 700; }
.site-header .logo, .site-header .crumb { white-space: nowrap; }

main { max-width: 1200px; margin: 0 auto; padding: 32px 40px 56px; }

h1 { font-size: 40px; font-weight: 900; line-height: 1.4; margin: 0 0 6px; }
h2 { font-size: 26px; font-weight: 900; margin: 0 0 20px; }
h3 { font-size: 22px; font-weight: 900; }

/* h1 の下のリード文 */
.lead { font-size: 20px; margin: 0 0 28px; }

/* スマホでだけ h1 の上に出すパンくず */
.crumb-sub { display: none; font-size: 13px; font-weight: 700; color: var(--muted); }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin: 28px 0;
  box-shadow: var(--shadow);
}

/* 見出しの左の番号の丸 */
.step-title { display: flex; align-items: center; gap: 12px; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  font-size: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 8px 18px;
  font: inherit;
  font-weight: 900;
  color: #fff;
  background: var(--btn);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--btn-shadow);
  cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--btn-shadow); }
.btn.secondary { background: #fff; color: var(--ink); border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.secondary:active { box-shadow: 0 2px 0 var(--line); }
.btn.back { min-height: 56px; padding: 0 28px; font-size: 20px; }

:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }

/* 分数の表示（全教材で共通利用） */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1.1;
  margin: 0 0.15em;
}
.frac .num { padding: 0 0.3em 0.1em; border-bottom: 0.1em solid currentColor; }
.frac .den { padding-top: 0.1em; }

/* 小数・分数の色（色だけに頼らず、必ず数字の形でも区別できる場所で使う） */
.is-dec { color: var(--blue-ink); }
.is-frac { color: var(--green); }

/* ① の「ポイント」の箱 */
.point { background: var(--tint-yellow); border-radius: 16px; padding: 14px 18px; margin: 0; }
.point .frac { font-size: 0.85em; }

/* ② わかったこと：色ちがいの3枚 */
.notes {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px;
}
.notes li { border-radius: 18px; padding: 20px; font-size: 19px; line-height: 1.8; }
.notes .note-blue { background: var(--tint-blue); }
.notes .note-green { background: var(--tint-green); }
.notes .note-yellow { background: var(--tint-yellow); }
.notes .frac { font-size: 0.85em; }

/* ③ クイズ（assets/js/quiz.js が作る部品） */
.q-progress { color: var(--muted); font-size: 16px; font-weight: 700; }
.q-prompt { font-size: 24px; font-weight: 900; line-height: 1.6; margin: 6px 0 12px; }
.q-big { font-size: 2rem; font-weight: 900; text-align: center; margin: 8px 0 16px; }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 12px 0; }
.choice {
  min-height: 84px; font: inherit; font-size: 34px; font-weight: 900;
  background: #fff; border: 3px solid var(--line); border-radius: 18px;
  box-shadow: 0 4px 0 var(--line); cursor: pointer; color: var(--ink);
}
.choice .frac { font-size: 0.8em; }
.choice:hover { border-color: var(--primary); }
.choice.right { background: #dff7e9; border-color: var(--green); }
.choice.wrong { background: #ffe3e3; border-color: var(--red); }
.choice:disabled { cursor: default; }
.feedback { min-height: 2em; font-size: 20px; font-weight: 700; margin: 16px 0; }
.feedback.ok { color: var(--green); }
.feedback.ng { color: var(--red); }
.result { text-align: center; }
.result .big-stars { font-size: 2.4rem; color: #e0a800; letter-spacing: 4px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* スマホ：文字は下げずに余白を詰める */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .site-header { padding: 12px 16px; }
  .site-header .logo { font-size: 19px; }
  .site-header .crumb { display: none; }
  .crumb-sub { display: block; }
  main { padding: 16px 16px 40px; }
  h1 { font-size: 28px; line-height: 1.3; margin: 2px 0 6px; }
  h2 { font-size: 20px; margin: 0 0 12px; }
  h3 { font-size: 18px; }
  .lead { font-size: 17px; margin: 0 0 16px; }
  .card { padding: 14px; margin: 12px 0; border-radius: 20px; }
  .step-title { gap: 10px; }
  .step-num { width: 32px; height: 32px; font-size: 18px; }
  .btn.back { min-height: 52px; padding: 0 24px; font-size: 18px; }

  .notes { grid-template-columns: 1fr; gap: 8px; }
  .notes li { border-radius: 12px; padding: 10px 12px; font-size: 17px; line-height: 1.7; }

  .q-progress { font-size: 14px; }
  .q-prompt { font-size: 18px; margin: 4px 0 10px; }
  .q-big { margin: 4px 0 12px; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .choice { min-height: 64px; font-size: 28px; border-radius: 16px; }
  .feedback { font-size: 17px; margin: 12px 0; }
}
