/* 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);
}

/* 「シム図鑑で開く」リンクボタン
   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;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  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);
}

/* ================================================================
   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 54px;
  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;
}

