/* ─── Base layer ─────────────────────────────────────────────
   Structural styles only. Each theme file overrides the CSS
   custom properties declared in :root and adds decorative
   layers via [data-theme="..."] scoped selectors.
   ────────────────────────────────────────────────────────── */

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

:root {
  /* These four are the contract every theme must define. */
  --bg: #f7f3ec;
  --bg-2: #efe7d8;
  --surface: #fff;
  --ink: #1a1a1a;
  --ink-soft: #5c5c5c;
  --accent: #6b2737;
  --accent-2: #c9a96a;

  --font-display: "Times New Roman", serif;
  --font-body: "Georgia", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius-sm: 6px;
  --radius: 14px;
  --radius-lg: 28px;

  --shadow-soft: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px -8px rgba(0,0,0,.12);
  --shadow-pop: 0 12px 40px -8px rgba(0,0,0,.25);

  --max-width: 720px;
  --ease-out: cubic-bezier(.22,.61,.36,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);

  /* Per-theme decorative density */
  --grain-opacity: 0;
  --atmosphere-opacity: 1;
}

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: clamp(15px, 1.6vw, 17px);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }

a { color: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ─── Atmosphere & grain (theme-decorated) ───────────────── */
.atmosphere, .grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
}
.atmosphere { opacity: var(--atmosphere-opacity); }
.grain      { opacity: var(--grain-opacity); mix-blend-mode: multiply; }

/* ─── Layout ─────────────────────────────────────────────── */
.invite {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) clamp(20px, 5vw, 48px) clamp(40px, 8vw, 80px);
  display: grid;
  gap: clamp(28px, 5vw, 56px);
}

.invite__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.monogram {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-display);
  font-size: clamp(48px, 8vw, 72px);
  line-height: 1;
  color: var(--accent);
}
.monogram__amp {
  font-size: .7em;
  color: var(--ink-soft);
  font-style: italic;
}

.kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ─── Hero ────────────────────────────────────────────────── */
.hero { text-align: center; display: grid; gap: 18px; }

.greeting {
  margin: 0;
  font-family: var(--font-body);
  font-style: italic;
  color: var(--ink-soft);
  font-size: clamp(16px, 2vw, 19px);
}
.greeting__name {
  font-style: normal;
  color: var(--accent);
  font-weight: 600;
}

.couple {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(48px, 9vw, 96px);
  line-height: 1;
  letter-spacing: -.01em;
  color: var(--ink);
}

.tagline {
  margin: 0 auto;
  max-width: 32ch;
  color: var(--ink-soft);
  font-size: clamp(15px, 1.8vw, 18px);
}

/* ─── Event details strip ────────────────────────────────── */
.details {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  gap: clamp(16px, 3vw, 36px);
  padding: clamp(20px, 4vw, 32px) clamp(16px, 4vw, 36px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.detail {
  display: grid;
  gap: 4px;
  text-align: center;
  min-width: 0;
}
.detail__label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .25em;
  color: var(--ink-soft);
}
.detail__value {
  font-family: var(--font-display);
  font-size: clamp(18px, 2.4vw, 22px);
  color: var(--ink);
  text-decoration: none;
}
.detail__value--link {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent);
  text-underline-offset: 4px;
  transition: text-decoration-color .2s var(--ease-out);
}
.detail__value--link:hover { text-decoration-color: var(--accent); }
.detail__sub { color: var(--ink-soft); font-size: 14px; }
.detail__divider {
  width: 1px;
  align-self: stretch;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
}
@media (max-width: 540px) {
  .details { grid-template-columns: 1fr; }
  .detail__divider { width: 100%; height: 1px; }
}

/* ─── RSVP ───────────────────────────────────────────────── */
.rsvp {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 5vw, 48px);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}
.rsvp__title {
  margin: 0 0 24px;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 400;
}

.rsvp__form { display: grid; gap: 24px; }

.choices {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  position: relative; /* runaway transforms are relative to flow */
}
@media (max-width: 560px) {
  .choices { grid-template-columns: 1fr; }
}

.choice {
  position: relative;
  display: block;
  cursor: pointer;
  transition: transform .35s var(--ease-spring), filter .2s var(--ease-out);
  will-change: transform;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }

.choice__face {
  display: grid;
  gap: 4px;
  text-align: center;
  padding: 18px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 60%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--ink) 8%, transparent);
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out), transform .2s var(--ease-out);
}
.choice:hover .choice__face,
.choice:focus-within .choice__face {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.choice input:checked ~ .choice__face {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.choice__label {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.6vw, 24px);
  color: var(--ink);
}
.choice__label em { font-style: italic; color: var(--accent); }
.choice__sub {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.choice--no.is-dodging {
  filter: drop-shadow(0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent));
}
.choice--no.is-shaking { animation: shakeNo .35s var(--ease-out); }
@keyframes shakeNo {
  0%,100% { transform: translate(var(--dodge-x, 0), var(--dodge-y, 0)) rotate(0); }
  20% { transform: translate(calc(var(--dodge-x, 0px) - 6px), var(--dodge-y, 0)) rotate(-2deg); }
  40% { transform: translate(calc(var(--dodge-x, 0px) + 6px), var(--dodge-y, 0)) rotate( 2deg); }
  60% { transform: translate(calc(var(--dodge-x, 0px) - 4px), var(--dodge-y, 0)) rotate(-1deg); }
  80% { transform: translate(calc(var(--dodge-x, 0px) + 4px), var(--dodge-y, 0)) rotate( 1deg); }
}

/* ─── Song input ─────────────────────────────────────────── */
.song { display: grid; gap: 8px; }
.song__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.song__icon { font-size: 14px; color: var(--accent); }
.song__input {
  width: 100%;
  padding: 14px 18px;
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--ink) 10%, transparent);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.song__input::placeholder { color: color-mix(in srgb, var(--ink-soft) 70%, transparent); }
.song__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* ─── Submit ─────────────────────────────────────────────── */
.submit {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: .02em;
  transition: transform .2s var(--ease-spring), background .2s var(--ease-out);
}
.submit:hover { transform: translateY(-2px) scale(1.02); background: var(--accent); }
.submit:active { transform: translateY(0) scale(.98); }
.submit:disabled { opacity: .6; cursor: progress; transform: none; }
.submit__arrow { display: inline-block; transition: transform .25s var(--ease-out); }
.submit:hover .submit__arrow { transform: translateX(4px); }

.form-error {
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: #b00020;
}

/* ─── Thanks state ───────────────────────────────────────── */
.thanks {
  text-align: center;
  display: grid;
  gap: 12px;
  padding: 12px;
  animation: thanksIn .6s var(--ease-out) both;
}
.thanks[hidden] { display: none; }
.rsvp__form[hidden] { display: none; }
.thanks__sparkle {
  font-size: 28px;
  color: var(--accent);
  animation: sparkleSpin 4s linear infinite;
}
.thanks__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 4vw, 36px);
}
.thanks__body { margin: 0; color: var(--ink-soft); }
@keyframes thanksIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes sparkleSpin {
  to { transform: rotate(360deg); }
}

/* ─── Footer ─────────────────────────────────────────────── */
.invite__footer {
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-soft);
}
.invite__footer p { margin: 0; }

/* ─── Toast (runaway button hints) ──────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 14px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity .25s var(--ease-out), transform .35s var(--ease-spring);
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Page-load reveal stagger ──────────────────────────── */
.invite__header, .hero, .details, .rsvp, .invite__footer {
  animation: rise .9s var(--ease-out) both;
}
.hero            { animation-delay: .08s; }
.details         { animation-delay: .18s; }
.rsvp            { animation-delay: .28s; }
.invite__footer  { animation-delay: .4s;  }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
