/*
 * Lesson template — interactive panels.
 * Rule: an interactive must answer a question the learner has just been
 * asked. Each panel starts with that question in .panel-question.
 * (Borrowed technique: Transformer Circuits' explorable figures.)
 */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin: 28px 0;
}
.panel-title {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.panel-question { color: var(--text); font-weight: 600; margin-bottom: 16px; }

/* ── Controls ─────────────────────────────────────────── */
.controls { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; margin-bottom: 16px; }
.control { display: flex; flex-direction: column; gap: 6px; min-width: 160px; flex: 1; }
.control label { font-size: 0.8rem; color: var(--text-dim); font-family: var(--mono); }
.control output { color: var(--text); font-weight: 600; }

input[type='range'] { width: 100%; accent-color: var(--accent); }

select {
  background: var(--bg-card-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card-alt);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.btn:hover { border-color: var(--accent); }
.btn.active { border-color: var(--accent); background: rgba(73, 138, 155, 0.15); color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* Plain-English result line under every interactive. */
.readout {
  background: var(--bg-card-alt);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.92rem;
  color: var(--text);
  margin-top: 14px;
}

/* ── Token chips ──────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg-card-alt);
}
.chip.cached { color: var(--role-cache); border-color: var(--role-cache); background: rgba(251, 191, 36, 0.08); }
.chip.new { color: var(--role-new); border-color: var(--role-new); background: rgba(244, 114, 182, 0.1); }
.chip.redo { color: var(--danger); border-color: var(--danger); background: rgba(248, 113, 113, 0.08); }

/* ── Horizontal bars (memory comparisons) ────────────── */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; font-size: 0.85rem; }
.bar-row .name { font-family: var(--mono); color: var(--text-dim); }
.bar-row .track { background: var(--bg-card-alt); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; }
.bar-row .val { font-family: var(--mono); color: var(--text); text-align: right; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 90px 1fr 80px; } }

/* ── Grids (attention masks, buffers, head groups) ────── */
.grid-wrap { overflow-x: auto; }
.cell-grid { display: inline-grid; gap: 3px; }
.cell {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--bg-card-alt);
  color: var(--text-dim);
}
.cell.on { background: rgba(73, 138, 155, 0.45); color: var(--text); }
.cell.self { background: var(--role-new); color: #0a0a0f; }
.cell.head { width: 46px; height: 38px; }
/* Row/column labels size to their text, so long labels are never cut off. */
.cell.label { background: none; width: auto; min-width: 30px; justify-content: flex-start; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.8rem; color: var(--text-dim); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
