:root {
  color-scheme: light;
  --navy: #0f172a;
  --gold: #d4af37;
  --offwhite: #f8fafc;
  --muted: #475569;
  --display: "Playfair Display", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--offwhite);
  color: var(--navy);
  font: 1rem/1.55 Inter, system-ui, sans-serif;
}

a { color: inherit; }
:focus-visible { outline: 3px solid #97720d; outline-offset: 3px; }
h1, h2 { font-family: var(--display); line-height: 1.15; margin: 0; }
p { margin: 0; }

.site-bar { background: var(--navy); color: white; }
.site-bar nav {
  max-width: 72rem;
  margin: auto;
  padding: .95rem clamp(1rem, 4vw, 2rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.site-bar a { text-decoration: none; }
.site-bar a:hover { text-decoration: underline; }
.brand { font: 800 1.75rem var(--display); }
.brand span { color: var(--gold); }

.editor { max-width: 72rem; margin: auto; padding: clamp(1rem, 4vw, 2rem); }
.intro { padding: 1.4rem 0 2rem; }
.intro h1 { font-size: clamp(2rem, 5vw, 3rem); }
.intro p { color: var(--muted); margin-top: .65rem; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(1rem, 4vw, 2.25rem); align-items: start; }

.panel {
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: white;
  box-shadow: 0 10px 25px #0f172a0a;
}

.templates { border: 0; padding: 0; margin: 0 0 1.15rem; min-width: 0; }
label, legend { font-size: .9rem; font-weight: 600; }
legend { padding: 0; margin-bottom: .4rem; }
.choices, .share-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.choices label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid #cbd5e1;
  border-radius: .6rem;
  padding: .55rem .65rem;
  cursor: pointer;
}
.choices label:has(:checked) { background: #fcf6e0; border-color: #97720d; }
input[type="radio"] { margin: 0; accent-color: #77580b; }

input:not([type="radio"]), textarea {
  display: block;
  width: 100%;
  min-height: 2.8rem;
  min-width: 0;
  margin: .3rem 0 1rem;
  padding: .6rem .7rem;
  border: 1px solid #94a3b8;
  border-radius: .6rem;
  background: white;
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; }
.event-time { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.optional, .hint { color: var(--muted); }
.optional { font-weight: 400; }
.hint { font-size: .875rem; margin-top: .75rem; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: .65rem 1.15rem;
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--navy);
  font: 700 .9rem/1.4 Inter, system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}
.primary { background: var(--gold); }
.primary:hover { background: #e1bd4d; }
.secondary { background: white; border-color: #94a3b8; }
.secondary:hover { background: var(--offwhite); }

.preview > h2 { margin: .2rem 0 .85rem; font-size: 1.25rem; }
.invitation {
  --card-bg: var(--navy);
  --card-text: #fffaf0;
  --card-accent: #f2d47a;
  display: flex;
  flex-direction: column;
  width: min(100%, 26rem);
  aspect-ratio: 9 / 16;
  min-height: min-content;
  margin-inline: auto;
  background: var(--card-bg);
  color: var(--card-text);
  border-radius: 1rem;
  padding: clamp(1rem, 4vw, 1.75rem);
  text-align: center;
  box-shadow: 0 14px 30px #0f172a1c;
  overflow-wrap: anywhere;
}
.invitation[data-template="cena"] { --card-bg: #faf3e0; --card-text: #0f172a; --card-accent: #79590f; }
.invitation[data-template="reunion"] { --card-bg: #284339; --card-text: #fffaf0; --card-accent: #f2d47a; }
.letter {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--card-accent);
  border-radius: .55rem;
  padding: 2rem clamp(.75rem, 4vw, 2rem);
}
.letter > * { max-width: 100%; }
.ornament { color: var(--card-accent); font-size: 1.6rem; }
.event-type { color: var(--card-accent); font-size: .875rem; text-transform: uppercase; letter-spacing: .12em; margin: .65rem 0; }
.event-title { font-size: clamp(1.8rem, 4vw, 2.9rem); }
.event-message { white-space: pre-wrap; margin-top: 1rem; }
.event-details { margin-top: 1.35rem; }
.event-date { font-weight: 600; }
.event-place { margin-top: .3rem; }
.event-map {
  margin-top: .75rem;
  border-color: var(--card-accent);
  color: var(--card-accent);
}
.event-map:hover { text-decoration: underline; }
.invitation footer { margin-top: 1rem; font-size: .875rem; color: var(--card-accent); }
.share { margin-top: 1rem; }
.share h2 { font-size: 1.3rem; margin-bottom: .75rem; }
#status { margin-top: .5rem; }
.guest { width: min(100%, 39rem); margin: auto; padding: clamp(1rem, 5vw, 3rem); }
.guest h1 { font-size: clamp(2rem, 6vw, 3.25rem); }
#invalid p { margin: 1rem 0; }

@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
  .guest .invitation {
    animation: invitation-arrive 550ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .guest .letter {
    position: relative;
    overflow: hidden;
  }

  .guest .letter::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(112deg, transparent 39%, rgb(212 175 55 / 15%) 50%, transparent 61%);
    background-size: 300% 100%;
    pointer-events: none;
    animation: invitation-glint 900ms 180ms ease-out both;
  }

  .guest .ornament {
    display: inline-block;
    animation: invitation-star 560ms 180ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .guest .event-title,
  .guest .event-details {
    animation: invitation-details 520ms 160ms ease-out both;
  }
}

@keyframes invitation-arrive {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes invitation-glint {
  from { background-position: 100% 50%; }
  to { background-position: 0% 50%; }
}

@keyframes invitation-star {
  from { opacity: 0; transform: scale(.65) rotate(-20deg); }
  65% { opacity: 1; transform: scale(1.12) rotate(5deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes invitation-details {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.envelope-trigger {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  width: min(100%, 26rem);
  margin: clamp(2rem, 14vh, 7rem) auto 0;
  padding: 0;
  border: 0;
  border-radius: .75rem;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.guest-envelope {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 1px solid #ac8c39;
  border-radius: .75rem;
  overflow: hidden;
  background: #15213a;
  box-shadow: 0 16px 30px #0f172a33;
}

.guest-envelope-fold,
.guest-envelope-flap {
  position: absolute;
  inset: 0;
}

.guest-envelope-fold {
  background: linear-gradient(140deg, #263654, #0f172a);
  clip-path: polygon(0 0, 50% 59%, 100% 0, 100% 100%, 0 100%);
}

.guest-envelope-flap {
  background: linear-gradient(145deg, #344462, #16243d);
  clip-path: polygon(0 0, 100% 0, 50% 61%);
}

.guest-envelope-seal {
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(2.7rem, 12vw, 3.7rem);
  aspect-ratio: 1;
  transform: translateY(39%);
  border: 2px solid #f2d47a;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  box-shadow: 0 3px 8px #0f172a80;
  font-size: 1.4rem;
}

@media (prefers-reduced-motion: no-preference) {
  .guest-envelope { transition: transform 220ms ease; }
  .envelope-trigger:is(:hover, :focus-visible) .guest-envelope { transform: translateY(-3px); }
}
