/* =========================
   解説ページ 共通CSS
   ========================= */

:root {
  --text: #222;
  --imp: #ff0000;
  /* 赤：重要 */
  --sub: #0070c0;
  /* 青：入試に出るが周辺 */
  --line: #222;
  --bg-box: #fafafa;
}

html,
body {
  background-color: #fff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  line-height: 1.85;
  color: var(--text);
  margin: 16px;
}

/* =========================
   空欄（クリックで表示/非表示）
   ========================= */
/* 見た目用。挙動は js-blank が担当 */
/* 空欄の基本形 */
.blank {
  --blank-inline-gap: 0.5em;
  display: inline-block;
  position: relative;
  top: 0;
  background: #fff;

  /* 下線 */
  border-bottom: 2px solid #222;

  /* data-answer の文字数に応じて幅を可変化 */
  min-width: calc((var(--blank-ch, 4) * 1em) + (var(--blank-inline-gap) * 2));

  /* タップしやすさ */
  padding: 0;
  cursor: pointer;
  user-select: none;
  text-align: center;
  vertical-align: -0.2em;
  line-height: 1.2;
  min-height: 1.2em;
  color: transparent;

  /* 見た目調整 */
  border-radius: 2px;
}

/* クリック判定を上下に約1cm拡張（左右はそのまま） */
.blank::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1cm;
  bottom: -1cm;
}

/* 答え文字は疑似要素で重ねる。下線位置は常に固定。 */
.blank::after {
  content: attr(data-display-answer);
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(2px + 0.02em);
  text-align: center;
  box-sizing: border-box;
  padding-left: var(--blank-inline-gap);
  padding-right: var(--blank-inline-gap);
  white-space: nowrap;
  line-height: 1;
  color: currentColor;
  opacity: 0;
}

.blank:hover {
  background: #fff;
}

/* 開いて答えが表示されている状態（JSが is-open を付ける） */
.blank.is-open {
  /* 下線は消さない */
  border-bottom: 2px solid #222;

  /* 答えが読みやすいよう少し強調 */
  color: var(--text);
  background: #fff;
}

.blank.is-open::after {
  opacity: 1;
  font-weight: 700;
}

/* data-color に応じた表示色（JSがクラス付与） */
.blank.is-open.answer-red {
  color: var(--imp);
}

.blank.is-open.answer-blue {
  color: var(--sub);
}

/* キーボード操作のフォーカス可視化（tabindex が付く） */
.blank:focus {
  outline: 2px solid rgba(21, 101, 192, 0.45);
  outline-offset: 2px;
}

/* =========================
   重要語・周辺語（色）
   ========================= */
.important {
  color: var(--imp);
  font-weight: 700;
}

.sub {
  color: var(--sub);
  font-weight: 600;
}

/* =========================
   四角で囲む（最重要・定義）
   ========================= */
.box {
  display: inline-block;
  padding: .15em .45em;
  margin: 0 .1em;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--bg-box);
  font-weight: 700;
}

/* =========================
   ボタン類
   ========================= */
button {
  padding: .45em .85em;
  font-size: 0.95rem;
  cursor: pointer;
  margin-right: .5em;
}

/* 解説ページ：レイアウト外枠 */
.kaisetsu h1,
.kaisetsu h2,
.kaisetsu h3,
.kaisetsu h4 {
  font-family: "MS Gothic", "ＭＳ ゴシック", sans-serif;
}

.kaisetsu {
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 14px 0 60px;
}

.kaisetsu-head {
  margin: 12px 0 18px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 23, 42, .10);
  border-radius: 14px;
  background: rgba(255, 255, 255, .85);
}

.kaisetsu-kicker {
  margin: 0 0 6px;
  color: rgba(15, 23, 42, .65);
  font-weight: 700;
  letter-spacing: .2px;
}

.kaisetsu-title {
  margin: 0;
  font-family: "MS Gothic", "ＭＳ ゴシック", sans-serif;
  font-size: 1.35rem;
  line-height: 1.25;
}

.kaisetsu-h2 {
  margin: 1.2em 0 .4em;
  font-family: "MS Gothic", "ＭＳ ゴシック", sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  padding-left: .6em;
  border-left: 5px solid rgba(0, 0, 0, .5);
}

.kaisetsu-h3 {
  font-family: "MS Gothic", "ＭＳ ゴシック", sans-serif;
  margin: .9em 0 .6em;
}

.kaisetsu-h4 {
  margin: 1.1em 0 .4em;
  font-family: "MS Gothic", "ＭＳ ゴシック", sans-serif;
  font-size: 1.02rem;
  font-weight: 800;
  opacity: .9;
}

.kaisetsu-outline {
  margin: .6em 0 1.2em;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, .12);
  border-radius: 10px;
  background: #fff;
}

.kaisetsu-outline-title {
  margin: 0 0 8px;
  display: inline-block;
  padding: 4px 10px;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: #0f172a;
  border-left: 4px solid #0f172a;
  background: rgba(15, 23, 42, .06);
  border-radius: 6px;
}

.kaisetsu-outline-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.kaisetsu-outline-list li {
  margin: 0;
}

.kaisetsu-outline-list a {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid rgba(15, 23, 42, .15);
  border-radius: 999px;
  color: #0f172a;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.kaisetsu-outline-list a:hover {
  background: rgba(15, 23, 42, .06);
}

.kaisetsu-h2 {
  scroll-margin-top: 90px;
}

/* 本文読みやすさ */
.kaisetsu-body {
  font-family: "MS Mincho", "ＭＳ 明朝", serif;
  font-size: 1.02rem;
  line-height: 1.9;
}

.kaisetsu-body p {
  margin: .7em 0;
}

.kaisetsu-body p {
  white-space: pre-wrap;
}

/* Word由来部品：38.php直書きstyleの移植先 */
.word-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: .95em;
}

.word-table td,
.word-table th {
  border: 1px solid rgba(0, 0, 0, .18);
  padding: 8px 10px;
  vertical-align: top;
  white-space: pre-wrap;
}

.word-textbox {
  border: 1px solid rgba(0, 0, 0, .30);
  padding: 10px 12px;
  margin: 12px 0;
  background: rgba(255, 255, 255, .9);
  border-radius: 10px;
  white-space: pre-wrap;
}

.word-image {
  margin: 12px 0;
}

.word-image img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 表：スマホで潰れないよう横スクロール（table-wrapを使う場合） */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 640px;
}

/* 空欄の視認性：空文字でも“空欄だ”と分かるように薄背景 */
.blank {
  background: rgba(0, 0, 0, .02);
}

.blank:hover {
  background: rgba(0, 0, 0, .05);
}

/* =========================
   印刷（必要なら）
   ========================= */
@media print {
  body {
    margin: 0;
  }

  button {
    display: none;
  }

  .blank:hover {
    background: transparent;
  }

  .blank:focus {
    outline: none;
  }

  .blank {
    border-bottom: 1px solid #000;
  }

  .blank::before {
    content: none;
  }
}