:root {
  color-scheme: light;
  --ink: #27312c;
  --muted: #6a746d;
  --paper: #fffaf0;
  --paper-deep: #f4ead7;
  --green: #2f7c63;
  --leaf: #dcefdc;
  --sun: #f3ae35;
  --blue: #65a8cf;
  --coral: #e97e66;
  --rose: #f5d4d0;
  --violet: #dad6f4;
  --shadow: 0 26px 70px rgba(26, 34, 30, 0.28);
  --turn: 0;
  --abs-turn: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 12% 12%, rgba(243, 174, 53, 0.34), transparent 24%),
    radial-gradient(circle at 84% 18%, rgba(101, 168, 207, 0.28), transparent 28%),
    linear-gradient(135deg, #f7ecd8 0%, #dcefe5 48%, #fff2df 100%);
  color: var(--ink);
}

img {
  display: block;
  width: 100%;
}

h1,
h2,
p,
figure {
  margin: 0;
}

.book-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.book-track {
  height: 100%;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  perspective: 1800px;
}

.book-track::-webkit-scrollbar {
  display: none;
}

.book-spread {
  --chapter: rgba(47, 124, 99, 0.11);
  position: relative;
  flex: 0 0 100vw;
  height: 100svh;
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 18px;
  transform-style: preserve-3d;
  isolation: isolate;
}

.book-spread::before {
  content: "";
  position: absolute;
  inset: 14px;
  z-index: -2;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.34);
  box-shadow: 0 26px 90px rgba(32, 42, 37, 0.2);
}

.book-spread::after {
  content: "";
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: 50%;
  z-index: 4;
  display: none;
  width: 34px;
  transform: translateX(-50%);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16), rgba(255, 255, 255, 0.7) 42%, rgba(0, 0, 0, 0.12)),
    linear-gradient(180deg, transparent, rgba(39, 49, 44, 0.08), transparent);
  opacity: calc(0.68 + var(--abs-turn) * 0.22);
  pointer-events: none;
  filter: blur(0.2px);
}

.page {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: clamp(18px, 4vw, 42px);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.6), transparent 16%, transparent 84%, rgba(0, 0, 0, 0.045)),
    repeating-linear-gradient(0deg, rgba(39, 49, 44, 0.018) 0 1px, transparent 1px 9px),
    var(--paper);
  box-shadow: var(--shadow);
  transform-style: preserve-3d;
  transition: filter 180ms ease;
}

.left-page {
  border-radius: 16px 16px 0 0;
  transform-origin: 100% 50%;
}

.right-page {
  border-radius: 0 0 16px 16px;
  transform-origin: 0 50%;
}

.page::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(39, 49, 44, 0.12);
  border-radius: 10px;
  pointer-events: none;
}

.page::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -58px;
  bottom: -66px;
  border-radius: 50%;
  background: var(--chapter);
  pointer-events: none;
}

.stamp {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 12px;
  padding: 7px 11px;
  border: 1px solid rgba(39, 49, 44, 0.18);
  border-radius: 999px;
  color: var(--green);
  background: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  max-width: 8em;
  margin-bottom: 16px;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  max-width: 9em;
  margin-bottom: 14px;
  font-size: clamp(30px, 4.7vw, 56px);
  line-height: 1.05;
  letter-spacing: 0;
}

.note {
  max-width: 28em;
  color: var(--muted);
  font-size: clamp(15px, 1.9vw, 19px);
  line-height: 1.72;
  font-weight: 550;
  overflow-wrap: anywhere;
}

figcaption {
  padding-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 650;
}

.book-label {
  width: fit-content;
  margin-top: clamp(24px, 5vw, 58px);
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--green);
  color: #fff8e7;
  font-weight: 900;
}

.rotate-note {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 20;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(39, 49, 44, 0.72);
  color: #ffffff;
  font-size: 12px;
  font-weight: 750;
  pointer-events: none;
}

.page-dots {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 18;
  display: none;
  gap: 6px;
  transform: translateX(-50%);
}

.page-dots span {
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: rgba(39, 49, 44, 0.22);
}

.page-dots span.is-active {
  background: var(--green);
}

.photo-cover {
  padding: 0;
  background: #142c25;
}

.photo-cover img,
.full-photo img,
.portrait-photo img,
.wide-photo img {
  height: 100%;
  object-fit: cover;
}

.photo-cover figcaption {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 2;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.88);
  color: var(--ink);
}

.cover-spread {
  --chapter: rgba(243, 174, 53, 0.24);
}

.cover-copy {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cover-spread .left-page {
  background:
    radial-gradient(circle at 18% 18%, rgba(243, 174, 53, 0.35), transparent 28%),
    linear-gradient(160deg, #fff4d8, #fffdf6 55%, #dfeee1);
}

.cover-spread .right-page img {
  object-position: center 58%;
}

.reunion-spread {
  --chapter: rgba(47, 124, 99, 0.14);
}

.wide-photo,
.portrait-photo,
.full-photo,
.polaroid-stack figure,
.action-layout figure,
.book-photo,
.face-row figure {
  padding: 9px;
  border-radius: 10px;
  background: #fffdf7;
  box-shadow: 0 18px 42px rgba(32, 42, 37, 0.16);
}

.wide-photo {
  height: min(46vh, 360px);
  margin-top: clamp(18px, 3vw, 32px);
}

.polaroid-stack {
  height: 100%;
  display: grid;
  grid-template-rows: 1.08fr 0.92fr 1fr;
  gap: 12px;
}

.polaroid-stack figure:nth-child(1) {
  transform: rotate(-1.4deg);
}

.polaroid-stack figure:nth-child(2) {
  transform: rotate(1.6deg);
}

.polaroid-stack figure:nth-child(3) {
  transform: rotate(-0.8deg);
}

.polaroid-stack img {
  height: calc(100% - 28px);
  border-radius: 7px;
  object-fit: cover;
}

.meal-spread {
  --chapter: rgba(233, 126, 102, 0.15);
}

.meal-spread .right-page {
  background:
    radial-gradient(circle at 18% 18%, rgba(243, 174, 53, 0.32), transparent 26%),
    linear-gradient(160deg, #fff0d2, #fffdf7 58%, #e7f5ec);
}

.portrait-photo {
  height: 100%;
}

.portrait-photo img {
  border-radius: 7px;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: clamp(18px, 3vw, 36px);
}

.stamp-grid img,
.table-row img,
.tiny-strip img,
.wheel-grid img,
.classroom-collage > img,
.face-wall img,
.face-row img,
.action-layout img {
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(32, 42, 37, 0.14);
}

.stamp-grid img {
  aspect-ratio: 1 / 1;
}

.table-spread {
  --chapter: rgba(243, 174, 53, 0.18);
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: clamp(20px, 4vw, 42px);
}

.table-row img {
  aspect-ratio: 1 / 1;
}

.full-photo {
  height: calc(100% - 108px);
}

.full-photo img {
  border-radius: 7px;
}

.tiny-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.tiny-strip img {
  aspect-ratio: 1 / 1;
}

.playground-spread {
  --chapter: rgba(101, 168, 207, 0.16);
}

.playground-spread .left-page,
.wheels-spread .right-page {
  background:
    linear-gradient(135deg, rgba(101, 168, 207, 0.18), transparent 48%),
    linear-gradient(180deg, #f5fcff, #fff8e9);
}

.action-layout {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
}

.action-layout figure {
  min-height: 0;
}

.action-layout figure:first-child {
  grid-row: span 2;
  transform: rotate(-1.2deg);
}

.action-layout figure:nth-child(2) {
  transform: rotate(1.7deg);
}

.action-layout figure:nth-child(3) {
  transform: rotate(-0.8deg);
}

.action-layout img {
  height: calc(100% - 30px);
}

.wheels-spread {
  --chapter: rgba(47, 124, 99, 0.13);
}

.wheel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: clamp(18px, 3vw, 32px);
}

.wheel-grid img {
  aspect-ratio: 1 / 1;
}

.classroom-spread {
  --chapter: rgba(218, 214, 244, 0.58);
}

.classroom-spread .left-page {
  background:
    radial-gradient(circle at 84% 18%, rgba(245, 212, 208, 0.8), transparent 24%),
    linear-gradient(180deg, #fff9f6, #f6f2ff);
}

.classroom-collage {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
}

.book-photo {
  grid-row: span 3;
}

.book-photo img {
  height: calc(100% - 30px);
  border-radius: 7px;
  object-fit: cover;
}

.classroom-collage > img {
  height: 100%;
}

.faces-spread {
  --chapter: rgba(233, 126, 102, 0.16);
}

.faces-spread .right-page {
  background:
    linear-gradient(160deg, rgba(233, 126, 102, 0.16), transparent 44%),
    linear-gradient(180deg, #fff8ec, #eef8f1);
}

.face-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: clamp(20px, 4vw, 42px);
}

.face-row figure:nth-child(1) {
  transform: rotate(-1.5deg);
}

.face-row figure:nth-child(2) {
  transform: rotate(1.4deg) translateY(16px);
}

.face-row img {
  aspect-ratio: 3 / 4;
}

.face-row figcaption {
  color: var(--green);
  font-weight: 900;
  text-align: center;
}

.face-wall {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
}

.face-wall img {
  height: 100%;
}

.closing-spread {
  --chapter: rgba(47, 124, 99, 0.16);
}

.closing-spread .right-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(circle at 84% 18%, rgba(243, 174, 53, 0.34), transparent 26%),
    linear-gradient(160deg, #fff5df, #e4f3e8);
}

.closing-spread h2 {
  max-width: 8em;
}

.section.is-visible .page > * {
  animation: rise 620ms ease both;
}

@keyframes rise {
  from {
    opacity: 0.36;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (orientation: landscape) {
  .book-spread {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: clamp(18px, 3vw, 34px);
  }

  .book-spread::after {
    display: block;
  }

  .page {
    height: calc(100svh - clamp(36px, 6vw, 68px));
    transform:
      translateZ(calc((1 - var(--abs-turn)) * 18px))
      rotateY(calc(var(--turn) * -8deg));
  }

  .left-page {
    border-radius: 16px 0 0 16px;
    box-shadow:
      inset -18px 0 30px rgba(39, 49, 44, 0.08),
      var(--shadow);
  }

  .right-page {
    border-radius: 0 16px 16px 0;
    box-shadow:
      inset 18px 0 30px rgba(39, 49, 44, 0.08),
      var(--shadow);
  }

  .right-page {
    transform:
      translateZ(calc((1 - var(--abs-turn)) * 22px))
      rotateY(calc(var(--turn) * -12deg));
  }

  .left-page {
    transform:
      translateZ(calc((1 - var(--abs-turn)) * 14px))
      rotateY(calc(var(--turn) * 6deg));
  }

  .rotate-note {
    display: none;
  }

  .page-dots {
    display: flex;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .book-spread {
    padding: 14px 24px;
  }

  .page {
    height: calc(100svh - 28px);
    padding: 22px;
  }

  h1 {
    font-size: 54px;
  }

  h2 {
    margin-bottom: 10px;
    font-size: 38px;
  }

  .note {
    font-size: 14px;
    line-height: 1.55;
  }

  .stamp {
    margin-bottom: 8px;
    padding: 5px 10px;
  }

  .wide-photo {
    height: min(34vh, 230px);
    margin-top: 14px;
  }

  .stamp-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-top: 16px;
  }

  .wheel-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: 16px;
  }

  .full-photo {
    height: calc(100% - 78px);
  }

  .tiny-strip {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 7px;
  }

  .polaroid-stack {
    gap: 8px;
  }

  figcaption {
    padding-top: 5px;
    font-size: 12px;
    line-height: 1.35;
  }
}

@media (orientation: portrait) {
  .book-track {
    perspective: 1200px;
  }

  .book-spread {
    overflow-y: auto;
    grid-template-rows: minmax(50svh, auto) minmax(50svh, auto);
  }

  .page {
    min-height: 50svh;
  }

  .left-page {
    border-radius: 16px 16px 0 0;
  }

  .right-page {
    border-radius: 0 0 16px 16px;
  }

  .stamp-grid,
  .wheel-grid,
  .face-wall {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-layout,
  .classroom-collage {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .action-layout figure:first-child,
  .book-photo {
    grid-row: auto;
  }

  .wide-photo,
  .full-photo,
  .portrait-photo {
    height: min(54svh, 520px);
  }
}

@media (max-width: 520px) {
  .book-spread {
    padding: 12px;
  }

  .page {
    padding: 18px;
  }

  h1 {
    font-size: 38px;
  }

  h2 {
    font-size: 30px;
  }

  .note {
    font-size: 15px;
  }

  .table-row,
  .face-row {
    gap: 8px;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }

  html,
  body {
    height: auto;
    overflow: visible;
    background: #ffffff;
  }

  .book-shell {
    position: static;
    overflow: visible;
  }

  .book-track {
    display: block;
    height: auto;
    overflow: visible;
    perspective: none;
  }

  .book-spread {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    break-after: page;
    page-break-after: always;
    padding: 18mm;
  }

  .book-spread::after {
    display: block;
  }

  .page {
    height: calc(100vh - 36mm);
    transform: none;
    box-shadow: none;
  }

  .rotate-note,
  .page-dots {
    display: none;
  }

  .section.is-visible .page > * {
    animation: none;
  }
}
