/* ============ base ============ */
:root {
  --bg-1: #0d0a1f;
  --bg-2: #1c1440;
  --bg-3: #2a1a4a;
  --ink: #f3eefc;
  --ink-dim: rgba(243, 238, 252, 0.55);
  --gold: #f0c987;
  --rose: #ff6b9d;
  --card: rgba(255, 255, 255, 0.055);
  --card-border: rgba(255, 255, 255, 0.12);
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Outfit", -apple-system, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg-2);
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: transparent;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* the gradient is a fixed layer, so overscroll rubber-banding just slides
   the content over a stationary sky instead of revealing anything */
.bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
  pointer-events: none;
}

/* sized with lvh so Safari's collapsing URL bar never resizes these layers */
#sky {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  pointer-events: none;
}

.glow {
  position: fixed;
  top: -20vh;
  left: 50%;
  transform: translateX(-50%);
  width: 130vw;
  height: 60vh;
  background: radial-gradient(ellipse at center,
    rgba(255, 107, 157, 0.14) 0%,
    rgba(240, 201, 135, 0.06) 40%,
    transparent 70%);
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 20px) 22px calc(env(safe-area-inset-bottom) + 40px);
}

/* ============ hero ============ */
.hero {
  text-align: center;
  padding: 52px 0 36px;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 9vw, 46px);
  line-height: 1.15;
  background: linear-gradient(120deg, #fff 20%, #f3d9ae 60%, var(--rose) 110%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.target-line {
  margin-top: 14px;
  font-size: 14px;
  font-weight: 300;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

/* ============ mode toggle ============ */
.mode-toggle {
  position: relative;
  display: flex;
  margin: 0 auto 26px;
  max-width: 340px;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: rise 0.9s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mode-thumb {
  position: absolute;
  top: 5px;
  left: 5px;
  width: calc(50% - 5px);
  height: calc(100% - 10px);
  background: linear-gradient(120deg, rgba(240, 201, 135, 0.9), rgba(255, 107, 157, 0.9));
  border-radius: 999px;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 2px 12px rgba(255, 107, 157, 0.35);
}

.mode-toggle.call .mode-thumb { transform: translateX(100%); }

.mode-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 11px 8px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.mode-toggle:not(.call) #modeVisit,
.mode-toggle.call #modeCall { color: #1a0f2e; }

/* ============ no call scheduled ============ */
.no-call {
  text-align: center;
  padding: 44px 24px;
  background: var(--card);
  border: 1px dashed rgba(240, 201, 135, 0.35);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.no-call-emoji { font-size: 40px; display: block; margin-bottom: 14px; }

.no-call-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  color: var(--ink-dim);
  margin-bottom: 22px;
}

.no-call .no-call-btn { flex: none; padding: 14px 28px; }

/* ============ countdown ============ */
.countdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  animation: rise 0.9s 0.12s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.unit-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 4px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.unit-value {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.unit-value.tick {
  transform: translateY(-4px) scale(1.06);
  opacity: 0.75;
}

.unit-label {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ============ progress ring ============ */
.progress-section {
  display: flex;
  justify-content: center;
  padding: 44px 0 10px;
  animation: rise 0.9s 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ring-wrap {
  position: relative;
  width: 210px;
  height: 210px;
}

.ring { width: 100%; height: 100%; transform: rotate(-90deg); }

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 552.9; /* 2πr, r=88 */
  stroke-dashoffset: 552.9;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 6px rgba(255, 107, 157, 0.45));
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ring-pct {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 700;
  background: linear-gradient(120deg, var(--gold), var(--rose));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ring-caption {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  line-height: 1.6;
}

/* ============ whimsy grid ============ */
.whimsy { padding-top: 40px; }

.section-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 20px;
  color: var(--ink-dim);
  margin-bottom: 20px;
}

.section-heading::before,
.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240, 201, 135, 0.35), transparent);
}

.whimsy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.whimsy-card {
  padding: 18px 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  opacity: 0;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.whimsy-card:active { transform: scale(0.97); border-color: rgba(255, 107, 157, 0.4); }

.whimsy-emoji { font-size: 24px; display: block; margin-bottom: 10px; }

.whimsy-value {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  display: block;
  line-height: 1.1;
}

.whimsy-label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 300;
  color: var(--ink-dim);
  line-height: 1.45;
}

/* ============ quote ============ */
.quote-section {
  position: relative;
  margin: 40px 0 8px;
  min-height: 150px;
  text-align: center;
}

.quote {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 50%;
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.6;
  color: rgba(243, 238, 252, 0.8);
  /* resting (hidden) state: transparent, sitting slightly low.
     A quote losing .active eases down into this over 0.9s. */
  opacity: 0;
  transform: translateY(calc(-50% + 14px));
  transition: opacity 0.9s ease-in-out, transform 0.9s ease-in-out;
}

/* arriving quote: floats up into place, starting only after the outgoing
   fade (0.9s) has finished — the gap is enforced by the CSS clock, not JS */
.quote.active {
  opacity: 1;
  transform: translateY(-50%);
  transition:
    opacity 1.2s ease-out 1s,
    transform 1.2s cubic-bezier(0.22, 1, 0.36, 1) 1s;
}

/* ============ footer ============ */
.footer {
  padding-top: 36px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(243, 238, 252, 0.3);
}

.heart-beat {
  display: inline-block;
  color: var(--rose);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ============ settings ============ */
.settings-btn {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 20;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(20, 14, 45, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease, color 0.25s ease;
}

.settings-btn:hover, .settings-btn:active { color: var(--gold); transform: rotate(40deg); }
.settings-btn svg { width: 22px; height: 22px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 5, 20, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  width: calc(100% - 28px);
  max-width: 400px;
  margin-bottom: calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(180deg, #1e1542, #141030);
  border: 1px solid var(--card-border);
  border-radius: 26px;
  padding: 26px 22px;
  max-height: 82vh;
  max-height: 82dvh;
  overflow-y: auto;
  transform: translateY(40px);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  margin-bottom: 20px;
  text-align: center;
}

.field { display: block; margin-bottom: 16px; }

.field span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.field small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 300;
  color: var(--ink-dim);
}

.field input {
  width: 100%;
  padding: 13px 14px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease;
  color-scheme: dark;
}

.field input:focus { border-color: var(--rose); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  flex: 1;
  padding: 14px 10px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(120deg, var(--gold), var(--rose));
  color: #1a0f2e;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--card-border);
  color: var(--ink);
}

body.guest .owner-only { display: none; }

.share-toast {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--gold);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.share-toast.show { opacity: 1; }

/* ============ celebration ============ */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 6, 26, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.celebrate.on { display: flex; }

#confetti { position: absolute; inset: 0; width: 100%; height: 100%; }

.celebrate-inner { position: relative; padding: 24px; animation: rise 1s cubic-bezier(0.22, 1, 0.36, 1) both; }

.celebrate-eyebrow {
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
}

.celebrate-title {
  font-family: var(--serif);
  font-size: clamp(40px, 12vw, 64px);
  font-weight: 700;
  background: linear-gradient(120deg, #fff, var(--gold), var(--rose));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.celebrate-sub {
  margin-top: 16px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--ink-dim);
}

/* ============ tap hearts ============ */
.tap-heart {
  position: fixed;
  z-index: 15;
  font-size: 20px;
  pointer-events: none;
  animation: float-away 1.6s ease-out forwards;
}

/* ============ animations ============ */
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

@keyframes float-away {
  0% { opacity: 1; transform: translateY(0) scale(0.6) rotate(0deg); }
  100% { opacity: 0; transform: translateY(-110px) scale(1.25) rotate(18deg); }
}

/* ============ larger screens ============ */
@media (min-width: 700px) {
  .page { max-width: 620px; }
  .whimsy-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-backdrop { align-items: center; }
  .modal { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
