:root {
  --bg: #f3f0ea;
  --text: #3a3a3a;
  --text-soft: #6e6e6e;
  --purple: #6b4e8a;
  --purple-dark: #563d72;
  --gray: #999;
  --gray-dark: #888;
  --rule: rgba(0, 0, 0, 0.18);
  /* Fixed iPhone 14 Pro Max frame */
  --card-w: 430px;
  --card-h: 932px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  font-family: 'Cormorant Garamond', 'Garamond', serif;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; }
a { color: inherit; }

/* ============ Stage ============
   Full viewport. Clips anything that overflows past the screen edges so
   no flowers appear outside the visible window. */
.stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============ Card ============
   Fixed-size design rectangle (iPhone 14 Pro Max aspect / dimensions),
   centered horizontally + vertically. The whole card (text, spacing,
   flowers, button) is uniformly scaled via `--card-scale` so that the
   430×932 design fills the viewport height (or the viewport width on
   very narrow screens). `--card-scale` is set by main.js on load and
   resize. transform: scale() does not affect layout, so the card stays
   centered inside .stage. */
.card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  flex: none;
  background: transparent;
  /* Visible overflow so the absolute-positioned flowers extend
     past the card boundary as designed. */
  overflow: visible;
  z-index: 1;
  transform: scale(var(--card-scale, 1));
  transform-origin: center center;
}

/* ============ Edge flowers ============
   Random decorative flowers placed in the strips of viewport that fall
   OUTSIDE the fixed 430x932 card. Stage's overflow:hidden naturally
   clips anything past the viewport edge, and main.js positions each
   element so that >=50% of it lies beyond the viewport. */
.edge-flowers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.edge-flowers img {
  position: absolute;
  user-select: none;
  pointer-events: none;
  transform-origin: center center;
  will-change: transform;
}

/* ============ Flowers ============ */
.flowers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.flower,
.bees {
  position: absolute;
  transform-origin: center center;
  user-select: none;
  pointer-events: none;
}

/* Canva-like color filters (calibrated approximation) */
.flower--aero {
  filter:
    saturate(0.88)
    brightness(1.06)
    contrast(0.95)
    hue-rotate(-4deg);
}

.flower--mono {
  filter:
    grayscale(1)
    brightness(1.1)
    contrast(0.9)
    sepia(0.18)
    hue-rotate(180deg);
}

/* ============ Content ============ */
.content {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120px 36px;
  text-align: center;
  pointer-events: none;
}

.content > * { pointer-events: auto; }

.content__top,
.content__middle,
.content__bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 3rem;
}

.content__date {
  font-size: 16px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
  font-weight: 400;
}

.content__lead {
  font-size: 12px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 18px;
  font-weight: 400;
}

.content__names {
  margin: 0;
  font-weight: 400;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

.content__names .amp {
  font-style: italic;
  font-weight: 400;
  opacity: 0.85;
  margin: 0 0.1em;
  text-transform: none;
}

.content__middle {
  gap: 22px;
}

.event__title {
  font-size: 14px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 400;
}

.event__place {
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
  font-weight: 400;
  line-height: 1.5;
}

.rsvp-text {
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--text);
  line-height: 1.7;
  font-style: italic;
}

.rsvp-text a {
  text-decoration: none;
  color: var(--text);
  font-style: italic;
}

.cta {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--purple);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 14px 28px;
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(107, 78, 138, 0.32);
  transition: transform 220ms ease, box-shadow 220ms ease, background 220ms ease;
  position: relative;
  z-index: 3;
}

.cta:hover { background: var(--purple-dark); transform: translateY(-1px); box-shadow: 0 14px 32px rgba(107, 78, 138, 0.38); }
.cta:active { transform: translateY(0); }
.cta:focus-visible { outline: 2px solid var(--purple-dark); outline-offset: 3px; }

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

.modal[aria-hidden="false"] {
  pointer-events: auto;
  opacity: 1;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 28, 50, 0.42);
  backdrop-filter: blur(2px);
}

.modal__panel {
  position: relative;
  background: #fbf9f4;
  border-radius: 8px;
  width: min(560px, 92vw);
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  padding: clamp(24px, 4vh, 40px);
  transform: scale(0.96);
  transition: transform 220ms cubic-bezier(.22,.61,.36,1);
}

.modal[aria-hidden="false"] .modal__panel { transform: scale(1); }

.modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 10px;
}
.modal__close:hover { color: var(--text); }

.modal__title {
  margin: 0 0 6px;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(26px, 4vh, 36px);
  color: var(--purple);
  text-align: center;
}

.modal__subtitle {
  margin: 2px 0;
  text-align: center;
  font-size: 15px;
  color: var(--text);
}

.modal__rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 16px auto;
  width: 80%;
}

.modal__deadline {
  text-align: center;
  font-size: 15px;
  color: var(--text);
  margin: 0 0 20px;
  line-height: 1.5;
}

/* ============ Form ============ */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 14px; color: var(--text-soft); line-height: 1.4; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field-row > .field { min-width: 0; }
/* When the menus row only has one visible field (no P2 menu), let it span full width. */
.field-row--menus:has(> [hidden]),
.field-row--names:has(> [hidden]) {
  grid-template-columns: 1fr;
}

.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid #d6d0c8;
  background: #fff;
  border-radius: 4px;
  color: var(--text);
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(107, 78, 138, 0.18);
}

/* Collapsible textareas: single-line by default, expand on hover/focus. */
.field textarea.field__expand {
  height: 42px;
  min-height: 42px;
  resize: none;
  overflow: hidden;
  white-space: nowrap;
  transition: height 500ms ease, min-height 500ms ease;
}
.field textarea.field__expand:hover,
.field textarea.field__expand:focus,
.field textarea.field__expand:not(:placeholder-shown),
.field textarea.field__expand.is-filled {
  height: 130px;
  min-height: 130px;
  overflow: auto;
  white-space: pre-wrap;
  resize: vertical;
}

.form__actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  flex: 1;
  min-width: 160px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 3px;
  transition: background 200ms ease, transform 150ms ease;
}

.btn--ghost { background: var(--gray); color: #fff; }
.btn--ghost:hover { background: var(--gray-dark); }

.btn--primary { background: var(--purple); color: #fff; }
.btn--primary:hover { background: var(--purple-dark); }

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.form__error {
  color: #a23a3a;
  font-size: 14px;
  margin: 0;
  text-align: center;
}

.already {
  text-align: center;
  font-size: 18px;
  font-style: italic;
  color: var(--purple);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.already p { margin: 0; }
.already__hint {
  font-size: 14px;
  font-style: normal;
  color: var(--text-soft);
}
.already__resubmit {
  margin-top: 4px;
}
