/* R31 表白/道歉 H5 · 13 套主题 */

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.4s ease, color 0.4s ease;
  padding-bottom: calc(6.5rem + env(safe-area-inset-bottom));
}

body.showcase-back-active { padding-top: calc(44px + env(safe-area-inset-top, 0)); }

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

.section {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem;
}

.section__title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 1.75rem;
  color: var(--primary);
  letter-spacing: 0.08em;
}

/* Confession themes */
body[data-theme='blush-pink'] {
  --primary: #F472B6; --primary-light: #FBCFE8; --accent: #FDF2F8;
  --bg: #FDF2F8; --bg-card: #FFFFFF; --text: #5C3D4A; --text-light: #9B8088;
  --font-title: Georgia, 'Songti SC', serif;
}
body[data-theme='rose-gold'] {
  --primary: #E8A87C; --primary-light: #F5D5C0; --accent: #FFF5EE;
  --bg: #FFF5EE; --bg-card: #FFFFFF; --text: #5C4033; --text-light: #8B7355;
  --font-title: Georgia, 'Songti SC', serif;
}
body[data-theme='cherry-red'] {
  --primary: #E63946; --primary-light: #FECACA; --accent: #FFF0F0;
  --bg: #FFF0F0; --bg-card: #FFFFFF; --text: #4A2825; --text-light: #8B5E5A;
  --font-title: Georgia, 'Songti SC', serif;
}
body[data-theme='lavender-dream'] {
  --primary: #A78BFA; --primary-light: #DDD6FE; --accent: #F5F3FF;
  --bg: #F5F3FF; --bg-card: #FFFFFF; --text: #4C3D5C; --text-light: #7B6B8B;
  --font-title: Georgia, 'Songti SC', serif;
}
body[data-theme='sky-blue'] {
  --primary: #60A5FA; --primary-light: #BFDBFE; --accent: #EFF6FF;
  --bg: #EFF6FF; --bg-card: #FFFFFF; --text: #1E3A5F; --text-light: #64748B;
  --font-title: -apple-system, BlinkMacSystemFont, sans-serif;
}
body[data-theme='mint-green'] {
  --primary: #34D399; --primary-light: #A7F3D0; --accent: #ECFDF5;
  --bg: #ECFDF5; --bg-card: #FFFFFF; --text: #3A4D40; --text-light: #6B8070;
  --font-title: 'KaiTi', 'STKaiti', serif;
}
body[data-theme='retro-gold'] {
  --primary: #D4A853; --primary-light: #FEF3C7; --accent: #FFF8E7;
  --bg: #FFF8E7; --bg-card: #FFFFFF; --text: #4A3D28; --text-light: #8B7B5A;
  --font-title: Georgia, 'Songti SC', serif;
}
body[data-theme='pure-minimal'] {
  --primary: #374151; --primary-light: #E5E7EB; --accent: #FAFAFA;
  --bg: #FAFAFA; --bg-card: #FFFFFF; --text: #111827; --text-light: #6B7280;
  --font-title: -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Apology themes */
body[data-theme='ocean-blue'] {
  --primary: #3B82F6; --primary-light: #BFDBFE; --accent: #EFF6FF;
  --bg: #EFF6FF; --bg-card: #FFFFFF; --text: #1E3A5F; --text-light: #64748B;
  --font-title: -apple-system, BlinkMacSystemFont, sans-serif;
}
body[data-theme='deepnight-blue'] {
  --primary: #1E3A5F; --primary-light: #CBD5E1; --accent: #F0F4F8;
  --bg: #F0F4F8; --bg-card: #FFFFFF; --text: #1E293B; --text-light: #64748B;
  --font-title: Georgia, 'Songti SC', serif;
}
body[data-theme='twilight-gray'] {
  --primary: #6B7280; --primary-light: #E5E7EB; --accent: #F3F4F6;
  --bg: #F3F4F6; --bg-card: #FFFFFF; --text: #374151; --text-light: #9CA3AF;
  --font-title: -apple-system, BlinkMacSystemFont, sans-serif;
}
body[data-theme='warm-apricot'] {
  --primary: #F59E0B; --primary-light: #FDE68A; --accent: #FFFBEB;
  --bg: #FFFBEB; --bg-card: #FFFFFF; --text: #78350F; --text-light: #A16207;
  --font-title: Georgia, 'Songti SC', serif;
}
body[data-theme='dark-green'] {
  --primary: #059669; --primary-light: #A7F3D0; --accent: #ECFDF5;
  --bg: #ECFDF5; --bg-card: #FFFFFF; --text: #064E3B; --text-light: #047857;
  --font-title: 'KaiTi', 'STKaiti', serif;
}

/* Hero + Envelope */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  overflow: hidden;
}

.hero__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.05);
}

.hero__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.3) 0%, rgba(0,0,0,.55) 100%);
}

.hero__content {
  position: relative;
  z-index: 1;
  padding: 2rem 1.5rem;
  animation: fadeUp 0.8s ease;
}

.envelope {
  position: relative;
  width: 120px;
  height: 80px;
  margin: 0 auto 1.25rem;
  animation: envelopeFloat 1.5s ease forwards;
}

.envelope__body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--primary, #F472B6);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.envelope__flap {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 40px;
  background: var(--primary-light, #FBCFE8);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transform-origin: top center;
  animation: flapOpen 1.2s ease 0.3s forwards;
}

.envelope__letter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.75rem;
  animation: letterOut 1s ease 0.8s forwards;
  opacity: 0;
}

@keyframes envelopeFloat {
  from { opacity: 0; transform: translateY(30px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes flapOpen {
  from { transform: rotateX(0deg); }
  to { transform: rotateX(180deg); opacity: 0.6; }
}
@keyframes letterOut {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(-10px); }
}

.hero__title {
  font-family: var(--font-title);
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.hero__sub {
  font-size: 0.95rem;
  opacity: 0.92;
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

.hero__countdown {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 999px;
  font-size: 0.85rem;
  backdrop-filter: blur(4px);
  margin-bottom: 1.5rem;
}

.hero__scroll {
  display: inline-block;
  font-size: 1.5rem;
  text-decoration: none;
  color: #fff;
  animation: bounceDown 2s ease infinite;
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Letter paper */
.letter-wrap {
  position: relative;
}

.letter-paper {
  background: #FFFEF7;
  background-image: linear-gradient(rgba(212,168,83,.06) 1px, transparent 1px);
  background-size: 100% 1.75rem;
  border-radius: 4px;
  padding: 2rem 1.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.08), inset 0 0 0 1px rgba(212,168,83,.15);
  border-top: 3px solid var(--primary);
}

.letter-paper__title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  text-align: center;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.letter-para {
  font-size: 1rem;
  line-height: 2;
  min-height: 2rem;
  margin-bottom: 1.25rem;
  color: #4A3728;
}

.letter-cursor {
  display: inline;
  animation: blink 0.8s step-end infinite;
  color: var(--primary);
  font-weight: 300;
}

.letter-para.done .letter-cursor { display: none; }

@keyframes blink {
  50% { opacity: 0; }
}

.letter-signature {
  text-align: right;
  font-family: 'KaiTi', 'STKaiti', cursive;
  font-size: 1.05rem;
  color: #6B5344;
  margin-top: 1.5rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.letter-signature.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Password lock */
.letter-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,254,247,.92);
  backdrop-filter: blur(6px);
  border-radius: 4px;
  z-index: 2;
}

.letter-lock--fly {
  animation: lockFly 0.6s ease forwards;
}

@keyframes lockFly {
  to { opacity: 0; transform: scale(1.1) translateY(-20px); pointer-events: none; }
}

.letter-lock__box {
  width: min(100%, 280px);
  padding: 1.25rem;
  text-align: center;
}

.letter-lock__title { font-weight: 700; margin-bottom: 0.5rem; color: var(--primary); }
.letter-lock__question { font-size: 0.9rem; margin-bottom: 0.75rem; }
.letter-lock__input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--primary-light);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}
.letter-lock__hint { font-size: 0.75rem; color: var(--text-light); margin-bottom: 0.75rem; }
.letter-lock__err { font-size: 0.8rem; color: #E63946; margin-bottom: 0.5rem; }

.letter-wrap:not(.letter-wrap--unlocked) .letter-paper {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
}

/* Moments */
.moments { position: relative; padding: 0.5rem 0; }

.moment-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.moment-item.visible { opacity: 1; transform: translateY(0); }

.moment-item--right { flex-direction: row-reverse; text-align: right; }

.moment-item__date {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 4.5rem;
  padding-top: 0.5rem;
}

.moment-item__card {
  flex: 1;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.moment-item--right .moment-item__card { flex-direction: row-reverse; }

.moment-item__icon { font-size: 1.5rem; }
.moment-item__text { font-size: 0.9rem; color: var(--text-light); }

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.gallery__item {
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
}

.gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.gallery__item:active img { transform: scale(1.03); }

/* Reply buttons */
.reply-btns {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.reply-btn {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 2px solid var(--primary);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.reply-btn:active {
  background: var(--primary);
  color: #fff;
}

.wish-toggle { margin-bottom: 0.75rem; }

/* Forms */
.rsvp-form {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  margin-bottom: 1rem;
}

.rsvp-form[hidden] { display: none !important; }

.rsvp-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
  margin-top: 0.75rem;
}
.rsvp-form label:first-of-type { margin-top: 0; }

.rsvp-form input,
.rsvp-form textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--primary-light);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
}

.rsvp-form textarea { min-height: 4rem; resize: vertical; }

.btn {
  display: inline-block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

/* Wish wall */
.wish-wall {
  margin-top: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--accent);
  border-radius: 12px;
}
.wish-wall__empty {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  padding: 0.75rem;
}
.wish-item {
  padding: 0.5rem;
  border-bottom: 1px dashed rgba(0,0,0,0.1);
  font-size: 0.9rem;
  animation: wishFadeIn 0.3s ease;
}
@keyframes wishFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.wish-ticker {
  margin-top: 0.75rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--primary-light);
  padding: 0.35rem 0;
}
.wish-ticker[hidden] { display: none !important; }
.wish-ticker__track {
  display: flex;
  gap: 2rem;
  width: max-content;
  animation: wishScroll 24s linear infinite;
}
.wish-ticker__item { white-space: nowrap; font-size: 0.8rem; color: var(--text); }
@keyframes wishScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal[hidden] { display: none !important; }

.modal__box {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  max-width: 320px;
  width: 100%;
  text-align: center;
  animation: fadeUp 0.3s ease;
}

.modal__emoji { font-size: 2.5rem; margin-bottom: 0.75rem; }
.modal__text { font-size: 1rem; margin-bottom: 0.5rem; color: var(--text); }

/* Footer CTA */
.footer-cta {
  background: var(--primary);
  color: #fff;
  padding: 2.5rem 1.25rem calc(2.5rem + env(safe-area-inset-bottom));
  text-align: center;
}

.footer-cta__title { font-family: var(--font-title); font-size: 1.35rem; margin-bottom: 0.5rem; }
.footer-cta__sub { font-size: 0.9rem; opacity: 0.9; margin-bottom: 1.25rem; }
.footer-cta__btns { display: flex; flex-direction: column; gap: 0.65rem; max-width: 320px; margin: 0 auto; }
.footer-cta .btn-outline { color: #fff; border-color: rgba(255,255,255,.7); background: rgba(255,255,255,.12); }
.footer-cta__contact { margin-top: 1.25rem; font-size: 0.85rem; opacity: 0.88; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none !important; }

.lightbox__img { max-width: 92vw; max-height: 85vh; object-fit: contain; }
.lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
}
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  font-size: 1.75rem;
  cursor: pointer;
}
.lightbox__prev { left: 0.75rem; }
.lightbox__next { right: 0.75rem; }

/* Contact footer */
.contact-footer {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 950;
  padding: 0.625rem 0.75rem;
  padding-bottom: calc(0.625rem + env(safe-area-inset-bottom));
  background: #1a2744;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.contact-footer__btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  max-width: 28rem;
  margin: 0 auto;
}

.contact-footer__cta,
.contact-footer__btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 0.625rem 0.5rem;
  font-size: 0.875rem;
  text-align: center;
  text-decoration: none;
  line-height: 1.25;
  cursor: pointer;
}

.contact-footer__cta {
  background: #c41e1e;
  color: #fff;
  font-weight: 600;
}

.contact-footer__btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.contact-footer__brand {
  margin-top: 0.375rem;
  text-align: center;
  font-size: 10px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.6);
}

html.has-contact-footer .zw-root .zw-fab {
  bottom: calc(5.75rem + env(safe-area-inset-bottom));
}

/* Theme panel */
.theme-panel {
  position: fixed;
  right: 1rem;
  bottom: calc(6.25rem + env(safe-area-inset-bottom));
  z-index: 900;
}

.theme-panel__toggle {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  cursor: pointer;
}

.theme-panel__list {
  position: absolute;
  bottom: 3.25rem;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
}

.theme-panel__list[hidden] { display: none !important; }

.theme-panel__list button {
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  background: var(--swatch, #ccc);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.theme-panel__list button.active { border-color: var(--text); }

.back-top {
  position: fixed;
  right: 1rem;
  bottom: calc(10rem + env(safe-area-inset-bottom));
  z-index: 890;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
  cursor: pointer;
  font-size: 1.1rem;
}
.back-top[hidden] { display: none !important; }

.music-btn {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0));
  right: 1rem;
  z-index: 880;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.85);
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
  cursor: pointer;
  font-size: 1.1rem;
}
body.showcase-back-active .music-btn { top: calc(3.25rem + env(safe-area-inset-top, 0)); }
.music-btn[hidden] { display: none !important; }
.music-btn.playing { animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 768px) {
  .gallery { grid-template-columns: repeat(3, 1fr); gap: 0.65rem; }
  .reply-btns { flex-direction: row; flex-wrap: wrap; }
  .reply-btn { flex: 1; min-width: 140px; width: auto; }
  .footer-cta__btns { flex-direction: row; max-width: 480px; }
  .footer-cta__btns .btn { width: auto; flex: 1; }
}
