/* Cradle — the running book.
   Paper pages stacked vertically, following the app's tokens (light/dark/skins).
   Two self-hosted OFL handwriting faces: Caveat (headings, letters) and
   Patrick Hand (body, captions). No network requests at runtime. */

@font-face {
  font-family: "Caveat";
  src: url("/fonts/Caveat.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Patrick Hand";
  src: url("/fonts/PatrickHand.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.rb {
  --rb-hand: "Caveat", "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  --rb-body: "Patrick Hand", "Bradley Hand", "Segoe Print", cursive;
  --rb-paper: var(--surface);
  --rb-ink: var(--text);
  --rb-pad: 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 100%;
  margin: 8px 0 24px;
  color: var(--rb-ink);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

/* ---------- a page ---------- */
.rb-page {
  position: relative;
  box-sizing: border-box;
  padding: var(--rb-pad) var(--rb-pad) calc(var(--rb-pad) + 14px);
  background:
    radial-gradient(var(--divider) .55px, transparent .8px) 0 0 / 18px 18px,
    var(--rb-paper);
  border: 1px solid var(--border);
  border-radius: var(--radius, 12px);
  box-shadow:
    var(--shadow-1),
    0 0 0 .5px var(--border-strong),
    0 1px 0 var(--border) inset,
    0 14px 30px -18px rgba(20, 20, 30, .28);
  transform: rotate(var(--tilt, 0deg));
  transform-origin: 50% 50%;
  min-height: 160px;
  overflow-wrap: anywhere;
}
[data-theme="dark"] .rb-page {
  box-shadow: var(--shadow-1), 0 0 0 .5px var(--border-strong), 0 14px 30px -18px rgba(0, 0, 0, .7);
}
/* hairline "stacked sheets" edge under each page */
.rb-page::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -3px;
  height: 3px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius, 12px) var(--radius, 12px);
  opacity: .8;
  pointer-events: none;
}

.rb-num {
  position: absolute;
  bottom: 10px;
  font: 500 11px/1 var(--font, system-ui, sans-serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--text-faint);
}
.rb-page:nth-child(odd) .rb-num { left: 18px; }
.rb-page:nth-child(even) .rb-num { right: 18px; }

/* ---------- title page ---------- */
.rb-title, .rb-end {
  text-align: center;
  padding-top: 44px;
  padding-bottom: 46px;
}
.rb-title-art, .rb-end-art { display: flex; justify-content: center; margin-bottom: 14px; }
.rb-title-art .dd, .rb-end-art .dd {
  width: 46px; height: 46px;
  color: var(--accent);
  stroke: currentColor; fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.rb-title h1 {
  margin: 0;
  font: 700 clamp(30px, 8vw, 40px)/1.12 var(--rb-hand);
  color: var(--rb-ink);
  letter-spacing: -.01em;
}
.rb-born {
  margin: 14px 0 0;
  font: 400 15px/1.4 var(--font, system-ui, sans-serif);
  color: var(--text-dim);
}
.rb-tagline {
  margin: 30px auto 0;
  max-width: 24ch;
  font: 400 17px/1.45 var(--rb-body);
  color: var(--text-faint);
}

/* ---------- chapter opener ---------- */
.rb-chapter { padding-top: 38px; padding-bottom: 40px; }
.rb-eyebrow {
  margin: 0 0 10px;
  font: 600 11px/1 var(--font, system-ui, sans-serif);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.rb-chapter h2 {
  margin: 0;
  font: 600 clamp(28px, 7vw, 34px)/1.1 var(--rb-hand);
  color: var(--rb-ink);
}
.rb-range {
  margin: 8px 0 0;
  font: 400 14px/1.4 var(--font, system-ui, sans-serif);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.rb-stamps { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 18px; }
.rb-stamp {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px 3px;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font: 600 14px/1 var(--rb-hand);
  letter-spacing: .02em;
  transform: rotate(-2.5deg);
  opacity: .85;
  background: var(--accent-soft);
  white-space: nowrap;
}
.rb-stamp .dd { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- entries page ---------- */
.rb-running {
  margin: -8px 0 16px;
  font: 500 10.5px/1 var(--font, system-ui, sans-serif);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.rb-entry { margin: 0 0 26px; }
.rb-entry:last-of-type { margin-bottom: 4px; }
.rb-entry + .rb-entry { padding-top: 22px; border-top: 1px solid var(--divider); }
.rb-date {
  font: 500 12px/1.2 var(--font, system-ui, sans-serif);
  color: var(--text-dim);
  letter-spacing: .01em;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.rb-body p, .rb-letter-text p { margin: 0 0 .7em; }
.rb-body p:last-child, .rb-letter-text p:last-child { margin-bottom: 0; }
.rb-body {
  font: 400 18px/1.5 var(--rb-body);
  color: var(--rb-ink);
}

/* milestone: a large handwritten heading with a doodle star */
.rb-milestone h3, .rb-note h3 {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 8px;
  font: 600 clamp(24px, 6.4vw, 30px)/1.15 var(--rb-hand);
  color: var(--rb-ink);
}
.rb-star {
  flex: none;
  width: 22px; height: 22px;
  margin-top: 5px;
  color: var(--accent);
  stroke: currentColor; fill: var(--accent-soft);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  transform: rotate(-8deg);
}

/* letter: italic handwriting, signed */
.rb-letter-text {
  font: 400 21px/1.42 var(--rb-hand);
  font-style: italic;
  color: var(--rb-ink);
  padding-left: 2px;
}
.rb-signature {
  margin-top: 10px;
  text-align: right;
  font: 500 20px/1.2 var(--rb-hand);
  color: var(--text-dim);
}

/* ---------- photos: taped polaroids ---------- */
.rb-photos { display: grid; gap: 14px; margin-top: 16px; }
.rb-photos.n1 { grid-template-columns: 1fr; }
.rb-photos.n3 { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 12px; }
.rb-photos.nm { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rb-polaroid {
  position: relative;
  margin: 8px 0 0;
  padding: 8px 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 6px 18px -12px rgba(20, 20, 30, .4), var(--shadow-1);
  transform: rotate(calc(var(--i, 0) * 1.6deg - .8deg));
  break-inside: avoid;
}
.rb-photos.n1 .rb-polaroid { transform: rotate(-.6deg); padding: 10px 10px 12px; }
.rb-photos.nm .rb-polaroid { padding: 5px 5px 6px; }
.rb-photos.nm .rb-polaroid figcaption { display: none; }
.rb-polaroid img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 2px;
  background: var(--surface);
}
.rb-photos.n1 .rb-polaroid img { aspect-ratio: 4 / 3; }
.rb-polaroid figcaption {
  margin-top: 8px;
  text-align: center;
  font: 400 15px/1.2 var(--rb-body);
  color: var(--text-dim);
}
.rb-photos.n3 .rb-polaroid figcaption { font-size: 13px; }
/* the tape */
.rb-polaroid::before {
  content: "";
  position: absolute;
  top: -8px; left: 50%;
  width: 46px; height: 14px;
  transform: translateX(-50%) rotate(calc(var(--i, 0) * -3deg + 2deg));
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 1px;
  opacity: .9;
}
.rb-photos.nm .rb-polaroid::before { width: 30px; height: 10px; top: -6px; }

/* ---------- end page ---------- */
.rb-end h2 { margin: 0; font: 600 clamp(28px, 7vw, 34px)/1.1 var(--rb-hand); color: var(--rb-ink); }
.rb-stats {
  margin: 12px 0 0;
  font: 500 13px/1.4 var(--font, system-ui, sans-serif);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.rb-invite {
  margin: 22px auto 0;
  max-width: 28ch;
  font: 400 17px/1.45 var(--rb-body);
  color: var(--text-faint);
}

@media (prefers-reduced-motion: reduce) {
  .rb { scroll-behavior: auto; }
}

/* ---------- print: clean A5-ish sheets ---------- */
@media print {
  @page { size: A5; margin: 14mm 13mm; }
  body.rb-printing > *:not(:has(.rb)) { display: none !important; }
  body.rb-printing :not(.rb):not(.rb *):not(:has(.rb)) { display: none !important; }
  .rb { display: block; gap: 0; margin: 0; color: #000; }
  .rb-page {
    transform: none !important;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    background: #fff;
    padding: 0 0 12mm;
    min-height: 0;
    break-inside: auto;
    page-break-inside: auto;
  }
  .rb-page::after { display: none; }
  .rb-title, .rb-chapter { break-before: page; page-break-before: always; min-height: 60vh; display: flex; flex-direction: column; justify-content: center; }
  .rb-title { break-before: auto; page-break-before: auto; }
  .rb-entries { break-before: auto; }
  .rb-entry { break-inside: avoid; page-break-inside: avoid; }
  .rb-num { display: none; }
  .rb-stamps { margin-top: 12px; }
  .rb-stamp { transform: none; color: #000; border-color: #000; background: none; }
  .rb-polaroid, .rb-photos.n1 .rb-polaroid { transform: none; box-shadow: none; background: #fff; border: 1px solid #ccc; }
  .rb-polaroid::before { display: none; }
  .rb-title h1, .rb-chapter h2, .rb-end h2, .rb-milestone h3, .rb-note h3, .rb-body, .rb-letter-text, .rb-signature { color: #000; }
  .rb-star { color: #000; fill: none; }
  .rb-eyebrow { color: #333; }
  .rb-date, .rb-range, .rb-born, .rb-stats { color: #555; }
  .rb-tagline, .rb-invite, .rb-running { color: #777; }
}
