/* css/components.css */

/* ================================================================
   Card Containers
   ================================================================ */
.card {
  max-width: var(--card-width);
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto 40px auto;
  background: var(--card-bg);
  backdrop-filter: var(--card-backdrop);
  -webkit-backdrop-filter: var(--card-backdrop);
  border: var(--card-border-width) solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 40px;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
  overflow-x: auto;
  overflow-y: visible;
}

.card h3 {
  margin-top: 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--col-text-sub, #94a3b8);
  color: var(--col-primary, #3b82f6);
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  margin-bottom: 25px;
}

.card h4 {
  color: var(--col-text);
  font-size: 1.05rem;
  margin-top: 28px;
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 3px solid var(--col-primary);
}

.card table,
.card pre,
.card code {
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}

.card p {
  line-height: 1.85;
  margin: 12px 0;
}

.card ul, .card ol {
  line-height: 1.8;
  padding-left: 1.4em;
}

.card li + li {
  margin-top: 4px;
}

@media (max-width: 768px) {
  .card {
    padding: 20px 14px;
    margin-bottom: 24px;
    border-radius: 14px;
  }
  .card h3 { font-size: 1.1rem; margin-bottom: 18px; }
}

/* ================================================================
   Point Box (.box-alert) — 重要ポイントの強調枠
   ================================================================ */
.box-alert {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 36px 0;
  border: 2px solid var(--col-warning);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.04) 0%, rgba(251, 191, 36, 0.08) 100%);
  border-radius: 16px;
  padding: 28px 24px;
  padding-top: 38px;
  position: relative;
  overflow: visible;
}

.box-alert-label {
  position: absolute;
  top: -14px;
  left: 20px;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: #fff;
  padding: 5px 18px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
  line-height: 1;
  white-space: nowrap;
  max-width: calc(100% - 40px);
  overflow: visible;
  text-overflow: clip;
}

.box-alert ul, .box-alert ol {
  margin: 8px 0;
  padding-left: 1.3em;
}

/* ================================================================
   Note Box (.box-note) — 答え・メモ枠
   ================================================================ */
.box-note {
  max-width: 92%;
  margin: 24px auto;
  padding: 20px 24px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--col-primary);
  border-radius: 10px;
  color: var(--col-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.box-note strong:first-child {
  display: block;
  margin-bottom: 6px;
  color: var(--col-primary);
  font-size: 0.95rem;
}

/* ================================================================
   Educational Elements
   ================================================================ */
strong {
  font-size: 1.05em;
  color: var(--col-primary);
  transition: color var(--transition-normal, 0.3s);
}

/* ================================================================
   Unified Explanation Styles (do NOT override per-page)
   ================================================================ */

/* シミュレーション/図解の埋め込み枠 */
.sim-embed {
  max-width: 460px;
  margin: 20px auto;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  position: relative;
  overflow: visible;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* 幅を広く使うシム。
   既定の 460px は、本文が 1000px 幅で流れるカードの中では細すぎて、
   左右に 280px ずつの空きができる（「シムだけ取り残されている」ように見える）。
   この修飾クラスを付けたシムは、論理座標（460 幅で設計）を保ったまま
   コンテナ幅まで**全体を拡大**する。文字も一緒に大きくなるので、
   投影したときの可読性も上がる。
   ※ 既定値を変えないのは、460 幅を前提に固定 px で組まれた既存のシムが
     多数あり、広げると行間を超えて文字が重なるため。 */
.sim-embed--wide {
  max-width: 760px;
}

/* 解説の図（静止図）。id が fig-…-sol の入れ物（例：fig-q8-sol。…_fig-q<N>-sol.js が TbFig で描く）。
   操作するシムの箱（淡い灰の地・枠・影）ではなく、白地・枠なしで本文になじませる。題は図の下（.tb-fig-cap）。
   ・幅の上限（600〜620px）は図のファイルが inline で決める。ここでは、決めていない図のための既定だけを置く
   ・.sim-embed canvas は touch-action:none（viewer.css。シムをドラッグするため）。静止図の上からは指でページを送れるようにする
   ・授業ページの側（生徒の解説の窓・教員の問題カードの解説）には、同じ決まりを quiz-renderer.js が差し込む
   ・図のファイルも同じ値を inline で当てている（保険）。**ここの値と食い違わせない** */
.sim-embed[id^="fig-"][id$="-sol"] {
  max-width: 620px;
  margin: 20px auto 2px;
  min-height: 0;
  background: #ffffff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.sim-embed[id^="fig-"][id$="-sol"] canvas {
  touch-action: auto;
}
.sim-embed[id^="fig-"][id$="-sol"] + .tb-fig-cap {
  max-width: 620px;
  margin: 2px auto 16px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.55;
  color: #64748b;
}

/* 「シム図鑑で開く」リンクボタン
   data-gallery-sim-id を持つ要素の直後に viewer.js が自動挿入する */
.gallery-link-wrap {
  text-align: center;
  margin: 6px 0 18px;
}
.gallery-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  color: #ffffff !important;
  text-decoration: none !important;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.gallery-link-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.4);
  filter: brightness(1.05);
}
.gallery-link-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* 直感的理解ボックス */
.intuition {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-left: 4px solid #10b981;
  padding: 16px 20px;
  border-radius: 0 12px 12px 0;
  margin: 20px 0;
  box-shadow: 0 1px 4px rgba(16, 185, 129, 0.08);
}

.intuition-title {
  font-weight: bold;
  color: #059669;
  font-size: 0.85rem;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* 強調ハイライト */
.highlight {
  font-weight: bold;
  color: #b45309;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  padding: 1px 6px;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ================================================================
   Images & Sub-Simulations
   ================================================================ */
.responsive-img {
  max-width: 100%;
  height: auto;
  max-height: 40vh;
  object-fit: contain;
  border-radius: 12px;
  margin: 20px auto;
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sub-sim-area {
  width: 100%;
  min-height: 250px;
  height: auto;
  margin: 20px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

/* ================================================================
   Buttons & Controls
   ================================================================ */
.sim-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff !important;
  border: 1px solid #cbd5e1 !important;
  color: var(--col-text) !important;
  /* 絵だけのボタン（▶ ⏸ ↺）は今までどおり 40px の丸。字の入ったボタンは、中身に合わせて横に伸びる。
     以前は幅を 40px に固定していたので、授業ページ用のシム（「▶ 発射」「M を半分に」など。
     sim-btn--text を付けていない）を解説に載せると、字が丸からはみ出していた（2026-10-07） */
  padding: 0 12px;
  width: auto;
  min-width: 40px;
  height: 40px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.sim-btn:hover {
  background: var(--col-primary) !important;
  color: #fff !important;
  border-color: var(--col-primary) !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
  transform: translateY(-1px);
}

/* ラベル付き（テキスト入り）のシムボタン。
   素の .sim-btn は 40px の円形アイコンボタンなので、
   「⏸ 一時停止」のような文字ラベルを入れると円からはみ出して重なる。
   この修飾クラスを併用すると横幅が内容に合わせて伸びるピル型になる。 */
.sim-btn--text {
  width: auto;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* ================================================================
   Details / Summary (別解・補足の折りたたみ)
   ================================================================ */
details {
  margin: 24px 0;
  background: #fefefe;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  transition: box-shadow var(--transition-normal);
}

details[open] {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

summary {
  padding: 14px 20px;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  outline: none;
  color: var(--col-primary);
  transition: background var(--transition-fast);
  border-radius: 12px;
  user-select: none;
}

summary:hover {
  background: rgba(59, 130, 246, 0.04);
}

summary::-webkit-details-marker { display: none; }

summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 10px;
  font-size: 0.75em;
  transition: transform 0.2s;
  color: var(--col-primary);
}

details[open] summary::before {
  transform: rotate(90deg);
}

details[open] summary {
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid var(--card-border);
}

.details-content {
  padding: 20px 24px;
}

/* ================================================================
   MathJax の行間調整
   ================================================================ */
.card .MathJax_Display,
.card mjx-container[jax="CHTML"][display="true"] {
  margin: 16px 0 !important;
}

/* ================================================================
   印刷用スタイル
   ================================================================ */
@media print {
  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .card,
  .box-alert,
  .box-note,
  .sub-sim-area,
  .responsive-img,
  details,
  figure,
  pre,
  table {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .box-alert {
    margin-top: 20px !important;
    margin-bottom: 20px !important;
    padding-top: 40px !important;
  }

  .box-alert-label {
    top: 10px !important;
    left: 15px !important;
    box-shadow: none !important;
  }

  .sim-btn {
    display: none !important;
  }
}

/* ================================================================
   Hint Page Components (hint.html)
   ================================================================ */

/* 観察ポイントボックス（シムの下に置く「何を見よう」） */
.hint-observe {
  background: #ecfdf5;
  border-left: 4px solid #10b981;
  padding: 14px 18px;
  margin: 18px 0;
  border-radius: 8px;
  color: #065f46;
  font-size: 14px;
  line-height: 1.7;
}
.hint-observe-title {
  font-weight: 700;
  color: #047857;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hint-observe ul {
  margin: 6px 0 0 0;
  padding-left: 22px;
}
.hint-observe li {
  margin-bottom: 4px;
}

/* 考え方ステップリスト（番号付きアプローチ） */
.hint-steps {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  counter-reset: hint-step;
}
.hint-steps > li {
  position: relative;
  padding: 14px 16px 14px 70px;
  margin-bottom: 10px;
  background: #f0f9ff;
  border-left: 4px solid #0284c7;
  border-radius: 8px;
  counter-increment: hint-step;
  line-height: 1.7;
}
.hint-steps > li::before {
  content: "Step " counter(hint-step);
  position: absolute;
  left: 10px;
  top: 14px;
  background: #0284c7;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.hint-steps > li strong {
  color: #0c4a6e;
}

/* 使う公式・法則リスト */
.hint-tools {
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 8px;
  padding: 14px 18px;
  margin: 18px 0;
}
.hint-tools-title {
  font-weight: 700;
  color: #854d0e;
  margin-bottom: 8px;
  font-size: 14px;
}
.hint-tools ul {
  margin: 0;
  padding-left: 22px;
  color: #713f12;
  font-size: 14px;
  line-height: 1.8;
}

/* 状況整理ボックス（何が起きているか） */
.hint-situation {
  background: #faf5ff;
  border-left: 4px solid #a855f7;
  padding: 14px 18px;
  margin: 14px 0;
  border-radius: 8px;
  color: #581c87;
  font-size: 14px;
  line-height: 1.7;
}
.hint-situation-title {
  font-weight: 700;
  color: #6b21a8;
  margin-bottom: 6px;
}


/* ═══════════════════════════════════════════════════════════════
   SimMath の読み取り帯（SimMath.readout(…, { band: true })）は、置かれた場所にかかわらず同じ見た目にする（2026-10-07）
   授業ページ（.card .interactive-area）と図鑑（#sim-target-area）には決まりがあったが、
   解説・ヒント・演習の中（.sim-embed）には無く、地色なし・16px の字で 390px では 2 行に折れていた。
   場所を問わない最低限の決まりをここに置く（授業ページ・図鑑の決まりは、より強い指定でこれに重なる）
   ═══════════════════════════════════════════════════════════════ */
.sim-math-readout.sim-readout {
  margin: 0;
  padding: 6px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(120deg, rgba(99, 102, 241, 0.10), rgba(14, 165, 233, 0.10));
  color: #1e293b;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sim-math-readout.sim-readout.sim-readout--solid { background: linear-gradient(120deg, #eef0fe, #e6f5fd); }
.sim-math-readout.sim-readout .sm-unit { font-weight: 600; opacity: 0.7; }
@media (max-width: 560px) {
  .sim-math-readout.sim-readout { font-size: 0.74rem; padding: 4px 8px; border-radius: 8px; line-height: 1.45; }
}

/* 解説の中のシムのスライダーの色を、サイトの主な色（水色）に決める（2026-10-09）。
   決めないと、ブラウザが OS のアクセントの色で塗る（Windows の設定が赤だと赤くなる）。授業ページ・図鑑は public/css/components.css に同じ決まり */
.sim-embed input[type="range"] { accent-color: #0ea5e9; }
