/* All interactive widget styles (converted from Svelte components) */

/* ===== SHARED BASE ===== */
.widget-box {
  background: var(--color-surface, #fffdfa);
  border: 1px solid var(--color-border, #e4ddd6);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem 0;
  font-family: var(--font-sans, 'Inter', sans-serif);
}
.widget-section-title {
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-text-subtle, #b6afa8);
}
.mode-toggle {
  display: flex; gap: 0; margin-bottom: 1.25rem;
  border: 1px solid var(--color-border, #e4ddd6);
  border-radius: 6px; overflow: hidden; width: fit-content;
}
.mode-btn {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.75rem; padding: 0.5rem 1rem; border: none;
  background: transparent; color: var(--color-text-muted, #5f5b57);
  cursor: pointer; transition: all 0.2s ease;
}
.mode-btn.active { background: var(--color-text, #1a1816); color: var(--color-bg, #fdf8f3); }
.mode-btn:not(.active):hover { background: var(--color-accent-light, #f6f1ec); }
.ctrl-btn, .replay-btn, .race-btn {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.75rem; padding: 0.3rem 0.8rem;
  border: 1px solid var(--color-border, #e4ddd6); border-radius: 4px;
  background: transparent; color: var(--color-text-muted, #5f5b57);
  cursor: pointer; transition: all 0.2s ease;
}
.ctrl-btn:hover, .replay-btn:hover, .race-btn:hover { background: var(--color-accent-light, #f6f1ec); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== LATENT STATE EXPLORER ===== */
.explorer { }
.explorer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.token-stream {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 1rem; background: var(--color-accent-light, #f6f1ec);
  border-radius: 6px; margin-bottom: 0.75rem; min-height: 3rem;
}
.token {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.8rem; padding: 0.15rem 0.4rem; border-radius: 3px;
  color: var(--color-text-subtle, #b6afa8); cursor: pointer;
  transition: all 0.25s ease; border: 1px solid transparent; background: none;
}
.token.processed { color: var(--tok-color); background: rgba(0,0,0,0.04); }
.token.current {
  color: var(--tok-color); background: rgba(0,0,0,0.08);
  border-color: var(--tok-color); font-weight: 600; transform: scale(1.08);
}
.legend { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.leg-item { display: flex; align-items: center; gap: 4px; font-size: 0.65rem; color: var(--color-text-subtle, #b6afa8); text-transform: uppercase; letter-spacing: 0.05em; }
.leg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.prob-section { margin-top: 0.5rem; }
.prob-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.prob-label { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.75rem; color: var(--color-text-muted, #5f5b57); }
.prob-step  { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.7rem; color: var(--color-text-subtle, #b6afa8); }
.prob-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.prob-row { display: flex; align-items: center; gap: 0.5rem; }
.prob-name { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.75rem; font-weight: 600; width: 45px; text-align: right; flex-shrink: 0; }
.prob-name.walk { color: #ef4444; }
.prob-name.drive { color: #22c55e; }
.prob-track { flex: 1; height: 22px; background: var(--color-accent-light, #f6f1ec); border-radius: 4px; overflow: hidden; }
.prob-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.walk-fill { background: linear-gradient(90deg, #ef4444, #f87171); }
.drive-fill { background: linear-gradient(90deg, #22c55e, #4ade80); }
.prob-val { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.75rem; font-weight: 600; width: 35px; color: var(--color-text, #1a1816); }
.annotation { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 0 6px 6px 0; font-size: 0.82rem; line-height: 1.5; color: var(--color-text, #1a1816); animation: fadeIn 0.4s ease; }
.distance-note { background: rgba(239,68,68,0.06); border-left: 3px solid #ef4444; }
.final-note { background: rgba(139,115,85,0.06); border-left: 3px solid var(--color-text-subtle, #b6afa8); }

/* ===== CHAIN OF THOUGHT ===== */
.cot-header { margin-bottom: 1rem; }
.step-display { padding: 1rem; background: var(--color-accent-light, #f6f1ec); border-radius: 6px; margin-bottom: 1rem; }
.step-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-subtle, #b6afa8); display: block; margin-bottom: 0.25rem; }
.step-tokens { margin-bottom: 0.75rem; }
.step-text { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.78rem; color: var(--color-text, #1a1816); line-height: 1.5; }
.ht-display { margin-bottom: 0.75rem; }
.ht-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ht-tag { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 3px; background: rgba(0,0,0,0.06); color: var(--color-text-muted, #5f5b57); transition: all 0.3s ease; }
.ht-tag.causal { background: rgba(34,197,94,0.15); color: #16a34a; font-weight: 600; }
.ht-tag.distance { background: rgba(239,68,68,0.12); color: #dc2626; }
.prob-display { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.75rem; }
.cot-prob-track { flex: 1; height: 18px; background: rgba(0,0,0,0.04); border-radius: 3px; overflow: hidden; }
.cot-prob-fill { height: 100%; border-radius: 3px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }
.cot-prob-val { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.7rem; font-weight: 600; width: 32px; color: var(--color-text, #1a1816); }
.step-note { font-size: 0.8rem; color: var(--color-text-muted, #5f5b57); font-style: italic; line-height: 1.4; }
.output-bubble { margin-top: 0.75rem; padding: 0.6rem 0.8rem; border-radius: 6px; font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.75rem; background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); color: var(--color-text, #1a1816); line-height: 1.5; }
.output-bubble.correct { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.2); }
.output-label { color: var(--color-text-subtle, #b6afa8); font-weight: 600; }
.controls { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.nav-btn { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.85rem; padding: 0.3rem 0.7rem; border: 1px solid var(--color-border, #e4ddd6); border-radius: 4px; background: transparent; color: var(--color-text-muted, #5f5b57); cursor: pointer; transition: all 0.2s ease; }
.nav-btn:hover:not(:disabled) { background: var(--color-accent-light, #f6f1ec); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }
.step-counter { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.7rem; color: var(--color-text-subtle, #b6afa8); }
.insight { margin-top: 1rem; padding: 0.75rem 1rem; background: rgba(34,197,94,0.06); border-left: 3px solid #22c55e; border-radius: 0 6px 6px 0; font-size: 0.82rem; line-height: 1.5; color: var(--color-text, #1a1816); animation: fadeIn 0.5s ease; }

/* ===== ENERGY LANDSCAPE ===== */
.landscape-wrap { margin-bottom: 0.5rem; }
.landscape-svg { width: 100%; height: auto; }
.well-label { font-size: 7px; font-weight: 500; fill: var(--color-text-subtle, #b6afa8); font-family: var(--font-mono, 'JetBrains Mono', monospace); text-transform: uppercase; letter-spacing: 0.05em; }
.depth-label { font-size: 6px; fill: var(--color-text-subtle, #b6afa8); font-family: var(--font-mono, 'JetBrains Mono', monospace); font-style: italic; }
.energy-ball { fill: #3b82f6; stroke: #2563eb; stroke-width: 1.5; transition: fill 0.3s ease, stroke 0.3s ease; }
.energy-ball.settled.correct { fill: #22c55e; stroke: #16a34a; }
.energy-ball.settled.wrong { fill: #ef4444; stroke: #dc2626; }
.ball-label { font-size: 7px; font-weight: 600; fill: var(--color-text-muted, #5f5b57); font-family: var(--font-mono, 'JetBrains Mono', monospace); }
.settle-result { padding: 0.75rem 1rem; border-radius: 0 6px 6px 0; font-size: 0.82rem; line-height: 1.5; color: var(--color-text, #1a1816); animation: fadeIn 0.5s ease; }
.wrong-result { background: rgba(239,68,68,0.06); border-left: 3px solid #ef4444; }
.correct-result { background: rgba(34,197,94,0.06); border-left: 3px solid #22c55e; }

/* ===== PATTERN RACE ===== */
.race-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.prompt-display { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.78rem; padding: 0.75rem 1rem; background: var(--color-accent-light, #f6f1ec); border-radius: 6px; margin-bottom: 1.25rem; line-height: 1.5; }
.prompt-label { color: var(--color-text-subtle, #b6afa8); }
.prompt-text { color: var(--color-text, #1a1816); }
.tracks { display: flex; flex-direction: column; gap: 0.75rem; }
.track { transition: all 0.3s ease; }
.track.winner { transform: scale(1.01); }
.track-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.track-label { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.75rem; font-weight: 500; color: var(--color-text, #1a1816); }
.track-freq { font-size: 0.65rem; color: var(--color-text-subtle, #b6afa8); text-transform: uppercase; letter-spacing: 0.05em; }
.track-bar { position: relative; height: 28px; background: var(--color-accent-light, #f6f1ec); border-radius: 4px; overflow: hidden; }
.track-fill { height: 100%; border-radius: 4px; transition: width 0.1s linear; }
.track-pct { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.7rem; font-weight: 600; transition: color 0.2s ease; }
.track-desc { font-size: 0.65rem; color: var(--color-text-subtle, #b6afa8); margin-top: 0.15rem; display: block; }
.race-result { display: flex; gap: 0.75rem; align-items: flex-start; margin-top: 1.25rem; padding: 1rem; background: rgba(239,68,68,0.06); border-left: 3px solid #ef4444; border-radius: 0 6px 6px 0; animation: fadeIn 0.5s ease; }
.result-text { font-size: 0.85rem; color: var(--color-text, #1a1816); line-height: 1.5; }
.result-sub { color: var(--color-text-muted, #5f5b57); font-size: 0.8rem; }

/* ===== SYSTEM COMPARISON ===== */
.systems-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.systems-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.75rem; }
.system { padding: 1rem; background: var(--color-accent-light, #f6f1ec); border-radius: 6px; transition: all 0.3s ease; }
.system-label { margin-bottom: 0.75rem; }
.sys-name { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.85rem; font-weight: 600; color: var(--color-text, #1a1816); display: block; }
.sys-type { font-size: 0.65rem; color: var(--color-text-subtle, #b6afa8); text-transform: uppercase; letter-spacing: 0.05em; }
.pipeline { display: flex; flex-direction: column; gap: 0; }
.pipe-step { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 4px; opacity: 0.3; transition: all 0.4s ease; }
.pipe-step.active { opacity: 1; }
.pipe-step.current { background: rgba(59,130,246,0.08); }
.pipe-icon { font-size: 0.9rem; flex-shrink: 0; }
.pipe-info { display: flex; flex-direction: column; }
.pipe-label { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.7rem; font-weight: 600; color: var(--color-text, #1a1816); text-transform: uppercase; letter-spacing: 0.03em; }
.pipe-detail { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.65rem; color: var(--color-text-muted, #5f5b57); }
.pipe-arrow { text-align: center; font-size: 0.6rem; color: var(--color-text-subtle, #b6afa8); opacity: 0.3; transition: opacity 0.3s ease; padding: 0 0 0 1rem; }
.pipe-arrow.active { opacity: 0.6; }
.vs-divider { display: flex; align-items: center; justify-content: center; }
.vs { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.7rem; font-weight: 600; color: var(--color-text-subtle, #b6afa8); text-transform: uppercase; letter-spacing: 0.1em; }
.question-box { margin-top: 1rem; padding: 0.75rem 1rem; background: rgba(139,92,246,0.06); border-left: 3px solid #8b5cf6; border-radius: 0 6px 6px 0; font-size: 0.82rem; line-height: 1.5; color: var(--color-text, #1a1816); animation: fadeIn 0.5s ease; }

/* ===== FPGA VS VARIABLE ===== */
.explainer {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem;
  padding: 1.5rem; background: var(--color-surface, #fffdfa);
  border: 1px solid var(--color-border, #e4ddd6); border-radius: 8px;
  margin: 1.5rem 0; font-family: var(--font-sans, 'Inter', sans-serif);
}
.side { display: flex; flex-direction: column; align-items: center; }
.explainer-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-subtle, #b6afa8); margin-bottom: 0.75rem; }
.explainer-content { display: flex; flex-direction: column; align-items: center; width: 100%; }
.explainer-divider { width: 1px; background: var(--color-border, #e4ddd6); }
.code-lines { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.8rem; margin-bottom: 0.75rem; }
.code-line { padding: 0.2rem 0.5rem; border-radius: 3px; color: var(--color-text-muted, #5f5b57); transition: all 0.3s ease; }
.code-line.active { background: rgba(59,130,246,0.12); color: #3b82f6; }
.variable-box { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border: 1px dashed var(--color-border, #e4ddd6); border-radius: 4px; margin-bottom: 0.5rem; }
.var-name { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.75rem; color: var(--color-text-subtle, #b6afa8); }
.var-value { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 1.25rem; font-weight: 600; color: var(--color-text, #1a1816); min-width: 2rem; text-align: center; transition: all 0.3s ease; }
.circuit { width: 100%; max-width: 180px; height: auto; margin-bottom: 0.5rem; }
.circuit-note { font-size: 0.75rem; color: var(--color-text-subtle, #b6afa8); margin: 0; text-align: center; }
.circ-node { fill: var(--color-surface, #fffdfa); stroke: var(--color-border, #e4ddd6); stroke-width: 1.5; transition: all 0.3s ease; }
.circ-node.active { fill: #dcfce7; stroke: #22c55e; }
.circ-node.output.active { fill: #fef3c7; stroke: #f59e0b; }
.circ-wire { stroke: var(--color-border, #e4ddd6); stroke-width: 2; stroke-linecap: round; transition: all 0.3s ease; }
.circ-wire.active { stroke: #3b82f6; }
.circ-gate { fill: var(--color-surface, #fffdfa); stroke: var(--color-border, #e4ddd6); stroke-width: 1.5; transition: all 0.3s ease; }
.circ-gate.active { fill: #ede9fe; stroke: #8b5cf6; }
.circ-gate-text { font-size: 8px; font-weight: 500; fill: var(--color-text-muted, #5f5b57); text-anchor: middle; }

/* Dark mode overrides for all widgets */
@media (prefers-color-scheme: dark) {
  .widget-box, .explainer { background: #22201d; border-color: #33302c; }
  .mode-toggle { border-color: #33302c; }
  .mode-btn.active { background: #e8e4e0; color: #1a1816; }
  .mode-btn:not(.active):hover, .ctrl-btn:hover, .replay-btn:hover, .race-btn:hover { background: #2c2825; }
  .step-display, .token-stream, .prompt-display { background: #2c2825; }
  .step-text, .prompt-text, .result-text, .question-box, .insight, .output-bubble, .annotation, .settle-result { color: #e8e4e0; }
  .ht-tag { background: rgba(255,255,255,0.06); color: #b6afa8; }
  .ht-tag.causal { background: rgba(34,197,94,0.12); color: #4ade80; }
  .ht-tag.distance { background: rgba(239,68,68,0.1); color: #f87171; }
  .prob-track, .cot-prob-track, .track-bar { background: rgba(255,255,255,0.04); }
  .prob-val, .cot-prob-val { color: #e8e4e0; }
  .nav-btn, .ctrl-btn, .replay-btn, .race-btn { border-color: #33302c; color: #b6afa8; }
  .output-bubble { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.15); }
  .output-bubble.correct { background: rgba(34,197,94,0.06); border-color: rgba(34,197,94,0.15); }
  .system, .step-display { background: #2c2825; }
  .sys-name, .pipe-label, .track-label { color: #e8e4e0; }
  .pipe-detail, .result-sub { color: #b6afa8; }
  .circ-node, .circ-gate { fill: #1a1816; stroke: #45403c; }
  .circ-wire { stroke: #45403c; }
  .circ-gate-text, .ball-label { fill: #b6afa8; }
  .variable-box { border-color: #33302c; }
  .var-value { color: #e8e4e0; }
  .wrong-result { background: rgba(239,68,68,0.08); }
  .correct-result { background: rgba(34,197,94,0.08); }
  .distance-note { background: rgba(239,68,68,0.08); }
}
@media (max-width: 540px) {
  .mode-toggle { width: 100%; }
  .mode-btn { flex: 1; text-align: center; }
  .explainer { grid-template-columns: 1fr; gap: 1.5rem; }
  .explainer-divider { width: 100%; height: 1px; }
}
@media (max-width: 640px) {
  .systems-grid { grid-template-columns: 1fr; }
  .vs-divider { padding: 0.5rem 0; }
}
