/* Each chapter starts below the persistent header and fills the available view. */
:root{--chapter-header:68px;--chapter-height:calc(100svh - var(--chapter-header))}
html{scroll-snap-type:y mandatory;scroll-padding-top:var(--chapter-header)}
html.invitation-locked,html.chapter-moving,html.language-changing,html:has(dialog[open]){scroll-snap-type:none}
html.chapter-moving{scroll-behavior:auto}
html.language-changing{scroll-behavior:auto;overflow-anchor:none}
html.language-changing body{overflow-anchor:none}
.topbar{height:var(--chapter-header);z-index:25}
main>section[id]{scroll-snap-align:start;scroll-snap-stop:always;scroll-margin:0;min-height:var(--chapter-height);box-sizing:border-box}
main>.section{padding:clamp(28px,5svh,56px) max(24px,6vw) 88px}
main>.hero{height:auto;min-height:var(--chapter-height);padding:35px 24px 86px}
.hero-copy{margin-top:0;max-width:560px;padding:clamp(22px,4svh,40px) clamp(22px,5vw,60px)}
.hero h1{font-size:clamp(55px,8vw,94px)}
.hero-image,.hero-shade{inset:5% 12% 9%}
.hero-caption{bottom:64px}
.hero-stamp{top:24px}
main>.photo-story{display:grid;grid-template-columns:minmax(0,1fr) minmax(245px,.9fr) minmax(0,1fr);align-content:center;gap:clamp(20px,4vw,55px);padding:42px 6vw 88px}
.photo-story .story-photo{height:clamp(280px,54svh,510px);min-height:0;width:100%;margin:0;align-self:center;animation:none}
.story-note{padding:0}
.story-note h2{font-size:clamp(28px,3.2vw,43px);line-height:1.18;margin-bottom:18px}
.story-note>p:not(.eyebrow){line-height:1.8;font-size:12px}
.story-note .eyebrow{margin-bottom:15px}
.handwritten{margin-top:18px}
main>.gallery-section{display:flex;flex-direction:column;justify-content:center;padding-inline:max(24px,calc((100% - 1050px)/2))}
.gallery-edition{margin-bottom:15px;padding-bottom:9px;flex:none}
.gallery-heading{display:flex;align-items:end;justify-content:space-between;margin-bottom:20px;gap:24px;flex:none}
.gallery-heading h2{font-size:clamp(32px,4vw,49px)}
.gallery-heading .eyebrow{margin-bottom:12px}
.gallery-heading>p{max-width:280px;font-size:11px;line-height:1.7;margin:0}
.album-book{width:100%;grid-template-columns:40px minmax(0,560px) 40px;gap:16px;padding:0}
.album-page{width:100%;max-width:560px;height:clamp(260px,43svh,420px);padding:32px 28px 54px;min-height:0;aspect-ratio:auto}
.album-photo{min-height:0;height:100%;max-height:none;object-fit:contain}
.album-caption{left:22px;right:22px;bottom:16px;font-size:14px}
.album-page-number{top:13px;right:20px}
.album-arrow{width:38px;height:38px;min-width:0}
.album-controls{width:min(100%,560px);margin-top:14px;flex:none}
main>.details{display:flex;flex-direction:column;align-items:center;justify-content:center}
.details>.eyebrow{margin-bottom:14px}
.details h2{font-size:clamp(34px,4.5vw,55px);margin-bottom:18px}
.details-grid{width:min(100%,900px);max-width:none;grid-template-columns:repeat(3,minmax(0,1fr));margin:30px auto 0}
.detail-card{padding:27px 20px}
.detail-icon{margin-bottom:15px}
.detail-card h3{font-size:24px}
main>.countdown-section{height:auto;min-height:var(--chapter-height);align-items:start;padding:clamp(24px,8svh,78px) 20px 88px}
.countdown-content h2{font-size:clamp(39px,5.5vw,65px)}
@media(min-width:1050px){
  .photo-story .story-photo{
    width:min(100%,340px,36svh);
    height:auto;
    aspect-ratio:2 / 3;
    justify-self:center;
  }
  main>.countdown-section{
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    align-items:center;
    gap:clamp(32px,6vw,100px);
    padding:28px max(7vw,calc((100% - 1200px)/2)) 64px;
    background:radial-gradient(ellipse at 65% 40%,#34443a,#1c2c24 72%);
  }
  .countdown-section::after{display:none}
  .countdown-section .countdown-photo{
    position:relative;
    inset:auto;
    grid-area:1 / 2;
    width:min(100%,calc((var(--chapter-height) - 92px) * 2 / 3));
    aspect-ratio:2 / 3;
    background-position:center;
    border:1px solid #eadcc64f;
    box-shadow:0 18px 50px #111b1780;
  }
  .countdown-section .countdown-content{grid-area:1 / 1}
}
main>.rsvp,main>.gift-section{display:flex;flex-direction:column;align-items:center;justify-content:center}
.rsvp h2,.gift-section h2{font-size:clamp(36px,4.8vw,57px);line-height:1.17}
.gift-section h2{max-width:640px}
.gift-open-card{flex:none}
main>.closing{height:auto;min-height:var(--chapter-height);padding:40px 24px 88px;overflow:hidden}
.chapter-nav{position:fixed;z-index:30;right:max(18px,env(safe-area-inset-right));bottom:max(16px,env(safe-area-inset-bottom));display:flex;align-items:center;gap:5px;padding:5px 6px 5px 16px;background:#fffdf9f2;border:1px solid #e8d2ca;border-radius:32px;box-shadow:0 6px 28px #6a4e4020;backdrop-filter:blur(12px);transition:opacity .2s}
.chapter-location{display:flex;flex-direction:column;gap:3px;min-width:93px;padding-right:8px}
.chapter-location>span:first-child{font:7px var(--sans);letter-spacing:.12em;color:#bd8a7b}
.chapter-location>span:last-child{font:12px var(--serif);color:#737755}
.chapter-nav button{width:42px;height:42px;padding:0;border:1px solid #ead9d2;border-radius:50%;color:#986650;background:#fffaf6;font:20px var(--serif);cursor:pointer;touch-action:manipulation}
.chapter-nav button:hover:not(:disabled){background:#f8e6eb;border-color:#e6a3b3}
.chapter-nav button:disabled{opacity:.3;cursor:default}
.chapter-nav button:focus-visible{outline:2px solid #df8da5;outline-offset:3px}
body.invitation-locked .chapter-nav,body:has(dialog[open]) .chapter-nav{opacity:0;visibility:hidden;pointer-events:none}
@media(max-width:1000px){
  main>.photo-story{grid-template-columns:1fr 1fr;gap:24px 20px;padding:30px 7vw 88px}
  .story-photo-one{order:1}.story-photo-two{order:2}
  .photo-story .story-photo{height:clamp(190px,35svh,340px);background-position:center 32%}
  .story-note{order:3;grid-column:1/-1;max-width:620px;width:100%;justify-self:center}
  .story-note h2{font-size:clamp(29px,4vw,39px)}
  .story-note h2 br{display:none}
  .story-note>p:not(.eyebrow){margin:12px 0 0}
  .handwritten{margin-top:15px}
}
@media(max-width:760px){
  :root{--chapter-header:62px}
  main>.section{padding:26px 24px 88px}
  main>.hero{padding:28px 26px 88px}
  .hero-copy{width:calc(100% - 10px);padding:28px 18px}
  .hero h1{font-size:clamp(50px,13vw,77px)}
  .hero .eyebrow{font-size:7px;line-height:1.6}
  .hero-image,.hero-shade{inset:5% 6% 8%}
  .hero-stamp{top:22px;right:6%}
  .hero-caption{font-size:6px;bottom:66px;padding:0 18px}
  main>.photo-story{padding:28px 24px 88px;gap:22px 14px}
  .photo-story .story-photo{height:clamp(155px,30svh,280px);border-width:3px}
  .story-note h2{font-size:clamp(27px,7.1vw,38px)}
  .story-note .eyebrow{font-size:8px;margin-bottom:12px}
  .story-note>p:not(.eyebrow){font-size:11px;line-height:1.75}
  .handwritten{font-size:13px;line-height:1.5}
  .photo-story:before{font-size:24px;top:7px}.photo-story:after{font-size:24px;bottom:65px}
  .gallery-edition{font-size:6px;margin-bottom:14px}
  .gallery-heading{display:block;margin-bottom:18px}
  .gallery-heading h2{font-size:clamp(29px,8.2vw,42px)}
  .gallery-heading .eyebrow{font-size:7px;margin-bottom:9px}
  .gallery-heading>p{font-size:10px;line-height:1.6;max-width:430px;margin-top:11px}
  .album-book{grid-template-columns:32px minmax(0,1fr) 32px;gap:8px}
  .album-page{height:clamp(220px,37svh,350px);padding:27px 12px 49px}
  .album-caption{font-size:12px;left:12px;right:12px;bottom:12px}
  .album-page-number{font-size:6px;top:10px;right:12px}
  .album-arrow{width:30px;height:30px;font-size:18px}
  .album-controls{font-size:7px;margin-top:13px}
  .album-instruction{font-size:5.5px;letter-spacing:0}
  .details-grid{max-width:500px;grid-template-columns:1fr;margin-top:22px}
  .detail-card{padding:20px 17px}
  .detail-card h3{font-size:21px;margin-bottom:9px}
  .detail-icon{margin-bottom:9px;font-size:12px}
  .detail-card .eyebrow{margin-bottom:9px;font-size:8px}
  .detail-card p:not(.eyebrow){font-size:10px;margin-bottom:12px}
  .detail-card a{font-size:9px}
  .details h2{margin-bottom:15px}
  .countdown-content h2{font-size:clamp(40px,11vw,57px)}
  .rsvp h2,.gift-section h2{font-size:clamp(33px,8.5vw,45px)}
  .gift-copy{font-size:11px;line-height:1.8}
  .chapter-nav{right:12px;bottom:max(12px,env(safe-area-inset-bottom));padding-left:13px}
  .chapter-location{min-width:82px}
}
@media(max-width:600px){
  .details-grid{grid-template-columns:1fr}
  .detail-card+.detail-card{border-left:0;border-top:1px solid #edb9c5}
  .detail-card{display:grid;grid-template-columns:auto 1fr;gap:7px 12px;align-items:center;text-align:left;padding:12px 16px}
  .detail-card .detail-icon,.detail-card .eyebrow{margin:0}
  .detail-card h3,.detail-card p:not(.eyebrow),.detail-card a{grid-column:1/-1;margin:0}
  .detail-card h3{font-size:19px}
  .detail-card p:not(.eyebrow){line-height:1.6}
  .detail-card a{justify-self:start}
}
@media(max-height:680px){
  main>.section{padding-top:22px;padding-bottom:78px}
  .hero-copy{padding-top:20px;padding-bottom:20px}
  main>.photo-story{padding-top:23px;padding-bottom:78px;gap:17px 12px}
  .photo-story .story-photo{height:clamp(145px,28svh,235px)}
  .story-note h2{font-size:clamp(26px,4vw,34px)}
  .story-note .eyebrow{margin-bottom:9px}
  .handwritten{margin-top:10px}
  .gallery-heading>p{display:none}
  .gallery-heading{margin-bottom:15px}
  .gallery-heading h2{font-size:31px}
  .gallery-edition{margin-bottom:11px}
  .album-page{height:clamp(205px,38svh,300px)}
  .detail-card{padding:14px 17px}
  .details-grid{margin-top:18px}
  .details>.eyebrow{margin-bottom:10px}
  .details h2{font-size:34px;margin-bottom:10px}
}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}.chapter-nav{transition:none}}
@media(max-width:600px) and (max-height:680px){.details h2{font-size:28px}.detail-card{padding:10px 15px}}

/* Photo-first album: a compact heading, full-width image stage, controls below. */
#gallery{--album-height:clamp(170px,calc(var(--chapter-height) - 236px),700px);padding:20px max(24px,calc((100% - 1080px)/2)) 78px;justify-content:center}
#gallery .gallery-heading{display:block;margin:0 0 12px;flex:none}
#gallery .gallery-heading .eyebrow{font-size:8px;line-height:1.4;margin:0 0 6px;letter-spacing:.11em}
#gallery .gallery-heading h2{font-size:32px;line-height:1.08;margin:0;max-width:none}
#gallery .album-book{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,3.4fr) minmax(0,1fr);
  align-items:center;
  gap:clamp(5px,1.8vw,22px);
  width:100%;
  max-width:1000px;
  height:var(--album-height);
  flex:none;
  padding:0;
  touch-action:pan-y pinch-zoom;
}
#gallery .album-page{
  display:grid;
  place-items:center;
  width:100%;
  max-width:none;
  height:100%;
  padding:0;
  border:0;
  background:none;
  box-shadow:none;
  overflow:visible;
  transform-style:flat;
}
#gallery .album-page::before{display:none}
.album-enlarge,.album-side{display:grid;place-items:center;appearance:none;padding:0;border:0;background:none;cursor:pointer;min-width:0}
.album-enlarge{max-width:100%;cursor:zoom-in}
#gallery .album-photo{
  display:block;
  width:auto;
  height:auto;
  min-height:0;
  max-width:100%;
  max-height:var(--album-height);
  object-fit:contain;
  border:clamp(4px,.65vw,9px) solid #fffdf9;
  background:#fffdf9;
  box-shadow:0 12px 32px #45291e30;
}
.album-side img{
  display:block;
  width:100%;
  height:min(calc(var(--album-height) * .65), 320px);
  object-fit:cover;
  border:clamp(3px,.5vw,7px) solid #fffdf9;
  opacity:.6;
  filter:blur(1px) saturate(.7);
  box-shadow:0 8px 18px #45291e23;
}
.album-side-prev img{transform:rotate(-4deg)}
.album-side-next img{transform:rotate(4deg)}
.album-side:focus-visible,.album-enlarge:focus-visible{outline:2px solid #a76778;outline-offset:4px}
@media (hover:hover){
  .album-side:hover img{filter:none;opacity:.9}
}
#gallery .album-controls{width:min(100%,420px);max-width:none;display:grid;grid-template-columns:42px 78px 42px;grid-template-rows:42px 2px 9px;justify-content:center;align-items:center;gap:5px 12px;margin:10px auto 0;flex:none}
#gallery .album-arrow{width:42px;height:42px;font-size:22px;grid-row:1}
/* Some iOS versions still zoom on repeated taps with touch-action: manipulation. */
#gallery .album-arrow,#gallery .album-side,.lightbox-nav{touch-action:none}
#gallery .album-prev{grid-column:1}
#gallery .album-next{grid-column:3}
#gallery .album-count{grid-column:2;grid-row:1;font-size:9px;text-align:center}
#gallery .album-progress{grid-column:1/-1;grid-row:2;width:100%;height:2px;display:block}
#gallery .album-instruction{grid-column:1/-1;grid-row:3;text-align:center;font-size:6px;letter-spacing:.03em;white-space:nowrap}
@media(max-width:760px){#gallery{--album-height:clamp(170px,min(105vw,calc(var(--chapter-height) - 236px)),490px);padding-inline:16px}#gallery .gallery-heading h2{font-size:27px}#gallery .gallery-heading .eyebrow{font-size:7px}#gallery .album-book{grid-template-columns:minmax(0,1fr) minmax(0,5fr) minmax(0,1fr)}.album-side img{height:min(calc(var(--album-height) * .54), 170px)}}


/* Nha Trang postcards surround the invitation on the first chapter. */
#home .hero-image{
  inset:0;
  clip-path:none;
  background:none;
  opacity:1;
  filter:none;
  animation:none;
  transform:none;
  overflow:hidden;
}
.hero-frame{
  position:absolute;
  background-size:cover;
  background-repeat:no-repeat;
}
.hero-frame-main{
  inset:0;
  background-image:url('assets/photos/nha-trang-trl09551.webp');
  background-position:center 28%;
}
#home .hero-shade{
  inset:0;
  clip-path:none;
  background:linear-gradient(180deg,#fdf7f0b3 0%,#fdf7f000 31%,#26151d00 67%,#26151da6 100%);
}
.hero-postcard{
  z-index:1;
  width:min(clamp(92px,13.5vw,184px),21svh);
  aspect-ratio:3 / 4;
  border:clamp(4px,.52vw,7px) solid #fff8ee;
  border-bottom-width:clamp(8px,1.15vw,15px);
  background-position:center 66%;
  box-shadow:0 10px 24px #26151d3d;
}
.hero-postcard-left{
  top:24%;
  left:9%;
  transform:rotate(-9deg);
  background-image:url('assets/photos/nha-trang-trl00239.webp');
}
.hero-postcard-right{
  top:25%;
  right:9%;
  transform:rotate(8deg);
  background-image:url('assets/photos/nha-trang-trl09443.webp');
}
.hero-postcard-extra{
  bottom:15%;
  width:min(clamp(76px,11vw,158px),18svh);
}
.hero-postcard-extra::after{
  content:'';
  position:absolute;
  width:42%;
  height:12px;
  top:-8px;
  left:29%;
  background:#f4ddd1ce;
}
.hero-postcard-lower-left{
  left:5%;
  transform:rotate(7deg);
  background-image:url('assets/photos/nha-trang-trl09587.webp');
}
.hero-postcard-lower-right{
  right:5%;
  bottom:13%;
  transform:rotate(-7deg);
  background-image:url('assets/photos/nha-trang-trl09702.webp');
  background-position:56% 52%;
}
#home .hero-copy{
  position:absolute;
  top:clamp(20px,5svh,54px);
  width:100%;
  max-width:none;
  padding:0 58px;
  background:none;
  border:0;
  box-shadow:none;
  color:#243747;
  animation:none;
}
#home .hero-copy .eyebrow{
  margin:0 0 8px;
  color:#7a314b;
  text-shadow:0 1px 4px #fff9;
}
#home .hero-copy h1{font-size:clamp(38px,min(8vw,11svh),88px);line-height:1.08;white-space:nowrap;text-shadow:0 2px 12px #fff8}
.hero-name,.hero-heart{display:inline-block}
.hero-heart{
  width:.59em;
  height:.59em;
  vertical-align:-.03em;
  color:#a74261;
  fill:none;
  stroke:currentColor;
  stroke-width:2.6;
  stroke-linecap:round;
  stroke-linejoin:round;
  transform-origin:center;
}
@media(prefers-reduced-motion:no-preference){
  .invitation-scene[data-phase='leaving'] ~ main .hero-name{
    animation:heroNameArrive .72s cubic-bezier(.22,.78,.24,1) .3s both;
  }
  .invitation-scene[data-phase='leaving'] ~ main .hero-name:last-child{animation-delay:.55s}
  .invitation-scene[data-phase='leaving'] ~ main .hero-heart path{
    stroke-dasharray:1;
    animation:heroHeartDraw .65s ease-out .75s both;
  }
  .invitation-scene[data-phase='leaving'] ~ main .hero-heart{
    animation:heroHeartBeat 1.15s ease-in-out 1.5s 2;
  }
  body:not(.invitation-locked):has(.chapter-nav[data-aligned='home']) .hero-stamp-heart{
    animation:stampHeartbeat 2.4s ease-in-out .9s infinite;
  }
}
@keyframes heroNameArrive{
  from{opacity:0;transform:translateY(10px)}
  to{opacity:1;transform:translateY(0)}
}
@keyframes heroHeartDraw{
  from{stroke-dashoffset:1;opacity:0}
  15%{opacity:1}
  to{stroke-dashoffset:0;opacity:1}
}
@keyframes heroHeartBeat{
  0%,35%,65%,100%{transform:scale(1)}
  22%{transform:scale(1.15)}
  48%{transform:scale(1.08)}
}
@keyframes stampHeartbeat{
  0%,28%,51%,100%{transform:scale(1);fill:transparent}
  14%{transform:scale(1.48);fill:currentColor}
  38%{transform:scale(1.26);fill:currentColor}
}
.hero-next{
  position:absolute;
  left:50%;
  bottom:94px;
  translate:-50% 0;
  border-color:#fff9;
  color:#fff;
  background:#392a3c6e;
}
.hero-next:hover,.hero-next:focus-visible{background:#fff;color:#73384e}
#home .hero-caption{color:#fff;text-shadow:0 1px 4px #281421}
#home .hero-stamp{
  grid-template-rows:repeat(3,1.2em);
  place-items:center;
  place-content:center;
  color:#a74261;
  transform:none;
  animation:none;
}
#home .hero-stamp span{font:inherit;color:inherit}
.hero-stamp-heart{
  width:1.15em;
  height:1.15em;
  color:#972c52;
  fill:transparent;
  stroke:currentColor;
  stroke-width:3;
  stroke-linejoin:round;
  transform-origin:center;
}
@media(max-width:760px){
  #home .hero-copy{padding-inline:40px}
  #home .hero-stamp{top:12px;right:12px;width:36px;height:36px;font-size:8px}
  .hero-frame-main{background-image:url('assets/photos/nha-trang-trl09222.webp');background-position:50% 60%}
  .hero-postcard{top:auto;bottom:14%;width:min(23%,115px)}
  .hero-postcard-left{left:5%}
  .hero-postcard-right{right:5%;bottom:16%}
  .hero-postcard-extra{display:none}
}

.rsvp-button{border:0;font-family:inherit;cursor:pointer}
.rsvp-dialog{width:min(720px,calc(100% - 24px));max-height:calc(100dvh - 24px);overflow:auto}
.rsvp-dialog h2{padding-inline:24px}
.rsvp-form-preview{text-align:left;max-width:370px;margin:20px auto;line-height:1.65;color:var(--muted)}
.rsvp-form-preview ul{padding-left:22px}
.rsvp-frame{width:100%;height:min(66dvh,740px);border:0;border-radius:8px;margin:14px 0 8px}
.rsvp-external{display:inline-block;text-decoration:underline}
.rsvp-external[hidden]{display:none}

.gift-qr-download{
  display:grid;
  justify-items:center;
  gap:8px;
  width:min(216px,100%);
  margin:12px auto 0;
  color:#833c50;
  font-size:12px;
  text-decoration:underline;
}
.gift-qr-paper{
  display:block;
  width:100%;
  padding:14px;
  background:#fff;
}
.gift-qr-crop{
  display:block;
  position:relative;
  aspect-ratio:1;
  overflow:hidden;
}
.gift-qr-crop img{
  position:absolute;
  width:170.707%;
  max-width:none;
  left:-35.354%;
  top:-46.465%;
  display:block;
}
.gift-qr-download:focus-visible{outline:2px solid #833c50;outline-offset:4px}

/* A fixed viewing area keeps the controls in place as photo ratios change. */
.lightbox[open]{
  box-sizing:border-box;
  width:min(94vw,1200px);
  height:min(85dvh,920px);
  max-width:none;
  max-height:none;
  padding:24px 62px 38px;
  overflow:hidden;
  overscroll-behavior:contain;
}
.lightbox[open] figure{width:100%;height:100%}
.lightbox[open] figure img{
  width:100%;
  height:100%;
  max-width:none;
  max-height:none;
  object-fit:contain;
}
.lightbox[open] .lightbox-close{z-index:1;top:10px;right:10px;width:44px;height:44px}
.lightbox[open] .lightbox-nav{top:50%;bottom:auto;width:44px;height:44px;transform:translateY(-50%)}
.lightbox[open] .lightbox-prev{left:10px}
.lightbox[open] .lightbox-next{right:10px}
.lightbox-count{
  position:absolute;
  left:50%;
  bottom:12px;
  transform:translateX(-50%);
  color:#71493f;
  font:12px/1.25 var(--sans);
  white-space:nowrap;
}
.lightbox[open] button:focus-visible{outline:2px solid #a74261;outline-offset:3px}

@media(max-width:760px), (pointer:coarse) and (max-height:600px){
  .lightbox[open]{
    inset:0;
    margin:0;
    width:100dvw;
    height:100dvh;
    padding:calc(56px + env(safe-area-inset-top)) env(safe-area-inset-right) calc(68px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
    border:0;
    border-radius:0;
    background:#271f20;
  }
  .lightbox[open] .lightbox-close{top:max(8px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right))}
  .lightbox[open] .lightbox-nav{top:auto;bottom:max(12px,env(safe-area-inset-bottom));width:48px;height:48px;transform:none}
  .lightbox-count{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 16px);color:#fff8ee}
  .lightbox[open] .lightbox-prev{left:calc(50% - 90px)}
  .lightbox[open] .lightbox-next{right:calc(50% - 90px)}
}
