/* The web flip card. Fonts are the app's OFL fonts; Devanagari and Bengali load only when a card uses them. */
@font-face { font-family: "PN Script"; src: url(fonts/great_vibes.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "PN Serif"; src: url(fonts/playfair_display.woff2) format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "PN Display"; src: url(fonts/poppins_regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "PN Display"; src: url(fonts/poppins_semibold.woff2) format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "PN Deva"; src: url(fonts/noto_sans_devanagari.woff2) format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+200C-200D, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF; }
@font-face { font-family: "PN DevaDisplay"; src: url(fonts/yatra_one.woff2) format("woff2"); font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+200C-200D, U+25CC, U+A8E0-A8FF; }
@font-face { font-family: "PN Beng"; src: url(fonts/noto_sans_bengali.woff2) format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0980-09FF, U+200C-200D, U+25CC; }
@font-face { font-family: "PN BengDisplay"; src: url(fonts/galada.woff2) format("woff2"); font-display: swap;
  unicode-range: U+0980-09FF, U+200C-200D, U+25CC; }
@font-face { font-family: "PN Pinyon"; src: url(fonts/pinyon_script.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "PN Cinzel"; src: url(fonts/cinzel.woff2) format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "PN Cormorant"; src: url(fonts/cormorant_garamond.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }

:root {
  --bg0: #7A1426; --bg1: #3A0612; --ink: #FBE7C6; --accent: #F2C46B;
  --cw: 320px; --ch: 400px;
  --script: "PN Script", "PN DevaDisplay", "PN BengDisplay", cursive;
  --serif: "PN Serif", "PN Deva", "PN Beng", Georgia, serif;
  --display: "PN Display", "PN Deva", "PN Beng", system-ui, sans-serif;
  --devanagari: "PN Deva", "PN Serif", serif;
  --pinyon: "PN Pinyon", "PN DevaDisplay", "PN BengDisplay", cursive;
  --cinzel: "PN Cinzel", "PN Deva", "PN Beng", Georgia, serif;
  --cormorant: "PN Cormorant", "PN Deva", "PN Beng", Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom));
  background: #1a0a0e;
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--bg1) 75%, #000), color-mix(in srgb, var(--bg1) 30%, #000));
  color: #F6EBDD; font-family: var(--display);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}

#stage { position: relative; width: var(--sw, var(--cw)); height: var(--sh, var(--ch)); flex: none; touch-action: pan-y; cursor: pointer; }
#book { position: absolute; inset: 0; z-index: 1; perspective: calc(var(--ch) * 2.8); }
#fx { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; pointer-events: none; }

.page { position: absolute; inset: 0; transform-origin: 0 50%; transform-style: preserve-3d; }
.page.turned { transform: rotateY(-180deg); }
.page.gone { visibility: hidden; }

/* Mid-turn the page is drawn by strips laid along the bend (see curl in invite.js). */
.page.curling { transform: none; }
.page.curling > .face { visibility: hidden; }
/* Clipped to the card like the app's turn; the clip flattens .curl, so it carries the book's perspective itself. */
.curl { position: absolute; inset: 0; pointer-events: none; perspective: calc(var(--ch) * 2.8); clip-path: inset(-15% 0 -15% 0); }
.strip { position: absolute; top: 0; height: 100%; transform-origin: 0 50%; transform-style: preserve-3d; will-change: transform; }
.sf, .sb { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.sb { transform: rotateY(180deg); }
.sf > .face, .sb > .face { box-shadow: none; }
.shade { position: absolute; inset: 0; }
.cast { position: absolute; inset: 0; border-radius: 6px; pointer-events: none; }
.page .curl .face .tx { opacity: 1; animation: none; }
.page .curl .face .tx > span { animation: none; clip-path: none; opacity: 1; }

.face { position: absolute; inset: 0; overflow: hidden; border-radius: 6px; backface-visibility: hidden;
  -webkit-backface-visibility: hidden; background: radial-gradient(ellipse at 50% 50%, var(--bg0), var(--bg1)); }
.front { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35); }
.back { transform: rotateY(180deg); filter: brightness(0.82); }
.back::before { content: ""; position: absolute; inset: 6%; border: 1px solid var(--accent); opacity: 0.35; border-radius: 3px; }
.frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
/* The cover motif and the vellum opener, moved by invite.js (intro). */
.sprite { position: absolute; object-fit: fill; pointer-events: none; transform-origin: 50% 50%; will-change: transform, opacity; }

.tx { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center;
  overflow: hidden; line-height: 1.22; color: var(--c); }
.tx > span { display: block; width: 100%; white-space: pre-line; overflow-wrap: break-word; }
.dark .tx:not(.gold) > span { text-shadow: 0 0.06em 0.3em rgba(0, 0, 0, 0.5); }
.tx.gold > span { color: transparent; -webkit-background-clip: text; background-clip: text;
  background-image: linear-gradient(180deg, #FFF4C8 0%, #F2C46B 42%, #B98322 68%, #FFE6A0 100%);
  filter: drop-shadow(0 0.05em 0.12em rgba(0, 0, 0, 0.45)); padding: 0.08em 0; }
.tx a { color: inherit; text-decoration: underline dotted; text-decoration-thickness: 0.06em; text-underline-offset: 0.2em; }
.tx.emoji { line-height: 1; }
.tx.line > span { white-space: nowrap; }
.live .tx.emoji > span { animation: pop 0.6s ease-out both, float 3s ease-in-out 0.6s infinite; }

/* Entrances, started when a page comes up. */
.page:not(.live) .tx { opacity: 0; }
.live .tx { animation: rise 0.9s ease-out both; animation-delay: var(--d); }
.live .tx.reveal { animation: none; }
.live .tx.reveal > span { animation: reveal 1.1s ease-out both; animation-delay: var(--d); }
@keyframes rise { from { opacity: 0; transform: translateY(0.4em); } to { opacity: 1; transform: none; } }
@keyframes reveal { from { clip-path: inset(0 100% 0 0); opacity: 0.2; } to { clip-path: inset(0 -5% 0 -5%); opacity: 1; } }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } to { transform: scale(1); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6%); } }

/* Doors and envelope: a closed page over the cover that opens onto it (opener in invite.js). */
.op { position: absolute; inset: 0; overflow: hidden; border-radius: 6px; pointer-events: none; }
.op.doors, .op.envfore { z-index: 2; }
.op.envback { z-index: 0; }
.op.doors { perspective: calc(var(--ch) * 1.6); }
.leaf { position: absolute; top: 0; width: 50%; height: 100%; overflow: hidden; will-change: transform, filter; }
.leaf.l { left: 0; transform-origin: 0 50%; }
.leaf.r { left: 50%; transform-origin: 100% 50%; }
.leaf .face { right: auto; width: 200%; border-radius: 0; box-shadow: none; backface-visibility: visible; -webkit-backface-visibility: visible; }
.leaf.r .face { left: -100%; }
.glow { position: absolute; inset: 0; opacity: 0; mix-blend-mode: screen;
  background: radial-gradient(ellipse 14% 70% at 50% 50%, rgba(255, 199, 115, 0.85), rgba(255, 199, 115, 0)); }
.op .slide { position: absolute; inset: 0; perspective: calc(var(--ch) * 2); will-change: transform; }
.op .env { position: absolute; left: 14%; top: 44%; width: 72%; height: 38%; pointer-events: none; }
/* The envelope's pieces in card %: the flap's tip is 23.75% below the hinge (44%), the pocket's V 20.9%. */
.inside { position: absolute; inset: 0; clip-path: polygon(14% 44%, 86% 44%, 50% 64.9%); background: linear-gradient(180deg, #948F86 44%, #CEC7BA 51%); }
.liner { position: absolute; inset: 0; clip-path: polygon(14% 44%, 86% 44%, 50% 20.25%); transform-origin: 50% 44%;
  background: #E2D9CA; visibility: hidden; }
.pocket { position: absolute; inset: 0; clip-path: polygon(14% 44%, 50% 64.9%, 86% 44%, 86% 82%, 14% 82%); }
.paper { position: absolute; inset: 0; clip-path: polygon(14% 44%, 50% 64.9%, 86% 44%, 50% 67.75%); background: #F5EDDD; }
.flap { position: absolute; inset: 0; clip-path: polygon(14% 44%, 86% 44%, 50% 67.75%); transform-origin: 50% 44%; }

/* Cinematic and stories: a 9:16 stage on black that plays by itself (reel in invite.js). */
.tall #stage { background: #000; overflow: hidden; border-radius: 10px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55); }
.tall #book { perspective: calc(var(--sh) * 2); }
.tall .page .face { inset: auto; left: calc(50% - var(--cw) / 2); top: calc(50% - var(--ch) / 2); width: var(--cw); height: var(--ch); }
.tall .page.live { z-index: 999 !important; }
.tall .page.out { z-index: 998 !important; }
.page.out .tx { opacity: 1; animation: none; }
.mode-cinematic .page { opacity: 0; transition: opacity 1.2s ease; }
.mode-cinematic .page.live, .mode-cinematic .page.out { opacity: 1; }
.mode-cinematic .face { border-radius: 0; box-shadow: none; }
.mode-cinematic .page .front { transition: transform 7s linear; }
.mode-cinematic .page.live .front { transform: scale(1.06); }
.leak { position: absolute; inset: 0; z-index: 3; opacity: 0; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 50%, rgba(255, 176, 96, 0.9), rgba(255, 110, 60, 0.35) 38%, rgba(0, 0, 0, 0) 68%); }
.leak.run { animation: leak 1.4s ease-in-out; }
@keyframes leak { from { opacity: 0; transform: translateX(-70%) scale(1.5); } 45% { opacity: 0.85; } to { opacity: 0; transform: translateX(70%) scale(1.5); } }
.grade { position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 236, 200, 0) 55%, rgba(0, 0, 0, 0.45)); }
.mode-stories .page { visibility: hidden; overflow: hidden; }
.mode-stories .page.live, .mode-stories .page.out { visibility: visible; }
.mode-stories .front { border-radius: calc(var(--sw) * 0.03); box-shadow: 0 1.5vh 4vh rgba(0, 0, 0, 0.55); }
.backdrop { position: absolute; left: -8%; top: -8%; width: 116%; height: 116%; filter: blur(22px) brightness(0.55);
  background: radial-gradient(ellipse at 50% 50%, var(--bg0), var(--bg1)); }
.backdrop img { width: 100%; height: 100%; object-fit: cover; }
.bars { position: absolute; left: 3%; right: 3%; top: 1.6%; z-index: 3; display: flex; gap: 4px; pointer-events: none; }
.bars span { flex: 1; height: 3px; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, 0.35); }
.bars i { display: block; width: 0; height: 100%; background: #fff; }

#actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; min-height: 52px; padding: 0 12px; }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 50px; padding: 0 20px; border-radius: 999px;
  border: 1.5px solid var(--accent); background: rgba(255, 255, 255, 0.08); color: #FFF7EA; font: 600 17px var(--display);
  text-decoration: none; cursor: pointer; }
.pill:active { background: rgba(255, 255, 255, 0.18); }
.hint { align-self: center; font-size: 16px; opacity: 0.85; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

.pill.primary { background: var(--accent); color: #2A0A10; border-color: var(--accent); }
button.pill { font: 600 17px var(--display); cursor: pointer; }

#rsvp { width: min(440px, 94vw); border: 1.5px solid var(--accent); border-radius: 22px; padding: 22px 20px 16px;
  background: color-mix(in srgb, var(--bg1) 70%, #000); color: #FFF7EA; font-family: var(--display); -webkit-user-select: text; user-select: text; }
#rsvp::backdrop { background: rgba(0, 0, 0, 0.6); }
#rsvp form { display: flex; flex-direction: column; gap: 14px; position: relative; }
#rsvp h2 { margin: 0 34px 0 0; font: 400 34px var(--script); color: var(--accent); }
#rsvp .close { position: absolute; top: -10px; right: -6px; width: 44px; height: 44px; border: 0; background: none; color: #FFF7EA; font-size: 30px; cursor: pointer; }
#rsvp .choices { display: grid; grid-template-columns: 1fr; gap: 8px; }
#rsvp .choices button { min-height: 52px; border-radius: 14px; border: 1.5px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.06);
  color: #FFF7EA; font: 600 18px var(--display); text-align: left; padding: 0 16px; cursor: pointer; }
#rsvp .choices button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 28%, transparent); }
#rsvp input, #rsvp textarea { box-sizing: border-box; width: 100%; min-height: 52px; border-radius: 14px; border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.25); color: #FFF7EA; font: 18px var(--display); padding: 12px 14px; resize: none; }
#rsvp input:focus, #rsvp textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
#rsvp .count { display: flex; align-items: center; gap: 12px; font-size: 17px; }
#rsvp .count[hidden] { display: none; }
#rsvp .count span { flex: 1; }
#rsvp output { min-width: 32px; text-align: center; font: 600 22px var(--display); }
#rsvp #rsvpSend { justify-content: center; min-height: 56px; font-size: 19px; }
#rsvp #rsvpSend:disabled { opacity: 0.6; }
#rsvp p { margin: 0; text-align: center; }
#rsvp p:empty { display: none; }
#rsvp .small { font-size: 13px; opacity: 0.75; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#nav { display: flex; align-items: center; gap: 18px; font-size: 16px; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 1.5px solid var(--accent); background: rgba(255, 255, 255, 0.06);
  color: #FFF7EA; font: 30px/1 var(--serif); cursor: pointer; padding: 0 0 4px; }
.round:disabled { opacity: 0.3; cursor: default; }
#count { min-width: 120px; text-align: center; }
#made { font-size: 13px; opacity: 0.75; }
#made a { color: inherit; }

#error { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 24px; text-align: center; font-size: 19px; background: #1a0a0e; }
#error[hidden] { display: none; }
.nojs { text-align: center; padding: 24px; }

@media (prefers-reduced-motion: reduce) {
  .live .tx, .live .tx.reveal > span, .live .tx.emoji > span, .hint, .leak.run { animation: none; }
  .mode-cinematic .page .front { transition: none; transform: none; }
}
