/*
 * Book page styles, shared by the book viewer, the signing preview and print.
 * A page is A5 portrait (148 x 210). Inner sizes use cqw (1% of page width),
 * so a page looks the same at any size, on screen or paper.
 */

.page {
  container-type: inline-size;
  position: relative;
  aspect-ratio: 148 / 210;
  width: 100%;
  box-sizing: border-box;
  background: #fffdf8;
  color: #1f2a44;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Nunito', system-ui, sans-serif;
}

.page .num {
  position: absolute;
  bottom: 3.5cqw;
  font-size: 2.6cqw;
  color: #6b7280;
}

/* ---------- Family page ---------- */
.page.family {
  /* Padding/gaps on the container itself must not use cqw (it would measure
     the window), so use % padding and margins on the children instead. */
  padding: 9% 8% 10%;
  justify-content: center;
  --hand-scale: 1;
}
.page.family > * + * { margin-top: 4cqw; }
.page.family > .num { margin-top: 0; }
.page.family > .photos { margin-top: 6cqw; }
.page.family .kid {
  margin: 0;
  font-family: var(--hand);
  font-weight: 400;
  font-size: calc(10cqw * var(--hand-scale));
  line-height: 1.1;
  color: #b9472a;
  text-align: center;
}
.page.family .photos {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 3cqw;
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
}
.polaroid {
  margin: 0;
  background: #fff;
  padding: 2cqw 2cqw 6cqw;
  box-shadow: 0 0.8cqw 2.4cqw rgba(31, 42, 68, 0.2);
  border: 1px solid #ece3d4;
  position: relative;
}
.polaroid::before {
  /* a strip of washi tape */
  content: '';
  position: absolute;
  top: -2cqw;
  left: 50%;
  width: 14cqw;
  height: 4cqw;
  margin-left: -7cqw;
  background: rgba(242, 184, 75, 0.55);
}
.polaroid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #eee6d8;
}
.tilt-0 { transform: rotate(-2.5deg); }
.tilt-1 { transform: rotate(2deg); }
.tilt-2 { transform: rotate(-1deg); }

.photos.n1 .polaroid { width: 66cqw; height: 74cqw; }
.photos.n2 .polaroid { width: 40cqw; height: 48cqw; }
.photos.n3 { flex-wrap: wrap; row-gap: 3cqw; }
.photos.n3 .polaroid { width: 36cqw; height: 34cqw; }

.page.family .message {
  white-space: pre-line;
  text-align: center;
  font-family: var(--hand);
  color: var(--ink);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.page.family .from {
  font-family: var(--hand);
  color: var(--ink);
  font-size: calc(5cqw * var(--hand-scale));
}
.page.family .drawing {
  width: 100%;
  max-height: 46cqw;
  flex: 0 1 auto;
}

/* Message size steps down as the page fills up. */
.len-s .message { font-size: calc(6.4cqw * var(--hand-scale)); }
.len-m .message { font-size: calc(5.4cqw * var(--hand-scale)); }
.len-l .message { font-size: calc(4.6cqw * var(--hand-scale)); }
.len-xl .message { font-size: calc(3.9cqw * var(--hand-scale)); }
.len-l .photos.n1 .polaroid, .len-xl .photos.n1 .polaroid { width: 52cqw; height: 58cqw; }
.len-l .photos.n2 .polaroid, .len-xl .photos.n2 .polaroid { width: 34cqw; height: 40cqw; }
.len-xl .photos.n3 .polaroid { width: 28cqw; height: 27cqw; }

/* ---------- Cover, dedication, back ---------- */
.page .script {
  font-family: 'Caveat', cursive;
  color: #b9472a;
}
.page .year {
  font-size: 3.6cqw;
  color: #5a6275;
}
.page.cover {
  padding: 6%;
  justify-content: center;
}
.cover-inner {
  flex: 1;
  width: 100%;
  border: 0.6cqw solid #e6ddcf;
  border-radius: 5cqw;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3cqw;
  text-align: center;
  padding: 6cqw;
  box-sizing: border-box;
}
.page.cover .script { font-size: 8cqw; }
.page.cover h1 {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 13cqw;
  line-height: 1.05;
  text-wrap: balance;
}
.confetti {
  width: 70cqw;
  height: auto;
}
.confetti.small { width: 50cqw; }

.page.dedication {
  padding: 12% 10%;
  justify-content: center;
  text-align: center;
}
.page.dedication > * + * { margin-top: 5cqw; }
.page.dedication > .num { margin-top: 0; }
.page.dedication h2 {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 10cqw;
  line-height: 1.1;
  text-wrap: balance;
}
.page.dedication .script {
  font-size: 7.4cqw;
  line-height: 1.25;
}

.page.back {
  padding: 12%;
  justify-content: flex-end;
  text-align: center;
}
.page.back .script { font-size: 6.6cqw; }
.page.back > * + * { margin-top: 2cqw; }
