:root {
  --paper: #F7F3E9;
  --paper-deep: #EFE9DA;
  --desk: #DCD5C5;
  --olive: #4C5B3C;
  --olive-soft: rgba(76, 91, 60, 0.45);
  --olive-faint: rgba(76, 91, 60, 0.16);
  --sage: #8A9474;
  --ink: #2E2B26;
  --ink-soft: rgba(46, 43, 38, 0.66);
  --terracotta: #9A5B45;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1200px 700px at 50% -10%, rgba(255, 253, 247, 0.5), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.05'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- The page ---------- */

.book {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(46, 43, 38, 0.22);
  overflow: hidden;
  background-image:
    radial-gradient(90% 60% at 50% 0%, rgba(255, 255, 255, 0.5), transparent 65%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.055'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* ---------- Screens ---------- */

.screen { display: none; }
.screen.active { display: block; animation: fade-up 0.45s ease both; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active { animation: none; }
  * { transition: none !important; }
}

/* ---------- Frame ---------- */

.frame {
  position: relative;
  margin: 22px 18px;
  padding: 44px 26px 52px;
  border: 1px solid var(--olive-soft);
  text-align: center;
}

.frame::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--olive-faint);
  pointer-events: none;
}

.frame::after,
.frame__corner {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  background:
    linear-gradient(var(--olive), var(--olive)) left top / 18px 1px no-repeat,
    linear-gradient(var(--olive), var(--olive)) left top / 1px 18px no-repeat,
    linear-gradient(var(--olive), var(--olive)) right top / 18px 1px no-repeat,
    linear-gradient(var(--olive), var(--olive)) right top / 1px 18px no-repeat,
    linear-gradient(var(--olive), var(--olive)) left bottom / 18px 1px no-repeat,
    linear-gradient(var(--olive), var(--olive)) left bottom / 1px 18px no-repeat,
    linear-gradient(var(--olive), var(--olive)) right bottom / 18px 1px no-repeat,
    linear-gradient(var(--olive), var(--olive)) right bottom / 1px 18px no-repeat;
}

/* ---------- Artwork slots ---------- */

.art {
  position: relative;
  aspect-ratio: 4 / 3;
  margin: 0 0 30px;
  border: 1px solid var(--olive-faint);
  overflow: hidden;
  background: var(--paper-deep);
}

.art__wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(90% 70% at 30% 25%, rgba(138, 148, 116, 0.42), transparent 62%),
    radial-gradient(80% 65% at 74% 78%, rgba(76, 91, 60, 0.28), transparent 60%),
    linear-gradient(160deg, rgba(255, 253, 247, 0.85), rgba(239, 233, 218, 0.25) 55%, rgba(76, 91, 60, 0.14));
}

.art__wash--event {
  background:
    radial-gradient(85% 60% at 24% 30%, rgba(255, 249, 230, 0.75), transparent 58%),
    radial-gradient(70% 55% at 78% 82%, rgba(76, 91, 60, 0.30), transparent 62%),
    radial-gradient(60% 45% at 60% 20%, rgba(138, 148, 116, 0.34), transparent 60%),
    linear-gradient(165deg, rgba(255, 253, 247, 0.9), rgba(239, 233, 218, 0.3) 60%, rgba(76, 91, 60, 0.16));
}

.art__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.art__img.is-loaded { display: block; }

h1:focus-visible,
h2:focus-visible,
.section-title:focus-visible {
  outline: none;
}

/* ---------- Typography ---------- */

.eyebrow {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--olive);
  font-family: var(--sans);
  font-weight: 600;
}

.names {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 11vw, 3.5rem);
  letter-spacing: 0.03em;
  color: var(--ink);
  line-height: 1.12;
}

.names .amp {
  font-style: italic;
  color: var(--sage);
  padding: 0 0.08em;
}

.invite {
  margin: 16px auto 0;
  max-width: 20em;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.06rem;
  color: var(--ink-soft);
}

.section-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}

.section-sub {
  margin: 0 auto 26px;
  max-width: 24em;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- Ornament ---------- */

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 26px 0 22px;
}

.ornament::before,
.ornament::after {
  content: "";
  width: 34px;
  height: 1px;
  background: var(--olive-soft);
}

.ornament__leaf {
  width: 16px;
  height: 9px;
  border-radius: 0 100% 0 100%;
  transform: rotate(-40deg);
  background: linear-gradient(135deg, var(--olive), var(--sage));
}

.ornament--large { margin: 30px 0 24px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 34px;
  border-radius: 999px;
  border: 1px solid var(--olive);
  background: transparent;
  color: var(--olive);
  font-family: var(--sans);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, opacity 0.22s ease;
  touch-action: manipulation;
}

.btn:hover { background: var(--olive); color: var(--paper); }

.btn--primary { background: var(--olive); color: var(--paper); }
.btn--primary:hover { background: var(--ink); border-color: var(--ink); }

.btn:focus-visible,
.link-back:focus-visible,
input:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 3px;
}

.btn--submit { width: 100%; }
.btn--submit .btn-pending { display: none; }
.btn--submit.is-pending .btn-label { display: none; }
.btn--submit.is-pending .btn-pending { display: inline; }
.btn--submit.is-pending { opacity: 0.75; pointer-events: none; }

.link-back {
  display: block;
  margin: 18px auto 0;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  cursor: pointer;
}

.link-back:hover { color: var(--olive); }

/* ---------- Event block ---------- */

.event-block {
  margin: 0 0 28px;
  text-align: center;
}

.event-block > div {
  padding: 10px 0;
  border-top: 1px solid var(--olive-faint);
}

.event-block > div:last-child { border-bottom: 1px solid var(--olive-faint); }

.event-block dt {
  font-size: 10.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--sage);
  margin-bottom: 3px;
}

.event-block dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--ink);
}

.gift {
  margin: 0 0 30px;
  padding: 20px 18px;
  border: 1px solid var(--olive-faint);
  background: rgba(247, 243, 233, 0.65);
}

.gift p {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.98rem;
  color: var(--ink-soft);
}

.gift p:last-child { margin-bottom: 0; }

/* ---------- Form ---------- */

.form {
  text-align: left;
  margin-top: 8px;
}

.field {
  margin: 0 0 26px;
  border: 0;
  padding: 0;
}

.field legend,
.field > label,
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--olive);
  font-weight: 600;
}

.hint {
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--sage);
  font-weight: 400;
}

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid rgba(46, 43, 38, 0.35);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.08rem;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: vertical; min-height: 64px; }

input:focus,
textarea:focus {
  outline: none;
  border-bottom-color: var(--olive);
}

.pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pills--wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  position: relative;
  display: block;
}

.pill input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.pill span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid var(--olive-soft);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill input:focus-visible + span {
  outline: 2px solid var(--olive);
  outline-offset: 3px;
}

.pill input:checked + span {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--paper);
}

.pill--sm span {
  min-height: 44px;
  padding: 0 16px;
  font-size: 0.86rem;
}

.dietary-other {
  margin-top: 10px;
}

.field-error {
  display: none;
  margin: 8px 0 0;
  font-size: 0.88rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--terracotta);
}

.field.invalid .field-error { display: block; }
.field.invalid input,
.field.invalid textarea { border-bottom-color: var(--terracotta); }

.submit-error {
  display: none;
  padding: 12px 14px;
  border: 1px solid rgba(154, 91, 69, 0.45);
  background: rgba(154, 91, 69, 0.07);
}

.submit-error.is-visible { display: block; }

.conditional { transition: opacity 0.25s ease; }
.conditional.is-hidden { display: none; }

.hp {
  position: absolute;
  left: -9999px;
  height: 0;
  width: 0;
  opacity: 0;
}

/* ---------- Thank you ---------- */

.frame--thanks { padding-top: 72px; padding-bottom: 72px; }

.confirmation {
  margin: 6px 0 26px;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  color: var(--sage);
}

/* ---------- Colophon ---------- */

.colophon {
  margin: 0;
  padding: 26px 0 34px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(76, 91, 60, 0.55);
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .frame { margin: 14px 10px; padding: 36px 18px 44px; }
  .art { margin-bottom: 24px; }
}
