/* Coding copilot: a 4-stage stepper (Understand, Approach, Code v1, Edge cases). Mobile-first. */

.pane.coding { flex: 1; overflow-y: auto; padding: 8px 8px 0; gap: 8px; overscroll-behavior: contain; }

.coding-head { display: flex; flex-direction: column; gap: 8px; }
.stepper {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none;
}
.stepper li {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: var(--radius-m);
  font-size: 0.72rem; color: var(--text-faint); text-align: center; border: 1px solid transparent;
}
.stepper li span {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-3); font: 700 0.75rem var(--font-mono);
}
.stepper li.done { color: var(--text-dim); }
.stepper li.done span { background: var(--live-soft); color: var(--live); }
.stepper li.active { color: var(--text); border-color: #1f4d47; background: var(--surface); }
.stepper li.active span { background: var(--live); color: var(--live-ink); }
.coding-tools { display: grid; grid-template-columns: 1fr auto; gap: 6px; }

.coding-status { margin: 0; padding: 0 4px; font-size: 0.88rem; color: var(--text-dim); }
.coding-status[data-state="busy"] { color: var(--busy); }
.coding-status[data-state="error"] { color: var(--danger); }

.change {
  padding: 8px 12px; border-radius: var(--radius-m); background: #2a1f0b; border: 1px solid #5a4214;
  color: #fcd58a; font-size: 0.92rem; animation: enter 260ms var(--ease);
}
.change b { margin-right: 6px; font: 700 0.68rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }

/* What to say right now: same treatment as the Live "say" block, pinned under the header. */
.say-strip {
  padding: 10px 12px; border-radius: var(--radius-m); background: var(--say-bg); border-left: 4px solid var(--live);
  font: 500 var(--text-say)/1.45 var(--font-read); color: #f2fffd;
}
.say-strip p { margin: 0; }
.say-strip .placeholder { color: #8fbdb6; font-style: normal; }

.stages { display: flex; flex-direction: column; gap: 8px; }
.stage { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.stage.current { border-color: #1f4d47; box-shadow: var(--shadow); }
.stage-head {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--tap); padding: 8px 12px; text-align: left;
  font: 650 0.98rem var(--font-read); color: var(--text-dim);
}
.stage.current .stage-head { color: var(--text); cursor: default; }
.stage-num {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-3); font: 700 0.75rem var(--font-mono);
}
.stage.current .stage-num { background: var(--live); color: var(--live-ink); }
.stage:not(.current) .stage-head::after { content: "▾"; margin-left: auto; color: var(--text-faint); }
.stage:not(.current).open .stage-head::after { content: "▴"; }
.pulse { width: 8px; height: 8px; margin-left: 4px; border-radius: 50%; background: var(--busy); animation: pulse 1.4s var(--ease) infinite; }
.stage-body { padding: 0 12px 12px; font: var(--text-body)/1.55 var(--font-read); }
.stage:not(.open) .stage-body { display: none; }

/* Inside a stage: section headings, step blocks, and "why" explanations. */
.stage-body h4 {
  margin: 14px 0 6px; padding-top: 10px; border-top: 1px solid var(--line);
  font: 700 0.72rem var(--font-mono); letter-spacing: 0.08em; color: var(--text-faint);
}
.stage-body > h4:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.stage-body h5 { margin: 14px 0 4px; font: 650 0.95rem var(--font-read); text-transform: none; letter-spacing: 0; color: var(--live); }
.stage-body ol > li { margin: 6px 0; }
.stage-body em { color: var(--text-dim); }
.copy-code {
  position: absolute; top: 6px; right: 6px; min-height: 28px; padding: 2px 10px; border-radius: var(--radius-s);
  background: var(--surface-3); color: var(--text-dim); font: 600 0.75rem var(--font-ui);
}
.copy-code:hover { color: var(--text); }

.cue {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px;
  border-radius: var(--radius-m); background: #0f2a1a; border: 1px solid #1f5135; color: #bbf7d0;
}

/* Actions stay within thumb reach at the bottom of the scrolling pane. */
.coding-actions {
  position: sticky; bottom: 0; z-index: 2; display: grid; grid-template-columns: 1fr 2fr; gap: 8px;
  margin: 0 -8px; padding: 8px; background: linear-gradient(transparent, var(--bg) 30%);
}
.coding-actions:has(#coding-next[hidden]) { grid-template-columns: 1fr; }

.problem-form { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 12px; }
.problem-form textarea { min-height: 44px; }

/* No problem yet: show only the say strip and the paste box. */
.pane.coding:not(.has-plan) :is(.stages, #coding-change, .coding-actions) { display: none; }

@media (min-width: 960px) {
  .pane.coding { padding: 14px 22px 0; gap: 10px; }
  .coding-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .stepper { display: flex; gap: 6px; }
  .stepper li { flex-direction: row; gap: 8px; padding: 6px 12px; font-size: 0.85rem; }
  .coding-tools { display: flex; }
  .say-strip { padding: 12px 16px; }
  .stage-head { padding: 10px 16px; }
  .stage-body { padding: 0 16px 16px; max-width: 980px; }
  .coding-actions { grid-template-columns: auto auto; justify-content: end; margin: 0 -22px; padding: 10px 22px; }
}
