/* ================================================
   DATE INVITE — THREE PHASES
   Phase 0: Folded note on the desk
   Phase 1: Unfolded note with crease lines
   Phase 2: Warm luxury editorial (the reveal)
   ================================================ */

:root {
  /* Note palette */
  --paper: #faf6f0;
  --paper-line: #c5d5e8;
  --paper-margin: #d4726a;
  --pencil: #3a3a3a;
  --ink-blue: #2b4b8c;
  --ink-red: #c0392b;

  /* Reveal palette */
  --night: #131110;
  --night-warm: #1a1714;
  --gold: #d4a853;
  --gold-dim: #a07d3a;
  --burgundy: #8c2f39;
  --cream: #f5efe6;
  --cream-dim: rgba(245, 239, 230, 0.5);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  font-family: 'Homemade Apple', cursive;
  background: #d4c5b2;
}

/* ---- DESK BACKGROUND ---- */

.desk {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(180, 160, 130, 0.4) 0%, transparent 70%),
    linear-gradient(180deg, #c9b99a 0%, #b8a88e 50%, #a89878 100%);
  z-index: 0;
}

.desk::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ================================================
   PHASE 0: FOLDED NOTE
   ================================================ */

.folded {
  position: relative;
  z-index: 10;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: foldedEntrance 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.folded.hidden {
  display: none;
}

@keyframes foldedEntrance {
  from {
    opacity: 0;
    transform: scale(0.8) rotate(-4deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(-1.5deg);
  }
}

.folded-paper {
  position: relative;
  width: 180px;
  height: 160px;
  background: var(--paper);
  border-radius: 2px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.06),
    0 2px 4px rgba(0,0,0,0.06),
    0 4px 8px rgba(0,0,0,0.08),
    0 8px 20px rgba(0,0,0,0.1),
    /* Layered paper thickness effect */
    2px 2px 0 #f0e8dc,
    4px 4px 0 #e8dfcf,
    5px 5px 0 #dfd5c4,
    6px 6px 2px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.folded:hover .folded-paper,
.folded:focus .folded-paper {
  transform: scale(1.04) rotate(1deg);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.06),
    0 4px 8px rgba(0,0,0,0.08),
    0 8px 16px rgba(0,0,0,0.1),
    0 16px 32px rgba(0,0,0,0.12),
    2px 2px 0 #f0e8dc,
    4px 4px 0 #e8dfcf,
    5px 5px 0 #dfd5c4,
    6px 6px 4px rgba(0,0,0,0.15);
}

.folded:active .folded-paper {
  transform: scale(0.97);
}

.folded-texture {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* Fold crease marks on the folded note */
.folded-edges {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.folded-edge {
  position: absolute;
  background: rgba(0,0,0,0.04);
}

.folded-edge-h {
  left: 8px;
  right: 8px;
  top: 50%;
  height: 1px;
  background: linear-gradient(to right,
    transparent, rgba(0,0,0,0.06) 15%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.06) 85%, transparent);
  box-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.folded-edge-v {
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 1px;
  background: linear-gradient(to bottom,
    transparent, rgba(0,0,0,0.06) 15%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.06) 85%, transparent);
  box-shadow: 1px 0 0 rgba(255,255,255,0.5);
}

.folded-to {
  font-family: 'Homemade Apple', cursive;
  font-size: 1.5rem;
  color: var(--pencil);
  position: relative;
  z-index: 1;
}

.folded-from {
  font-family: 'Homemade Apple', cursive;
  font-size: 1rem;
  color: #8a7e72;
  position: relative;
  z-index: 1;
}

.folded-hint {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b5a898;
  position: relative;
  z-index: 1;
  animation: hintPulse 2.5s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---- Unfold animation ---- */

.folded.unfolding .folded-paper {
  animation: unfoldNote 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes unfoldNote {
  0% {
    transform: scale(1) rotate(0deg);
  }
  30% {
    transform: scale(1.05) rotate(2deg);
  }
  60% {
    transform: scale(1.8) rotate(-1deg);
    opacity: 1;
  }
  100% {
    transform: scale(2.5) rotate(0deg);
    opacity: 0;
  }
}

/* ================================================
   PHASE 1: THE UNFOLDED NOTE
   ================================================ */

.note {
  position: relative;
  z-index: 10;
  width: 92%;
  max-width: 460px;
  background: var(--paper);
  padding: 50px 40px 40px 52px;
  transform: rotate(-2deg);
  box-shadow:
    1px 2px 4px rgba(0,0,0,0.08),
    3px 6px 20px rgba(0,0,0,0.12),
    8px 14px 40px rgba(0,0,0,0.08);

  /* Lined paper */
  background-image:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      var(--paper-line) 31px,
      var(--paper-line) 32px
    );
  background-position: 0 48px;
  background-color: var(--paper);

  /* Red margin */
  border-left: 3px solid var(--paper-margin);

  /* Entrance from unfold */
  transition: transform 0.8s cubic-bezier(0.4, 0, 0, 1), opacity 0.8s ease;
}

.note.hidden {
  display: none;
}

.note.entering {
  display: block;
  animation: noteFromUnfold 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes noteFromUnfold {
  from {
    opacity: 0;
    transform: rotate(-1deg) scale(0.6);
  }
  to {
    opacity: 1;
    transform: rotate(-2deg) scale(1);
  }
}

/* Paper texture overlay */
.paper-texture {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* ---- FOLD CREASE LINES ---- */

.crease {
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

.crease-h {
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(to right,
    transparent 0%,
    rgba(0,0,0,0.04) 5%,
    rgba(0,0,0,0.07) 20%,
    rgba(0,0,0,0.08) 50%,
    rgba(0,0,0,0.07) 80%,
    rgba(0,0,0,0.04) 95%,
    transparent 100%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6),
    0 -1px 0 rgba(0,0,0,0.02);
}

.crease-v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(0,0,0,0.04) 5%,
    rgba(0,0,0,0.07) 20%,
    rgba(0,0,0,0.08) 50%,
    rgba(0,0,0,0.07) 80%,
    rgba(0,0,0,0.04) 95%,
    transparent 100%);
  box-shadow:
    1px 0 0 rgba(255,255,255,0.6),
    -1px 0 0 rgba(0,0,0,0.02);
}

/* Binder holes */
.note-holes {
  position: absolute;
  left: -2px;
  top: 60px;
  display: flex;
  flex-direction: column;
  gap: 68px;
}

.hole {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid #c5bba8;
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.1);
  margin-left: -8px;
}

/* ---- NOTE CONTENT ---- */

.note-content {
  position: relative;
}

.note-to {
  font-size: 1.1rem;
  color: var(--ink-blue);
  margin-bottom: 22px;
  opacity: 0;
}

.note.entering .note-to {
  animation: pencilWrite 0.6s ease 0.4s forwards;
}

.note-question {
  font-size: 1.45rem;
  color: var(--pencil);
  text-align: center;
  line-height: 1.9;
  margin: 16px 0 8px;
  opacity: 0;
}

.note.entering .note-question {
  animation: pencilWrite 0.6s ease 0.7s forwards;
}

.note-when {
  font-size: 1.15rem;
  color: var(--ink-red);
  text-align: center;
  margin-bottom: 28px;
  opacity: 0;
  position: relative;
}

.note.entering .note-when {
  animation: pencilWrite 0.6s ease 1s forwards;
}

.note-when::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background: var(--ink-red);
  opacity: 0.4;
  border-radius: 1px;
}

@keyframes pencilWrite {
  from {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(1px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* ---- CHOICES ---- */

.choices {
  display: flex;
  justify-content: center;
  gap: 44px;
  margin: 28px 0 18px;
  opacity: 0;
}

.note.entering .choices {
  animation: pencilWrite 0.6s ease 1.3s forwards;
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.choice:active {
  transform: scale(0.94);
}

.circle-svg {
  width: 90px;
  height: 90px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.drawn-circle {
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.choice-label {
  font-family: 'Homemade Apple', cursive;
  font-size: 1.35rem;
  color: var(--pencil);
  padding: 18px 22px;
  position: relative;
  z-index: 1;
}

/* Yes hover — hint of the circle */
#yes-choice:hover .drawn-circle,
#yes-choice:focus .drawn-circle {
  stroke-dashoffset: 200;
}

/* Yes circled state — full circle draw */
#yes-choice.circled .drawn-circle {
  stroke-dashoffset: 0;
  stroke-width: 3.5;
}

/* No choice */
#no-choice {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

/* ---- DOODLES ---- */

.doodle {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.note.entering .doodle-arrow {
  animation: doodleFade 0.5s ease 1.8s forwards;
}

.note.entering .doodle-heart {
  animation: doodleFade 0.5s ease 2s forwards;
}

.note.entering .doodle-star {
  animation: doodleFade 0.5s ease 2.2s forwards;
}

.doodle-arrow {
  width: 50px;
  bottom: 8px;
  right: -8px;
  transform: rotate(12deg);
}

.doodle-heart {
  width: 28px;
  top: 10px;
  right: 22px;
}

.doodle-star {
  width: 22px;
  bottom: 14px;
  left: 8px;
}

@keyframes doodleFade {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 0.35; transform: scale(1); }
}

/* ---- NOTE EXIT ---- */

.note.folding {
  transform: rotate(-2deg) translateY(-30px) scale(0.85);
  opacity: 0;
  pointer-events: none;
}

/* ================================================
   PHASE 2: THE REVEAL
   ================================================ */

.reveal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--night);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s ease, visibility 0s 1s;
}

.reveal.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 1.2s ease, visibility 0s 0s;
}

/* Film grain texture */
.reveal-grain {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: overlay;
}

/* Warm vignette */
.reveal::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 168, 83, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(140, 47, 57, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 1;
}

.reveal-content {
  position: relative;
  z-index: 2;
  width: 90%;
  max-width: 520px;
  padding: 60px 0 80px;
}

/* ---- HEADER ---- */

.reveal-header {
  text-align: center;
  margin-bottom: 50px;
}

.reveal-eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(20px);
}

.reveal.active .reveal-eyebrow {
  animation: revealUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
}

.reveal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 3.2rem;
  font-weight: 300;
  color: var(--cream);
  letter-spacing: -0.02em;
  line-height: 1.1;
  opacity: 0;
  transform: translateY(20px);
}

.reveal.active .reveal-title {
  animation: revealUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
}

.reveal-divider {
  margin: 20px auto;
  width: 120px;
  opacity: 0;
}

.reveal.active .reveal-divider {
  animation: revealFade 1s ease 0.8s forwards;
}

.reveal-date {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-weight: 400;
  font-style: italic;
  color: var(--cream-dim);
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(20px);
}

.reveal.active .reveal-date {
  animation: revealUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.9s forwards;
}

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes revealFade {
  to { opacity: 1; }
}

/* ---- TIMELINE ---- */

.timeline {
  position: relative;
  padding-left: 32px;
  margin: 40px 0;
}

.timeline-line {
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(to bottom, var(--gold), var(--gold-dim), transparent);
  transform: scaleY(0);
  transform-origin: top;
}

.reveal.active .timeline-line {
  animation: lineGrow 1.5s cubic-bezier(0.22, 1, 0.36, 1) 1s forwards;
}

@keyframes lineGrow {
  to { transform: scaleY(1); }
}

.timeline-item {
  position: relative;
  margin-bottom: 36px;
  opacity: 0;
  transform: translateX(-16px);
}

.reveal.active .timeline-item {
  animation: itemSlide 0.7s cubic-bezier(0.22, 1, 0.36, 1) calc(1.2s + var(--i) * 0.25s) forwards;
}

@keyframes itemSlide {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.timeline-dot {
  position: absolute;
  left: -29px;
  top: 8px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--night);
  box-shadow: 0 0 0 1px var(--gold-dim);
}

.timeline-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(212, 168, 83, 0.12);
  border-radius: 12px;
  padding: 24px 26px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.timeline-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(212, 168, 83, 0.25);
}

/* ---- CARD IMAGES ---- */

.card-img {
  margin: -24px -26px 18px -26px;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  position: relative;
}

.card-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, var(--night) 100%);
  pointer-events: none;
}

.card-img img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  filter: brightness(0.85) saturate(0.9);
  transition: transform 0.6s ease, filter 0.6s ease;
}

.timeline-card:hover .card-img img {
  transform: scale(1.03);
  filter: brightness(0.9) saturate(1);
}

.timeline-time {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  display: block;
  margin-bottom: 8px;
}

.timeline-card h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.65rem;
  font-weight: 400;
  color: var(--cream);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.timeline-card p {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 300;
  color: var(--cream-dim);
  line-height: 1.65;
}

.timeline-card ul {
  list-style: none;
  padding: 10px 0 6px;
}

.timeline-card li {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--cream);
  padding: 5px 0 5px 18px;
  position: relative;
}

.timeline-card li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  transform: translateY(-50%);
  opacity: 0.7;
}

.aside {
  font-style: italic;
  opacity: 0.5 !important;
  font-size: 0.85rem !important;
  margin-top: 6px;
}

/* ---- FOOTER ---- */

.reveal-footer {
  text-align: center;
  margin-top: 50px;
  padding-top: 30px;
  border-top: 1px solid rgba(212, 168, 83, 0.1);
  opacity: 0;
}

.reveal.active .reveal-footer {
  animation: revealUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 2.2s forwards;
}

.footer-line {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--cream-dim);
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}

.footer-sign-off {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 300;
  font-style: italic;
  color: var(--gold);
}

/* ---- CONFETTI ---- */

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  opacity: 0;
  animation: confettiFall var(--fall-duration) cubic-bezier(0.25, 0.46, 0.45, 0.94) var(--fall-delay) forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0deg);
  }
  25% {
    opacity: 1;
    transform: translateY(25vh) translateX(var(--drift)) rotate(calc(var(--spin) * 0.25));
  }
  50% {
    opacity: 0.9;
    transform: translateY(50vh) translateX(calc(var(--drift) * -0.5)) rotate(calc(var(--spin) * 0.5));
  }
  100% {
    opacity: 0;
    transform: translateY(105vh) translateX(var(--drift)) rotate(var(--spin));
  }
}

/* ---- RESPONSIVE ---- */

@media (max-width: 480px) {
  .folded-paper {
    width: 160px;
    height: 142px;
  }

  .folded-to {
    font-size: 1.3rem;
  }

  .folded-from {
    font-size: 0.85rem;
  }

  .note {
    padding: 42px 28px 32px 42px;
    width: 94%;
  }

  .note-question {
    font-size: 1.2rem;
    line-height: 2;
  }

  .note-when {
    font-size: 1rem;
  }

  .choices {
    gap: 32px;
  }

  .choice-label {
    font-size: 1.15rem;
    padding: 14px 18px;
  }

  .circle-svg {
    width: 76px;
    height: 76px;
  }

  .reveal-title {
    font-size: 2.4rem;
  }

  .reveal-content {
    padding: 40px 0 60px;
  }

  .timeline {
    padding-left: 28px;
  }

  .timeline-card {
    padding: 20px 20px;
  }

  .card-img {
    margin: -20px -20px 14px -20px;
  }

  .card-img img {
    height: 150px;
  }

  .timeline-card h3 {
    font-size: 1.4rem;
  }

  .note-holes {
    display: none;
  }
}

@media (max-width: 360px) {
  .note-question {
    font-size: 1.05rem;
  }

  .reveal-title {
    font-size: 2rem;
  }
}
