/* Scale the workspace from its available width, independently of the navigation.
   Keep print reference-sheet dimensions in their existing stylesheet. */
@media screen {
  .main { container-type: inline-size; container-name: workspace; }
  .page {
    --content-size: clamp(1rem, .94rem + .15cqi, 1.125rem);
    --measure: 76ch;
    width: 100%;
    max-width: 100rem;
    padding: clamp(1.5rem, 3cqi, 3rem) clamp(1rem, 3cqi, 3rem) 4rem;
    font-size: var(--content-size);
  }
  .page.prose { max-width: 82ch; }
  .page > h1, .module-head h1 { font-size: clamp(1.8rem, 1.35rem + 2cqi, 3rem); }
  .course-intro h1 { font-size: clamp(2rem, 1.4rem + 3cqi, 4rem); }
  .page-lede, .module-head .tagline, .course-intro > p { font-size: 1em; max-width: 70ch; }
  .reading-layout { max-width: calc(76ch + 15rem); margin-inline: auto; column-gap: clamp(1.5rem, 2.5cqi, 3rem); }
  .lesson, .module-start { width: 100%; max-width: 100%; }
  .prose p, .prose li { font-size: 1em; line-height: 1.8; }
  .lesson-head h2 { font-size: clamp(1.4rem, 1.15rem + .8cqi, 1.85rem); }
  .module-start { padding: clamp(1rem, 2.2cqi, 2rem); }
  .lesson-toc { max-height: calc(100dvh - 180px); overflow-y: auto; }
  .library-card > p, .project-card > p, .case-stage > p { max-width: 76ch; }
  .library-card h2 { font-size: clamp(1.25rem, 1.05rem + .5cqi, 1.6rem); }
  .research-filters label { min-width: 0; }
  .page :is(input, select, textarea) { max-width: 100%; }
  .page h1, .page h2 { overflow-wrap: anywhere; }
  /* Single-column reading stays centered rather than stretching line lengths. */
  @media (max-width: 1400px) {
    .reading-layout { max-width: 76ch; }
    .lesson-toc { max-height: none; overflow: visible; }
  }
  @media (max-width: 600px) {
    .page :is(input, select, textarea) { font-size: 1rem; }
    .page :is(.library-card, .project-card, .pathway-card, .case-player) { padding: 1rem; }
    .topbar { padding-inline: 1rem; }
    .topbar-caption { display: none; }
  }
  /* Cards and figures respond to the content area, including beside the sidebar. */
  @container workspace (max-width: 52rem) {
    .pathway-grid, .resource-stage-grid { grid-template-columns: minmax(0, 1fr); }
    .expansion-figure-body { grid-template-columns: minmax(0, 1fr); }
    .expansion-figure-controls { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
  }
  @container workspace (max-width: 38rem) {
    .research-filters { grid-template-columns: minmax(0, 1fr); }
  }
  @media (max-height: 600px) {
    .equation-toolbar { position: static; }
    .lesson-toc { top: 76px; max-height: calc(100dvh - 96px); }
    .lesson, .module-start { scroll-margin-top: 76px; }
  }
  @media (max-height: 600px) and (max-width: 900px) {
    .lesson, .module-start { scroll-margin-top: 130px; }
  }
}
