/**
 * Chemical & Physical Changes Lab styles.
 *
 * Page-local palette per the house lab convention (see thermal-energy.css).
 * Two meaning-carrying colors run through the whole page and match the
 * PS.8.1.4 slide deck: TEAL = physical change, RUST = chemical change.
 * Neither is ever the only signal: every use is paired with the word.
 *
 * WCAG 2.1 AA: 0.75rem minimum font size, 44px touch targets on every
 * control, correctness never conveyed by color alone (feedback carries a
 * check or cross plus "Correct." / "Not yet."), :focus-visible rings on
 * every interactive element, reduced motion respected (main.js plays the
 * scene as still frames under prefers-reduced-motion).
 *
 * The Lab Notebook panel's structure comes from
 * assets/labs/shared/lab-notebook.css; this file only sets its colors
 * under .labnb--cp and styles the caller-owned cp-nb-* classes.
 */
:root {
  --bg: #eef4f3;
  --paper: #fff;
  --ink: #16262e;
  --muted: #51636d;
  --line: #d3e0de;

  --phys: #0f766e;
  --phys-bg: #e6f6f3;
  --chem: #a8421a;
  --chem-bg: #fdf0e8;

  --accent: #1d4e89;
  --accent-bg: #eaf1fa;
  --good: #1a7f4b;
  --good-bg: #e9f8ef;
  --bad: #c92a2a;
  --bad-bg: #fff1f1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body { background: var(--bg); color: var(--ink); }
.cp-wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 28px; }
.cp-wrap, .cp-wrap * { font-family: 'Inter', system-ui, sans-serif; }
.cp-wrap h1, .cp-wrap h2, .cp-wrap h3, .cp-wrap h4, .cp-eyebrow, .cp-part, .cp-btn, .cp-prog-t {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
}
.cp-sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.cp-wrap :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.cp-wrap [tabindex="-1"]:focus { outline: none; }

/* HERO ------------------------------------------------------------------ */
.cp-hero { padding: 18px 8px 6px; text-align: center; }
.cp-hero-title { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.cp-hero h1 { font-weight: 700; font-size: clamp(1.7rem, 4.4vw, 2.5rem); line-height: 1.05; letter-spacing: -.02em; }
.cp-eyebrow {
  font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: .75rem;
  color: #fff; background: linear-gradient(90deg, var(--phys) 0 50%, var(--chem) 50% 100%);
  padding: 5px 12px; border-radius: 6px;
}
.cp-sub { max-width: 700px; margin: 8px auto 0; color: var(--muted); font-size: 1rem; font-weight: 500; line-height: 1.5; }
.cp-standard {
  display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); font-size: .8rem; font-weight: 600; color: var(--muted);
}

/* PANELS + PROSE -------------------------------------------------------- */
.cp-prose, .cp-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; margin: 16px 0; box-shadow: 0 6px 20px rgba(22, 38, 46, .05);
}
.cp-prose h2, .cp-panel h2 { font-weight: 700; font-size: 1.35rem; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cp-part {
  font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #fff; background: var(--ink); padding: 4px 10px; border-radius: 6px;
}
.cp-prose p, .cp-prose li { font-size: 1rem; line-height: 1.6; }
.cp-prose p { margin-bottom: 10px; }
.cp-prose ul, .cp-prose ol { margin: 0 0 10px 22px; }
.cp-prose li { margin-bottom: 3px; }
.cp-bigq {
  font-family: 'Space Grotesk', sans-serif; font-size: clamp(1.15rem, 2.6vw, 1.5rem) !important; font-weight: 600;
  text-align: center; padding: 14px; margin: 14px 0 !important; border-radius: 12px;
  background: linear-gradient(90deg, var(--phys-bg), var(--chem-bg));
}
.cp-bigq strong:first-of-type { color: var(--phys); }
.cp-bigq strong:last-of-type { color: var(--chem); }
.cp-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin: 14px 0; }
.cp-card { border-radius: 14px; padding: 16px; border: 2px solid; }
.cp-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.cp-card-phys { border-color: var(--phys); background: var(--phys-bg); }
.cp-card-phys h3 { color: var(--phys); }
.cp-card-chem { border-color: var(--chem); background: var(--chem-bg); }
.cp-card-chem h3 { color: var(--chem); }
.cp-callout { background: var(--accent-bg); border: 1px solid #c5d6ec; border-radius: 12px; padding: 14px 16px; margin: 14px 0; }
.cp-callout ol { margin: 8px 0 0 22px; }
.cp-gloss { font-size: .9rem !important; color: var(--muted); margin-bottom: 0 !important; }
.cp-gloss a { color: var(--accent); font-weight: 600; }
.cp-panel-sub { color: var(--muted); font-size: .95rem; line-height: 1.5; margin-bottom: 14px; }

/* PROGRESS STRIP -------------------------------------------------------- */
.cp-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; position: sticky; top: 0; z-index: 5; padding: 8px 0; background: var(--bg); }
.cp-prog {
  display: flex; flex-direction: column; gap: 1px; min-height: 44px; padding: 8px 12px; border-radius: 12px;
  background: var(--paper); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.cp-prog-k { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cp-prog-t { font-weight: 700; font-size: .95rem; }
.cp-prog-v { font-size: .8rem; color: var(--muted); font-weight: 500; }
.cp-prog-done { border-color: var(--good); background: var(--good-bg); }
.cp-prog-done .cp-prog-v { color: var(--good); font-weight: 700; }
.cp-prog-done .cp-prog-t::after { content: ' \2713'; color: var(--good); }
.cp-prog-locked .cp-prog-t { color: var(--muted); }

/* BUTTONS --------------------------------------------------------------- */
.cp-btn {
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 2px solid var(--ink);
  background: var(--paper); color: var(--ink); font-size: .95rem; font-weight: 600; cursor: pointer;
}
.cp-btn:hover:not(:disabled) { background: #f1f5f4; }
.cp-btn-primary { background: var(--ink); color: #fff; }
.cp-btn-primary:hover:not(:disabled) { background: #24414e; }
.cp-btn:disabled { opacity: .45; cursor: not-allowed; }
.cp-btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* STATION BAR ----------------------------------------------------------- */
.cp-stationbar { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 16px; }
.cp-chipbtn {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); cursor: pointer; font-size: .85rem; font-weight: 500;
}
.cp-chipbtn:hover { border-color: var(--ink); }
.cp-chipbtn-n {
  flex: 0 0 auto; min-width: 30px; height: 30px; padding: 0 4px; border-radius: 8px; display: grid; place-items: center;
  background: #e3ebea; font-weight: 700; font-size: .8rem; font-family: 'Space Grotesk', sans-serif;
}
.cp-chipbtn-t { flex: 1 1 auto; line-height: 1.25; }
.cp-chipbtn-c { color: var(--good); font-weight: 700; font-size: 1.05rem; }
.cp-chipbtn-on { border-color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); font-weight: 700; }
.cp-chipbtn-on .cp-chipbtn-n { background: var(--ink); color: #fff; }
.cp-chipbtn-done { background: var(--good-bg); border-color: #b5e2c6; }

/* STATION --------------------------------------------------------------- */
.cp-station { border-top: 1px solid var(--line); padding-top: 16px; }
.cp-station-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.cp-station-num { font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cp-station-head h3 { font-size: 1.3rem; font-weight: 700; flex: 1 1 auto; }
.cp-chip { font-size: .8rem; font-weight: 700; color: var(--good); background: var(--good-bg); border: 1px solid #b5e2c6; padding: 4px 10px; border-radius: 999px; }

.cp-step { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdfc; }
.cp-step h4 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cp-step-n {
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--ink); color: #fff; font-size: .85rem;
}
.cp-step-passed { border-color: #b5e2c6; }
.cp-step-passed .cp-step-n { background: var(--good); }
.cp-step-sub { color: var(--muted); font-size: .95rem; line-height: 1.5; margin-bottom: 10px; }
.cp-setup { font-size: 1rem; line-height: 1.5; margin-bottom: 10px; }
.cp-stage { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f4f7fb; max-width: 640px; }
.cp-scene { display: block; width: 100%; height: auto; aspect-ratio: 400 / 240; }
.cp-scene text { font-family: 'Inter', system-ui, sans-serif; }
.cp-result:not(:empty) {
  margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--accent-bg);
  border: 1px solid #c5d6ec; font-size: .98rem; line-height: 1.5; max-width: 640px;
}
.cp-result:not(:empty)::before { content: 'What happened: '; font-weight: 700; }

/* Wide panel: scene on the left, the reading and the controls beside it.
 * A container query, not a media query, so it follows the station's real
 * width wherever the page is shown. */
.cp-station { container-type: inline-size; }
@container (min-width: 760px) {
  #cp-step-observe {
    display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); column-gap: 20px;
    grid-template-areas: "h h" "stage setup" "stage btns" "stage result" "stage .";
    grid-template-rows: auto auto auto auto 1fr;
  }
  #cp-step-observe h4 { grid-area: h; }
  #cp-step-observe .cp-stage { grid-area: stage; max-width: none; }
  #cp-step-observe .cp-setup { grid-area: setup; }
  #cp-step-observe .cp-btn-row { grid-area: btns; margin-top: 4px; }
  #cp-step-observe .cp-result { grid-area: result; }
}

/* OPTIONS (radio + checkbox rows) --------------------------------------- */
.cp-choice, .cp-evidence { border: 0; margin: 10px 0 0; min-width: 0; }
.cp-choice legend { font-weight: 700; font-size: 1rem; margin-bottom: 8px; line-height: 1.4; }
.cp-opt {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 12px; margin-bottom: 6px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); cursor: pointer; font-size: .97rem; line-height: 1.4;
}
.cp-opt:hover { border-color: var(--ink); }
.cp-opt input { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px; accent-color: var(--ink); }
.cp-opt span small { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.cp-opt:has(input:checked) { border-color: var(--ink); background: #f1f5f4; box-shadow: inset 0 0 0 1px var(--ink); }
.cp-opt:has(input:disabled) { cursor: default; opacity: .8; }
.cp-choice-big { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 10px; }
.cp-choice-big legend { grid-column: 1 / -1; }
.cp-choice-big .cp-opt { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.05rem; align-items: center; }
.cp-opt-phys { border-color: var(--phys); color: var(--phys); }
.cp-opt-chem { border-color: var(--chem); color: var(--chem); }
.cp-opt-phys:has(input:checked) { background: var(--phys-bg); border-color: var(--phys); box-shadow: inset 0 0 0 1px var(--phys); }
.cp-opt-chem:has(input:checked) { background: var(--chem-bg); border-color: var(--chem); box-shadow: inset 0 0 0 1px var(--chem); }
.cp-opt-phys input { accent-color: var(--phys); }
.cp-opt-chem input { accent-color: var(--chem); }

.cp-evidence { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.cp-ev-h { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.cp-ev-h-phys { color: var(--phys); }
.cp-ev-h-chem { color: var(--chem); }

.cp-sentence {
  font-family: 'Space Grotesk', sans-serif; font-size: 1.08rem; line-height: 1.5; font-weight: 500;
  padding: 12px 14px; border-radius: 10px; border: 2px dashed var(--line); background: var(--paper); margin-bottom: 6px;
}

/* FEEDBACK -------------------------------------------------------------- */
.cp-feedback:empty { display: none; }
.cp-feedback { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: .97rem; line-height: 1.5; border: 1px solid; }
.cp-feedback ul { margin: 6px 0 0 20px; }
.cp-feedback li { margin-bottom: 4px; }
.cp-fb-good { background: var(--good-bg); border-color: #b5e2c6; color: #0f4d2c; }
.cp-fb-bad { background: var(--bad-bg); border-color: #f3c0c0; color: #7a1c1c; }

.cp-wrapup { margin-top: 14px; padding: 16px; border-radius: 14px; background: var(--good-bg); border: 1px solid #b5e2c6; }
.cp-wrapup p { font-size: 1.02rem; line-height: 1.55; }
.cp-wrapup p::before { content: 'Take-away: '; font-weight: 700; }

/* PARTICLE FIGURES ------------------------------------------------------ */
.cp-fig { margin-top: 10px; }
.cp-pfig { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-pbox { flex: 1 1 170px; max-width: 280px; min-width: 150px; }
.cp-pbox svg { display: block; width: 100%; height: auto; }
.cp-pbox svg text { font-family: 'Inter', system-ui, sans-serif; }
.cp-pbox figcaption { text-align: center; font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.cp-parrow { font-size: 1.6rem; color: var(--muted); flex: 0 0 auto; }
.cp-plegend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0 !important; padding: 0; }
.cp-plegend li { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink); margin: 0; }
.cp-plegend svg { flex: 0 0 auto; }

/* TRICKY CASES ---------------------------------------------------------- */
.cp-locked { padding: 14px; border-radius: 12px; border: 2px dashed var(--line); color: var(--muted); font-weight: 600; text-align: center; }
.cp-casebar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cp-dot {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--paper);
  font-weight: 700; font-size: .9rem; color: var(--ink); cursor: pointer; font-family: 'Space Grotesk', sans-serif;
}
.cp-dot:hover { border-color: var(--ink); }
.cp-dot-done { background: var(--good-bg); border-color: #b5e2c6; color: var(--good); }
.cp-dot-on { border-color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.cp-case { border-top: 1px solid var(--line); padding-top: 14px; }
.cp-case h3 { font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.cp-case-text { font-size: 1.12rem; line-height: 1.55; font-weight: 500; }

/* MASTERY --------------------------------------------------------------- */
.cp-best { font-size: 1rem; font-weight: 600; }
.cp-q { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.cp-q:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.cp-q legend { font-weight: 600; }
.cp-q-n { font-family: 'Space Grotesk', sans-serif; font-weight: 700; }
.cp-q .cp-fig { margin: 0 0 12px; }
.cp-score { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.cp-score-pass { color: var(--good); }
#cp-mastery-result p { line-height: 1.55; }
#cp-mastery-result h4 { font-size: 1.05rem; margin: 18px 0 8px; }
.cp-skilltable { width: 100%; max-width: 520px; border-collapse: collapse; margin-top: 14px; font-size: .95rem; }
.cp-skilltable caption { text-align: left; font-weight: 700; margin-bottom: 6px; font-family: 'Space Grotesk', sans-serif; }
.cp-skilltable th, .cp-skilltable td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.cp-skilltable thead th { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cp-skilltable tbody th { font-weight: 500; }
.cp-ok { color: var(--good); font-weight: 700; }
.cp-review { color: var(--bad); font-weight: 700; }
.cp-review-list { margin-left: 22px; }
.cp-review-list li { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }
.cp-review-list p { font-size: .95rem; margin-bottom: 4px; }
.cp-rv-right { background: #fbfdfc; }
.cp-rv-wrong { background: var(--bad-bg); border-color: #f3c0c0 !important; }
.cp-rv-skill { display: inline-block; margin-left: 8px; font-size: .75rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: var(--paper); }
.cp-rv-yours { color: #7a1c1c; }
.cp-rv-answer { font-weight: 600; }
.cp-rv-why { color: var(--muted); }

/* LAB NOTEBOOK ---------------------------------------------------------- */
.labnb--cp {
  --labnb-surface: #fff; --labnb-border: var(--line); --labnb-ink: var(--ink);
  --labnb-muted: var(--muted); --labnb-accent: var(--accent);
  margin-top: 0; border-top: 0; padding-top: 0;
}
.cp-nb-label { font-family: 'Space Grotesk', sans-serif; font-size: .8rem; }
.cp-nb-h { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; }
.cp-nb-props a { color: var(--accent); font-weight: 600; }
.cp-nb-field textarea { min-height: 96px; font-size: .97rem; line-height: 1.5; }
.labnb--cp .labnb-log { max-height: 220px; overflow-y: auto; }

.cp-copyright { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 20px; }

@media (max-width: 560px) {
  .cp-prose, .cp-panel { padding: 14px; border-radius: 14px; }
  .cp-step { padding: 12px; }
  .cp-progress { gap: 6px; }
  .cp-prog { padding: 6px 8px; }
  .cp-prog-k { display: none; }
  .cp-prog-t { font-size: .85rem; }
  .cp-prog-v { font-size: .75rem; }
  .cp-stationbar { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cp-parrow { transform: rotate(90deg); flex-basis: 100%; text-align: center; }
  .cp-pbox { max-width: none; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
