/* ── Reset & root ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --cream:          #fdf8f2;
  --parchment:      #f5eddf;
  --surface:        #ffffff;
  --ink:            #231a17;
  --ink-soft:       rgba(35,26,23,0.55);
  --ink-body:       rgba(35,26,23,0.70);
  --ink-placeholder: rgba(35,26,23,0.20);
  --ch-border:      rgba(35,26,23,0.15);
  --rose:           #c4786a;
  --rose-pale:      #f5ddd6;
  --rose-mid:       #e8b4a8;
  --rose-hover:     #b56859;
  --rose-shadow:    rgba(196,120,106,0.35);
  --rose-shadow-lg: rgba(196,120,106,0.45);
  --gold:           #c9a066;
  --gold-pale:      #f5e9d6;
  --sage:           #7d8c72;
  --sage-pale:      #dfe8d8;
  --border:         rgba(35,26,23,0.08);
}

/* ── Midnight template ── */
[data-template="midnight"] {
  --cream:          #0f0f1a;
  --parchment:      #161625;
  --surface:        #1c1c2e;
  --ink:            #f0ece4;
  --ink-soft:       rgba(240,236,228,0.50);
  --ink-body:       rgba(240,236,228,0.70);
  --ink-placeholder: rgba(240,236,228,0.20);
  --ch-border:      rgba(240,236,228,0.15);
  --rose:           #c9a066;
  --rose-pale:      rgba(201,160,102,0.15);
  --rose-mid:       rgba(201,160,102,0.35);
  --rose-hover:     #b08040;
  --rose-shadow:    rgba(201,160,102,0.30);
  --rose-shadow-lg: rgba(201,160,102,0.40);
  --gold:           #c9a066;
  --gold-pale:      rgba(201,160,102,0.12);
  --sage:           #7d9b8c;
  --sage-pale:      rgba(125,155,140,0.15);
  --border:         rgba(240,236,228,0.08);
}

/* ── Garden template ── */
[data-template="garden"] {
  --cream:          #f4f7f0;
  --parchment:      #e8f0e0;
  --surface:        #ffffff;
  --ink:            #1a2416;
  --ink-soft:       rgba(26,36,22,0.55);
  --ink-body:       rgba(26,36,22,0.70);
  --ink-placeholder: rgba(26,36,22,0.20);
  --ch-border:      rgba(26,36,22,0.15);
  --rose:           #6b9e5e;
  --rose-pale:      #deecd8;
  --rose-mid:       #b8d4ae;
  --rose-hover:     #5a8a4e;
  --rose-shadow:    rgba(107,158,94,0.30);
  --rose-shadow-lg: rgba(107,158,94,0.40);
  --gold:           #a07840;
  --gold-pale:      #ede0cc;
  --sage:           #8b7355;
  --sage-pale:      #e8ddd0;
  --border:         rgba(26,36,22,0.08);
}

html {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 100%;
}
html.overlay-open { overflow: hidden; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Jost', sans-serif;
  font-weight: 300;
  height: 100%;
}

/* ── Music bar ── */
.music-bar {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 18px 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-soft);
  box-shadow: 0 2px 16px rgba(35,26,23,0.08);
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.music-bar-icon {
  width: 22px; height: 22px;
  background: var(--rose-pale);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}
.music-wave {
  display: flex; align-items: center;
  gap: 2px; height: 12px;
}
.wave-bar {
  width: 2px;
  background: var(--rose);
  border-radius: 2px;
  animation: wave var(--d, 0.8s) ease-in-out infinite alternate;
}
@keyframes wave {
  from { height: 3px; }
  to   { height: var(--h, 12px); }
}

/* ── Chapter dots ── */
.chapters {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
}
.ch {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  border: 1px solid var(--ch-border);
  cursor: pointer;
  transition: all 0.3s;
}
.ch.active { background: var(--rose); border-color: var(--rose); transform: scale(1.5); }
.ch.done   { background: var(--rose-mid); border-color: var(--rose-mid); }

/* ── Sections base ── */
.proposal-section {
  scroll-snap-align: start;
  height: 100vh;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Botanical SVG ── */
.botanical {
  position: absolute;
  opacity: 0.12;
  pointer-events: none;
}
.botanical-tl { top: 0; left: 0; }
.botanical-tr { top: 0; right: 0; transform: rotate(90deg); }
.botanical-bl { bottom: 0; left: 0; transform: rotate(270deg); }
.botanical-br { bottom: 0; right: 0; transform: rotate(180deg); }

/* ── Animations ── */
@keyframes lift {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Cover ── */
.proposal-section--cover { background: var(--cream); flex-direction: column; }
.cover-envelope { position: relative; text-align: center; z-index: 2; padding: 40px; }

.cover-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--rose); margin-bottom: 32px;
  opacity: 0; animation: lift 1s ease 0.4s forwards;
}
.cover-tag-line { width: 24px; height: 1px; background: var(--rose); }

.cover-for {
  font-size: 13px; font-weight: 300;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 12px;
  opacity: 0; animation: lift 1s ease 0.7s forwards;
}
.cover-name {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(72px, 14vw, 144px);
  font-weight: 600; color: var(--ink);
  line-height: 1; margin-bottom: 20px;
  opacity: 0; animation: lift 1.4s ease 0.9s forwards;
  letter-spacing: -2px;
}
.cover-divider {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 20px;
  opacity: 0; animation: lift 1s ease 1.3s forwards;
}
.cover-divider-line {
  width: 48px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--rose-mid));
}
.cover-divider-line.right {
  background: linear-gradient(90deg, var(--rose-mid), transparent);
}
.cover-divider-ornament { font-size: 16px; color: var(--rose); opacity: 0.6; }
.cover-from {
  font-size: 13px; color: var(--ink-soft); letter-spacing: 0.08em; margin-bottom: 52px;
  opacity: 0; animation: lift 1s ease 1.5s forwards;
}
.cover-begin {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  opacity: 0; animation: lift 1s ease 2.2s forwards;
}
.cover-begin-btn {
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--rose); background: var(--rose-pale); border: none;
  padding: 10px 28px; border-radius: 100px;
  cursor: pointer; font-family: 'Jost', sans-serif; transition: all 0.3s;
}
.cover-begin-btn:hover { background: var(--rose-mid); color: white; }

/* ── Letter ── */
.proposal-section--letter {
  background: var(--surface);
  align-items: flex-start;
  overflow-y: auto;
  scroll-snap-align: start;
}
.paper {
  max-width: 620px; width: 100%;
  margin: 0 auto; padding: 80px 64px;
  position: relative; z-index: 2;
}
.paper::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: 32px;
  width: 1px; background: var(--rose-pale);
}
.section-chapter {
  font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--rose); margin-bottom: 28px;
  display: flex; align-items: center; gap: 10px;
}
.section-chapter::after {
  content: ''; flex: 1; height: 1px; background: var(--rose-pale);
}
.section-chapter--sage { color: var(--sage); }
.section-chapter--sage::after { background: var(--sage-pale); }

.letter-heading {
  font-family: 'Lora', serif;
  font-size: clamp(24px, 3.5vw, 38px);
  font-weight: 400; font-style: italic;
  line-height: 1.25; color: var(--ink); margin-bottom: 32px;
}
.letter-content {
  font-size: 16px; color: var(--ink-body);
  line-height: 2; font-weight: 300;
}
.letter-content p { margin-bottom: 20px; }
.letter-content p:first-child::first-letter {
  font-family: 'Lora', serif;
  font-size: 58px; font-weight: 500;
  float: left; line-height: 0.8;
  margin-right: 8px; margin-top: 10px;
  color: var(--rose);
}
.letter-sig { margin-top: 40px; display: flex; flex-direction: column; gap: 4px; }
.letter-sig-name {
  font-family: 'Dancing Script', cursive;
  font-size: 38px; font-weight: 600; color: var(--ink); line-height: 1;
}
.letter-sig-note { font-size: 12px; color: var(--ink-soft); letter-spacing: 0.06em; }

/* ── Gallery ── */
.proposal-section--gallery { background: var(--parchment); flex-direction: column; padding: 0; }
.gallery-label {
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--rose); z-index: 3; white-space: nowrap;
}
.polaroid-strip {
  display: flex; gap: 20px;
  padding: 80px 48px 48px;
  overflow-x: auto; align-items: center;
  width: 100%; height: 100%;
  scrollbar-width: none; cursor: grab;
}
.polaroid-strip:active { cursor: grabbing; }
.polaroid-strip::-webkit-scrollbar { display: none; }
.polaroid {
  background: white;
  padding: 14px 14px 40px;
  box-shadow: 0 4px 24px rgba(35,26,23,0.12);
  flex-shrink: 0; position: relative; transition: transform 0.3s;
}
.polaroid:nth-child(odd)  { transform: rotate(-1.5deg); }
.polaroid:nth-child(even) { transform: rotate(1deg); }
.polaroid:hover { transform: rotate(0) scale(1.03); z-index: 10; }
.polaroid-frame {
  width: 220px; height: 220px;
  overflow: hidden; position: relative;
  background: var(--rose-pale);
}
.polaroid-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.polaroid-caption {
  position: absolute; bottom: 10px; left: 14px; right: 14px;
  font-family: 'Dancing Script', cursive;
  font-size: 16px; color: var(--ink-soft); text-align: center;
}
.gallery-scroll-hint {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft); opacity: 0.5;
}

/* ── Timeline ── */
.proposal-section--timeline {
  background: var(--cream);
  align-items: flex-start; overflow-y: auto;
}
.tl-wrap {
  max-width: 560px; width: 100%;
  margin: 0 auto; padding: 80px 48px;
  position: relative; z-index: 2;
}
.tl-event {
  display: grid; grid-template-columns: 80px 1fr;
  gap: 24px; margin-bottom: 40px; align-items: start;
}
.tl-left { text-align: right; padding-top: 4px; }
.tl-month {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--rose); display: block;
}
.tl-year {
  font-size: 22px; font-family: 'Lora', serif;
  font-style: italic; color: var(--ink-soft); line-height: 1.1;
}
.tl-right {
  border-left: 1px solid var(--border);
  padding-left: 24px; position: relative;
}
.tl-right::before {
  content: ''; position: absolute;
  left: -4px; top: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rose-pale); border: 1px solid var(--rose-mid);
}
.tl-title {
  font-family: 'Lora', serif;
  font-size: 18px; font-style: italic;
  color: var(--ink); margin-bottom: 8px; line-height: 1.3;
}
.tl-body { font-size: 13px; color: var(--ink-soft); line-height: 1.8; }
.tl-photo { margin-top: 12px; width: 100%; border-radius: 6px; }

/* ── Music ── */
.proposal-section--music { background: var(--cream); }
.music-embed-wrap {
  width: 100%; max-width: 560px; padding: 40px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.music-embed-label {
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--rose);
}
.music-embed-track {
  font-family: 'Lora', serif; font-style: italic;
  font-size: 20px; color: var(--ink-soft);
}

/* ── Video ── */
.proposal-section--video { background: #0f0c0a; }
.recipient-video {
  width: 100%; max-height: 100vh; display: block; outline: none;
}

/* ── Quiz ── */
.proposal-section--quiz { background: var(--surface); }
.envelope {
  position: relative; z-index: 2; text-align: center;
  max-width: 460px; width: 100%; padding: 48px 40px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 8px 40px var(--border);
}
.envelope::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--rose-pale), var(--rose), var(--rose-pale));
}
.envelope-wax {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--rose-pale); border: 2px solid var(--rose-mid);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
}
.envelope-wax-letter {
  font-family: 'Dancing Script', cursive; font-size: 24px; color: var(--rose);
}
.envelope-tag {
  font-size: 9px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--rose); margin-bottom: 16px;
}
.envelope-question {
  font-family: 'Lora', serif;
  font-size: clamp(18px, 2.5vw, 26px); font-style: italic;
  color: var(--ink); line-height: 1.4; margin-bottom: 28px;
}
.envelope-error {
  font-size: 12px; color: var(--rose); font-style: italic; margin-bottom: 12px;
}
.envelope-hint {
  font-size: 12px; color: var(--ink-soft); font-style: italic; margin-bottom: 20px;
  padding: 10px 16px; background: var(--gold-pale); border-radius: 6px;
}
.envelope-input {
  width: 100%; background: var(--cream);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 18px; font-size: 15px; color: var(--ink);
  font-family: 'Lora', serif; font-style: italic; text-align: center;
  outline: none; margin-bottom: 14px; transition: border-color 0.3s;
}
.envelope-input:focus { border-color: var(--rose-mid); }
.envelope-input::placeholder { color: var(--ink-placeholder); }
.envelope-input--error { border-color: var(--rose-mid); background: var(--rose-pale); }
.envelope-btn {
  width: 100%; background: var(--rose); color: white;
  border: none; border-radius: 8px; padding: 14px;
  font-size: 13px; font-weight: 500; letter-spacing: 0.08em;
  cursor: pointer; font-family: 'Jost', sans-serif; transition: all 0.3s;
}
.envelope-btn:hover { background: var(--rose-hover); }

.quiz-passed-card, .quiz-ended-card {
  text-align: center; padding: 32px;
}
.quiz-passed-card p, .quiz-ended-card p {
  font-family: 'Lora', serif; font-style: italic;
  font-size: 20px; color: var(--sage);
}

/* ── Reveal ── */
.proposal-section--reveal { background: var(--parchment); }
.reveal-inner {
  position: relative; z-index: 2; text-align: center;
  max-width: 640px; padding: 40px;
}
.reveal-intro {
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--rose); margin-bottom: 40px;
  opacity: 0; animation: lift 1s ease 0.2s forwards;
}
.reveal-question {
  font-family: 'Lora', serif;
  font-size: clamp(40px, 7vw, 80px);
  font-weight: 500; font-style: italic;
  color: var(--ink); line-height: 1.15; margin-bottom: 16px;
  opacity: 0; animation: lift 1.6s ease 0.5s forwards;
}
.reveal-question em { color: var(--rose); font-weight: 400; }
.reveal-from {
  font-family: 'Dancing Script', cursive; font-size: 22px;
  color: var(--ink-soft); margin-bottom: 52px;
  opacity: 0; animation: lift 1s ease 1s forwards;
}
.reveal-actions {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  opacity: 0; animation: lift 1s ease 1.4s forwards;
}
.btn-yes {
  background: var(--rose); color: white; border: none;
  border-radius: 100px; padding: 18px 64px;
  font-size: 16px; font-weight: 400;
  font-family: 'Lora', serif; font-style: italic;
  cursor: pointer; transition: all 0.3s; letter-spacing: 0.02em;
  box-shadow: 0 4px 20px var(--rose-shadow);
}
.btn-yes:hover { background: var(--rose-hover); transform: translateY(-2px); box-shadow: 0 8px 30px var(--rose-shadow-lg); }
.btn-no {
  background: transparent; border: none;
  font-size: 12px; color: var(--ink-soft);
  cursor: pointer; font-family: 'Jost', sans-serif;
  letter-spacing: 0.06em; padding: 8px; transition: color 0.3s;
}
.btn-no:hover { color: var(--ink); }

/* ── Reveal confirmation ── */
.reveal-confirm { text-align: center; }
.reveal-confirm-text {
  font-size: 12px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 20px;
  opacity: 0; animation: lift 0.5s ease forwards;
}

/* ── Yes overlay ── */
.yes-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s ease;
  text-align: center; padding: 40px;
}
.yes-overlay.show { opacity: 1; pointer-events: all; }
.yes-ornament {
  font-family: 'Dancing Script', cursive; font-size: 80px;
  color: var(--rose); line-height: 1; margin-bottom: 8px;
  animation: yes-pop 0.6s cubic-bezier(0.34,1.56,0.64,1) 0.3s both;
}
.yes-headline {
  font-family: 'Lora', serif;
  font-size: clamp(36px, 7vw, 64px); font-style: italic;
  color: var(--ink); line-height: 1.1; margin-bottom: 20px;
  animation: lift 1s ease 0.6s both;
}
.yes-sub {
  font-size: 15px; color: var(--ink-soft);
  max-width: 360px; line-height: 1.8;
  animation: lift 1s ease 0.9s both;
}
@keyframes yes-pop {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Confetti ── */
.confetti-piece {
  position: fixed; pointer-events: none;
  animation: confetti-fall var(--dur) ease-in var(--delay) both;
  z-index: 600; border-radius: var(--r, 2px);
}
@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(var(--rot)); opacity: 0.6; }
}

/* ── Responded state ── */
.reveal-responded {
  text-align: center; z-index: 2; position: relative;
}
.reveal-responded-emoji { font-family: 'Dancing Script', cursive; font-size: 80px; color: var(--rose); margin-bottom: 16px; }
.reveal-responded-text {
  font-family: 'Lora', serif; font-style: italic;
  font-size: clamp(28px, 4vw, 44px); color: var(--ink);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .paper { padding: 60px 32px 60px 52px; }
  .tl-wrap { padding: 60px 24px; }
  .chapters { right: 12px; }
  .polaroid-frame { width: 180px; height: 180px; }
}

/* ── Preview banner ── */
.preview-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: rgba(28, 17, 24, 0.92);
  backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 10px 20px;
}
.preview-banner-close {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.2s;
}
.preview-banner-close:hover { color: #fff; }

.reveal-actions--preview { opacity: 0.4; }
