/* Nov 25 (Dan and Grace): The Story of Us, with their photos (design/artifacts/n45). Opens on their beach photo across
   the whole screen with the title in the clouds just above their heads; the chapters zig-zag close together like a
   scrapbook (hand-torn photo edges, a slight tilt, a strip of paper tape); the villa paints in at the end.
   Everything is prefixed sp- so nothing here touches the invitation's own styles. The opening (.sp-hero) is also
   drawn small on the storybook's page on the invitation (js/book.js), so the book opens straight into it. */
.sp-page { --page: #F5EEE2; --ink: #3A2A1D; --muted: #76664F; --line: #D8C8AE; --wine: #721812; --card: #FBF7EE;
  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif; --script: "Pinyon Script", "Snell Roundhand", cursive; --body: "Work Sans", system-ui, -apple-system, sans-serif;
  background: var(--page); color: var(--ink); font: 400 16px/1.6 var(--body); overflow-x: clip; }
.sp-page * { box-sizing: border-box; }

/* 1. the opening: their photo, cut just under their feet, across the whole width; a strip of sky, then the title
   right over their heads. Their heads are 53% of the width above the photo's foot (on a phone the photo fills the
   height: 39.7% of it). */
.sp-hero { --tt: calc(min(6.6vw, 11.5vh) * .92 + min(9.6vw, 16.5vh) * .94 + 2.2vw); position: relative; overflow: hidden; height: min(133vw, calc(53vw + 1vw + var(--tt) + clamp(28px, 4.5vh, 60px))); }
.sp-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%; }
.sp-t { position: absolute; left: 0; right: 0; bottom: calc(53vw + 1vw); margin: 0; z-index: 2; display: grid; justify-items: center; text-align: center; padding: 0 16px; line-height: .9; color: #2E241B; }
.sp-t .t1 { font: 500 clamp(44px, min(6.6vw, 11.5vh), 124px)/.92 var(--display); text-transform: uppercase; letter-spacing: -.005em; white-space: nowrap; text-shadow: 0 0 40px rgba(255, 252, 246, .55); }
.sp-t .t2 { font: 400 clamp(56px, min(9.6vw, 16.5vh), 176px)/1 var(--script); color: var(--wine); margin-top: -.06em; text-shadow: 0 0 34px rgba(255, 252, 246, .6); }
.sp-t .t3 { margin-top: .9em; font: 600 clamp(12px, 1vw, 16px)/1 var(--body); letter-spacing: .34em; text-transform: uppercase; color: #4A3B2D; padding-left: .34em; }
.sp-edge { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 44px; z-index: 2; display: block; }
.sp-back { position: fixed; top: max(16px, env(safe-area-inset-top, 0px)); left: max(16px, env(safe-area-inset-left, 0px)); z-index: 10; font: 500 12px var(--body); letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink); background: rgba(245, 238, 226, .86); border: 1px solid var(--line); padding: 9px 14px; border-radius: 999px; text-decoration: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sp-back:focus-visible { outline: 2px solid var(--wine); outline-offset: 3px; }

/* 2. the chapters, close together, zig-zagging */
.sp-story { width: min(1360px, calc(100% - 2 * max(24px, env(safe-area-inset-left, 0px)))); margin: 0 auto; padding: clamp(56px, 9vh, 110px) 0 calc(5vh + 40px); display: grid; gap: clamp(56px, 11vh, 130px); }
.sp-ch { display: grid; grid-template-columns: 1.6fr 1fr; gap: clamp(32px, 5vw, 84px); align-items: center; }
.sp-ch.flip { grid-template-columns: 1fr 1.6fr; }
.sp-ch.flip .sp-print { order: 2; }
.sp-ch.small { grid-template-columns: 1.4fr 1fr; } .sp-ch.small.flip { grid-template-columns: 1fr 1.4fr; }
.sp-print { position: relative; margin: 0; filter: drop-shadow(0 3px 7px rgba(58, 42, 29, .18)); }
.sp-print .ph { position: relative; aspect-ratio: var(--ar, 4 / 5); overflow: hidden; max-height: 84vh; margin: 0 auto; clip-path: var(--torn); }
.sp-print .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--fp, 50% 40%); filter: grayscale(1) sepia(.45) contrast(.82) brightness(1.08) blur(1.2px); transition: filter 1.6s ease-out; }
.sp-print.dev .ph img { filter: none; }
.sp-print::after { content: ""; position: absolute; top: -16px; left: 50%; width: clamp(90px, 22%, 150px); height: 34px; transform: translateX(-50%) rotate(var(--tape, -3deg)); z-index: 2;
  background: linear-gradient(90deg, rgba(0, 0, 0, .04), transparent 12%, transparent 88%, rgba(0, 0, 0, .04)), rgba(236, 224, 199, .82);
  clip-path: polygon(0 6%, 4% 0, 8% 8%, 12% 1%, 16% 7%, 20% 0, 80% 0, 84% 6%, 88% 0, 92% 7%, 96% 1%, 100% 6%, 100% 94%, 96% 100%, 92% 93%, 88% 100%, 84% 94%, 80% 100%, 20% 100%, 16% 94%, 12% 100%, 8% 93%, 4% 100%, 0 94%); }
.sp-copy { display: grid; gap: 10px; max-width: 30em; }
.sp-copy .when { font: 600 12px/1 var(--body); letter-spacing: .26em; text-transform: uppercase; color: var(--muted); }
.sp-copy h2 { margin: 0; font: 400 clamp(40px, 4.4vw, 60px)/1.05 var(--script); color: var(--wine); }
.sp-copy p { margin: 0; color: var(--ink); font-size: 17px; }

/* the photos and words arrive softly, once; a photo settles at its tilt and straightens a little under the pointer */
.sp-rise { opacity: 0; transform: translateY(18px); transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .2, 1); }
.sp-rise.in { opacity: 1; transform: none; }
.sp-print.sp-rise { transform: translateY(18px) rotate(var(--tilt, -1deg)); }
.sp-print.sp-rise.in { transform: rotate(var(--tilt, -1deg)); }
@media (hover: hover) { .sp-print.sp-rise.in:hover { transform: rotate(0deg) translateY(-6px); } }

/* 3. the ending: the villa, edge to edge, tucked right under the last photo (its own empty top, 18% of it, goes under) */
.sp-end { display: grid; justify-items: center; text-align: center; gap: 14px; margin-top: calc(-1 * clamp(56px, 11vh, 130px) - 7.6vw); }
.sp-villa { position: relative; width: 100vw; margin-inline: calc(50% - 50vw); aspect-ratio: 1536 / 698; }
.sp-villa img { position: absolute; inset: 0; width: 100%; height: 100%; }
.sp-villa .vc { -webkit-mask-image: radial-gradient(circle at 50% 70%, #000 calc(var(--vp, 0) * 70%), transparent calc(var(--vp, 0) * 70% + 18%)); mask-image: radial-gradient(circle at 50% 70%, #000 calc(var(--vp, 0) * 70%), transparent calc(var(--vp, 0) * 70% + 18%)); }
.sp-villa .vi { opacity: calc(1 - var(--vp, 0) * .7); }
.sp-end h2 { margin: 0; font: 400 clamp(40px, 4.6vw, 64px)/1.05 var(--script); color: var(--wine); }
.sp-end a { margin-top: 10px; font: 600 12px var(--body); letter-spacing: .2em; text-transform: uppercase; color: var(--ink); border: 1px solid var(--line); padding: 14px 22px; text-decoration: none; background: var(--card); }

@media (max-width: 820px) {
  .sp-hero { height: 100svh; }
  .sp-t { bottom: calc(39.7% + 40px); } .sp-t .t1 { font-size: 13vw; } .sp-t .t2 { font-size: 16vw; }
  .sp-ch, .sp-ch.flip, .sp-ch.small, .sp-ch.small.flip { grid-template-columns: 1fr; gap: 22px; }
  .sp-ch.flip .sp-print { order: 0; }
  .sp-ch .sp-print { width: 94%; }
  .sp-ch.flip .sp-print { justify-self: end; }
  .sp-ch.flip .sp-copy { justify-self: end; text-align: right; }
  .sp-copy h2 { font-size: 44px; }
}
@media (prefers-reduced-motion: reduce) { .sp-rise { opacity: 1; transition: none; } .sp-print .ph img { filter: none; transition: none; } }

/* the storybook on the invitation: its right-hand page carries a small copy of the opening, sized so that when the
   book's page fills the screen it is exactly the story page's first screen (js/book.js) */
.sp-mini { position: absolute; overflow: hidden; pointer-events: none; }
.sp-mini .sp-shot { position: absolute; left: 0; top: 0; width: 100vw; height: 100vh; overflow: hidden; transform-origin: 0 0; }

/* Dec 1 (Dan): each photo can be zoomed and moved in its frame from the private page (--fp where, --fz how close) */
.sp-print .ph img { transform: scale(var(--fz, 1)); transform-origin: var(--fp, 50% 40%); }

/* Dec 1 (Dan): the private page's story editor shows this page with edit buttons (?preview=1&edit=1) */
.sp-editing .sp-rise { opacity: 1 !important; transform: none !important; }
.sp-editing .sp-print.sp-rise { transform: rotate(var(--tilt, -1deg)) !important; }
.sp-ebar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.sp-hero .sp-ebar { position: absolute; right: 28px; top: 28px; margin: 0; z-index: 5; }
.sp-ch.flip .sp-ebar { justify-content: flex-end; }
.sp-end .sp-ebar { justify-content: center; margin: 14px 0 0; }
.sp-eb { font: 600 15px/1 "Work Sans", system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; padding: 14px 22px; border-radius: 999px; border: 1px solid #B9A88C; background: #fff; color: #3A2A1D; cursor: pointer; box-shadow: 0 2px 8px rgba(58, 42, 29, .12); }
.sp-eb.dark { background: #3A2A1D; color: #FBF7EE; border-color: #3A2A1D; }
.sp-eb:hover { filter: brightness(1.06); }
.sp-eb.add { display: block; width: min(1100px, calc(100% - 80px)); margin: 70px auto 0; padding: 34px; border: 3px dashed #C9B99E; background: transparent; box-shadow: none; font-size: 18px; color: #76664F; }
.sp-etag { position: absolute; left: 28px; top: 20px; z-index: 6; background: #fff; border: 1px solid #ddd; border-radius: 999px; padding: 8px 14px; font: 600 13px "Work Sans", system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: #6E6E73; }
.sp-end { position: relative; }

/* Dec 1 (Dan): the photos in their own colours from the start (no sepia that turns to colour) */
.sp-print .ph img, .sp-print.dev .ph img { filter: none; transition: none; }
/* Dec 1 (Dan): the photos looked yellow while scrolling: they faded in over the cream page. Now they arrive at full
   strength (only the gentle rise stays), so they are always their own colours. */
.sp-print.sp-rise { opacity: 1; transition: transform .9s cubic-bezier(.2, .7, .2, 1); }
