@font-face {
  font-family: "Poem Courier";
  src: url("assets/poem-courier.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: SUIT;
  src: url("assets/suit-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #22221f;
  --muted: #63625c;
  --olive: #51512f;
  --paper: #f7f7f5;
  --table: #e6e4dd;
  --rule: #cfcec6;
  --grain: url("assets/poem-paper.png");
  --gothic: "Apple SD Gothic Neo", SUIT, "Malgun Gothic", sans-serif;
  --courier: "Poem Courier", "Courier New", monospace;
  --gutter: clamp(18px, 6vw, 48px);
}

* { box-sizing: border-box; }

html {
  min-width: 260px;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--table);
  color: var(--ink);
  font: 400 16px/1.7 var(--gothic);
  word-break: keep-all;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, p, figure, blockquote, fieldset { margin: 0; }
h1, h2, h3, h4 { font-weight: 500; }
button, input, select { font: inherit; color: inherit; }
button, a, summary { touch-action: manipulation; }
button, summary { cursor: pointer; }
button { padding: 0; border: 0; background: transparent; }
a { color: inherit; text-underline-offset: .25em; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 4px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#invitation-content {
  width: min(100%, 510px);
  margin-inline: auto;
  outline: none;
}

/* The opening photo and envelope share a center. Its paper edges become
   the initial crop, so the photo is already there when the seal lifts. */
.opening-hero {
  --envelope-width: min(94cqw, 98cqh);
  --envelope-height: calc(var(--envelope-width) * 484 / 788);
  --side-inset: calc((100cqw - var(--envelope-width)) / 2);
  --top-inset: calc((100cqh - var(--envelope-height)) / 2);
  --opening-duration: 640ms;
  --opening-ease: cubic-bezier(.32, .04, .15, 1);
  position: relative;
  isolation: isolate;
  container-type: size;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.opening-cloth, .opening-print, .opening-inscription, .opening-photo-link {
  position: absolute;
  inset: 0;
}
.opening-cloth {
  display: none;
  background:
    radial-gradient(ellipse at -9% 8%, #858257, #676d48 29%, transparent 72%),
    linear-gradient(132deg, #525a3f, #484f35 55%, #3b412d);
}
.corduroy, .opening-photo {
  display: block;
  width: 100%;
  height: 100%;
}
.opening-print { overflow: hidden; background: #e6e1d6; }
.opening-photo {
  object-fit: cover;
  object-position: 50% 25%;
}
.opening-photo-link:focus-visible { outline-offset: -4px; }
.opening-inscription {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(7dvh, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
}
.opening-signature { display: block; width: clamp(170px, 63vw, 250px); }
.opening-scroll {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 44px;
  color: #fffdf7;
}
.opening-scroll svg {
  width: 17px;
  height: 11px;
  filter: drop-shadow(0 1px 1px #29261fc9);
}
.opening-envelope, .opening-trigger {
  position: absolute;
  top: var(--top-inset);
  left: var(--side-inset);
  width: var(--envelope-width);
  height: var(--envelope-height);
}
.opening-envelope {
  display: none;
  background: #f7f4ec var(--grain) repeat;
  background-blend-mode: multiply;
  box-shadow: 1px 2px 2px #1d2118a8, 3px 5px 7px #23251b59, 7px 12px 17px -8px #1c211996;
  pointer-events: none;
}
.opening-seam {
  position: absolute;
  inset: 0 0 37%;
  background: inherit;
  background-blend-mode: multiply;
  box-shadow: inset 0 1px 0 #fffb, 0 1px 2px #302f2a38, 1px 3px 5px #46412e17;
}
.opening-address {
  position: absolute;
  top: 10.71%;
  inset-inline: .5rem;
  display: grid;
  justify-items: center;
  font: 400 clamp(10px, 2.82vw, 13.2px)/1.45 var(--courier);
  letter-spacing: .055em;
}
.opening-wax {
  position: absolute;
  top: 63%;
  left: 41%;
  width: 18%;
  height: auto;
  transform: translateY(-50%);
  filter: drop-shadow(1px 2px 1px #312c2057) drop-shadow(3px 5px 3px #433c2836);
}
.opening-trigger:focus-visible, .opening-scroll:focus-visible { outline-color: #faf5e5; }
.opening-hero:has(.opening-trigger:active) .opening-wax { transform: translateY(-50%) scale(.96); }
body:is([data-letter-state="sealed"], [data-letter-state="opening"]) { overflow: hidden; }
body:is([data-letter-state="sealed"], [data-letter-state="opening"]) :is(.opening-cloth, .opening-envelope) {
  display: block;
}
body:is([data-letter-state="sealed"], [data-letter-state="opening"]) .letter-rest { display: none; }
body[data-letter-state="sealed"] .opening-print { visibility: hidden; }
body[data-letter-state="opening"] .opening-print {
  animation: unframe var(--opening-duration) var(--opening-ease) both;
}
body[data-letter-state="opening"] .opening-photo {
  animation: settle-photo var(--opening-duration) var(--opening-ease) both;
}
body[data-letter-state="opening"] .opening-envelope { animation: unseal 145ms cubic-bezier(.42, 0, .64, 1) both; }
body[data-letter-state="opening"] .opening-inscription { animation: reveal-ink 220ms 390ms ease-out both; }
@keyframes unframe {
  from { clip-path: inset(var(--top-inset) var(--side-inset)); }
  to { clip-path: inset(0); }
}
@keyframes settle-photo {
  from { transform: translateY(min(var(--top-inset), 17cqh)); }
  to { transform: translateY(0); }
}
@keyframes unseal { to { opacity: 0; } }
@keyframes reveal-ink { from { opacity: 0; } to { opacity: 1; } }

.letter-rest { background: var(--paper) var(--grain) repeat; }
.letter { text-align: center; }
.letter-message, .letter-occasion { position: relative; }
.letter-occasion { padding-inline: var(--gutter); }
.letter-occasion::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 3px;
  pointer-events: none;
  background: linear-gradient(to bottom, #34352b29, #fff9 56%, transparent);
}
.opening-hero:focus, #opening-letter:focus { outline: none; }
.opening-note {
  border-top: 1px solid #d9d5ca;
  padding: clamp(60px, 11vh, 100px) clamp(18px, 6vw, 45px) 0;
}
.invitation-message { font-size: clamp(15px, 4vw, 17px); line-height: 1.9; letter-spacing: -.026em; text-wrap: balance; }
.invitation-message p + p { margin-top: 1.25em; }
.signature-guide {
  display: grid;
  justify-items: center;
  margin-top: 32px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: -.012em;
  line-height: 1.55;
}
.signature-guide a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  color: var(--olive);
  text-decoration-color: #9d9c86;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.signature-guide a span { font-size: 12px; }

.letter-photo { display: block; }
.letter-photo img { display: block; width: 100%; height: auto; }
.invitation-print { margin: 33px 16px 0; }
.families {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 4vw, 20px);
  padding: 0 clamp(20px, 7vw, 38px);
  margin-block: 28px clamp(44px, 11vw, 58px);
}
.portrait {
  padding: 4px;
  background: #fffefa;
  box-shadow: 0 0 0 1px #39342617, 0 1px 3px #3934261c;
}
.families figure:nth-child(2) { margin-top: 18px; }
.portrait img { aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 36%; }
.families figcaption { margin-top: 13px; line-height: 1.5; }
.families strong { display: block; font-size: 16px; font-weight: 550; }
.families span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

.letter-occasion {
  padding-block: clamp(43px, 10vw, 63px) 32px;
  scroll-margin-top: 14px;
}
/* This section receives programmatic focus on a return visit. */
.letter-occasion:focus { outline: none; }
.event-date { font-size: 16px; letter-spacing: -.025em; }
.venue { margin-top: 5px; font-size: 19px; }
.address { margin-top: 5px; color: var(--muted); font-size: 14px; }
.occasion-actions, .map-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: 18px;
  margin-top: 15px;
}
.occasion-actions a, .map-actions > *, .letter-footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--olive);
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: #9d9c86;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

summary {
  position: relative;
  min-height: 48px;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  color: var(--olive);
  font: 400 18px/1 var(--courier);
}
details[open] > summary::after { content: "−"; }
.date-details { max-width: 282px; margin: 10px auto 0; }
.date-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.date-details > summary::after { font-size: 15px; }
.calendar { max-width: 270px; margin: 0 auto 10px; font-family: var(--courier); }
.calendar h3 { margin: 6px 0 13px; font: 400 16px/1.5 var(--courier); }
.calendar-week, .calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  justify-items: center;
  gap: 5px 1px;
}
.calendar-week { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.calendar-days span {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  font-size: 14px;
}
.calendar-days .wedding-day {
  border: 1px solid var(--olive);
  border-radius: 50%;
  color: var(--olive);
}
.countdown { color: var(--muted); font-size: 13px; }

.guest-info { padding: 29px var(--gutter) 20px; }
.guest-info > details { border-bottom: 1px solid var(--rule); }
.guest-info > details:first-of-type { border-top: 1px solid var(--rule); }
.guest-info summary {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 15px 1px;
  font-size: 16px;
}
.detail-body { padding: 0 0 22px; font-size: 15px; }
.detail-body p, .accounts p { color: var(--muted); }
.venue-map { margin-top: 14px; }
.venue-map img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); }
.venue-map figcaption { margin-top: 3px; text-align: right; font-size: 11px; color: var(--muted); }
.map-actions { justify-content: flex-start; margin-top: 5px; }
.travel-item { margin-top: 17px; }
.travel-item h4 { margin-bottom: 3px; font-size: 15px; font-weight: 600; }
.film-details video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: #252620; }
.primary-button {
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid #96977b;
  color: var(--olive);
  font-size: 15px;
}
.detail-body .primary-button { margin: 10px 0; }
.draft-note { color: var(--muted); font-size: 13px; }

.photo-album {
  container-type: inline-size;
  padding-block: 25px 8px;
}
.photo-album h2 {
  margin-bottom: 25px;
  text-align: center;
  font: 400 18px/1.4 var(--courier);
  letter-spacing: .12em;
}
.gallery-track {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  grid-auto-columns: max-content;
  gap: 5px;
  margin-left: 16px;
  padding-right: 16px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-track:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; }
.gallery-tile {
  display: block;
  width: min(44vw, 224px);
  width: 44cqw;
  height: min(63vw, 321px);
  height: 63cqw;
  scroll-snap-align: start;
  background-color: #edece7;
}
.gallery-wide { width: min(92vw, 469px); width: 92cqw; }
.gallery-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-tile[data-photo-id="1421"] img { object-position: 22% center; }
.gallery-tile:focus-visible { outline-offset: -3px; outline-color: var(--paper); }
.gallery-controls, .gallery-pager { display: flex; align-items: center; }
.gallery-controls {
  justify-content: space-between;
  margin: 7px 16px 0;
  color: var(--muted);
  font-size: 13px;
}
.gallery-pager { gap: 2px; }
.gallery-pager button {
  width: 44px;
  height: 44px;
  font: 22px/1 var(--gothic);
  color: var(--ink);
}
.gallery-pager button:disabled { opacity: .3; cursor: default; }
#gallery-position { min-width: 7ch; text-align: center; font: 12px/1.3 var(--courier); }

.letter-footer { padding: 32px var(--gutter) 46px; text-align: center; }
.closing-print { width: min(100%, 360px); margin: 0 auto 24px; }
.signed-closing {
  display: grid;
  gap: 5px;
  font-size: 16px;
  letter-spacing: -.035em;
  line-height: 1.7;
}
.signed-closing span:last-child { color: var(--muted); font-size: 14px; }
.letter-footer > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin-top: 16px; }
.letter-footer button { font-size: 13px; }

dialog {
  width: min(90%, 390px);
  max-height: 88dvh;
  padding: 34px 25px 25px;
  border: 1px solid var(--rule);
  background: var(--paper) var(--grain) repeat;
  color: var(--ink);
}
dialog::backdrop { background: #202019b8; }
.dialog-close {
  position: absolute;
  top: 2px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font-size: 27px;
  line-height: 1;
}
dialog h2 { margin-bottom: 8px; font-size: 21px; }
#lightbox {
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: max(48px, calc(env(safe-area-inset-top) + 44px)) 0 max(6px, env(safe-area-inset-bottom));
  border: 0;
  background: #22221f;
  color: white;
}
html:has(#lightbox[open]) { overflow: hidden; }
#lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
#lightbox .dialog-close {
  top: max(2px, env(safe-area-inset-top));
  right: max(5px, env(safe-area-inset-right));
  z-index: 1;
  color: white;
}
#large-photo {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}
.lightbox-nav { display: flex; justify-content: center; align-items: center; gap: 27px; color: white; }
.lightbox-nav button { min-width: 44px; min-height: 46px; font-size: 27px; }
.lightbox-nav span { font: 400 14px/1.5 var(--courier); }
#rsvp-form label { display: block; margin-top: 16px; font-size: 15px; }
#rsvp-form fieldset { border: 0; padding: 0; margin-top: 17px; }
#rsvp-form fieldset label { display: inline-flex; align-items: center; min-height: 44px; gap: 6px; margin: 0 14px 0 0; }
#rsvp-form :is(input:not([type="radio"]), select) {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 7px 11px;
  border: 1px solid #a9a99c;
  border-radius: 0;
  background: #fff;
  font-size: 16px;
}
input[type="radio"] { width: 17px; height: 17px; accent-color: var(--olive); }
#rsvp-form .primary-button { width: 100%; margin-top: 24px; }
#rsvp-result { margin-top: 15px; white-space: pre-line; font-size: 14px; }
#toast {
  position: fixed;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 10;
  width: max-content;
  max-width: 90%;
  padding: 9px 16px;
  transform: translate(-50%, 5px);
  pointer-events: none;
  opacity: 0;
  background: #36372e;
  color: white;
  text-align: center;
  font-size: 14px;
  transition: transform 160ms ease, opacity 160ms ease;
}
#toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (orientation: landscape) and (max-height: 500px) {
  #invitation-content { width: 100%; }
  .letter-rest { max-width: 510px; margin-inline: auto; }
  .opening-photo { object-position: 50% 26%; }
  .opening-inscription {
    padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
      max(3px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
  .opening-inscription h1 { align-self: flex-start; }
  .opening-signature { width: clamp(130px, 24vw, 185px); }
}
@media (max-width: 350px) {
  :root { --gutter: 13px; }
  .opening-note { padding-inline: 8px; }
  .families span { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0s !important;
  }
  html { scroll-behavior: auto; }
  .opening-hero:has(.opening-trigger:active) .opening-wax { transform: translateY(-50%); }
}
