/* ===================================================
   VALENTINE — handcrafted for Claudia
   =================================================== */

:root {
  --bg:        #f7f0ea;
  --bg-warm:   #f2e8df;
  --ink:       #2c2320;
  --ink-soft:  #6b5c53;
  --accent:    #c45c6a;
  --accent-dk: #9b1b30;
  --cream:     #fffaf5;
  --serif:     'Cormorant Garamond', 'Georgia', serif;
  --sans:      'Inter', -apple-system, sans-serif;
  --display:   'Playfair Display', 'Georgia', serif;
}

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

html {
  font-size: 16px;
  /* safe area for notch phones */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ===== FILM GRAIN OVERLAY ===== */
.grain {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  opacity: 0.035;
  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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px;
}

/* ===== PETAL CANVAS ===== */
#petal-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* ===== CURSOR HEARTS ===== */
.cursor-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 800;
}

.cursor-heart {
  position: absolute;
  pointer-events: none;
  animation: cursor-float 1.2s ease-out forwards;
}

@keyframes cursor-float {
  0%   { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.3) rotate(20deg); }
}

/* ===== SCREEN SYSTEM ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

.content-wrap {
  text-align: center;
  padding: 30px 24px;
  max-width: 520px;
  width: 100%;
  position: relative;
  z-index: 3;
}

/* ===== SHARED BUTTON ===== */
.btn-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border: 1.5px solid var(--ink);
  border-radius: 100px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.35s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-main:hover {
  background: var(--ink);
  color: var(--cream);
}

.btn-main svg { transition: transform 0.3s ease; }
.btn-main:hover svg { transform: translateX(3px); }

.btn-on-dark {
  border-color: rgba(255,255,255,0.5);
  color: rgba(255,255,255,0.9);
}

.btn-on-dark:hover {
  background: white;
  color: var(--accent);
  border-color: white;
}

/* ===== SHARED ANIMATIONS ===== */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

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

/* ==============================
   SCREEN 1 — INTRO
   ============================== */
#screen-intro { background: var(--bg); }

/* Envelope */
.intro-envelope {
  position: relative;
  width: 140px;
  height: 100px;
  margin: 0 auto 44px;
  animation: gentle-float 4s ease-in-out infinite;
  cursor: pointer;
}

.env-back {
  position: absolute;
  bottom: 0;
  width: 140px;
  height: 80px;
  background: #dcc7b3;
  border-radius: 4px;
}

.env-front {
  position: absolute;
  bottom: 0;
  width: 140px;
  height: 80px;
  background: #e8d5c4;
  border-radius: 0 0 4px 4px;
  clip-path: polygon(0 30%, 50% 70%, 100% 30%, 100% 100%, 0 100%);
  z-index: 3;
}

.env-flap {
  position: absolute;
  top: 0;
  width: 140px;
  height: 60px;
  background: #f0e4d7;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  z-index: 4;
  transform-origin: top center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.intro-envelope:hover .env-flap,
.intro-envelope.opened .env-flap {
  transform: rotateX(180deg);
}

.env-letter {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 60px;
  background: var(--cream);
  border-radius: 3px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.5s ease 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.env-letter span {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--accent);
}

.intro-envelope:hover .env-letter,
.intro-envelope.opened .env-letter {
  transform: translateX(-50%) translateY(-30px);
}

.env-seal {
  position: absolute;
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.intro-envelope:hover .env-seal { opacity: 0; }

.intro-heading {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.8rem;
  color: var(--ink);
  margin-bottom: 12px;
  line-height: 1.1;
  animation: fade-up 1s ease 0.2s both;
}

.intro-sub {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 44px;
  animation: fade-up 1s ease 0.5s both;
}

#btn-start { animation: fade-up 1s ease 0.8s both; }

/* ==============================
   SCREEN 2 — THE QUESTION
   ============================== */
#screen-question { background: var(--bg); }

.q-rose-left, .q-rose-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.q-rose-left { left: -10px; }
.q-rose-right { right: -10px; transform: translateY(-50%) scaleX(-1); }

.q-pretext {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin-bottom: 20px;
  animation: fade-up 0.8s ease both;
}

.q-heading {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.4rem;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 44px;
  animation: fade-up 0.8s ease 0.2s both;
}

.q-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  animation: fade-up 0.8s ease 0.4s both;
}

.btn-yes {
  padding: 14px 52px;
  border: none;
  border-radius: 100px;
  background: var(--accent);
  color: white;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(196, 92, 106, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.btn-yes:hover {
  box-shadow: 0 6px 30px rgba(196, 92, 106, 0.5);
  transform: scale(1.03);
}

.btn-no {
  padding: 14px 36px;
  border: 1.5px solid #ccc;
  border-radius: 100px;
  background: transparent;
  color: #999;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.q-hint {
  margin-top: 28px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
  font-size: 1rem;
  min-height: 1.5em;
}

/* ==============================
   SCREEN 3 — SHE SAID YES
   ============================== */
#screen-omg {
  background: var(--accent-dk);
  background: linear-gradient(160deg, #1a0810 0%, var(--accent-dk) 50%, #2a0f18 100%);
}

.omg-heading {
  font-family: var(--display);
  font-weight: 700;
  font-size: 3.8rem;
  color: white;
  margin-bottom: 8px;
  animation: scale-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  text-shadow: 0 4px 30px rgba(0,0,0,0.3);
}

.omg-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: rgba(255,255,255,0.75);
  margin-bottom: 32px;
  animation: fade-up 0.8s ease 0.4s both;
}

.omg-divider {
  width: 40px;
  height: 1px;
  background: rgba(255,255,255,0.3);
  margin: 0 auto 32px;
  animation: fade-up 0.8s ease 0.6s both;
}

#btn-to-letter { animation: fade-up 0.8s ease 0.8s both; }

/* heart particles */
.omg-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.heart-particle {
  position: absolute;
  bottom: -40px;
  opacity: 0;
  animation: rise-heart linear forwards;
}

@keyframes rise-heart {
  0%   { opacity: 0; transform: translateY(0) scale(0.8) rotate(0deg); }
  8%   { opacity: 0.6; }
  85%  { opacity: 0.4; }
  100% { opacity: 0; transform: translateY(-110vh) scale(0.3) rotate(30deg); }
}

/* ==============================
   SCREEN 4 — THE LETTER
   ============================== */
#screen-letter {
  background: var(--bg-warm);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  justify-content: flex-start;
}

#screen-letter .letter-wrap {
  margin: 0 auto;
}

.letter-wrap {
  padding: 50px 24px 60px;
  max-width: 540px;
  width: 100%;
  text-align: center;
}

.letter-paper {
  background: var(--cream);
  border-radius: 4px;
  padding: 48px 40px;
  margin-bottom: 36px;
  text-align: left;
  box-shadow:
    0 1px 3px rgba(0,0,0,0.04),
    0 10px 40px rgba(0,0,0,0.07);
  position: relative;
  animation: fade-up 0.8s ease both;
}

.letter-paper::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 36px;
  width: 1px;
  background: rgba(196, 92, 106, 0.15);
}

.letter-paper::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      rgba(196, 92, 106, 0.06) 31px,
      rgba(196, 92, 106, 0.06) 32px
    );
  pointer-events: none;
}

.letter-greeting {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.letter-body {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 2;
  color: var(--ink-soft);
  position: relative;
  z-index: 1;
}

.letter-body p { margin-bottom: 16px; }
.letter-body p:last-child { margin-bottom: 0; }

/* typewriter */
.letter-body .char {
  opacity: 0;
  animation: type-in 0.04s ease forwards;
}

@keyframes type-in {
  to { opacity: 1; }
}

.letter-closing {
  margin-top: 32px;
  text-align: right;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink-soft);
  position: relative;
  z-index: 1;
}

.letter-closing .char {
  opacity: 0;
  animation: type-in 0.04s ease forwards;
}

.letter-sig {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--accent);
  margin-top: 4px;
}

#btn-to-gallery {
  opacity: 0;
  transition: opacity 0.6s ease;
}

#btn-to-gallery.visible {
  opacity: 1;
}

/* ==============================
   SCREEN 5 — PHOTO GALLERY
   ============================== */
#screen-gallery {
  background: var(--ink);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  justify-content: flex-start;
}

.gallery-wrap {
  padding: 60px 24px 80px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  margin: 0 auto;
}

.gallery-heading {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.8rem;
  color: white;
  margin-bottom: 8px;
  animation: fade-up 0.8s ease both;
}

.gallery-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 36px;
  animation: fade-up 0.8s ease 0.2s both;
}

.gallery-scroll {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 40px;
}

.gallery-card {
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 16px 50px rgba(0,0,0,0.4);
  animation: fade-up 0.7s ease calc(var(--i) * 0.15s + 0.3s) both;
  background: #1a1a1a;
}

.gallery-card img {
  display: block;
  width: 100%;
  height: auto;
}

#btn-to-final {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.8);
  animation: fade-up 0.8s ease 1s both;
}

#btn-to-final:hover {
  background: white;
  color: var(--ink);
  border-color: white;
}

/* ==============================
   SCREEN 6 — FINAL
   ============================== */
#screen-final {
  background: linear-gradient(160deg, #1a0a0e 0%, #2a0f18 40%, #1a0a0e 100%);
  overflow: hidden;
}

.final-wrap { position: relative; z-index: 3; }

.final-messages {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 420px;
  margin: 0 auto 36px;
}

.final-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(196, 92, 106, 0.2);
  border-radius: 16px;
  padding: 28px 16px;
  text-align: center;
  animation: fade-up 0.6s ease calc(var(--d) * 0.2s) both;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.final-card:hover {
  transform: translateY(-4px);
  border-color: rgba(196, 92, 106, 0.45);
}

.final-rose-icon {
  margin-bottom: 14px;
  transition: transform 0.4s ease;
}

.final-card:hover .final-rose-icon {
  transform: scale(1.1);
}

.final-card p {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.85);
  font-style: italic;
  line-height: 1.4;
}

.final-heart {
  margin: 0 auto 16px;
  width: 56px;
  animation: heartbeat 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(196, 92, 106, 0.5));
}

.final-heart svg { display: block; }

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.2); }
  28% { transform: scale(1); }
  42% { transform: scale(1.15); }
  56% { transform: scale(1); }
}

.final-forever {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.6rem;
  color: rgba(255, 255, 255, 0.8);
  animation: fade-up 0.8s ease 1s both;
}

/* ===== RESPONSIVE — iPhone safe ===== */
@media (max-width: 600px) {
  .intro-heading { font-size: 2.2rem; }
  .q-heading { font-size: 1.8rem; }
  .omg-heading { font-size: 2.8rem; }
  .btn-yes { padding: 13px 42px; font-size: 0.95rem; }
  .btn-no { padding: 12px 28px; font-size: 0.85rem; }
  .btn-main { padding: 12px 26px; font-size: 0.8rem; }
  .letter-paper { padding: 36px 28px; }
  .letter-greeting { font-size: 1.3rem; }
  .gallery-wrap { padding: 40px 16px 50px; }
  .gallery-heading { font-size: 2.2rem; }
  .final-messages { gap: 10px; }
  .final-card { padding: 22px 12px; }
  .final-forever { font-size: 1.3rem; }
  .q-rose-left, .q-rose-right { display: none; }
}

/* iPhone notch / dynamic island safe area */
@supports (padding-top: env(safe-area-inset-top)) {
  .screen { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}
