/* Open When — styles. You don't need to edit this file. */

:root {
  --bg: #fdf5f2;
  --bg2: #f9e6ea;
  --ink: #5a3e48;
  --ink-soft: #94737f;
  --rose: #e597a5;
  --rose-deep: #c96479;
  --paper: #fffdf8;
  --rule: #f2e1e4;
  --hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  --ui: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 14px 34px -14px rgba(150, 80, 100, .38);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, #fde1e7 0, transparent 42%),
    radial-gradient(circle at 92% 88%, #ece2f8 0, transparent 40%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- shared bits ---------- */

main { position: relative; z-index: 1; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(28px, env(safe-area-inset-top)) 16px max(36px, env(safe-area-inset-bottom));
  animation: fade-up .6s ease both;
}
.center {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}

.card-soft {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, .8);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 28px;
  padding: 32px 24px 28px;
  box-shadow: var(--shadow);
}

.hand {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 2.7rem;
  line-height: 1.05;
  color: var(--rose-deep);
  margin: .15em 0 .2em;
}
.muted { color: var(--ink-soft); margin: 0; }

.btn {
  appearance: none; -webkit-appearance: none;
  border: 0;
  font: inherit; font-weight: 700; font-size: 1rem;
  color: #fff;
  background: var(--rose-deep);
  padding: .85em 1.7em;
  border-radius: 999px;
  box-shadow: 0 8px 20px -8px rgba(201, 100, 121, .75);
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .7; }
.btn-soft { background: #fff; color: var(--rose-deep); box-shadow: 0 8px 20px -12px rgba(150, 80, 100, .6); }
.btn:focus-visible, .link-btn:focus-visible { outline: 3px solid var(--rose); outline-offset: 3px; }

.link-btn {
  background: none; border: 0;
  font: inherit; font-weight: 600;
  color: var(--rose-deep);
  padding: .6em .8em;
  cursor: pointer;
}

/* ---------- floating hearts ---------- */

.hearts { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.heart {
  position: absolute;
  bottom: -40px;
  color: var(--rose);
  opacity: 0;
  animation: float var(--d, 12s) linear infinite both;
}
@keyframes float {
  0%   { transform: translate(0, 0) rotate(-12deg); opacity: 0; }
  10%  { opacity: .55; }
  80%  { opacity: .35; }
  100% { transform: translate(var(--drift, 0), -112vh) rotate(14deg); opacity: 0; }
}

.pulse { font-size: 2.6rem; color: var(--rose); animation: pulse 1.1s ease-in-out infinite; }

/* ---------- envelope ---------- */

.env {
  --env: #f6c9d0; --env-dark: #eeb0bb; --env-light: #fadbe0;
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 7;
  perspective: 900px;
  filter: drop-shadow(0 8px 10px rgba(150, 80, 100, .16));
}
.env--lavender { --env: #ddd0f1; --env-dark: #cab8ea; --env-light: #e9e0f7; }
.env--peach    { --env: #fbd8c3; --env-dark: #f4c1a3; --env-light: #fde5d7; }
.env--mint     { --env: #cde8da; --env-dark: #b2dac5; --env-light: #def1e7; }
.env--sky      { --env: #cfe0f3; --env-dark: #b5cdeb; --env-light: #dfeaf8; }

.env-back {
  position: absolute; inset: 0;
  background: var(--env-dark);
  border-radius: 8px;
}
.env-paper {
  position: absolute; left: 7%; right: 7%; top: 6%; bottom: 8%;
  z-index: 2;
  background: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 22%, var(--rule) 22% 24%);
  background-position: 0 30%;
  border-radius: 4px;
  transition: transform .75s cubic-bezier(.2, .75, .25, 1);
}
.env-paper::after {
  content: '♥';
  position: absolute; left: 0; right: 0; top: 6%;
  text-align: center;
  font-size: clamp(9px, 2.6vw, 15px);
  color: var(--rose);
}
.env-pocket {
  position: absolute; inset: 0;
  z-index: 3;
  background: var(--env);
  border-radius: 8px;
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.env-pocket::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--env-light);
  clip-path: polygon(0 100%, 50% 48%, 100% 100%);
}
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%;
  z-index: 4;
  background: var(--env-dark);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform .6s cubic-bezier(.45, .05, .3, 1), z-index 0s .3s;
}
.env-seal {
  position: absolute; left: 50%; top: 56%;
  z-index: 5;
  width: 24%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e7909f, var(--rose-deep) 70%);
  box-shadow: 0 2px 4px rgba(120, 40, 60, .3), inset 0 0 0 3px rgba(255, 255, 255, .16);
  display: grid; place-items: center;
  transition: transform .35s ease, opacity .35s ease;
}
.env-seal svg { width: 48%; height: 48%; fill: #fff8f9; }

/* opened (in the grid): flap gone, letter peeking out */
.env.is-opened .env-flap,
.env.is-opened .env-seal { display: none; }
.env.is-opened .env-paper { transform: translateY(-22%); }

/* opening animation steps */
.env.is-unsealed .env-seal { transform: translate(-50%, -50%) scale(0) rotate(-25deg); opacity: 0; }
.env.is-flap-open .env-flap { transform: rotateX(180deg); z-index: 1; }
.env.is-peeking .env-paper { transform: translateY(-26%); }
.env.is-lifting .env-paper { transform: translateY(-66%); }

.mini-env { width: 130px; margin: 52px auto 14px; }

/* ---------- lock screen ---------- */

.hint {
  font-size: .95rem;
  background: var(--bg2);
  border-radius: 14px;
  padding: .65em 1em;
  margin: 16px 0 0;
}
.lock-form { display: grid; gap: 12px; margin-top: 20px; }
.lock-form input {
  width: 100%;
  font: inherit; font-size: 16px;  /* 16px stops iPhones from zooming in */
  padding: .85em 1.1em;
  border-radius: 999px;
  border: 2px solid var(--rule);
  background: #fff;
  color: var(--ink);
  text-align: center;
  outline: none;
  transition: border-color .2s;
}
.lock-form input:focus { border-color: var(--rose); }
.lock-msg { min-height: 1.5em; margin: 2px 0 0; color: var(--rose-deep); font-weight: 600; font-size: .95rem; }
.shake { animation: shake .45s ease; }

/* ---------- intro ---------- */

.intro-message {
  font-family: var(--hand);
  font-size: 1.6rem;
  line-height: 1.3;
  white-space: pre-line;
  margin: 10px 0 6px;
}
.intro-sign {
  font-family: var(--hand);
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--rose-deep);
  white-space: pre-line;
  margin: 0 0 24px;
}
.intro > :not(.mini-env) { animation: fade-up .7s ease both; }
.intro > :nth-child(2) { animation-delay: 1.1s; }
.intro > :nth-child(3) { animation-delay: 1.35s; }
.intro > :nth-child(4) { animation-delay: 1.6s; }
.intro > :nth-child(5) { animation-delay: 1.85s; }

/* ---------- letters grid ---------- */

.letters-head { text-align: center; max-width: 960px; margin: 6px auto 18px; }
.letters-for { margin: 0; font-weight: 600; color: var(--ink-soft); }
.progress {
  display: inline-block;
  margin: 10px 0 0;
  font-size: .85rem; font-weight: 700;
  color: var(--rose-deep);
  background: rgba(255, 255, 255, .75);
  padding: .3em .9em;
  border-radius: 999px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px 18px;
  max-width: 960px;
  margin: 0 auto;
}
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 28px; } }
@media (min-width: 920px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  appearance: none; -webkit-appearance: none;
  background: none; border: 0;
  font: inherit; color: inherit;
  padding: 12% 4px 0;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  cursor: pointer;
  animation: fade-up .55s ease both;
  animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}
.card .env { transition: transform .25s ease; }
@media (hover: hover) { .card:hover .env { transform: translateY(-4px) rotate(-1.5deg); } }
.card:active .env { transform: scale(.95); }
.card:focus-visible { outline: 3px solid var(--rose); outline-offset: 6px; border-radius: 14px; }

.card-eyebrow {
  margin-top: 12px;
  font-size: .72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft);
}
.card-title {
  font-family: var(--hand);
  font-size: 1.55rem; font-weight: 700;
  line-height: 1.05;
  margin-top: 2px;
}
.card-status {
  margin-top: 8px;
  font-size: .75rem; font-weight: 700;
  color: var(--rose-deep);
  background: rgba(255, 255, 255, .85);
  padding: .2em .75em;
  border-radius: 999px;
}
.card.is-locked .env-seal { background: radial-gradient(circle at 35% 30%, #cbbcc4, #a99099 70%); }
.card.is-locked .env-pocket,
.card.is-locked .env-flap { filter: saturate(.55); }
.card.is-locked .card-status { color: var(--ink-soft); }

.letters-foot { text-align: center; margin-top: 34px; }

/* ---------- overlay: opening + letter ---------- */

#overlay {
  position: fixed; inset: 0;
  z-index: 20;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: rgba(253, 240, 243, .9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .3s ease;
}
#overlay.is-visible { opacity: 1; }

.stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding-top: 18vh;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.stage:empty { display: none; }
.stage .env { width: min(78vw, 340px); animation: pop-in .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.stage.is-done { opacity: 0; transform: scale(1.06); }

.sheet {
  position: relative;
  max-width: 580px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 64px) 16px calc(env(safe-area-inset-bottom) + 32px);
  display: flex; flex-direction: column; align-items: center;
  gap: 22px;
}
.sheet:empty { display: none; }

.sheet-close {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px); right: 12px;
  z-index: 2;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 1.7rem; line-height: 1;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.paper {
  position: relative;
  width: 100%;
  background: var(--paper);
  border-radius: 6px;
  padding: 34px 22px 34px;
  box-shadow: 0 22px 50px -22px rgba(120, 60, 80, .5);
  animation: paper-in .65s cubic-bezier(.2, .8, .2, 1) both;
}
.paper::before {  /* a little strip of washi tape */
  content: '';
  position: absolute; top: -12px; left: 50%;
  width: 110px; height: 26px;
  transform: translateX(-50%) rotate(-3deg);
  background: repeating-linear-gradient(45deg, rgba(229, 151, 165, .5) 0 8px, rgba(240, 180, 190, .5) 8px 16px);
}
.paper-eyebrow {
  margin: 0;
  text-align: center;
  font-size: .75rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.paper-title {
  font-family: var(--hand);
  font-size: 2.4rem; font-weight: 700;
  line-height: 1.05;
  text-align: center;
  color: var(--rose-deep);
  margin: 4px 0 18px;
}
.paper-body {
  font-family: var(--hand);
  font-size: 1.6rem;
  line-height: 2.4rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(2.4rem - 1px), var(--rule) calc(2.4rem - 1px) 2.4rem);
}
.paper-sign {
  font-family: var(--hand);
  font-size: 1.7rem;
  line-height: 1.2;
  text-align: right;
  white-space: pre-line;
  color: var(--rose-deep);
  margin: 26px 0 0;
}

.paper-photos { display: grid; gap: 22px; margin: 28px 4px 6px; }
.photo {
  margin: 0;
  background: #fff;
  padding: 10px 10px 12px;
  border-radius: 3px;
  box-shadow: 0 10px 22px -12px rgba(90, 40, 60, .4);
  transform: rotate(-1.4deg);
}
.photo:nth-child(even) { transform: rotate(1.2deg); }
.photo-frame { background: var(--bg2); }
.photo-frame.is-loading {
  aspect-ratio: 4 / 3;
  background: linear-gradient(100deg, var(--bg2) 30%, #fff6f7 50%, var(--bg2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.photo-frame.is-missing { padding: 22px 12px; font-size: .85rem; color: var(--ink-soft); text-align: center; }
.photo img { display: block; width: 100%; height: auto; cursor: zoom-in; animation: fade-in .4s ease both; }
.photo figcaption {
  font-family: var(--hand);
  font-size: 1.35rem;
  line-height: 1.2;
  text-align: center;
  margin-top: 8px;
}

/* ---------- "not yet" ---------- */

.notyet {
  margin-top: 14vh;
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 28px;
  padding: 30px 24px 26px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop-in .5s cubic-bezier(.2, .9, .3, 1.2) both;
}
.notyet-icon { font-size: 2.6rem; display: inline-block; animation: wobble 2.2s ease-in-out infinite; }
.notyet-title { font-family: var(--hand); font-size: 2.3rem; line-height: 1.1; color: var(--rose-deep); margin: 6px 0 8px; }
.notyet-text { margin: 0; white-space: pre-line; }
.notyet-when {
  font-weight: 700; font-size: .95rem;
  background: var(--bg2);
  border-radius: 14px;
  padding: .65em 1em;
  margin: 18px 0 20px;
}

/* ---------- photo zoom ---------- */

#lightbox {
  position: fixed; inset: 0;
  z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(40, 25, 30, .92);
  cursor: zoom-out;
  animation: fade-in .25s ease both;
}
#lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }

.oops-icon { font-size: 2.6rem; }

/* ---------- animations ---------- */

@keyframes fade-up  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in   { from { opacity: 0; transform: scale(.85) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes paper-in { from { opacity: 0; transform: translateY(40px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes shimmer  { to { background-position: -200% 0; } }
@keyframes pulse    { 50% { transform: scale(1.18); opacity: .7; } }
@keyframes wobble   { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes shake    { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
