/* Practice page: "a well-made lesson", warm paper, deep ink, one terracotta accent.
   The store inside the preview has its own look (lesson-code.js). */
:root {
  --paper: #f4eee3;
  --paper-2: #ebe3d4;
  --card: #fffdf8;
  --line: #e2d9c8;
  --line-strong: #cfc4b0;
  --ink: #1e2421;
  --muted: #575c57;
  --accent: #b8432a;
  --accent-dark: #9a3620;
  --accent-tint: #f8e6dc;
  --pine: #2f6b4f;
  --pine-dark: #245640;
  --pine-tint: #e2eee6;
  --code-bg: #1f2421;
  --code-bar: #2b312d;
  --code-text: #ede6d6;
  --code-muted: #8f928a;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 16px; top: -60px; z-index: 10;
  padding: 10px 16px; font-weight: 700; color: var(--card); background: var(--ink); border-radius: 8px;
}
.skip:focus { top: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 32px; padding: 14px 32px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-mark { flex: none; }
.topbar-text { min-width: 0; }
.topbar-course {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.topbar-title { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1.25; }

.progress { display: flex; align-items: center; gap: 0; margin: 0; padding: 0; list-style: none; }
.progress-step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 16px; font-weight: 600; }
.progress-step + .progress-step::before {
  content: ""; display: block; width: 32px; height: 2px; margin: 0 10px; background: var(--line-strong);
}
.progress-num {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border: 2px solid var(--line-strong); border-radius: 50%;
  font-size: 15px; font-weight: 700; color: var(--muted); background: var(--card);
}
.progress-step.is-current { color: var(--ink); }
.progress-step.is-current .progress-num { color: #fff; background: var(--accent); border-color: var(--accent); }
.progress-step.is-done { color: var(--pine-dark); }
.progress-step.is-done .progress-num { color: #fff; background: var(--pine); border-color: var(--pine); }
.progress-step.is-done + .progress-step::before { background: var(--pine); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 37.5rem) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 24px 32px;
}

.panel, .preview {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(30, 36, 33, 0.04), 0 8px 24px rgba(30, 36, 33, 0.05);
}
.panel { padding: 32px 36px 36px; }

/* ---------- Shared bits ---------- */
.eyebrow {
  margin: 0 0 10px; font-size: 14px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent-dark);
}

.tag {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 3.4em; padding: 3px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 14px; font-weight: 700; line-height: 1.3; letter-spacing: 0.02em;
}
.tag-html { color: #8e3119; background: #f6ded5; }
.tag-css { color: #1f5444; background: #dcebe3; }
.tag-js { color: #6a4a0c; background: #f3e6c6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px;
  font: inherit; font-weight: 700; line-height: 1.2; text-decoration: none;
  border: 2px solid transparent; border-radius: 10px; cursor: pointer;
}
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { color: var(--ink); background: var(--card); border-color: var(--ink); }
.btn-secondary:hover { background: var(--paper); }
.btn-large { min-height: 56px; padding: 12px 28px; font-size: 19px; }
.btn-large::after, .btn-next::after { content: "\2192"; font-weight: 400; }

.small { margin: 10px 0 0; font-size: 15px; color: var(--muted); }

code {
  font-family: var(--mono); font-size: 0.86em;
  padding: 1px 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 5px;
  overflow-wrap: anywhere;
}

kbd {
  display: inline-block; padding: 0 6px; font-family: var(--mono); font-size: 0.85em;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--card);
}

/* ---------- Intro ---------- */
.intro-title {
  margin: 0 0 14px; font-family: var(--serif); font-size: 44px; font-weight: 700;
  line-height: 1.08; letter-spacing: -0.01em;
}
.intro-title:focus { outline: none; }
.intro-lead { margin: 0 0 24px; font-size: 19px; color: var(--muted); max-width: 32em; }

.intro-steps { margin: 0 0 24px; padding: 0; list-style: none; counter-reset: s; }
.intro-steps li {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--line); font-size: 18px;
}
.intro-steps li:last-child { border-bottom: 1px solid var(--line); }
.intro-steps li::before {
  counter-increment: s; content: counter(s);
  width: 1.2em; font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--muted);
}

.intro-safe {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0 0 26px; padding: 12px 16px; border-radius: 10px;
  font-size: 16px; font-weight: 600; color: var(--pine-dark); background: var(--pine-tint);
}
.intro-safe svg { flex: none; margin-top: 1px; }
.intro-tip { margin: 16px 0 0; font-size: 15px; color: var(--muted); }

/* ---------- Step ---------- */
.step-kicker {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px; font-size: 15px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.step-title {
  margin: 0 0 8px; font-family: var(--serif); font-size: 34px; font-weight: 700; line-height: 1.12;
}
/* These headings only take focus from script, so screen readers start reading there. */
.step-title:focus, .done-title:focus { outline: none; }
.step-why { margin: 0 0 20px; font-size: 19px; color: var(--muted); }

.editor { overflow: hidden; background: var(--code-bg); border-radius: 12px; }
.editor-bar {
  display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
  padding: 0 14px 0 0; background: var(--code-bar);
}
.editor-file {
  padding: 8px 16px; font-family: var(--mono); font-size: 14px; color: var(--code-text);
  background: var(--code-bg); border-top: 3px solid var(--accent);
}
.editor-note { align-self: center; font-size: 13px; color: var(--code-muted); }

.editor-body { padding: 12px 0 14px; font-family: var(--mono); font-size: 18px; line-height: 1.6; color: var(--code-text); }
.code-row { display: flex; align-items: flex-start; padding-right: 16px; }
.ln {
  flex: none; width: 3.2em; padding-right: 0.9em; text-align: right;
  color: var(--code-muted); user-select: none; font-size: 0.85em; line-height: 1.88;
}
.code-text { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.code-row--gap .code-text { font-family: var(--sans); font-size: 15px; font-style: italic; color: var(--code-muted); line-height: 1.9; }

.code-row--input { align-items: center; margin: 4px 0; padding-top: 4px; padding-bottom: 4px; background: #2c332e; }
.code-row--input .ln { color: var(--code-text); line-height: 1.4; }
.code-pad { flex: none; white-space: pre; }
.code-input {
  flex: 1 1 auto; min-width: 0; min-height: 46px; padding: 6px 12px;
  font-family: var(--mono); font-size: 18px; color: var(--ink);
  background: var(--card); border: 2px dashed var(--accent); border-radius: 7px;
}
.code-input::placeholder { color: #6b6f69; opacity: 1; }
.code-input:focus-visible { outline: 3px solid #f0b49d; outline-offset: 2px; border-style: solid; }
.code-input.is-wrong { border-style: solid; border-color: #d0603f; }
.code-input.is-right { border-style: solid; border-color: var(--pine); background: #eef6f0; }

.tok-tag, .tok-attr, .tok-str, .tok-sel, .tok-prop, .tok-fn { white-space: nowrap; }
.tok-tag { color: #f2a58b; }
.tok-attr { color: #e7c88e; }
.tok-str { color: #a9d6b8; }
.tok-sel { color: #f2a58b; }
.tok-prop { color: #e7c88e; }
.tok-key { color: #c9b4f0; }
.tok-num { color: #f0c27a; }
.tok-fn { color: #9cc8e8; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }
.actions-tip { font-size: 15px; color: var(--muted); }

.feedback:empty { display: none; }
.feedback {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 18px; padding: 12px 16px; border-radius: 10px; font-weight: 600;
}
.feedback::before { flex: none; font-weight: 800; }
.feedback--ok { color: #1d5239; background: var(--pine-tint); }
.feedback--ok::before { content: "\2713"; }
.feedback--hint { color: #7a2e14; background: var(--accent-tint); }
.feedback--hint::before { content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; background: var(--accent-dark); font-size: 14px; margin-top: 2px; }
.feedback--info { color: var(--ink); background: var(--paper); }
.feedback--info::before { content: "i"; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; background: var(--ink); font-size: 14px; font-family: var(--serif); margin-top: 2px; }

.next-row { margin-top: 14px; }
.check-it { margin: 0 0 14px; font-size: 17px; }
.check-it::before { content: "Check: "; font-weight: 700; color: var(--pine-dark); }
.next-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-next { color: #fff; background: var(--pine); border-color: var(--pine); }
.btn-next:hover { background: var(--pine-dark); border-color: var(--pine-dark); }
.btn-see { display: none; }

/* ---------- Finish ---------- */
.done-stamp { display: block; margin-bottom: 14px; }
.done-tick { stroke-dasharray: 48; stroke-dashoffset: 0; animation: tick 600ms ease-out 150ms both; }
@keyframes tick { from { stroke-dashoffset: 48; } }
.done-title { margin: 0 0 10px; font-family: var(--serif); font-size: 48px; font-weight: 700; line-height: 1.05; }
.done-lead { margin: 0 0 22px; font-size: 19px; color: var(--muted); }

.recap { margin: 0 0 16px; padding: 0; list-style: none; }
.recap li { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.recap li:last-child { border-bottom: 1px solid var(--line); }
.recap .tag { margin-top: 2px; }
.recap div { min-width: 0; }
.recap-what { margin: 0 0 4px; font-weight: 700; }
.recap code { font-size: 15px; }
.recap-order { margin: 0 0 20px; font-size: 17px; }
.done-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.more { margin-top: 24px; padding: 16px 18px; background: var(--paper); border-radius: 10px; }
.more-title { margin: 0 0 6px; font-weight: 700; }
.more ul { margin: 0; padding-left: 1.2em; font-size: 16px; }
.more li + li { margin-top: 4px; }

/* ---------- Preview ---------- */
.preview { padding: 10px 12px 12px; position: sticky; top: 16px; }
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 2px 4px 10px;
}
.preview-title { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.preview-url {
  display: flex; align-items: center; gap: 8px; flex: 1 1 200px; justify-content: center;
  margin: 0; padding: 6px 14px; font-size: 14px; color: var(--muted); background: var(--paper); border-radius: 999px;
}
.size-toggle { display: inline-flex; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; }
.size-btn {
  min-height: 40px; min-width: 88px; padding: 6px 16px;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--ink);
  background: transparent; border: 0; border-radius: 999px; cursor: pointer;
}
.size-btn[aria-pressed="true"] { color: var(--card); background: var(--ink); }
.size-btn:focus-visible { outline-offset: 1px; }

.stage {
  position: relative; overflow: hidden;
  height: clamp(420px, calc(100vh - 186px), 900px);
  background: var(--paper-2); border-radius: 10px;
}
.frame-wrap { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.preview-frame { display: block; border: 0; background: #f8f3ea; }
.stage--phone .preview-frame {
  border-radius: 26px;
  box-shadow: 0 0 0 10px var(--ink), 0 24px 48px rgba(30, 36, 33, 0.25);
}

/* ---------- Footer ---------- */
.page-foot { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 32px; padding: 0 32px 32px; }
.linklike {
  min-height: 44px; padding: 6px 2px; font: inherit; font-weight: 600; color: var(--ink);
  background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.teacher summary { display: flex; align-items: center; min-height: 44px; color: var(--muted); cursor: pointer; }
.teacher-list { margin: 4px 0 0; padding-left: 1.4em; }
.teacher-list li + li { margin-top: 6px; }
.noscript { padding: 24px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .done-tick { animation: none; }
}

/* ---------- Shorter laptop screens (e.g. 1366 x 768) ---------- */
@media (min-width: 1101px) and (max-height: 860px) {
  .topbar { padding-top: 10px; padding-bottom: 10px; }
  .layout { padding-top: 18px; padding-bottom: 18px; gap: 20px; }
  .panel { padding: 24px 28px 28px; }
  .intro-title { font-size: 38px; }
  .intro-lead { margin-bottom: 16px; font-size: 18px; }
  .intro-steps { margin-bottom: 16px; }
  .intro-steps li { padding: 9px 0; }
  .intro-safe { margin-bottom: 18px; }
  .step-title { font-size: 30px; }
  .step-why { margin-bottom: 14px; font-size: 18px; }
  .editor-body { font-size: 17px; line-height: 1.5; }
  .code-input { font-size: 17px; min-height: 44px; }
  .actions, .feedback { margin-top: 14px; }
  .done-title { font-size: 40px; }
  .done-lead { margin-bottom: 14px; }
  .recap li { padding: 9px 0; }
  .more { margin-top: 16px; padding: 12px 16px; }
  .stage { height: clamp(420px, calc(100vh - 170px), 900px); }
  .next-row { margin-top: 10px; }
  .check-it { margin-bottom: 10px; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
  .stage { height: 560px; }
  .btn-see { display: inline-flex; }
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .topbar { padding: 12px 16px; }
  .topbar-title { font-size: 18px; }
  .progress { width: 100%; }
  .progress-step + .progress-step::before { width: 18px; margin: 0 8px; }
  .layout { padding: 16px; gap: 16px; }
  .panel { padding: 22px 18px 24px; }
  .intro-title { font-size: 32px; }
  .intro-lead, .step-why, .done-lead { font-size: 17px; }
  .step-title { font-size: 27px; }
  .done-title { font-size: 36px; }
  .editor-body { font-size: 15px; }
  .ln { width: 2.6em; padding-right: 0.7em; }
  .code-row { padding-right: 10px; }
  .code-input { font-size: 16px; padding: 6px 8px; }
  .editor-note { display: none; }
  .btn-large { width: 100%; }
  .stage { height: 520px; }
  .preview-url { order: 3; flex-basis: 100%; }
  .page-foot { padding: 0 16px 24px; }
}
