/* Topic interactive lab — Algebra */

.algebra-lab {
  --lab-accent: var(--chip-math);
  --lab-2: #b89fd9;
  --lab-muted: var(--color-text-muted);
  max-width: 920px;
  font-family: var(--font-body);
}

/* ── Header ──────────────────────────────────────────────── */

.algebra-lab__header { margin-bottom: var(--space-6); }
.algebra-lab__eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lab-accent);
  margin-bottom: var(--space-2);
}
.algebra-lab__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: var(--space-3);
}
.algebra-lab__intro {
  font-size: var(--text-sm);
  color: var(--lab-muted);
  line-height: 1.65;
  max-width: 62ch;
}

/* ── Tabs ────────────────────────────────────────────────── */

.algebra-lab__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.algebra-lab__tab {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: oklch(from var(--color-text) l c h / 0.04);
  color: var(--lab-muted);
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive),
    border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}
.algebra-lab__tab:hover {
  color: var(--color-text);
  border-color: oklch(from var(--lab-accent) l c h / 0.45);
}
.algebra-lab__tab[aria-selected="true"] {
  color: var(--color-bg);
  background: linear-gradient(125deg, oklch(from var(--lab-accent) l c h / 0.88), var(--lab-2));
  border-color: transparent;
  box-shadow: 0 0 18px oklch(from var(--lab-accent) l c h / 0.2);
}
.algebra-lab__tab:focus-visible {
  outline: 2px solid var(--lab-accent);
  outline-offset: 2px;
}

/* ── Panels ──────────────────────────────────────────────── */

.algebra-lab__panel {
  display: none;
  animation: algebra-lab-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.algebra-lab__panel.is-active { display: block; }

@keyframes algebra-lab-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .algebra-lab__panel { animation: none; }
}

/* ── Canvas stage wrap ───────────────────────────────────── */

.algebra-lab__stage-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-divider);
  overflow: hidden;
  margin-bottom: var(--space-4);
  background:
    radial-gradient(ellipse at 50% 60%, oklch(from var(--lab-accent) l c h / 0.06) 0%, transparent 70%),
    oklch(from var(--color-text) l c h / 0.02);
}
.algebra-lab__stage-wrap--graph { max-width: 520px; }

.algebra-lab__canvas {
  display: block;
  width: 100%;
}
.algebra-lab__canvas--balance { height: 280px; }
.algebra-lab__canvas--graph   { aspect-ratio: 1 / 1; }
.algebra-lab__canvas--ineq    { height: 130px; }

/* ── Section label ───────────────────────────────────────── */

.algebra-lab__section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-4);
}

/* ── Equation display ────────────────────────────────────── */

.algebra-lab__equation {
  position: relative;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  text-align: center;
  color: var(--color-text);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: oklch(from var(--lab-accent) l c h / 0.06);
  border: 1px solid oklch(from var(--lab-accent) l c h / 0.15);
}
.algebra-lab__equation::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, oklch(from var(--lab-accent) l c h / 0.1) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: algebra-shimmer 5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes algebra-shimmer {
  0%, 65% { transform: translateX(-100%); }
  85%     { transform: translateX(100%); }
  100%    { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .algebra-lab__equation::after { animation: none; display: none; }
}
.algebra-lab__equation--solved {
  border-color: var(--lab-accent);
  box-shadow: 0 0 24px oklch(from var(--lab-accent) l c h / 0.25);
}

/* ── Operations bar ──────────────────────────────────────── */

.algebra-lab__ops {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-4);
}
.algebra-lab__ops-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--lab-muted);
  margin-right: var(--space-1, 0.25rem);
}
.algebra-lab__op-input {
  width: 4rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: center;
}
.algebra-lab__op-input:focus {
  outline: 2px solid var(--lab-accent);
  outline-offset: 1px;
}
.algebra-lab__op-btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition-interactive), background var(--transition-interactive);
}
.algebra-lab__op-btn:hover {
  border-color: var(--lab-accent);
  background: oklch(from var(--lab-accent) l c h / 0.08);
}
.algebra-lab__op-btn:focus-visible {
  outline: 2px solid var(--lab-accent);
  outline-offset: 2px;
}

/* ── Steps history ───────────────────────────────────────── */

.algebra-lab__steps {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--lab-muted);
  line-height: 2;
  margin-bottom: var(--space-4);
  padding-left: var(--space-4);
  border-left: 2px solid oklch(from var(--lab-accent) l c h / 0.2);
  min-height: 1.5rem;
}
.algebra-lab__steps:empty { display: none; }

/* ── Inequality controls ─────────────────────────────────── */

.algebra-lab__ineq-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-4);
}
.algebra-lab__toggle {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--lab-muted);
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.algebra-lab__toggle:hover {
  border-color: oklch(from var(--lab-accent) l c h / 0.4);
  color: var(--color-text);
}
.algebra-lab__toggle.is-active {
  border-color: var(--lab-accent);
  background: oklch(from var(--lab-accent) l c h / 0.15);
  color: var(--color-text);
}
.algebra-lab__toggle:focus-visible {
  outline: 2px solid var(--lab-accent);
  outline-offset: 2px;
}

/* ── Graph info row ──────────────────────────────────────── */

.algebra-lab__graph-info {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--lab-muted);
  margin-bottom: var(--space-3);
}

/* ── Shared feedback ─────────────────────────────────────── */

.algebra-lab__feedback {
  font-size: var(--text-sm);
  color: var(--lab-muted);
  line-height: 1.55;
  min-height: 1.5rem;
  margin-bottom: var(--space-3);
}
.algebra-lab__feedback--ok { color: var(--lab-accent); font-weight: 600; }
.algebra-lab__feedback--err { color: #e07070; }

/* ── Buttons ─────────────────────────────────────────────── */

.algebra-lab__btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  margin-bottom: var(--space-4);
}
.algebra-lab__btn {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition-interactive), background var(--transition-interactive);
}
.algebra-lab__btn:hover {
  border-color: oklch(from var(--lab-accent) l c h / 0.4);
}
.algebra-lab__btn--primary {
  background: oklch(from var(--lab-accent) l c h / 0.18);
  border-color: var(--lab-accent);
}
.algebra-lab__btn--primary:hover {
  background: oklch(from var(--lab-accent) l c h / 0.28);
}
.algebra-lab__btn:focus-visible {
  outline: 2px solid var(--lab-accent);
  outline-offset: 2px;
}

/* ── Fine print ──────────────────────────────────────────── */

.algebra-lab__fine {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-6);
  line-height: 1.5;
  max-width: 68ch;
}

/* ── Celebrate animation ─────────────────────────────────── */

@keyframes algebra-celebrate {
  from { opacity: 0; transform: scale(0.85); }
  60%  { transform: scale(1.04); }
  to   { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  @keyframes algebra-celebrate { from, to { opacity: 1; transform: none; } }
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
  .algebra-lab__ops { gap: var(--space-1, 0.25rem); }
  .algebra-lab__op-btn { padding: 0.4rem 0.65rem; font-size: 0.7rem; }
  .algebra-lab__op-input { width: 3.2rem; }
  .algebra-lab__canvas--balance { height: 220px; }
  .algebra-lab__canvas--ineq { height: 110px; }
  .algebra-lab__ineq-controls { gap: var(--space-1, 0.25rem); }
}
