/* ====================================== */
/* Spline Webapp - Style Sheet            */
/* ====================================== */

:root {
  --primary-color: #0066cc;
  --secondary-color: #ff6b6b;
  --success-color: #51cf66;
  --warning-color: #ffd43b;
  --error-color: #ff6b6b;
  --bg-color: #f8f9fa;
  --text-color: #333;
  --border-color: #ddd;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* ====== ヘッダー ====== */
header {
  background: linear-gradient(135deg, var(--primary-color), #0052a3);
  color: white;
  padding: 30px 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 2rem;
  margin-bottom: 10px;
}

header p {
  font-size: 0.95rem;
  opacity: 0.9;
}

/* ====== メインコンテナ ====== */
main {
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 20px;
}

/* ====== セクション ====== */
section {
  background: white;
  border-radius: 8px;
  margin-bottom: 30px;
  padding: 25px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

section h2 {
  color: var(--primary-color);
  font-size: 1.3rem;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 10px;
}

section h3 {
  color: #555;
  font-size: 1.1rem;
  margin-top: 20px;
  margin-bottom: 15px;
}

section h4 {
  color: #666;
  font-size: 1rem;
  margin-top: 15px;
  margin-bottom: 10px;
}

/* ====== グリッドレイアウト ====== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ====== フォーム要素 ====== */
label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: #333;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.3s;
}

/* 分割数ボックス: ブラウザ標準スピナーを非表示 */
#divNum {
  width: 70px !important;
  padding: 6px 8px !important;
  text-align: center;
}
#divNum::-webkit-inner-spin-button,
#divNum::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ====== スピンボタン（分割数 ±1/±5/±10） ====== */
.spin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  min-width: 38px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-color);
  background: white;
  border: 1.5px solid var(--primary-color);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  user-select: none;
}
.spin-btn:hover {
  background: var(--primary-color);
  color: white;
}
.spin-btn:active {
  opacity: 0.8;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: 'Courier New', monospace;
}

/* ====== ラジオボタン ====== */
.radio-group {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="radio"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

input[type="radio"] + label {
  margin: 0;
  cursor: pointer;
  font-weight: normal;
}

/* ====== ボタン ====== */
button {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-block;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: #0052a3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

.btn-success {
  background-color: var(--success-color);
  color: white;
}

.btn-success:hover {
  background-color: #40c057;
}

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  flex-wrap: wrap;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ====== エラー・警告表示 ====== */
.error-box {
  background-color: #ffe6e6;
  border-left: 4px solid var(--error-color);
  padding: 15px;
  border-radius: 4px;
  color: #c92a2a;
  font-size: 0.9rem;
  margin-bottom: 15px;
}

.warning-box {
  background-color: #fff8e1;
  border-left: 4px solid var(--warning-color);
  padding: 15px;
  border-radius: 4px;
  color: #f08c00;
}

.info-box {
  background-color: #e7f5ff;
  border-left: 4px solid var(--primary-color);
  padding: 15px;
  border-radius: 4px;
  color: #0066cc;
}

#errorContainer {
  margin-bottom: 15px;
}

/* ====== テーブル ====== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  font-size: 0.9rem;
}

.matrix-table {
  background-color: #f9f9f9;
  border: 1px solid var(--border-color);
}

.matrix-table th,
.matrix-table td {
  border: 1px solid var(--border-color);
  padding: 5px 8px;
  text-align: right;
  white-space: nowrap;
}

.matrix-table th {
  background-color: #e8f4ff;
  font-weight: 600;
  color: #0066cc;
  text-align: center;
  border-color: #0066cc;
}

.matrix-table td {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  background-color: white;
}

.matrix-table tbody tr:nth-child(odd) td {
  background-color: #f9fbff;
}

.matrix-table tbody tr:hover td {
  background-color: #e8f4ff;
}

/* ====== キャンバス・グラフ ====== */
#chartContainer {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  margin: 15px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#chartCanvas {
  max-width: 100%;
  height: auto;
}

/* ====== 折りたたみセクション ====== */
.collapsible {
  cursor: pointer;
  padding: 15px;
  background-color: #f0f0f0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.collapsible:hover {
  background-color: #e8e8e8;
}

.collapsible.active {
  background-color: #e7f5ff;
  border-color: var(--primary-color);
}

.collapse-icon {
  transition: transform 0.3s;
}

.collapsible.active .collapse-icon {
  transform: rotate(180deg);
}

.collapse-content {
  display: none;
  padding: 15px;
  background-color: #fafafa;
  border: 1px solid var(--border-color);
  border-top: none;
  margin-bottom: 10px;
}

.collapse-content.active {
  display: block;
}

/* ====== モード説明 ====== */
#modeDescription {
  background-color: #e7f5ff;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 15px;
  border-left: 4px solid var(--primary-color);
}

/* ====== 結果表示 ====== */
#resultSummary {
  background-color: #f0fdf4;
  padding: 15px;
  border-radius: 4px;
  border-left: 4px solid var(--success-color);
  margin-bottom: 20px;
}

#resultSummary p {
  margin: 5px 0;
}

/* ====== 学習コンテンツ ====== */
#learningContent {
  background-color: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
}

#learningContent code,
#learningContent pre {
  background-color: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}

/* ====== 数式表示 ====== */
.formula-box {
  background-color: #f9f9f9;
  border-left: 4px solid var(--primary-color);
  padding: 15px;
  margin: 15px 0;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  overflow-x: auto;
}

/* ====== レスポンシブ対応 ====== */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }

  section {
    padding: 15px;
  }

  .btn-group {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  table {
    font-size: 0.8rem;
  }

  .matrix-table th,
  .matrix-table td {
    padding: 6px;
  }
}

/* ====== スクロールバー（Webkit） ====== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ====== 理論・計算ステップレイアウト ====== */
.theory-step {
  border-left: 4px solid var(--primary-color);
  background: white;
  margin-bottom: 24px;
  border-radius: 0 6px 6px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}

.step-label {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 16px;
  letter-spacing: 0.03em;
}

.step-body {
  padding: 18px 20px;
}

.theory-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 8px;
}

@media (max-width: 900px) {
  .theory-split {
    grid-template-columns: 1fr;
  }
}

.theory-formula {
  border-right: 1px solid var(--border-color);
  padding-right: 20px;
}

@media (max-width: 900px) {
  .theory-formula {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-right: 0;
    padding-bottom: 16px;
  }
}

.theory-values {
  padding-left: 4px;
}

.theory-col-head {
  font-weight: 600;
  font-size: 0.88rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e0e0e0;
}

.val-placeholder {
  color: #aaa;
  font-style: italic;
  font-size: 0.9rem;
  margin: 0;
}

/* 条件グリッド（STEP3 連立方程式条件リスト） */
.cond-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}

@media (max-width: 700px) {
  .cond-grid {
    grid-template-columns: 1fr;
  }
}

.cond-item {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.9rem;
}

.cond-badge {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  margin-right: 6px;
  vertical-align: middle;
}

.formula-inline {
  display: inline-block;
  background: #f0f4fa;
  border-radius: 3px;
  padding: 2px 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.88rem;
  margin-top: 4px;
}

/* ====== フッター ====== */
footer {
  background-color: #333;
  color: #ccc;
  padding: 20px;
  text-align: center;
  margin-top: 50px;
  font-size: 0.9rem;
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}
