:root {
  --ivory: #f6f0e6;
  --ink: #6f604a;
  --green: #0f2a24;
  --green-2: #143a31;
  --gold: #c9a04a;
  --gold-hi: #f6e3a6;
  --P: 120px; --H: 162px; --ew: 340px; --eh: 240px; --u: 1.2px;
  --mx: .5; --my: .5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--ivory);
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none; -webkit-user-select: none;
}

#app {
  position: fixed; inset: 0;
  overflow: hidden;
  touch-action: manipulation;
  cursor: pointer;
  outline: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 42%, #fdfaf4 0%, #f4ede1 55%, #e7dcc9 100%);
}
#dust { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .48 0 0 0 0 .38 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Title & hint ---------- */
.title {
  position: absolute; left: 0; right: 0;
  top: max(2.2vh, env(safe-area-inset-top));
  text-align: center; pointer-events: none; z-index: 20;
}
/* Bismillah at the very top: the cleaned calligraphy is a mask filled with the same shimmering gold foil */
.bismillah {
  /* height-capped too, so on short/wide screens the heading never reaches the envelope */
  width: clamp(120px, min(44vw, 20vh), 270px); aspect-ratio: 4.168; margin: 0 auto 1.1vh;
  background: linear-gradient(100deg, #8a6421 0%, #d9b665 18%, #fff1c4 30%, #c99a3f 42%, #f7e2a1 55%, #9c7428 70%, #e9cd84 85%, #8a6421 100%);
  background-size: 250% 100%;
  -webkit-mask: url(assets/bismillah-mask.png) center / contain no-repeat;
  mask: url(assets/bismillah-mask.png) center / contain no-repeat;
  animation: foilText 7s ease-in-out infinite alternate;
  transform-origin: 50% 50%;
}
@media (prefers-reduced-motion: reduce) { .bismillah { animation: none; } }
/* very old browsers without CSS masks would show a plain gold bar: hide it there instead */
@supports not ((-webkit-mask-image: none) or (mask-image: none)) { .bismillah { display: none; } }
/* hidden until the opening sequence (app.js) brings things in, so nothing flashes on first paint */
#app.booting .bismillah, #app.booting .title .eyebrow, #app.booting .title .names,
#app.booting .stage, #app.booting .hint { opacity: 0; }
.eyebrow {
  font-size: clamp(10px, 2.6vw, 13px); letter-spacing: .32em; text-transform: uppercase;
  color: #8d7c5f;
}
.names {
  font-family: "Great Vibes", cursive; font-size: clamp(30px, min(9.5vw, 6.4vh), 56px); line-height: 1.15; margin-top: .1em;
}
.names .amp { font-size: .8em; }

.hint {
  position: absolute; left: 0; right: 0;
  bottom: max(3.5vh, calc(env(safe-area-inset-bottom) + 12px));
  text-align: center; pointer-events: none; z-index: 20;
}
.hint-row {
  display: inline-flex; align-items: center; gap: .7em;
  font-size: clamp(11px, 3vw, 14px); letter-spacing: .26em; text-transform: uppercase; color: #7a6a4f;
  transition: opacity .45s ease;
}
.hint.hidden .hint-row { opacity: 0; }
#app.viewing .hint-row { color: #eadfc6; }
#app.viewing .tap-ring, #app.viewing .tap-ring::after { border-color: #e2c98a; }
#app.viewing .dots i { background: rgba(234,223,198,.35); }
#app.viewing .dots i.on { background: #e8cd86; }
.tap-ring {
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid #b89550; position: relative;
}
.tap-ring::after {
  content: ""; position: absolute; inset: -1px; border-radius: 50%; border: 1px solid #b89550;
  animation: ring 2.2s ease-out infinite;
}
@keyframes ring { 0% { transform: scale(1); opacity: .9 } 100% { transform: scale(2.4); opacity: 0 } }
/* "Powered by Ryno": a quiet light-gold credit; the mark carries a slow, faint foil sheen */
.credit {
  display: flex; align-items: center; justify-content: center; gap: .55em;
  margin-bottom: 28px; opacity: 0; transition: opacity .6s ease;
}
/* only on the opening screen */
#app.at-start .credit { opacity: .72; }
.credit-mark {
  width: 31px; height: 24px; flex: none;
  transform: translateY(-3.5px);
  background: linear-gradient(105deg, #9e7f45 0%, #b8995f 38%, #e8d6a8 50%, #b8995f 62%, #9e7f45 100%);
  background-size: 320% 100%;
  -webkit-mask: url(assets/ryno-mark.png) center / contain no-repeat;
  mask: url(assets/ryno-mark.png) center / contain no-repeat;
  animation: rynoSheen 6.5s ease-in-out infinite;
}
@keyframes rynoSheen { 0%, 55% { background-position: 100% 0 } 85%, 100% { background-position: 0% 0 } }
.credit-text {
  font-size: clamp(15px, 3.9vw, 18px); letter-spacing: .24em; text-transform: uppercase;
  color: #a88b5a;
}
@media (prefers-reduced-motion: reduce) { .credit-mark { animation: none; } }
.dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; opacity: 0; transition: opacity .45s ease; }
.dots.show { opacity: 1; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #cdbb97; transition: background .4s, transform .4s; }
.dots i.on { background: #a98538; transform: scale(1.35); }

/* ---------- Gold foil text ---------- */
.foil-text {
  background: linear-gradient(100deg, #8a6421 0%, #d9b665 18%, #fff1c4 30%, #c99a3f 42%, #f7e2a1 55%, #9c7428 70%, #e9cd84 85%, #8a6421 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  animation: foilText 7s ease-in-out infinite alternate;
  padding: .15em .3em; /* script swashes overhang their box; keep them inside the clipped gold */
}
@keyframes foilText { from { background-position: 0% 50% } to { background-position: 100% 50% } }

/* ---------- Stage ---------- */
.stage { position: absolute; inset: 0; perspective: 1700px; }
.stage > * { position: absolute; left: 50%; top: 50%; }

/* Envelope = the tri-fold itself */
.flipper { width: var(--P); height: var(--H); z-index: 10; }
.flipper > .folder, .flipper > .env-face { position: absolute; left: 0; top: 0; }
.env-face {
  width: var(--P); height: var(--H); border-radius: 2px; z-index: 2;
  box-shadow: 0 calc(var(--u)*4) calc(var(--u)*10) rgba(40,28,8,.35), 0 1px 2px rgba(0,0,0,.3);
}
.env-face::after {
  content: ""; position: absolute; inset: calc(var(--u)*3.2); border: 1px solid rgba(201,160,74,.32); border-radius: 1px; pointer-events: none;
}

/* Outside of the pointed flap (seen when the envelope is turned over) */
.flap-shape-out {
  position: absolute; inset: 0;
  clip-path: polygon(0 0, 60% 0, 100% 50%, 60% 100%, 0 100%);
}
.flap-edge { position: absolute; inset: 0; width: 100%; height: 100%; }
.invited {
  position: absolute; left: 34%; top: 50%; white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-90deg);
  font-family: "Pinyon Script", cursive; font-size: calc(var(--u) * 15); line-height: 1.2;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.5));
}
.seal {
  position: absolute; left: 84%; top: 50%;
  width: calc(var(--P) * .34); height: calc(var(--P) * .34);
  margin-left: calc(var(--P) * -.17); margin-top: calc(var(--P) * -.17);
  filter: drop-shadow(0 calc(var(--u)*1.2) calc(var(--u)*1.6) rgba(0,0,0,.5));
}
.seal-half { position: absolute; inset: 0; transform: rotate(-90deg); }
.seal-half svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* left half overlaps the crack slightly so the closed seal shows no seam */
.seal-l { clip-path: polygon(0 0, 54.5% 0, 48.5% 18%, 56.5% 36%, 46.5% 54%, 55.5% 72%, 49.5% 100%, 0 100%); }
.seal-r { clip-path: polygon(53% 0, 100% 0, 100% 100%, 48% 100%, 54% 72%, 45% 54%, 55% 36%, 47% 18%); }

.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.burst i {
  position: absolute; left: 0; top: 0; width: calc(var(--u)*2.4); height: calc(var(--u)*2.4);
  margin: calc(var(--u)*-1.2) 0 0 calc(var(--u)*-1.2); border-radius: 50%;
  background: radial-gradient(circle, #fff7d6 0%, #e8c66f 45%, rgba(201,160,74,0) 70%);
  opacity: 0;
}
.dim {
  left: 0; top: 0; width: 100%; height: 100%; z-index: 9; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(20,16,10,.55), rgba(10,8,5,.78));
}

/* ---------- Folder ---------- */
.folder { width: var(--P); height: var(--H); perspective: calc(var(--P) * 7); }
.panel { position: absolute; top: 0; width: var(--P); height: var(--H); transform-style: preserve-3d; }
.panel-center { left: 0; z-index: 1; border-radius: 2px; box-shadow: 0 calc(var(--u)*3) calc(var(--u)*8) rgba(40,28,8,.35); }
.panel-left { left: calc(var(--P) * -1); z-index: 2; transform-origin: 100% 50%; }
.panel-right { left: var(--P); z-index: 3; transform-origin: 0% 50%; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 2px; }
.face.back { transform: rotateY(180deg); }
.panel-right .face { box-shadow: 0 calc(var(--u)*3) calc(var(--u)*8) rgba(40,28,8,.35); }

/* Emerald card stock: soft light falloff + fine grain + faint fibres + gentle mottling, with a bevelled edge */
.velvet {
  background:
    radial-gradient(ellipse 130% 95% at 22% 12%, rgba(255,255,255,.06), rgba(255,255,255,0) 58%),
    radial-gradient(ellipse 90% 70% at 85% 100%, rgba(0,0,0,.25), rgba(0,0,0,0) 70%),
    linear-gradient(155deg, #133a32 0%, #0f2f29 45%, #0a241f 100%);
}
.velvet::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  mix-blend-mode: soft-light; opacity: .6;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='560' height='280'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.018 .5' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='.55'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='640'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' seed='9' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)' opacity='.6'/%3E%3C/svg%3E");
  background-size: 220px 220px, 560px 280px, 640px 640px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 -1px 0 rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.025);
}
.flap-shape {
  position: absolute; inset: 0;
  clip-path: polygon(40% 0, 100% 0, 100% 100%, 40% 100%, 0 50%);
}
.panel-left .face { filter: drop-shadow(0 calc(var(--u)*3) calc(var(--u)*5) rgba(40,28,8,.35)); }
.crest { position: absolute; left: 38%; top: 50%; width: 46%; transform: translateY(-50%); opacity: .95; }
.crest svg { width: 100%; height: auto; display: block; }

.fold-light, .shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; border-radius: inherit; }
.fold-light { background: linear-gradient(90deg, rgba(0,0,0,.65), rgba(0,0,0,.35)); }
.panel-left .fold-light { clip-path: polygon(40% 0, 100% 0, 100% 100%, 40% 100%, 0 50%); }
.shade { background: rgba(8,6,3,.62); z-index: 6; }
.panel-center .shade { z-index: 0; }
.panel-left .shade { clip-path: polygon(40% 0, 100% 0, 100% 100%, 40% 100%, 0 50%); }

.pocket { position: absolute; left: 0; right: 0; top: 40%; bottom: 0; z-index: 5; pointer-events: none; }
.pocket svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* While the envelope is open (cards moving), the pocket front and dimming overlays get their own fixed
   GPU layers: drawn once, at final size, then reused, so cards sliding underneath never force the browser
   to rebuild/redraw them mid-animation (the flicker on iOS / in-app browsers). */
.folder[data-flat="1"] .pocket { will-change: transform; }
.folder[data-flat="1"] .shade { will-change: opacity; }

/* Envelope front: wreath + names (laid out landscape) */
.cover-inner {
  position: absolute; left: 50%; top: 50%;
  width: var(--H); height: var(--P);
  transform: translate(-50%, -50%) rotate(-90deg);
  display: flex; align-items: center; justify-content: center;
}
.wreath { position: absolute; left: 50%; top: 50%; width: 74%; transform: translate(-50%, -50%); }
.wreath svg { width: 100%; height: auto; display: block; }
.cover-names {
  position: relative; text-align: center; font-family: "Great Vibes", cursive;
  font-size: calc(var(--u) * 15); line-height: 1.12;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.45));
}
.cover-names .amp { font-size: .75em; }

/* ---------- Cards ---------- */
.card {
  position: absolute; z-index: 1;
  transform-origin: 50% 50%;
  border-radius: 3px;
  box-shadow: 0 6px 22px rgba(0,0,0,.38), 0 1px 3px rgba(0,0,0,.3);
  background: #f3ebdf;
  isolation: isolate;
}
/* Wedding card: back of the pocket; an inner layer turns over to reveal the front */
#cardWed { z-index: 0; }
.wcard { background: transparent; box-shadow: none; }
.wflip { position: absolute; inset: 0; transform-style: preserve-3d; }
.wface {
  position: absolute; inset: 0; border-radius: 3px; overflow: hidden;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  box-shadow: 0 6px 22px rgba(0,0,0,.38), 0 1px 3px rgba(0,0,0,.3);
}
.wface img { width: 100%; height: 100%; display: block; }
.wfront { transform: rotateX(180deg); }
/* soft band of light drifting across the card (same timing curve as the other cards' shine) */
.wsheen { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.wsheen i {
  position: absolute; top: 0; left: -15%; width: 130%; height: 100%;
  background: linear-gradient(112deg,
    rgba(255,255,255,0) 36%, rgba(255,247,228,.0) 40%, rgba(255,247,228,.30) 50%, rgba(255,247,228,0) 60%, rgba(255,255,255,0) 64%);
  animation: glint 6.8s cubic-bezier(.45,0,.25,1) infinite; animation-delay: .9s;
}
@media (prefers-reduced-motion: reduce) { .wsheen i { animation: none; } }
#cardIntro { z-index: 1; }
#cardPre { z-index: 2; }
.card img { width: 100%; height: 100%; display: block; border-radius: inherit; }
.foil {
  position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none;
  -webkit-mask-image: var(--mask); mask-image: var(--mask);
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.foil.soft { opacity: .7; }
.reflect {
  position: absolute; inset: -50%;
  background: linear-gradient(125deg,
    rgba(255,255,255,0) 18%, rgba(255,248,222,.34) 30%, rgba(46,26,0,.26) 39%, rgba(255,255,255,0) 49%,
    rgba(255,248,222,.26) 61%, rgba(46,26,0,.2) 71%, rgba(255,255,255,0) 82%);
  translate: calc((var(--mx) - .5) * 26%) calc((var(--my) - .5) * 26%);
  transition: translate .8s cubic-bezier(.2,.7,.2,1);
  animation: drift 9s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateX(-7%) } to { transform: translateX(7%) } }
/* Same band, angle and travel as before, on a box 4.6x smaller (less GPU memory on phones).
   Stops / translate are recomputed so the band's width and path in card space are unchanged. */
.glint {
  position: absolute; top: 0; left: -15%; width: 130%; height: 100%;
  background: linear-gradient(112deg,
    rgba(255,255,255,0) 34.51%, rgba(255,251,234,.0) 38.93%, rgba(255,251,234,.9) 50%, rgba(255,251,234,0) 61.07%, rgba(255,255,255,0) 65.49%);
  animation: glint 5.2s cubic-bezier(.45,0,.25,1) infinite;
}
.glint.slow { animation-duration: 7.5s; animation-delay: 1.5s; }
.glint.fast { animation-duration: 3.8s; animation-delay: .6s; }
@keyframes glint { 0% { transform: translateX(-83.08%) } 55%, 100% { transform: translateX(83.08%) } }

/* While the envelope is open the panels don't fold, so drop the 3D context: cards then
   restack in a plain 2D layer (avoids iOS/WebView flicker when a card's z-index changes). */
.folder[data-flat="1"] .panel { transform-style: flat; }
.folder[data-flat="1"] .face { -webkit-backface-visibility: visible; backface-visibility: visible; }
.folder[data-flat="1"] .face.back { visibility: hidden; }
.glitter { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; border-radius: inherit; }

@media (prefers-reduced-motion: reduce) {
  .reflect, .glint, .foil-text, .tap-ring::after { animation: none !important; }
}
