/* Debug Foundry chapter base — one layout for every chapter:
   the title, the model, the current step in focus, one bright Next.
   Motion tokens from the gentle-motion rulebook: 120ms press (scale .97),
   180ms disclosures, 240ms panels, ease-out cubic-bezier(0.23,1,0.32,1),
   hover gated to fine pointers, reduced motion handled globally. */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* Chapter pages: the title stays modest so model + caption fit one viewport. */
.page > .hero { margin-bottom: clamp(18px, 3vw, 30px); }
.page > .hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.7rem); }

/* The model + caption + controls move as one unit (the fullscreen target). */
.stage-focus { display: grid; gap: 16px; }
.stage-focus .stage { height: clamp(320px, 50vh, 520px); }
@media (max-width: 700px) {
  .stage-focus .stage { height: min(92vw, 52vh); }
  /* the in-scene tag owns the top; the meter chip takes the empty corner */
  .stage .meter { top: auto; bottom: 12px; right: 12px; }
}
/* the hint leaves once the learner is driving: no text sits over the scene */
.hint { font-size: 13px; transition: opacity 180ms var(--ease-out); }
.hint.hint-gone { opacity: 0; pointer-events: none; }
.hint .mob { display: none; }
@media (max-width: 700px) {
  .hint { max-width: 46%; }
  .hint .desk { display: none; }
  .hint .mob { display: inline; }
}
.stage-focus:fullscreen {
  background: var(--paper);
  padding: clamp(12px, 3vw, 32px);
  align-content: center;
  overflow: auto;
}
.stage-focus.pseudo-fs {
  position: fixed; inset: 0; z-index: 70;
  background: var(--paper);
  padding: 14px;
  align-content: center;
  overflow: auto;
}
.stage-focus:fullscreen .stage,
.stage-focus.pseudo-fs .stage { height: min(70vh, 640px); }

/* The caption: the current step's sentence, big, directly under the model.
   Space is reserved by flow — text never overlaps the 3D. */
.cap-big {
  margin: 0;
  max-width: 40rem;
  font-size: clamp(1.25rem, 1rem + 1.6vw, 1.75rem);
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-wrap: pretty;
  min-height: 2.7em; /* two lines always reserved: no layout jump between steps */
}
.cap-big .toy {
  display: block;
  margin-top: 4px;
  font-size: 0.68em;
  font-weight: 450;
  color: var(--muted);
}

/* Controls: Next is the one bright action; the rest are quiet icons. */
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 700px) {
  /* deliberate: Next takes the row, the icons share one row under it */
  .btn-next { flex: 1 0 100%; justify-content: center; }
}
.btn-next {
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 650;
  font-size: 1.05rem;
  padding: 12px 26px;
  box-shadow: var(--shadow-soft);
  transition: transform 120ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
html[data-theme="dark"] .btn-next { color: #10131a; }
.btn-next:active { transform: scale(0.97); }
.btn-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: none;
  display: inline-grid;
  place-items: center;
  transition: transform 120ms var(--ease-out), border-color 180ms ease, color 180ms ease;
}
.btn-icon:active { transform: scale(0.97); }
.btn-icon[disabled] { opacity: 0.35; pointer-events: none; }
.btn-icon[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .btn-next:hover { transform: translateY(-1px); }
  .btn-icon:hover { border-color: var(--accent); }
}

/* Step dots: position without words. */
.dots { display: flex; gap: 9px; align-items: center; padding-left: 6px; }
.dots button {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--line);
  padding: 0;
  transition: transform 180ms var(--ease-out), background 180ms ease;
}
.dots button[aria-current="step"] { background: var(--accent); transform: scale(1.35); }

/* The full step list, on demand: a 240ms panel entering from its trigger side. */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: #1c202866;
  display: grid;
  place-items: end center;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  width: min(680px, 100%);
  max-height: 72vh;
  overflow: auto;
  padding: 10px 22px 26px;
  box-shadow: var(--shadow);
  animation: sheet-in 240ms var(--ease-out);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 10px;
  font-weight: 650;
  font-size: 1.02rem;
}
.sheet-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: none;
  display: inline-grid;
  place-items: center;
  transition: transform 120ms var(--ease-out), border-color 180ms ease;
}
.sheet-close:active { transform: scale(0.97); }
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (min-width: 700px) {
  .sheet-backdrop { place-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sheet li button {
  display: flex; gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  line-height: 1.4;
  transition: background 120ms ease;
}
.sheet li button:hover { background: var(--accent-soft); }
.sheet li button[aria-current="step"] { background: var(--accent-soft); font-weight: 600; }
.sheet .n { flex: 0 0 1.6em; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}

/* The article, on demand. */
.chapter-read { margin-top: clamp(28px, 5vw, 44px); }
.chapter-read > summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent);
  list-style: none;
  padding: 10px 0;
}
.chapter-read > summary::-webkit-details-marker { display: none; }
.chapter-read > summary .icon { transition: transform 180ms var(--ease-out); }
.chapter-read[open] > summary .icon { transform: rotate(90deg); }
