/* The foreground is the next section itself, not a duplicate animated prop. */
.desk-chapter {
  --desk-p: 0;
  --desk-scroll: 0px;
  --workbook-open: 0;
  --workbook-unfold: 1;
  --workbook-paper: #f2ecdf;
  --scene-height: max(940px, 100svh, 48vw);
  --book-overlap: 20px;
  position: relative;
  isolation: isolate;
  background: var(--blue);
  overflow: clip;
}
.desk-chapter .hero--desk,
.depth-ready .desk-chapter .hero--desk {
  height: var(--scene-height);
  min-height: 0;
  max-height: none;
  overflow: visible;
  z-index: 0;
  --desk-p: inherit;
}
.desk-chapter .desk-stage,
.depth-ready .desk-chapter .desk-stage {
  position: relative;
  height: var(--scene-height);
  min-height: 0;
  overflow: visible;
}
.depth-ready .desk-chapter .hero--desk { position: sticky; top: 0; }
.desk-chapter .desk-stage::after { display: none; }
.desk-chapter .hero-copy {
  padding-top: clamp(100px, 10.8svh, 124px);
  transform: translate3d(0, calc(var(--desk-scroll) * -1), 0);
}
.desk-chapter h1 { font-size: clamp(58px, min(6.2vw, 7.6svh), 88px); }
.desk-chapter .desk-world { width: max(100%, 192svh); aspect-ratio: 2 / 1; bottom: 0; mask-image: none; }
.desk-chapter a { scroll-margin-block: 96px; }
.desk-chapter .desk-room {
  inset: 0;
  transform: translate3d(0, calc(var(--desk-scroll) * -.65), 0);
  pointer-events: auto;
}
.desk-chapter .desk-backdrop { position: absolute; inset: 0; }
.desk-chapter .desk-backdrop img { object-fit: fill; mask-image: linear-gradient(transparent, #000 20%, #000 95%, transparent); }
/* Restore the complete original photograph, including the objects' contact
   shadows. The wider plate only continues the room around its outer edges. */
.desk-chapter .desk-photo {
  inset: 4.3% auto auto 12.7%; width: 72.2%; height: 96.2667%;
  mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
}
.desk-chapter .desk-photo img { object-fit: fill; clip-path: none; mask-image: linear-gradient(transparent, #000 8%, #000 95%, transparent); }
/* A matching empty desktop continues behind the opening paper's corners.
   Its overlap sits behind the photograph, preserving the keyboard and props. */
.desk-chapter .desk-room::after {
  content: ""; position: absolute; z-index: -1; top: 90%; left: 0; width: 100%; height: 80%;
  background: url('../images/desk-walnut-continuation.webp') center top / 100% auto;
  mask-image: linear-gradient(transparent, #000 10%);
  pointer-events: none;
}
/* Typography follows the physical monitor, not the width of the browser. */
.desk-chapter .digital-course-screen {
  left: 35.68%; top: 45.87%; width: 28.23%; height: 32.36%;
  container-type: inline-size;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  padding: .9% 1.2% 1.2%; gap: 9px;
}
.desk-chapter .screen-heading > span { font-size: clamp(15px, 4.3cqw, 26px); }
.desk-chapter .screen-heading small { font-size: clamp(8px, 2cqw, 12px); }
.desk-chapter .folio { padding: 10px 12px; justify-content: space-between; }
.desk-chapter .folio-name { font-size: clamp(15px, 4.4cqw, 28px); }
.desk-chapter .folio--closure .folio-name { font-size: clamp(13px, 3.7cqw, 24px); }
.desk-chapter .folio-bottom { display: flex; flex-shrink: 0; margin-top: auto; font-size: clamp(8px, 1.9cqw, 12px); line-height: 1.2; padding-top: 4px; }
.desk-chapter .folio-bottom i { font-size: clamp(12px, 3cqw, 19px); line-height: 1; }

.desk-chapter .workbook {
  position: relative;
  z-index: 8;
  margin-top: calc(var(--book-overlap) * -1);
  padding: 0;
  background: transparent;
  color: var(--blue);
  min-height: 770px;
  isolation: isolate;
}
.workbook-paper { position: absolute; inset: 0; z-index: -1; pointer-events: none; transform-origin: 50% 0; transform-style: preserve-3d; }
.depth-ready .workbook-paper { transform: perspective(1800px) rotateX(calc((1 - var(--workbook-unfold)) * 20deg)); }
.workbook-leaf { position: absolute; top: 0; bottom: 0; width: 50.02%; transform-style: preserve-3d; }
.workbook-leaf--left { left: 0; transform-origin: 100% 0; }
.workbook-leaf--right { right: 0; transform-origin: 0 0; }
.depth-ready .workbook-leaf--left { transform: perspective(1800px) rotateY(calc((1 - var(--workbook-unfold)) * -34deg)); }
.depth-ready .workbook-leaf--right { transform: perspective(1800px) rotateY(calc((1 - var(--workbook-unfold)) * 34deg)); }
.workbook-fold-light { position: absolute; inset: 24px 0 0; opacity: calc((1 - var(--workbook-unfold)) * .16); background: linear-gradient(90deg, transparent, #725e40); mask-image: linear-gradient(transparent, #000 100px); }
.workbook-leaf--right .workbook-fold-light { background: linear-gradient(90deg, #725e40, transparent); }
.workbook-edge { position: absolute; top: 0; width: 100%; height: 120px; overflow: visible; filter: drop-shadow(0 -8px 12px #10232a35); }
.workbook-cover { fill: #a6b5a1; }
.workbook-page-stack { fill: #dfd7c6; stroke: #eee6d7; stroke-width: 1.5; }
.workbook-page-top { fill: var(--workbook-paper); }
.workbook-edge-light { fill: none; stroke: #fffaf0; stroke-width: 1.4; opacity: .75; }
.workbook-ground { position: absolute; inset: 119px 0 0; background: var(--workbook-paper); }
.workbook-ground::after { content: ""; position: absolute; inset: -78px 0 0; background: url('../images/paper-grain.svg'); opacity: .065; mask-image: linear-gradient(transparent, #000 60px); }
.workbook-gutter {
  position: absolute; top: 23px; left: calc(50% - 22px); width: 44px; height: 260px;
  background: linear-gradient(90deg, transparent, #927b5830 44%, #79664a38 48%, #fffbf28f 53%, transparent);
  mask-image: linear-gradient(#000, transparent);
  opacity: calc(1 - var(--workbook-open) * .7);
}
.workbook-notes { position: absolute; inset: 0; pointer-events: none; }
.workbook-note {
  position: absolute; display: grid; place-items: center; margin: 0;
  width: clamp(94px, 8.4vw, 122px); aspect-ratio: 1.06;
  color: #283e3c; background: var(--note-color);
  border-radius: 1px 2px 15px 2px;
  box-shadow: 2px 9px 12px -5px #57472f47, inset 0 1px 1px #fff8;
  font: 23px/1.1 'Bradley Hand', 'Segoe Print', 'Comic Sans MS', cursive;
  text-align: center; transform-origin: 50% 20%;
}
.workbook-note::before { content: ""; position: absolute; inset: 0; background: linear-gradient(170deg, #fff4, transparent 35%, #7167440a 80%, #fff3); border-radius: inherit; }
.workbook-note::after { content: ""; position: absolute; right: 0; bottom: 0; width: 19px; height: 17px; background: linear-gradient(138deg, #ffffff4d, var(--note-fold) 55%, #8c7a4840 58%, transparent 64%); border-radius: 100% 0 11px 0; }
.workbook-note span { position: relative; padding: 12px 6px; white-space: nowrap; }
.workbook-note--yellow { --note-color: #ead69d; --note-fold: #f5e5b2; top: 36px; left: 38%; transform: rotate(-6deg); }
.workbook-note--sage { --note-color: #b8c7a4; --note-fold: #d4dec3; top: 43px; right: 38%; transform: rotate(5deg); }
.depth-ready .workbook-note--yellow { transform: translate3d(calc(var(--workbook-open) * -7vw), calc(var(--workbook-open) * 85px), 0) rotate(calc(-6deg + var(--workbook-open) * 2deg)); }
.depth-ready .workbook-note--sage { transform: translate3d(calc(var(--workbook-open) * 7vw), calc(var(--workbook-open) * 265px), 0) rotate(calc(5deg - var(--workbook-open) * 2deg)); }
.workbook-copy { position: relative; width: min(780px, 64%); padding: 220px 24px 120px; margin: auto; text-align: center; }
.workbook-copy h2 { font-size: clamp(42px, 4.5vw, 68px); max-width: 680px; margin: 0 auto; color: var(--blue); }
.workbook-lede { max-width: 32ch; margin: 28px auto 0; font-size: 22px; line-height: 1.6; color: #344e58; }
.workbook .recognition-note { display: block; margin: 38px auto 0; max-width: 49ch; color: #415660; font-size: 16px; }
.workbook .fine-rule { margin: 0 auto 22px; width: 42px; background: #8b947c; }
.desk-chapter.is-moving .desk-room,
.desk-chapter.is-moving .workbook-paper { will-change: transform; }

@media (min-width: 761px) and (max-width: 1100px) {
  .desk-chapter { --scene-height: 940px; }
  .desk-chapter .desk-world { width: 1533px; bottom: 0; }
  .desk-chapter h1 { font-size: 62px; }
  .workbook-copy { width: 64%; }
  .workbook-note { width: 98px; font-size: 19px; }
  .depth-ready .workbook-note--yellow { transform: translate3d(calc(var(--workbook-open) * -11vw), calc(var(--workbook-open) * 65px), 0) rotate(-5deg); }
  .depth-ready .workbook-note--sage { transform: translate3d(calc(var(--workbook-open) * 11vw), calc(var(--workbook-open) * 330px), 0) rotate(4deg); }
}
@media (max-width: 760px) {
  .desk-chapter { --scene-height: 820px; --book-overlap: 12px; }
  .depth-ready .desk-chapter .hero--desk { position: relative; }
  .desk-chapter .hero-copy { padding-top: 137px; transform: none; }
  .desk-chapter h1 { font-size: clamp(39px, 10.3vw, 58px); }
  .desk-chapter .desk-world { width: min(calc(100% + 660px), 1090px); bottom: 0; }
  .desk-chapter .desk-room { transform: translate3d(0, calc(var(--desk-p) * -6px), 0); }
  .desk-chapter .digital-course-screen { padding: 1.2%; gap: 6px; }
  .desk-chapter .screen-heading > span { font-size: 14px; }
  .desk-chapter .screen-heading small { font-size: 8px; }
  .desk-chapter .folio { padding: 5px 7px; }
  .desk-chapter .folio-name { font-size: 14px; line-height: 1.02; }
  .desk-chapter .folio--closure .folio-name { font-size: 10px; line-height: 1.02; }
  .desk-chapter .folio-bottom { font-size: 8px; padding-top: 2px; }
  .desk-chapter .folio-bottom i { font-size: 12px; }
  .desk-chapter .workbook { min-height: 670px; }
  .workbook-edge { height: 84px; }
  .workbook-ground { top: 83px; }
  .workbook-gutter { top: 17px; height: 180px; }
  .depth-ready .workbook-paper { transform: perspective(1400px) rotateX(calc((1 - var(--workbook-unfold)) * 6deg)); }
  .depth-ready .workbook-leaf--left { transform: perspective(1400px) rotateY(calc((1 - var(--workbook-unfold)) * -16deg)); }
  .depth-ready .workbook-leaf--right { transform: perspective(1400px) rotateY(calc((1 - var(--workbook-unfold)) * 16deg)); }
  .workbook-note { width: 86px; font-size: 18px; }
  .workbook-note--yellow { top: 32px; left: 18%; }
  .workbook-note--sage { top: 39px; right: 18%; }
  .depth-ready .workbook-note--yellow { transform: translate3d(calc(var(--workbook-open) * -8px), calc(var(--workbook-open) * -4px), 0) rotate(-5deg); }
  .depth-ready .workbook-note--sage { transform: translate3d(calc(var(--workbook-open) * 8px), calc(var(--workbook-open) * 12px), 0) rotate(4deg); }
  .workbook-copy { width: 100%; padding: 168px 25px 74px; }
  .workbook-copy h2 { font-size: clamp(35px, 9.2vw, 46px); }
  .workbook-lede { font-size: 18px; margin-top: 24px; }
  .workbook .recognition-note { margin-top: 28px; font-size: 15px; max-width: 36ch; }
  .workbook .recognition-note br { display: none; }
}
@media (min-width: 1101px) and (min-height: 780px) and (max-height: 949px) {
  .desk-chapter .desk-world { bottom: 26px; }
}
@media (max-width: 370px) {
  .desk-chapter { --scene-height: 780px; }
  .desk-chapter .hero-copy { padding-top: 132px; }
  .desk-chapter h1 { font-size: 33px; }
}
@media (min-width: 761px) and (max-height: 779px) {
  .depth-ready .desk-chapter .hero--desk { position: relative; }
  .desk-chapter .hero-copy { transform: none; }
  .desk-chapter .desk-room { transform: translate3d(0, calc(var(--desk-p) * -6px), 0); }
}
@media (prefers-reduced-motion: reduce) {
  .depth-ready .desk-chapter .hero--desk { position: relative; }
  .desk-chapter .hero-copy, .desk-chapter .desk-room,
  .depth-ready .workbook-paper, .depth-ready .workbook-leaf { transform: none !important; will-change: auto !important; }
  .depth-ready .workbook-note--yellow { transform: rotate(-5deg); }
  .depth-ready .workbook-note--sage { transform: rotate(4deg); }
}
