/* Layout and components. Colours and fonts come from theme.css only. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

h1,
h2 {
  font-family: var(--font-script);
  font-weight: 400;
}

legend {
  font-family: var(--font-label);
  font-weight: 500;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 2.4rem;
  line-height: 1.2;
}

p {
  margin: 0;
}

a {
  color: var(--color-accent);
}

.muted {
  color: var(--color-text-muted);
}

/* ---------- Preview banner ---------- */

.preview-banner {
  padding: 0.6rem 1rem;
  background: var(--color-accent-soft);
  font-size: 0.95rem;
  text-align: center;
}

/* ---------- Top menu ---------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem 0.5rem;
  border-bottom: 1px solid var(--color-header-rule);
  background: var(--color-header);
  color: var(--color-header-ink);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.9rem;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0 0;
  border-top: 1px solid var(--color-header-rule);
  list-style: none;
}

.site-nav ul a {
  display: inline-block;
  padding: 0.35rem 0;
  color: inherit;
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-decoration: none;
  text-transform: uppercase;
}

.site-nav :focus-visible {
  outline-color: var(--color-header-ink);
}

/* Logo: the image (config.js) is a mask filled with the current text colour,
   so one file works on light and dark backgrounds. The box is 4:3 to fit the
   script monogram. Without an image, the initials show as text instead. */
.logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 9rem;
  aspect-ratio: 4 / 3;
  color: inherit;
  text-decoration: none;
}

.logo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  -webkit-mask: var(--logo-image, none) center / contain no-repeat;
  mask: var(--logo-image, none) center / contain no-repeat;
}

.logo-initials {
  position: relative;
  font-family: var(--font-script);
  font-size: 1.75rem;
  line-height: 1;
  white-space: nowrap;
}

.logo-small {
  width: 4rem;
}

.logo-small .logo-initials {
  font-size: 0.85rem;
}

/* ---------- Hero: photo, script names, invitation line ---------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 0 0 3rem;
  scroll-margin-top: 6rem;
  text-align: center;
}

/* Full width on phones; framed and centred from tablet up. */
.hero-photo {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 80vh;
  overflow: hidden;
  background: var(--intro-placeholder);
  color: var(--intro-ink);
}

.hero-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-placeholder {
  font-size: 0.95rem;
  opacity: 0.8;
}

/* Welcome message (#86): a letter-spaced caps title, a short Sage rule,
   then the paragraphs in the body font. */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  max-width: 30rem;
  margin-top: 0.75rem;
  padding: 0 16px;
}

.welcome-title {
  margin: 0;
  font-family: var(--font-label);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-wrap: balance; /* "We're so glad / you're here", not a lone "here" */
}

.welcome-title::after {
  content: '';
  display: block;
  width: 3rem;
  margin: 1.1rem auto 0;
  border-top: 1px solid var(--color-border);
}

/* The intro moves focus here for screen readers (js/app.js). It's not a
   control, so no focus ring. */
.welcome-title:focus {
  outline: none;
}

.welcome-text {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.eyebrow {
  font-family: var(--font-label);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.names {
  margin: 0;
  font-family: var(--font-script);
  font-size: clamp(2.6rem, 12vw, 4.25rem);
  font-weight: 400;
  line-height: 1.15;
}

.names.small {
  font-size: 2.6rem; /* same as the section headings */
}

/* ---------- Details card: date, venue, countdown, RSVP ---------- */

.invite-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 4.5rem 2rem;
  background: var(--color-card);
  box-shadow: inset 0 0 0 10px var(--color-card), inset 0 0 0 11px var(--color-border);
}

/* Corner ornaments: one image, mirrored into each corner. */
.invite-card::before,
.invite-card::after,
.card-corners::before,
.card-corners::after {
  content: '';
  position: absolute;
  width: 84px;
  height: 84px;
  background: var(--frame-corner) center / contain no-repeat;
  pointer-events: none;
}

.invite-card::before {
  top: 4px;
  left: 4px;
}

.invite-card::after {
  top: 4px;
  right: 4px;
  transform: scaleX(-1);
}

.card-corners::before {
  bottom: 4px;
  left: 4px;
  transform: scaleY(-1);
}

.card-corners::after {
  right: 4px;
  bottom: 4px;
  transform: scale(-1);
}

.invite-when,
.invite-where {
  display: flex;
  flex-direction: column;
  font-family: var(--font-label);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.invite-when strong,
.invite-where strong {
  font-size: 1.1rem;
  font-weight: 600;
}

.invite-closing {
  font-family: var(--font-script);
  font-size: 1.6rem;
}

/* The schedule's date line; the venue name matches it. */
.date,
.venue-name {
  font-family: var(--font-label);
  font-size: 1.2rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ---------- Sections ---------- */

/* The bands' full-width rules reach 100vmax past each side. main spans the
   screen, so clipping here cuts them at the screen edges; otherwise Chrome on
   Android widens the page to fit them and zooms everything out (iOS Safari
   ignores the overflow). clip, unlike hidden, leaves scrolling untouched. */
main {
  overflow-x: clip;
}

main > section {
  max-width: 560px;
  margin: 0 auto;
  padding: 3rem 1rem;
  scroll-margin-top: 5.5rem; /* clear the sticky menu */
  text-align: center;
}

main > section > h2 {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 2.6rem;
}

/* Full-width band, coloured per section (band-* classes, theme.css). The shadow paints the colour out to the screen
   edges while the content keeps the section's width. */
main > section.band {
  background: var(--color-band);
  box-shadow: 0 0 0 100vmax var(--color-band);
  clip-path: inset(0 -100vmax);
  position: relative;
  color: var(--color-band-ink);
}

/* Sage rules across the full width at the top and bottom of each band. The
   band and the page differ only in hue, so the rules mark the edge. */
main > section.band::before,
main > section.band::after {
  content: '';
  position: absolute;
  left: -100vmax;
  right: -100vmax;
  height: 1px;
  background: var(--color-band-rule);
}

main > section.band::before {
  top: 0;
}

main > section.band::after {
  bottom: 0;
}

.band-champagne {
  --color-band: var(--color-band-champagne);
}

.band-elise {
  --color-band: var(--color-band-elise);
}

.band > h2 {
  border-color: var(--color-band-rule);
}

.band .muted {
  color: var(--color-band-muted);
}

/* ---------- Timeline ---------- */

/* One centre line; events alternate right, left, right... */
.timeline {
  position: relative;
  display: grid;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: 50%;
  width: 1px;
  background: var(--color-text);
}

.timeline li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 50%;
  margin-left: 50%;
  padding: 0 0 2rem 1.25rem;
}

.timeline li:nth-child(even) {
  margin-left: 0;
  padding: 0 1.25rem 2rem 0;
}

.timeline li:last-child {
  padding-bottom: 0.5rem;
}

/* Interleave the two columns: each step starts partway down the previous one. */
.timeline li + li {
  margin-top: -3rem;
}

/* A guest who sees one event gets it centred, without the line. */
.timeline:has(li:only-child)::before,
.timeline li:only-child::before {
  display: none;
}

.timeline li:only-child {
  width: auto;
  margin-left: 0;
  padding: 0;
}

/* Dot on the line, level with the time. */
.timeline li::before {
  content: '';
  position: absolute;
  top: 0.4rem;
  left: -4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-text);
}

.timeline li:nth-child(even)::before {
  right: -5px;
  left: auto;
}

.timeline-icon {
  order: -1;
  width: 56px;
  height: 56px;
  margin-bottom: 0.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* With an icon, the dot sits beside the icon instead. */
.timeline li:has(.timeline-icon)::before {
  top: 1.6rem;
}

.timeline .time {
  font-family: var(--font-label);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
}

.timeline .title {
  font-family: var(--font-label);
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.timeline .venue {
  font-size: 0.95rem;
  line-height: 1.4;
}

.timeline .note {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

address {
  margin: 0.5rem 0 1.25rem;
  color: var(--color-text-muted);
  font-style: normal;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-block;
  min-height: 44px;
  padding: 0.6rem 1.5rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font: inherit;
  font-family: var(--font-label);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

/* Primary hover: a lighter Tea Leaves. */
.button:hover {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-hover);
}

/* Secondary / outlined (Google Maps, Change my response): Ivory with a Tea
   Leaves edge, so the filled RSVP button stays the strongest action.
   Hover fills it. */
.button-outline {
  background: var(--color-bg);
  color: var(--color-accent);
}

.button-outline:hover {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.link {
  align-self: center;
  padding: 0.25rem;
  border: 0;
  background: none;
  color: var(--color-accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- RSVP ---------- */

.card {
  position: relative;
  margin-top: 1.5rem;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  text-align: left;
}

/* On a band: double outline around the card, like a mat in a frame. */
.band .card {
  margin: 2rem 0.9rem 0.9rem;
  border: 0;
  box-shadow:
    0 0 0 7px var(--color-band),
    0 0 0 8px var(--color-band-rule),
    0 0 0 12px var(--color-band),
    0 0 0 13px var(--color-band-rule);
  color: var(--color-text);
}

/* Elise card on the Champagne RSVP band, so the form stands out. */
#rsvp-root {
  background: var(--color-rsvp-card);
}

.band .card .muted {
  color: var(--color-text-muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

fieldset {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

legend {
  padding: 0 0.4rem;
  font-size: 1.05rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.event-meta {
  color: var(--color-text-muted);
  font-size: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field > span,
.field > label {
  font-size: 1rem;
}

input:not([type]),
input[type='text'],
input[type='email'],
input[type='password'],
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-field-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 1rem; /* >= 16px stops iOS zooming on focus */
}

::placeholder {
  color: var(--color-placeholder);
  opacity: 1; /* Firefox dims placeholders by default */
}

/* Access code with a show/hide toggle inside the right edge. */
.password-field {
  position: relative;
}

.password-field input {
  padding-right: 3rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

.password-toggle .icon-hide,
.password-toggle[aria-pressed='true'] .icon-show {
  display: none;
}

.password-toggle[aria-pressed='true'] .icon-hide {
  display: block;
}

/* One row per matching invitation: name on the left, seats on the right. */
.choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
}

.choice small {
  flex: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stepper button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
  background: transparent;
  color: var(--color-accent);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.stepper button:disabled {
  border-color: var(--color-border);
  color: var(--color-border);
  cursor: default;
}

.stepper output {
  min-width: 2ch;
  font-size: 1.4rem;
  text-align: center;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 32px;
  cursor: pointer;
}

.check input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--color-accent);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.25rem 1rem;
}

/* ---------- RSVP steps ---------- */

/* Clear the sticky menu when a new step scrolls the card back into view. */
#rsvp-root {
  scroll-margin-top: 5.5rem;
}

.steps-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.back-link {
  align-self: auto;
  min-height: 44px;
}

/* Centred in the card whether or not the Back link shows. */
.steps-top {
  position: relative;
}

.progress-dots {
  position: absolute;
  left: 50%;
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  transform: translateX(-50%);
}

.progress-dots li {
  width: 0.55rem;
  height: 0.55rem;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
}

.progress-dots li.done {
  background: var(--color-border); /* Sage: Elise would vanish on the Elise card */
}

.progress-dots li.current {
  background: var(--color-accent);
}

.step-title {
  margin: 0; /* font: the script h3 style */
}

.step-title:focus {
  outline: none;
}

.answer-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.answer {
  min-height: 56px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-accent);
  font: inherit; /* body size, like the rest of the form */
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.answer:hover,
.answer[aria-pressed='true'] {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

.diet-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.diet-count {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.diet-count .stepper {
  gap: 0.6rem;
}

.field-hint {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.greeting {
  font-family: var(--font-script);
  font-size: 1.9rem;
  line-height: 1.3;
}

.error {
  color: var(--color-error);
}

.summary {
  margin: 0;
  padding-left: 1.2rem;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-surface) 85%, transparent);
}

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--color-accent-soft);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* ---------- Footer ---------- */

/* Photo above the footer (config.js footerImage): whole on phones, a
   cropped banner on wider screens, centred a little above the middle so
   faces stay in frame. */
.footer-photo {
  display: block;
  width: 100%;
  height: auto;
}

@media (min-width: 768px) {
  .footer-photo {
    height: 440px;
    object-fit: cover;
    object-position: 50% 45%;
  }
}

footer {
  padding: 2rem 1rem 3rem;
  background: var(--color-footer);
  color: var(--color-footer-ink);
  text-align: center;
}

.signoff {
  margin: 0.5rem 0 0;
  font-family: var(--font-body);
}

/* ---------- Tablet and desktop ---------- */

@media (min-width: 768px) {
  body {
    font-size: 1.2rem;
  }

  .hero {
    padding: 3rem 2rem 4rem;
  }

  .hero-photo {
    width: min(100%, 520px);
    border-radius: var(--radius);
  }

  .site-nav {
    flex-direction: row;
    justify-content: center;
    gap: 2rem;
    padding: 0.6rem 2rem;
  }

  .site-nav ul {
    width: auto;
    gap: 0 2rem;
    padding: 0;
    border: 0;
  }

  .site-nav ul a {
    font-size: 0.85rem;
  }

  main > section {
    max-width: 640px;
    padding: 4rem 2rem;
  }

  .timeline li {
    padding-left: 2rem;
  }

  .timeline li:nth-child(even) {
    padding-right: 2rem;
  }

  .card {
    padding: 2rem;
  }
}

/* Wide screens: photo on the left, the welcome message on the right. */
@media (min-width: 960px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(0, 440px);
    align-items: center;
    justify-content: center;
    column-gap: 4rem;
  }

  .hero-photo {
    width: 100%;
  }

  .welcome {
    margin: 0;
    padding: 0;
  }
}

/* ---------- Calendar links, directions, FAQ ---------- */

.calendar-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.calendar-links a {
  padding: 0.25rem 0;
}

.directions {
  display: grid;
  gap: 2rem;
  margin-top: 2.5rem;
  text-wrap: pretty;
}

/* Text under a sub-heading (FAQ answers, directions) is a step smaller than
   the heading: 16.8px under 18px on phones, about 18px under 19.2px on
   desktop. */
.directions p {
  font-size: var(--answer-size);
}

/* Serif headings (#87), like the FAQ questions: letter-spaced caps, then
   the train / bus sub-headings in body-font italics. */
.directions-title {
  margin-bottom: 0.5rem;
  font-family: var(--font-label);
  font-size: 1em;
  font-weight: 500;
  letter-spacing: 0.15em;
  line-height: 1.4;
  text-transform: uppercase;
}

.directions-subtitle {
  margin: 1rem 0 0.25rem;
  font-family: var(--font-body);
  font-size: 1em;
  font-style: italic;
  font-weight: 400;
}

.directions-title + .directions-subtitle {
  margin-top: 0;
}

/* Sentosa entry: set apart by Sage rules above and below. */
.directions-note {
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  font-style: italic;
}

h3 {
  margin: 0 0 0.25rem;
  font-family: var(--font-script);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1.3;
}

.faq {
  display: grid;
  gap: 2rem;
  margin-top: 2rem;
}

/* Sub-headings (FAQ questions, Venue directions) are the same size as the
   body text under them (1em), set apart by capitals and spacing. */
.faq h3 {
  margin-bottom: 0.5rem;
  font-family: var(--font-label);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 1em;
  line-height: 1.4;
}

.faq p {
  color: var(--color-band-muted);
  font-size: var(--answer-size);
  text-wrap: pretty; /* avoid a single word alone on the last line */
}

/* ---------- Entrance (photo + envelope) ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  overflow: hidden;
  background: var(--intro-placeholder);
  color: var(--intro-ink);
  text-align: center;
  transition: opacity 1s ease, transform 1s ease;
}

html.show-intro .intro {
  display: block;
}

html.show-intro body {
  overflow: hidden;
}

.intro.is-done {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.04);
}

.intro-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Shading between the photo and the text. */
.intro::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--intro-scrim);
}

.intro-placeholder {
  position: absolute;
  top: 1rem;
  left: 0;
  right: 0;
  z-index: 1;
  font-size: 0.8rem;
  opacity: 0.7;
}

.intro-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 1.5rem;
  height: 100%;
  padding: clamp(2rem, 8vh, 5rem) 16px;
}

.intro-content p {
  margin: 0;
}

.intro-caption {
  max-width: 18rem;
  font-family: var(--font-label);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.intro-heading {
  font-family: var(--font-script);
  font-size: clamp(2.75rem, 12vw, 4rem);
  line-height: 1.2;
}

/* With a photo: heading, envelope and caption stacked in the sky. The photo
   fills the screen's height (cropped at the sides on phones, whole on wide
   screens), so a point in it sits at the same height on every screen. The
   envelope is centred at --envelope-y, sized by the screen's height
   (--envelope-half is half the pocket's height), and the caption ends ~59%
   down, just above the hilltop (~63%) and the couple (~73%) in the current photo.
   Re-check these numbers when the photo changes. */
.intro.has-photo {
  --envelope-y: 45%;
  --envelope-w: min(62vw, 300px, 28vh);
  --envelope-half: calc(var(--envelope-w) * 245 / 720); /* half the pocket's height */
  --envelope-gap: clamp(0.5rem, 2vh, 1.25rem);
  --caption-size: clamp(0.7rem, 3.2vw, 0.85rem);
}

/* Centre the envelope itself, not the stage: the pocket's middle is
   (165 + 245 / 2) / 410 of the way down the stage. */
.intro.has-photo .envelope {
  position: absolute;
  top: var(--envelope-y);
  left: 50%;
  transform: translate(-50%, calc(-100% * 287.5 / 410));
}

.intro.has-photo .intro-top,
.intro.has-photo .intro-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  margin: 0 auto;
}

.intro.has-photo .intro-top {
  bottom: calc(100% - var(--envelope-y) + var(--envelope-half) + var(--envelope-gap));
}

/* Letter-spacing also trails the last letter; matching left padding keeps the
   text centred on the envelope. */
/* As boxes the two gaps match, but the heading's line box has 0.362em of
   empty space below its baseline (only the Y dips a little), while the
   caption's has 0.467em above its capitals. The margin cancels the
   difference, so the gap from the heading's baseline to the envelope equals
   the gap from the envelope to the top of the caption's capitals at every
   size (measured in Pinyon Script and Cormorant Garamond). */
.intro.has-photo .intro-heading {
  margin-bottom: calc(0.467 * var(--caption-size) - 0.362em);
  padding-left: 0.04em;
  font-size: calc(var(--envelope-w) * 0.16);
  letter-spacing: 0.04em;
}

.intro.has-photo .intro-caption {
  top: calc(var(--envelope-y) + var(--envelope-half) + var(--envelope-gap));
  max-width: none;
  padding-left: 0.2em;
  font-size: var(--caption-size);
}

/* On screens wider than the portrait photo, cropping it to fill would cut off
   its top and bottom (the sky, the couple's feet), so show all of it, with a
   blurred copy filling the sides. */
@media (min-aspect-ratio: 3/4) {
  .intro.has-photo .intro-photo {
    object-fit: contain;
  }

  .intro.has-photo::before {
    content: '';
    position: absolute;
    inset: -40px;
    background: var(--intro-photo-url) center / cover;
    filter: blur(24px) brightness(0.7);
  }
}

/* The envelope is the button: a plain pocket with a scalloped flap edged in
   cut-out vine lace (tools/envelope-flap.py), and a plain scalloped seal. The button is a stage 360 x 410 (in the SVGs' units): the
   envelope fills the bottom 245, and the 165 above it is where the flap stands
   when it opens. Everything is sized from --envelope-w. */
.intro {
  --envelope-w: min(70vw, 300px, 32vh);
}

.envelope {
  position: relative;
  width: var(--envelope-w);
  aspect-ratio: 360 / 410;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: calc(var(--envelope-w) * 3.33);
  user-select: none;
}

.envelope:focus-visible {
  outline: none;
}

.envelope:focus-visible .envelope-pocket {
  outline: 2px solid var(--intro-ink);
  outline-offset: 6px;
}

.envelope-defs {
  position: absolute;
}

.envelope > svg {
  position: absolute;
  left: 0;
  width: 100%;
  overflow: visible;
}

/* 1. Inside of the back */
.envelope-back {
  bottom: 0;
  z-index: 1;
  height: calc(100% * 245 / 410);
  fill: var(--envelope-inside);
  filter: drop-shadow(0 12px 24px rgb(60 50 35 / 0.12));
}

/* 2. Front pocket */
.envelope-pocket {
  bottom: 0;
  z-index: 3;
  height: calc(100% * 245 / 410);
  pointer-events: none;
}

.envelope-pocket {
  /* The front's edge casts a soft shadow into the opening. */
  filter: drop-shadow(0 -1px 2px rgb(80 70 50 / 0.16));
}

.envelope-pocket-front {
  fill: var(--envelope);
  stroke: var(--envelope-edge);
  stroke-width: 1.5;
}

/* A highlight along the mouth's edges, where the paper catches the light. */
.envelope-pocket-lip {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
}

/* The bottom flap's edges. */
.envelope-pocket-fold {
  fill: none;
  stroke: var(--envelope-seam);
  stroke-width: 1;
}

/* 3. Flap, hinged on the back panel's top edge. Closed, it is turned 180deg so
   it folds down over the pocket, covering the V mouth; opening lifts it
   upright to show the inside through the mouth. */
.envelope-flap {
  top: 0;
  z-index: 4;
  height: calc(100% * 165 / 410);
  transform: rotateX(180deg);
  transform-origin: bottom center;
  filter: drop-shadow(0 -4px 6px rgb(80 70 50 / 0.14));
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.envelope-flap-paper {
  fill: var(--envelope);
}

/* Lace: the cut-away band gets a hairline edge, and the vines, tendrils and
   leaves standing in it are paper outlined in --envelope-seam, so the lace
   reads against the pocket (closed) and the sky (open). Each stroke is drawn
   twice: a wider seam-coloured one, then the paper on top. */
.envelope-lace-cut {
  fill: none;
  stroke: var(--envelope-seam);
  stroke-width: 0.8;
}

.envelope-lace use {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.envelope-lace-vine-edge,
.envelope-lace-tendril-edge {
  stroke: var(--envelope-seam);
}

.envelope-lace-vine-edge {
  stroke-width: 3.2;
}

.envelope-lace-tendril-edge {
  stroke-width: 2.5;
}

.envelope-lace .envelope-lace-leaf {
  fill: var(--envelope);
  stroke: var(--envelope-seam);
  stroke-width: 0.8;
}

.envelope-lace-vine,
.envelope-lace-tendril {
  stroke: var(--envelope);
}

.envelope-lace-vine {
  stroke-width: 2.1;
}

.envelope-lace-tendril {
  stroke-width: 1.5;
}

.envelope-flap-edge {
  fill: none;
  stroke: var(--envelope-seam);
  stroke-width: 2;
}

.envelope-seal-paper {
  fill: var(--seal);
}

.envelope-seal-edge {
  fill: none;
  stroke: var(--seal-edge);
  stroke-width: 0.8;
}

.envelope-seal-monogram {
  fill: var(--seal-ink);
}

.envelope-seal-initials {
  fill: var(--seal-ink);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-style: italic;
  letter-spacing: 0.3px;
}

.envelope-seal {
  transition: opacity 0.25s ease;
}

/* Open: the flap lifts and the seal fades, then the whole screen fades away
   (js/app.js). */
.intro.is-opening .envelope-flap {
  filter: drop-shadow(0 4px 6px rgb(80 70 50 / 0.12));
  transform: rotateX(0deg);
}

.intro.is-opening .envelope-seal {
  opacity: 0;
}

@media (hover: hover) {
  .intro:not(.is-opening) .envelope:hover .envelope-flap {
    transform: rotateX(166deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro.is-done {
    transform: none;
  }

  .envelope-flap {
    transition: none;
  }
}

/* ---------- Music toggle ---------- */

.music-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-accent);
  cursor: pointer;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--color-text) 15%, transparent);
}

.music-toggle[aria-pressed='true'] .mute-line {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Month calendar (details card) ---------- */

.calendar {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 20rem;
}

.calendar-month {
  font-family: var(--font-script);
  font-size: 2.6rem;
  line-height: 1.1;
}

.calendar-grid {
  width: 100%;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-collapse: collapse;
  border-top: 1px solid var(--color-border);
  table-layout: fixed;
  font-family: var(--font-label);
  text-align: center;
}

.calendar-grid th {
  padding-bottom: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calendar-grid td {
  height: 2.25rem;
  font-size: 1.05rem;
  font-variant-numeric: lining-nums tabular-nums;
}

.calendar-day-wedding {
  position: relative;
  color: var(--color-accent-ink);
  font-weight: 600;
}

.calendar-day-wedding svg {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.4rem;
  height: 2.4rem;
  fill: var(--color-accent);
  transform: translate(-50%, -48%);
}

.calendar-day-wedding span[aria-hidden] {
  position: relative;
}

/* ---------- Countdown ---------- */

.countdown {
  display: flex;
  gap: 1.5rem;
}

.countdown div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3.5rem;
}

.countdown span {
  font-family: var(--font-label);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.1;
}

.countdown small {
  color: var(--color-text-muted);
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.photo-frame {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-accent-soft);
  color: var(--color-text-muted);
  font-size: 0.95rem;
  object-fit: cover;
}

img.photo-frame {
  border: 0;
}

/* ---------- Gallery ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.gallery .photo-frame {
  aspect-ratio: 1;
}

.gallery button {
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.lightbox {
  max-width: 94vw;
  max-height: 94vh;
  padding: 0.5rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--color-surface);
  text-align: center;
}

.lightbox::backdrop {
  background: color-mix(in srgb, var(--color-text) 75%, transparent);
}

.lightbox-stage {
  touch-action: pan-y; /* sideways drags are swipes (js/app.js) */
  user-select: none;
  -webkit-user-select: none;
}

.lightbox-stage img {
  display: block;
  max-width: 100%;
  max-height: 74vh;
  max-height: 74dvh;
  margin: 0 auto 0.5rem;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.lightbox-nav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
}

.lightbox-nav:disabled {
  border-color: var(--color-border);
  color: var(--color-border);
  cursor: default;
}

/* Close: same label serif as the counter, in letter-spaced capitals. */
.lightbox .link {
  display: block;
  margin: 0.25rem auto 0;
  min-height: 44px;
  font-family: var(--font-label);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-underline-offset: 0.25em;
}

.lightbox-count {
  min-width: 4.5ch;
  font-family: var(--font-label);
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  font-variant-numeric: lining-nums tabular-nums;
}

@media (min-width: 768px) {
  #gallery {
    max-width: 880px;
  }

  .gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }
}
