/* ─────────────────────────────────────────────
   The invitation: the printed card on its own, and the full-screen viewer it opens.
   (The scroll-driven version that used to live here is kept, unused, in ../_review/unwrap-frames.)
   ───────────────────────────────────────────── */

.invitation { background: var(--ground); }
.invitation-inner { display: flex; flex-direction: column; align-items: center; text-align: center; }
.invitation .section-head { margin-bottom: clamp(34px, 5vw, 60px); }
/* The two arrangements of the heading (see index.html): one of each pair shows. */
html:not([data-heading="name"]) .invitation .head-b, html[data-heading="name"] .invitation .head-a { display: none; }

/* The small line "For … & Family": a touch tighter than other labels, and on one line whenever its length allows.
   --fit-em is its natural width in ems (set by gate.js), so the type shrinks just enough to fit a narrow screen. */
.invitation .eyebrow { text-wrap: balance; }
.invitation .eyebrow .head-a { display: block; letter-spacing: .22em; }
.invitation .eyebrow .head-a.is-oneline {
  white-space: nowrap;
  font-size: max(8.5px, min(1em, calc((100vw - 2 * var(--pad)) / var(--fit-em, 1))));
}

/* The heading as "For … & Family": the name in script, a little smaller than a one-word title so it fits. */
.title .head-b .title-script { font-size: clamp(2.5rem, 1.5rem + 4.4vw, 4.75rem); color: var(--brass); }   /* the name itself in gold */
.title .head-b .title-serif { font-size: clamp(1.3rem, 1rem + 1.6vw, 2.4rem); }
@media (min-width: 761px) { .title .head-b .title-script { white-space: nowrap; } }   /* wide screens: the name is never split */
@media (max-width: 760px) {
  /* narrow screens: three lines, as on the opening card */
  .title .head-b > span { display: block; }
  .title .head-b .title-serif { vertical-align: 0; }
  .title .head-b .title-script { text-wrap: balance; margin-block: .06em; }
}
.invitation .title-script { color: var(--fg); }

.invitation-card {
  display: block; width: min(440px, 100%); padding: 0; border: 0; border-radius: 0; background: none; cursor: zoom-in;
  /* the card is white on a cream page: a hairline and a soft shadow hold its edge */
  box-shadow: 0 0 0 1px var(--line), 0 34px 64px -34px rgba(0, 0, 0, .55);
}
.invitation-card img { display: block; width: 100%; height: auto; }
.invitation-read { margin-top: clamp(26px, 4vw, 38px); }
/* short screens (small phones, or phones with their browser bars showing): tuck the arrow closer and make it a little smaller */
@media (max-height: 700px) {
  .invitation-read { margin-top: 10px; }
  .invitation-read .scroll-hint { width: 42px; height: 42px; }
}

.invitation .countdown { margin-top: clamp(22px, 3.4vh, 40px); }

/* When the invitation is the top of the page (no names card above it): it fills the first screen, with a little light
   at the top, clears the navigation, and the card is never taller than the screen has room for, so it shows whole. */
html:not([data-top="names"]) .invitation {
  min-height: min(100vh, 1080px); min-height: min(100svh, 1080px);
  padding-block: clamp(88px, 12vh, 128px) clamp(40px, 7vh, 88px);
  display: flex; flex-direction: column; justify-content: center;
  background: radial-gradient(120% 70% at 50% 0%, var(--ground-lift) 0%, rgba(86, 32, 44, 0) 70%), var(--ground);
}
html:not([data-top="names"]) .invitation .section-head { margin-bottom: clamp(24px, 4vh, 48px); }
/* --room is everything on the first screen that is not the card: navigation, heading, the scroll arrow beneath, the margins. */
html:not([data-top="names"]) .invitation-card { --room: 434px; width: min(440px, 100%, max(190px, calc((100vh - var(--room)) * .705))); }
html[data-countdown="on"]:not([data-top="names"]) .invitation-card { --room: 524px; }     /* leave room for the countdown beneath */
@media (max-width: 620px) {
  html:not([data-top="names"]) .invitation-card { --room: 384px; }
  html[data-countdown="on"]:not([data-top="names"]) .invitation-card { --room: 469px; }
}
/* the heading as "For … & Family" is taller (a long name runs to a second line), so it needs more */
html[data-heading="name"]:not([data-top="names"]) .invitation.has-guest .invitation-card { --room: 480px; }
html[data-heading="name"][data-countdown="on"]:not([data-top="names"]) .invitation.has-guest .invitation-card { --room: 570px; }
@media (max-width: 760px) {
  html[data-heading="name"]:not([data-top="names"]) .invitation.has-guest .invitation-card { --room: 490px; }
  html[data-heading="name"][data-countdown="on"]:not([data-top="names"]) .invitation.has-guest .invitation-card { --room: 575px; }
}
@supports (height: 100svh) {
  html:not([data-top="names"]) .invitation-card { width: min(440px, 100%, max(190px, calc((100svh - var(--room)) * .705))); }
}

/* ── the card, enlarged ── */
.viewer {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1500;
  background: var(--ground);
  opacity: 0; transition: opacity .35s ease;
}
.viewer[hidden] { display: none; }
.viewer.is-open { opacity: 1; }
.viewer-scroll { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.viewer-inner { min-width: 100%; min-height: 100%; width: -webkit-max-content; width: max-content; display: flex; align-items: center; justify-content: center; padding: 64px 16px 24px; }
.viewer-img { display: block; width: min(calc(100vw - 32px), calc((100vh - 96px) * .705)); height: auto; cursor: zoom-in; box-shadow: 0 0 0 1px var(--line), 0 34px 64px -30px rgba(0, 0, 0, .6); }
.viewer.is-zoomed .viewer-img { width: max(200vw, 900px); max-width: none; cursor: zoom-out; }
.viewer-close {
  position: absolute; z-index: 2; top: max(14px, env(safe-area-inset-top)); right: 14px;
  min-height: 44px; padding: 0 18px 0 calc(18px + .3em);
  color: var(--fg); background: rgba(68, 20, 31, .88); cursor: pointer;
  border: 1px solid var(--brass); border-radius: 0;
}
.viewer-hint { position: absolute; z-index: 2; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); text-align: center; color: var(--ink-soft); font-style: italic; font-size: .92em; pointer-events: none; }
.viewer.is-zoomed .viewer-hint { display: none; }

/* very short screens (an iPhone SE in Safari, small Androids with their bars showing): let the card get smaller still, so the
   arrow beneath it stays on the first screen */
@media (max-height: 620px) {
  html:not([data-top="names"]) .invitation-card { width: min(440px, 100%, max(130px, calc((100svh - var(--room)) * .705))); }
}
