/* ==========================================================================
   Engagement RSVP — styles
   Two cross-fading backdrops: elegant ivory day / candlelit night with
   red-and-green fireworks (see script.js for the canvas engine).
   ========================================================================== */

/* ---------- Design tokens ---------- */

:root {
  --page-max: 44rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  /* Light theme (default) — warm ivory, blush, sage */
  --bg: #faf7f0;
  --bg-halo: rgba(213, 173, 158, 0.28);
  --ink: #3b352e;
  --muted: #8d8477;
  --accent: #b98273;          /* dusty rose   */
  --accent-2: #7c8f6f;        /* soft sage    */
  --card-bg: rgba(255, 253, 247, 0.85);
  --card-border: rgba(59, 53, 46, 0.12);
  --line: rgba(59, 53, 46, 0.16);
  --input-underline: rgba(59, 53, 46, 0.25);
  --btn-bg: #3b352e;
  --btn-ink: #faf7f0;
  --error: #b04a3f;
  --choice-bg: transparent;
  --choice-ink: var(--ink);
  --shadow: 0 10px 30px rgba(59, 53, 46, 0.08);
}

html[data-theme="dark"] {
  --bg: #0a0f24;
  --ink: #f2ead9;             /* warm candlelight white */
  --muted: #a89f92;
  --accent: #d9a5a0;          /* blush under moonlight  */
  --accent-2: #9dbb8f;        /* sage at night          */
  --card-bg: rgba(18, 24, 44, 0.62);
  --card-border: rgba(242, 234, 217, 0.14);
  --line: rgba(242, 234, 217, 0.18);
  --input-underline: rgba(242, 234, 217, 0.3);
  --btn-bg: #e2c38b;          /* candle gold */
  --btn-ink: #241d12;
  --error: #e88a7d;
  --choice-bg: transparent;
  --choice-ink: var(--ink);
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: color 0.5s ease;
}

::selection { background: var(--accent); color: #fff; }

h1, h2, h3, .names { font-family: var(--serif); font-weight: 500; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.25s; }
a:hover { border-bottom-color: currentColor; }

/* ---------- Backdrops (cross-fade) ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  transition: opacity 0.7s ease;
}

.backdrop-light {
  opacity: 1;
  background:
    radial-gradient(1100px 520px at 50% -12%, var(--bg-halo) 0%, transparent 62%),
    var(--bg);
}

.backdrop-dark {
  opacity: 0;
  background:
    linear-gradient(180deg,
      #070b1b 0%,
      #0a1027 42%,
      #10142e 68%,
      #1a1530 100%);
}

html[data-theme="dark"] .backdrop-light  { opacity: 0; }
html[data-theme="dark"] .backdrop-dark   { opacity: 1; }

/* Moon + stars + vignette live inside the dark backdrop */
.moon {
  position: absolute;
  top: 9%;
  right: 14%;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #fdf8e3, #efe3bd 62%, #d9cba1 100%);
  box-shadow:
    0 0 34px 10px rgba(248, 240, 214, 0.22),
    0 0 120px 40px rgba(248, 240, 214, 0.10);
  opacity: 0.9;
}

.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255,255,255,.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 12%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 41% 30%, rgba(255,255,255,.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 10%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 63% 26%, rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 74% 16%, rgba(255,255,255,.65) 50%, transparent 51%),
    radial-gradient(2px 2px at 84% 34%, rgba(255,255,255,.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 91% 22%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 18% 42%, rgba(255,255,255,.75) 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 52%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 44%, rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 52%, rgba(255,255,255,.6) 50%, transparent 51%);
  animation: twinkle 5.5s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(3, 5, 14, 0.55) 100%);
}

/* Fireworks canvas sits between backdrop and content */
#fx {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease;
}

html[data-theme="dark"] #fx { opacity: 1; }

/* ---------- Candles (night floor) ---------- */

.night-floor {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease;
}

html[data-theme="dark"] .night-floor { opacity: 1; }

.candles {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(18px, 4vw, 44px);
  padding-bottom: 2px;
}

.candle { position: relative; display: flex; flex-direction: column; align-items: center; }

.wax {
  display: block;
  width: 13px;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(180deg, #f4e8d2, #e3d2b4 78%, #cdb997);
  box-shadow: inset -2px 0 3px rgba(120, 96, 60, 0.35);
}

.c1 .wax { height: 54px; }
.c2 .wax { height: 72px; }
.c3 .wax { height: 46px; }
.c4 .wax { height: 84px; }
.c5 .wax { height: 62px; }
.c6 .wax { height: 50px; }
.c7 .wax { height: 76px; }

.wick {
  position: absolute;
  bottom: var(--wax-h, 60px);
  width: 2px;
  height: 6px;
  background: #453629;
  border-radius: 1px;
}
.c1 .wick { bottom: 54px; } .c2 .wick { bottom: 72px; } .c3 .wick { bottom: 46px; }
.c4 .wick { bottom: 84px; } .c5 .wick { bottom: 62px; } .c6 .wick { bottom: 50px; }
.c7 .wick { bottom: 76px; }

.flame {
  position: absolute;
  bottom: var(--flame-b, 60px);
  width: 11px;
  height: 18px;
  transform-origin: 50% 100%;
  background: radial-gradient(circle at 50% 72%,
      #fff8d9 0%, #ffd97e 42%, #ffa53d 72%, rgba(255, 122, 41, 0) 100%);
  border-radius: 50% 50% 50% 50% / 64% 64% 36% 36%;
  filter: blur(0.4px);
  animation: flicker 2.6s ease-in-out infinite;
}
.c1 .flame { bottom: 60px; animation-delay: 0s; }
.c2 .flame { bottom: 78px; animation-delay: 0.5s; animation-duration: 2.2s; }
.c3 .flame { bottom: 52px; animation-delay: 1.1s; animation-duration: 3s; }
.c4 .flame { bottom: 90px; animation-delay: 0.3s; animation-duration: 2.4s; }
.c5 .flame { bottom: 68px; animation-delay: 1.6s; animation-duration: 2.8s; }
.c6 .flame { bottom: 56px; animation-delay: 0.8s; animation-duration: 2.3s; }
.c7 .flame { bottom: 82px; animation-delay: 1.3s; animation-duration: 2.7s; }

@keyframes flicker {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  22%      { transform: scale(1.06, 0.94) skewX(2.5deg); }
  48%      { transform: scale(0.93, 1.09) skewX(-2.5deg); }
  74%      { transform: scale(1.04, 0.97) skewX(1.5deg); }
}

/* soft warm halo behind each flame, and light pooled on the ground */
.candle::before {
  content: "";
  position: absolute;
  bottom: var(--halo-b, 64px);
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 176, 84, 0.34) 0%, transparent 70%);
}
.c1::before { bottom: 62px; } .c2::before { bottom: 80px; } .c3::before { bottom: 54px; }
.c4::before { bottom: 92px; } .c5::before { bottom: 70px; } .c6::before { bottom: 58px; }
.c7::before { bottom: 84px; }

.ground-glow {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 130px;
  background:
    radial-gradient(58% 90px at 50% 100%, rgba(255, 170, 76, 0.16) 0%, transparent 70%),
    linear-gradient(180deg, transparent 0%, rgba(10, 10, 22, 0.55) 100%);
}

/* ---------- Theme toggle ---------- */

#theme-toggle {
  position: fixed;
  top: 50%;
  right: clamp(10px, 2.4vw, 22px);
  transform: translateY(-50%);
  z-index: 20;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background-color 0.4s, color 0.4s, border-color 0.4s, transform 0.2s;
}

#theme-toggle:hover { transform: translateY(-50%) scale(1.06); }
#theme-toggle:active { transform: translateY(-50%) scale(0.96); }

#theme-toggle svg { width: 22px; height: 22px; }

#theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] #theme-toggle .icon-sun  { display: block; }
html[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* ---------- Layout ---------- */

.page {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: clamp(3.5rem, 10vh, 6rem) clamp(1.25rem, 5vw, 2rem) 9.5rem;
  display: flex;
  flex-direction: column;
  gap: clamp(3rem, 8vh, 4.5rem);
}

/* ---------- Hero ---------- */

.hero { text-align: center; }

.hero-sprigs {
  display: flex;
  justify-content: center;
  gap: clamp(1rem, 6vw, 3rem);
  color: var(--accent-2);
  opacity: 0.8;
  margin-bottom: 1.4rem;
}

.sprig { width: clamp(90px, 16vw, 150px); height: auto; }
.sprig.flip { transform: scaleX(-1); }
.sprig use { fill-opacity: 0.55; }

.eyebrow {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.9rem;
}

.names {
  font-size: clamp(2.6rem, 8vw, 4.3rem);
  line-height: 1.15;
  margin: 0 0 1.1rem;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.date-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  color: var(--muted);
  margin: 0;
}

/* Divider: hairline — leaf pair — hairline */
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--accent-2);
  margin-top: 2rem;
}

.divider-line {
  display: block;
  width: clamp(56px, 12vw, 110px);
  height: 1px;
  background: currentColor;
  opacity: 0.45;
}

.divider-leaf { width: 40px; height: 20px; opacity: 0.7; }

/* ---------- Story ---------- */

.story { text-align: center; }

.story-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  line-height: 1.7;
  color: var(--ink);
  max-width: 34ch;
  margin: 0 auto;
}

.story-hint {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ---------- Details ---------- */

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

.detail-card {
  text-align: center;
  padding: 1.6rem 1rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background-color 0.4s, border-color 0.4s, transform 0.25s;
}

.detail-card:hover { transform: translateY(-3px); }

.detail-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.65rem;
}

.detail-value {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 0 0 0.3rem;
}

.detail-sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
  overflow-wrap: anywhere;
}

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

.rsvp { scroll-margin-top: 2rem; }

.rsvp-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: clamp(1.8rem, 5vw, 2.8rem);
  text-align: center;
  transition: background-color 0.4s, border-color 0.4s;
}

.rsvp-title {
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  margin: 0 0 0.4rem;
}

.rsvp-deadline {
  font-style: italic;
  font-family: var(--serif);
  color: var(--muted);
  font-size: 0.98rem;
  margin: 0 0 2rem;
}

/* Fields */

.field { margin: 0 0 1.8rem; text-align: left; }

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

input[type="text"] {
  display: block;
  width: 100%;
  padding: 0.65rem 0.1rem;
  font: inherit;
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--input-underline);
  border-radius: 0;
  outline: none;
  transition: border-color 0.3s;
}

input[type="text"]::placeholder { color: var(--muted); opacity: 0.65; font-style: italic; }
input[type="text"]:focus { border-bottom-color: var(--accent); }
input[type="text"].invalid { border-bottom-color: var(--error); }

fieldset.field { border: none; padding: 0; margin-inline: 0; }
legend.field-label { padding: 0; }

/* Yes / No choice pills */
.choices {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.choice {
  position: relative;
  flex: 1 1 180px;
  cursor: pointer;
}

.choice input {
  /* Hide visually but keep keyboard/screen-reader accessible:
     opacity (not display/visibility/clip) keeps the control exposed. */
  position: absolute;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.choice span {
  display: block;
  text-align: center;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--choice-ink);
  background: var(--choice-bg);
  transition: background-color 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.choice:hover span { border-color: var(--accent); }

.choice input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fdfaf4;
  box-shadow: 0 6px 18px rgba(185, 130, 115, 0.35);
}

html[data-theme="dark"] .choice input:checked + span {
  color: #241d12;
  box-shadow: 0 6px 18px rgba(217, 165, 160, 0.25);
}

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

.field-error {
  margin: 0.55rem 0 0;
  font-size: 0.86rem;
  color: var(--error);
}

.turnstile-field { display: flex; justify-content: center; }

/* Submit button */

.submit-btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 0.95rem 2.6rem;
  color: var(--btn-ink);
  background: var(--btn-bg);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background-color 0.4s, color 0.4s, transform 0.2s, opacity 0.2s;
}

.submit-btn:hover:not(:disabled) { transform: translateY(-2px); }
.submit-btn:active:not(:disabled) { transform: translateY(0); }

.submit-btn:disabled { opacity: 0.55; cursor: wait; }

.form-status { margin: 1.1rem 0 0; font-size: 0.95rem; min-height: 1.4em; }
.form-status.error { color: var(--error); }

/* Success panel */

.rsvp-success { padding: 0.5rem 0 0.5rem; }

.success-title {
  font-size: clamp(1.6rem, 4vw, 2rem);
  margin: 0 0 0.6rem;
}

.success-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.rsvp-success .divider { margin-top: 1.6rem; }

/* Privacy + footer */

.privacy-note {
  text-align: center;
  font-size: 0.84rem;
  color: var(--muted);
  margin: 1.3rem auto 0;
  max-width: 46ch;
}

.footer { text-align: center; }

.footer-note {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .details { grid-template-columns: 1fr; gap: 0.8rem; }
  .detail-card { padding: 1.2rem 1rem; }
  #theme-toggle { top: auto; bottom: 18px; right: 14px; transform: none; }
  #theme-toggle:hover, #theme-toggle:active { transform: scale(1.05); }
  .page { padding-bottom: 11rem; } /* room for candles + toggle */
  .hero-sprigs { gap: 0.6rem; }
  .moon { width: 90px; height: 90px; right: 8%; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .flame, .stars { animation: none; }
  .detail-card, .submit-btn, #theme-toggle { transition: none; }
  .detail-card:hover, .submit-btn:hover:not(:disabled) { transform: none; }
}
