/* 易读书 · 交互科普 — 文章共享组件（compare、insight、legend、timeline 等） */

/* ── 语义色扩展 ── */
.hero h1 .orange { color: var(--orange); }
.hero h1 .purple { color: var(--purple); }
strong { color: var(--text); font-weight: 600; }
code, .formula-mono { font-family: 'Roboto Mono', monospace; }
.formula { font-family: 'Roboto Mono', monospace; }

.card h3 .num.blue { background: var(--primary); }
.card h3 .num.orange { background: var(--orange); }
.card h3 .num.green { background: var(--green); }
.card h3 .num.red { background: var(--red); }
.card h3 .num.purple { background: var(--purple); }

.formula-box.orange { background: linear-gradient(135deg, rgba(249,115,22,.08), rgba(249,115,22,.04)); border-color: rgba(249,115,22,.2); }
.formula-box.green { background: linear-gradient(135deg, rgba(5,150,105,.08), rgba(5,150,105,.04)); border-color: rgba(5,150,105,.2); }
.formula.orange { color: var(--orange); }
.formula.green { color: var(--green); }

.alert.blue { background: rgba(37,99,235,.08); border-left-color: var(--primary); }
.alert.blue strong { color: var(--primary); }
.alert.purple { background: rgba(124,58,237,.08); border-left-color: var(--purple); }
.alert.purple strong { color: var(--purple); }
.alert.green { background: rgba(5,150,105,.08); border-left-color: var(--green); }
.alert.green strong { color: var(--green); }
.alert.red { background: rgba(220,38,38,.08); border-left-color: var(--red); }
.alert.red strong { color: var(--red); }

.panel.purple { border-top-color: var(--purple); }
.panel.red { border-top-color: var(--red); }

.sum-item.orange { border-top-color: var(--orange); }
.sum-item.orange h4 { color: var(--orange); }
.sum-item.green { border-top-color: var(--green); }
.sum-item.green h4 { color: var(--green); }
.sum-item.purple { border-top-color: var(--purple); }
.sum-item.purple h4 { color: var(--purple); }
.sum-item.blue { border-top-color: var(--primary); }
.sum-item.blue h4 { color: var(--primary); }
.sum-item.pink { border-top-color: #EC4899; }
.sum-item.pink h4 { color: #EC4899; }

/* ── compare / insight ── */
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 22px 0; }
.compare-item { background: var(--card); border-radius: var(--radius-sm); padding: 24px 20px; text-align: center; box-shadow: var(--shadow-clay); }
.compare-item .icon { margin-bottom: 12px; }
.compare-item h4 { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.compare-item p { font-size: .88rem; line-height: 1.65; margin: 0; }
.compare-item.good { border-top: 4px solid var(--green); }
.compare-item.bad { border-top: 4px solid var(--red); }

.insight { background: linear-gradient(135deg, rgba(37,99,235,.06), rgba(124,58,237,.06)); border-left: 4px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 20px 24px; margin: 22px 0; }
.insight h4 { font-family: 'Baloo 2', cursive; font-size: 1.05rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.insight p { font-size: .95rem; margin: 0; color: var(--text-muted); }

/* ── stat grid ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 18px 0; }
.stat-box { background: rgba(124,58,237,.08); border-radius: var(--radius-sm); padding: 18px 16px; text-align: center; border-top: 3px solid var(--purple); }
.stat-box.blue { background: rgba(37,99,235,.08); border-top-color: var(--primary); }
.stat-box.orange { background: rgba(249,115,22,.08); border-top-color: var(--orange); }
.stat-box.green { background: rgba(5,150,105,.08); border-top-color: var(--green); }
.stat-box h5 { font-family: 'Baloo 2', cursive; font-size: .95rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.stat-box p { font-size: .82rem; margin: 0; color: var(--text-muted); }

/* ── illustrations ── */
.illus { background: var(--card); border-radius: var(--radius); padding: 24px; margin: 22px 0; box-shadow: var(--shadow-clay); overflow-x: auto; }
.illus svg { width: 100%; height: auto; display: block; }
.illus-title { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; text-align: center; margin-bottom: 16px; color: var(--text-muted); }

/* ── timeline ── */
.timeline { position: relative; margin: 24px 0; padding-left: 28px; border-left: 3px solid rgba(37,99,235,.2); }
.timeline-item { position: relative; margin-bottom: 24px; padding: 16px 20px; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow-clay); }
.timeline-item::before { content: ''; position: absolute; left: -36px; top: 20px; width: 14px; height: 14px; background: var(--primary); border-radius: 50%; border: 3px solid var(--bg); }
.timeline-item.y2::before { background: var(--orange); }
.timeline-item.y3::before { background: var(--green); }
.timeline-item.y4::before { background: var(--purple); }
.timeline-item h4 { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.timeline-item p { font-size: .88rem; margin: 0; }

/* ── data table ── */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: var(--radius-sm); overflow: hidden; margin: 18px 0; box-shadow: var(--shadow-clay); font-size: .9rem; }
.data-table th { background: var(--purple); color: white; font-family: 'Baloo 2', cursive; padding: 12px 16px; text-align: center; }
.data-table td { padding: 10px 16px; text-align: center; background: var(--card); border-bottom: 1px solid rgba(0,0,0,.05); color: var(--text-muted); }
.data-table tr:last-child td { border-bottom: none; }

/* ── universe decorative ── */
.universe { background: linear-gradient(135deg, #1E1B4B, #312E81); border-radius: var(--radius); padding: 32px 24px; margin: 24px 0; color: white; text-align: center; }
.universe h3 { color: white; font-size: 1.3rem; margin-bottom: 12px; }
.universe p { color: rgba(255,255,255,.75); }
.constellation { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 20px; }
.constellation span { background: rgba(255,255,255,.12); padding: 8px 16px; border-radius: 999px; font-size: .85rem; }

/* ── metaphor (SVM) ── */
.metaphor { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 22px 0; }
.metaphor-card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-clay); border-top: 4px solid var(--primary); }
.metaphor-card.orange { border-top-color: var(--orange); }
.metaphor-card.green { border-top-color: var(--green); }
.metaphor-card h4 { font-family: 'Baloo 2', cursive; font-size: 1rem; font-weight: 700; margin-bottom: 10px; }
.metaphor-card p { font-size: .88rem; margin: 0; }

/* ── legend (canvas demos) ── */
.legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 14px; font-size: .85rem; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.legend .dot.red { background: var(--red); }
.legend .dot.green { background: var(--green); }
.legend .dot.blue { background: var(--primary); }
.legend .line { width: 22px; height: 3px; border-radius: 2px; display: inline-block; }
.legend .line.solid { background: var(--primary); }
.legend .line.dashed { background: repeating-linear-gradient(90deg, var(--orange) 0 4px, transparent 4px 8px); height: 2px; }
.legend .plane { width: 22px; height: 3px; background: var(--purple); display: inline-block; border-radius: 2px; }

.btn-purple { background: var(--purple); color: white; box-shadow: 0 4px 14px rgba(124,58,237,.28); }
.btn-purple:hover { background: #6D28D9; transform: translateY(-1px); }
.btn-green { background: var(--green); color: white; box-shadow: 0 4px 14px rgba(5,150,105,.28); }
.btn-green:hover { background: #10B981; transform: translateY(-1px); }

/* ── XOR 3D demo ── */
.xor-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 22px 0; }
.xor-step { background: var(--card); border-radius: var(--radius-sm); padding: 20px; box-shadow: var(--shadow-clay); display: flex; gap: 14px; align-items: flex-start; }
.xor-step .step-num { width: 32px; height: 32px; background: var(--purple); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Baloo 2', cursive; font-weight: 700; flex-shrink: 0; }
.xor-step h4 { font-family: 'Baloo 2', cursive; font-size: .95rem; font-weight: 700; margin-bottom: 4px; }
.xor-step p { font-size: .85rem; margin: 0; }

.xor-wrap { display: flex; flex-direction: column; gap: 16px; }
.xor-canvas-box { position: relative; width: 100%; height: 420px; border-radius: var(--radius-sm); overflow: hidden; background: #0F172A; box-shadow: inset 0 2px 12px rgba(0,0,0,.3); }
.xor-canvas-box canvas { width: 100% !important; height: 100% !important; display: block; }
.xor-overlay { position: absolute; top: 12px; left: 12px; z-index: 2; pointer-events: none; }
.view-label { background: rgba(255,255,255,.9); padding: 6px 14px; border-radius: 999px; font-family: 'Baloo 2', cursive; font-size: .82rem; font-weight: 700; color: var(--text); }
.xor-legend { position: absolute; bottom: 12px; left: 12px; background: rgba(255,255,255,.92); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .78rem; color: var(--text-muted); z-index: 2; pointer-events: none; }
.xor-legend div { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.xor-legend div:last-child { margin-bottom: 0; }
.xor-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ── 函数页：输入输出机器 ── */
.machine { display: grid; grid-template-columns: 1fr auto 1.4fr auto 1fr; gap: 14px; align-items: center; margin: 24px 0; padding: 24px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-clay); }
.machine-box { padding: 18px 14px; border-radius: var(--radius-sm); text-align: center; }
.machine-box.input { background: rgba(37,99,235,.08); }
.machine-box.output { background: rgba(5,150,105,.08); }
.machine-box h5 { font-family: 'Baloo 2', cursive; font-size: .9rem; font-weight: 700; margin-bottom: 8px; }
.machine-box .val { font-family: 'Roboto Mono', monospace; font-size: 1.6rem; font-weight: 700; }
.machine-box.input .val { color: var(--primary); }
.machine-box.output .val { color: var(--green); }
.machine-box .lbl { font-size: .76rem; color: var(--text-muted); margin-top: 4px; }
.machine-core { padding: 22px 16px; background: linear-gradient(135deg, var(--orange), #FB923C); border-radius: var(--radius-sm); text-align: center; box-shadow: 0 6px 20px rgba(249,115,22,.25); color: white; min-width: 160px; }
.machine-core h5 { font-family: 'Baloo 2', cursive; font-size: .95rem; font-weight: 700; margin-bottom: 4px; }
.machine-core .rule { font-family: 'Roboto Mono', monospace; font-size: 1rem; font-weight: 700; background: rgba(0,0,0,.18); padding: 4px 12px; border-radius: 8px; display: inline-block; }
.machine-controls { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 16px; align-items: flex-end; }
.arrow { color: var(--text-muted); display: flex; align-items: center; justify-content: center; }

/* ── quiz ── */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 22px 0; }
.quiz-card { background: var(--card); border-radius: var(--radius-sm); padding: 18px; box-shadow: var(--shadow-clay); text-align: center; }
.quiz-card canvas { width: 100%; height: 140px; background: #fff; border-radius: 8px; }
.quiz-card .q-text { font-family: 'Baloo 2', cursive; font-size: .9rem; font-weight: 600; margin: 10px 0 8px; }
.quiz-btns { display: flex; gap: 8px; justify-content: center; }
.quiz-btn { font-family: 'Baloo 2', cursive; font-size: .82rem; font-weight: 700; padding: 7px 18px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; background: var(--bg); color: var(--text-muted); }
.quiz-btn.yes.selected { background: var(--green); color: white; }
.quiz-btn.no.selected { background: var(--red); color: white; }
.quiz-feedback { font-size: .78rem; margin-top: 8px; min-height: 18px; font-weight: 600; }
.quiz-feedback.ok { color: var(--green); }
.quiz-feedback.bad { color: var(--red); }

.canvas-info { position: absolute; top: 10px; right: 10px; background: rgba(37,99,235,.92); color: white; border-radius: 8px; padding: 8px 14px; font-family: 'Roboto Mono', monospace; font-size: .82rem; pointer-events: none; }

code { font-family: 'Roboto Mono', monospace; background: rgba(37,99,235,.08); color: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: .92em; }

@media (max-width: 720px) {
  .machine { grid-template-columns: 1fr; }
  .arrow { transform: rotate(90deg); }
  .xor-canvas-box { height: 300px; }
}
