/* ─────────────────────────────────────────────────────────────────
   JUNK JOURNAL — Pretty, Layered, Scrapbook
   Pastel papers · washi · lace · pressed flowers · ribbon
   ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surface (cream tablecloth) */
  --cloth: #f6ece0;
  --cloth-deep: #ead9c2;
  --cloth-soft: #fbf4e8;

  /* Page papers */
  --paper-cream: #fbf3e4;
  --paper-ivory: #f8efde;
  --paper-blush: #f2dcde;
  --paper-sage: #d6e0c8;
  --paper-sky: #d4dde8;
  --paper-butter: #f2e7b8;
  --paper-lilac: #e2d8e6;

  /* Pastel pigments */
  --rose: #d8949a;
  --rose-soft: #e8b8be;
  --rose-deep: #b46873;
  --sage: #93a886;
  --sage-deep: #6e8366;
  --butter: #d8b85a;
  --butter-soft: #ecd884;
  --sky: #8aa0c0;
  --sky-soft: #b4c4d8;
  --lavender: #b89cc4;
  --coral: #d9876a;
  --plum: #7a4a64;

  /* Ink — warm dark brown, not black */
  --ink: #432822;
  --ink-soft: #6e4a3c;
  --ink-mute: #8e6c5c;
  --ink-pen: #4a5a8c;

  /* Type */
  --f-script: "Pinyon Script", "Snell Roundhand", cursive;
  --f-hand: "Caveat", cursive;
  --f-hand-soft: "Shadows Into Light", cursive;
  --f-typewriter: "Special Elite", "Courier Prime", monospace;
  --f-serif: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  --f-display: "Permanent Marker", "Marker Felt", sans-serif;
  --f-mono: "Courier Prime", "Courier New", monospace;

  /* Book */
  --book-w: min(94vw, 1180px);
  --book-h: calc(var(--book-w) * 0.66);
}

html, body { min-height: 100%; }

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(232, 184, 190, 0.22) 0%, transparent 70%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(180, 140, 110, 0.18) 0%, transparent 70%),
    linear-gradient(180deg, var(--cloth-soft) 0%, var(--cloth) 50%, var(--cloth-deep) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--f-serif);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
::selection { background: var(--rose); color: var(--paper-cream); }

.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 2000;
  opacity: 0.22;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0.25  0 0 0 0 0.18  0 0 0 0 0.14  0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1990;
  background: radial-gradient(ellipse 120% 90% at 50% 50%, transparent 60%, rgba(120, 60, 60, 0.08) 100%);
}

/* ─── Masthead ───────────────────────────────────────────── */
.masthead {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 22px 40px 0;
  gap: 22px;
  color: var(--ink-soft);
}
.masthead-spacer { flex: 1; }
.masthead-meta {
  font-family: var(--f-hand);
  font-size: 16px;
  color: var(--rose-deep);
  letter-spacing: 0.02em;
  opacity: 0.85;
}
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-script);
  font-size: 22px;
  padding: 4px 14px;
  letter-spacing: 0.02em;
  position: relative;
}
.stamp::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1.2px solid currentColor;
  border-radius: 24px;
  opacity: 0.5;
}
.stamp.red { color: var(--rose-deep); }
.stamp.blue { color: var(--sage-deep); }

/* ─── Stage / title ──────────────────────────────────────── */
.stage {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 60px 40px;
  min-height: calc(100vh - 64px);
}

.title-block {
  text-align: center;
  margin: 16px 0 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.title-tag {
  background:
    radial-gradient(ellipse at 50% 50%, var(--paper-ivory) 0%, var(--paper-cream) 80%);
  padding: 8px 22px;
  margin-bottom: 18px;
  box-shadow: 2px 3px 0 rgba(180, 100, 110, 0.18);
  border-radius: 2px;
  position: relative;
}
.title-tag::before,
.title-tag::after {
  content: "";
  position: absolute;
  width: 50px;
  height: 16px;
  top: -8px;
  background:
    repeating-linear-gradient(135deg, rgba(232, 184, 190, 0.85) 0 6px, rgba(216, 148, 154, 0.7) 6px 12px);
  border-radius: 1px;
}
.title-tag::before { left: -16px; transform: rotate(-22deg); }
.title-tag::after { right: -16px; transform: rotate(22deg); background: repeating-linear-gradient(135deg, rgba(184, 200, 168, 0.85) 0 6px, rgba(147, 168, 134, 0.7) 6px 12px); }
.tag-line {
  font-family: var(--f-hand);
  font-size: 17px;
  color: var(--ink);
}
.display-title {
  position: relative;
  line-height: 0.9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.02em;
  margin-top: 8px;
}
.title-word {
  position: relative;
  display: inline-block;
}
.title-marker {
  font-family: var(--f-script);
  font-size: clamp(96px, 17vw, 220px);
  color: var(--rose-deep);
  font-weight: 400;
  letter-spacing: -0.02em;
  text-shadow:
    1px 2px 0 rgba(255, 255, 255, 0.6),
    3px 5px 0 rgba(180, 100, 110, 0.16);
  transform: rotate(-2deg);
}
.title-word--lower {
  font-family: var(--f-script);
  color: var(--sage-deep);
  font-size: clamp(84px, 14vw, 196px);
  transform: rotate(1deg) translateX(28px);
  margin-top: -0.25em;
  text-shadow:
    1px 2px 0 rgba(255, 255, 255, 0.6),
    3px 5px 0 rgba(110, 131, 102, 0.18);
}
.title-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}
.title-sub {
  font-family: var(--f-hand);
  font-size: 18px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.washi {
  display: inline-block;
  width: 84px;
  height: 18px;
  opacity: 0.9;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  border-radius: 1px;
}
.washi-mint { background: repeating-linear-gradient(90deg, #cee0c0 0 8px, #b8d2a4 8px 16px); }
.washi-peach { background: repeating-linear-gradient(135deg, #f2d6c2 0 8px, #e8c2a8 8px 16px); }
.washi-pink { background:
  radial-gradient(circle at 8px 8px, #d8949a 2px, transparent 2.5px) 0 0 / 16px 16px,
  #f2dcde; }
.washi-blue { background:
  linear-gradient(0deg, #b4c4d8 50%, #c8d6e4 50%); }
.washi-mustard { background:
  radial-gradient(circle at 6px 6px, #d8b85a 2px, transparent 2.5px) 0 0 / 12px 12px,
  #ecd884; }

/* ─── Book ───────────────────────────────────────────── */
.book-stage {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  perspective: 2400px;
  perspective-origin: 50% 50%;
  margin-top: 8px;
}

.book {
  position: relative;
  width: var(--book-w);
  height: var(--book-h);
  transform-style: preserve-3d;
  outline: none;
  cursor: grab;
  transform: rotate(-0.4deg);
}
.book:active { cursor: grabbing; }

.book-shadow {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: -28px;
  height: 50px;
  background: radial-gradient(ellipse at 50% 0%, rgba(120, 70, 60, 0.32) 0%, rgba(120, 70, 60, 0.14) 40%, transparent 75%);
  filter: blur(8px);
  z-index: 0;
}

.page-slot {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  z-index: 1;
  overflow: hidden;
}
.page-slot-left { left: 0; border-radius: 4px 1px 1px 4px; box-shadow: -2px 4px 8px rgba(120, 70, 60, 0.22), -8px 14px 28px rgba(120, 70, 60, 0.16); }
.page-slot-right { right: 0; border-radius: 1px 4px 4px 1px; box-shadow: 2px 4px 8px rgba(120, 70, 60, 0.22), 8px 14px 28px rgba(120, 70, 60, 0.16); }

.page {
  position: absolute;
  inset: 0;
  background: var(--paper-cream);
  overflow: hidden;
}
.page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' seed='6'/><feColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.2  0 0 0 0 0.18  0 0 0 0.1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>");
  mix-blend-mode: multiply;
  opacity: 0.6;
  z-index: 3;
}
.page-slot-left .page::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(120,70,60,0.18) 0%, transparent 5%, transparent 92%, rgba(120,70,60,0.12) 100%);
  z-index: 4;
}
.page-slot-right .page::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to left, rgba(120,70,60,0.18) 0%, transparent 5%, transparent 92%, rgba(120,70,60,0.12) 100%);
  z-index: 4;
}

.page-art { position: absolute; inset: 0; z-index: 1; }
.page-art svg, .page-art img {
  display: block; width: 100%; height: 100%;
  object-fit: contain;
  user-select: none; pointer-events: none;
}

.spine {
  position: absolute;
  top: 0; left: 50%;
  width: 6px;
  height: 100%;
  transform: translateX(-50%);
  background:
    linear-gradient(to right, transparent 0%, rgba(120, 70, 60, 0.4) 40%, rgba(120, 70, 60, 0.55) 50%, rgba(120, 70, 60, 0.4) 60%, transparent 100%);
  z-index: 6;
  pointer-events: none;
}
.binding-stitches {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  padding: 24px 0;
}
.binding-stitches span {
  display: block;
  width: 10px;
  height: 2.2px;
  background: var(--rose-deep);
  border-radius: 1px;
  opacity: 0.85;
}

/* ─── Flipping leaves ─────────────────────────────────── */
.flip-leaf {
  position: absolute;
  top: 0; width: 50%; height: 100%;
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 7;
  display: none;
  will-change: transform;
}
.flip-leaf.is-active { display: block; }
.flip-leaf-forward { left: 50%; transform-origin: left center; transform: rotateY(var(--angle, 0deg)); }
.flip-leaf-backward { left: 0; transform-origin: right center; transform: rotateY(var(--angle, 0deg)); }

.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: var(--paper-cream);
}
.face::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' seed='6'/><feColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.2  0 0 0 0 0.18  0 0 0 0.1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>");
  mix-blend-mode: multiply;
  opacity: 0.6;
  z-index: 3;
}
.flip-leaf-forward .face-back,
.flip-leaf-backward .face-back { transform: rotateY(180deg); }

.curl-shadow-front,
.curl-shadow-back {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
  backface-visibility: hidden;
}
.flip-leaf-forward .curl-shadow-front {
  background: linear-gradient(to left, transparent 0%, transparent 55%, rgba(80, 40, 30, 0.42) 100%);
}
.flip-leaf-forward .curl-shadow-back {
  transform: rotateY(180deg);
  background: linear-gradient(to right, transparent 0%, transparent 55%, rgba(80, 40, 30, 0.42) 100%);
}
.flip-leaf-backward .curl-shadow-front {
  background: linear-gradient(to right, transparent 0%, transparent 55%, rgba(80, 40, 30, 0.42) 100%);
}
.flip-leaf-backward .curl-shadow-back {
  transform: rotateY(180deg);
  background: linear-gradient(to left, transparent 0%, transparent 55%, rgba(80, 40, 30, 0.42) 100%);
}

.book::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  pointer-events: none;
  z-index: 6;
  opacity: var(--drop-shadow, 0);
  background: linear-gradient(to left, rgba(80, 40, 30, 0) 0%, rgba(80, 40, 30, 0.3) 50%, rgba(80, 40, 30, 0) 100%);
  left: var(--drop-shadow-x, 50%);
  display: var(--drop-shadow-display, none);
  transform: translateX(-50%);
}

/* ─── Corners ─────────────────────────────────────────── */
.corner {
  position: absolute;
  width: 64px; height: 64px;
  z-index: 9;
  cursor: grab;
  opacity: 0;
  transition: opacity 280ms ease;
}
.corner:active { cursor: grabbing; }
.book:hover .corner,
.book:focus-within .corner { opacity: 0.75; }
.corner:hover { opacity: 1 !important; }
.corner svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(120, 70, 60, 0.4)); }
.corner-br { bottom: 0; right: 0; }
.corner-bl { bottom: 0; left: 0; }
.corner-bl svg { transform: scaleX(-1); }

/* ─── Controls ────────────────────────────────────────── */
.reader-controls {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 60px;
  color: var(--ink-soft);
}
.ctl-btn {
  background: var(--paper-ivory);
  border: 1.5px solid var(--rose);
  border-radius: 18px;
  cursor: pointer;
  font-family: var(--f-hand);
  font-size: 18px;
  color: var(--rose-deep);
  padding: 6px 18px;
  letter-spacing: 0.02em;
  transition: all 220ms ease;
  box-shadow: 1px 2px 0 rgba(180, 100, 110, 0.16);
}
.ctl-btn:hover {
  background: var(--paper-blush);
  transform: translateY(-1px);
  box-shadow: 2px 3px 0 rgba(180, 100, 110, 0.2);
}
.folio {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: var(--ink);
  font-family: var(--f-hand);
  font-size: 20px;
}
.folio-current { color: var(--ink); }
.folio-total { color: var(--ink-mute); font-size: 14px; font-family: var(--f-serif); font-style: italic; }

/* ─── Colophon ────────────────────────────────────────── */
.colophon {
  position: relative;
  z-index: 5;
  padding: 90px 60px 60px;
  border-top: 1px dashed rgba(180, 100, 110, 0.3);
  margin-top: 60px;
}
.colophon-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 80px;
  max-width: 1180px;
  margin: 0 auto;
  align-items: start;
}
.colophon-prose .stamp { margin-bottom: 22px; }
.colophon-text {
  font-family: var(--f-serif);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 52ch;
}
.colophon-text em {
  font-style: italic;
  color: var(--rose-deep);
}
.colophon-meta {
  list-style: none;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.colophon-meta li {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 8px;
  border-bottom: 1px dotted rgba(180, 100, 110, 0.3);
}
.meta-k {
  font-family: var(--f-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--rose-deep);
  min-width: 88px;
  letter-spacing: 0.04em;
}
.meta-v {
  font-family: var(--f-hand);
  font-size: 16px;
  color: var(--ink);
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 30px 40px;
  background: var(--paper-cream);
  background-image:
    radial-gradient(circle at 22px 22px, rgba(216, 148, 154, 0.45) 3px, transparent 3.5px),
    radial-gradient(circle at 22px 22px, rgba(147, 168, 134, 0.35) 2px, transparent 2.5px);
  background-size: 60px 60px, 40px 40px;
  cursor: pointer;
  position: relative;
  transition: transform 220ms ease, box-shadow 320ms ease;
  box-shadow:
    -2px 4px 8px rgba(120, 70, 60, 0.18),
    -6px 12px 24px rgba(120, 70, 60, 0.14);
  transform: rotate(-1deg);
  text-align: center;
  border-radius: 4px;
}
.upload-zone::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1.5px dashed rgba(180, 100, 110, 0.4);
  pointer-events: none;
  border-radius: 2px;
}
.upload-zone:hover {
  transform: rotate(-1deg) translateY(-3px);
  box-shadow:
    -4px 8px 14px rgba(120, 70, 60, 0.24),
    -10px 18px 36px rgba(120, 70, 60, 0.18);
}
.upload-zone.is-dragging {
  background: #fff4d8;
  transform: rotate(-1deg) scale(1.02);
}
.washi-tape-tl,
.washi-tape-tr {
  position: absolute;
  width: 96px;
  height: 22px;
  opacity: 0.92;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}
.washi-tape-tl {
  top: -10px;
  left: -16px;
  transform: rotate(-22deg);
  background: repeating-linear-gradient(90deg, #cee0c0 0 8px, #b8d2a4 8px 16px);
}
.washi-tape-tr {
  top: -10px;
  right: -16px;
  transform: rotate(22deg);
  background: radial-gradient(circle at 8px 8px, #d8949a 2px, transparent 2.5px) 0 0 / 16px 16px, #f2dcde;
}
.upload-mark {
  font-family: var(--f-script);
  font-size: 56px;
  color: var(--rose-deep);
  line-height: 1;
  position: relative;
}
.upload-text {
  font-family: var(--f-script);
  font-size: 36px;
  color: var(--ink);
  position: relative;
  line-height: 1.1;
}
.upload-hint {
  font-family: var(--f-hand);
  font-size: 14px;
  color: var(--ink-mute);
  margin-top: 6px;
  position: relative;
}
.upload-status {
  margin-top: 12px;
  font-family: var(--f-hand);
  font-size: 16px;
  color: var(--rose-deep);
  min-height: 18px;
  position: relative;
}

.footer-band {
  margin-top: 80px;
  text-align: center;
  font-family: var(--f-hand);
  font-size: 16px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.footer-band .dot { color: var(--rose-deep); }

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --book-w: 92vw; --book-h: calc(var(--book-w) * 0.7); }
  .stage { padding: 12px 24px 40px; }
  .colophon { padding: 60px 24px 40px; }
  .colophon-grid { grid-template-columns: 1fr; gap: 40px; }
  .masthead { padding: 16px 24px 0; flex-wrap: wrap; gap: 12px; }
}

/* ─── Reveal ────────────────────────────────────────── */
.title-block, .book-stage, .reader-controls {
  opacity: 0;
  animation: fade-up 1s ease forwards;
}
.title-block { animation-delay: 0.05s; }
.book-stage { animation-delay: 0.3s; }
.reader-controls { animation-delay: 0.6s; }
.masthead { opacity: 0; animation: fade-down 0.8s ease forwards; animation-delay: 0.1s; }

@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
