/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --stanza-bg-blur: 3px;
  --stanza-bg-padding: 16px;
  --stanza-bg-border-width: 1px;
  --stanza-bg-border-color: rgba(255, 214, 224, 0.28);
  --stanza-bg-radius: 14px;
}

html,
body {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  height: 100vh;
  height: 100svh;
  height: var(--app-height, 100svh);
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x;
  font-family: 'Cormorant Garamond', 'Georgia', serif;
  background: linear-gradient(135deg, #1a0a0e 0%, #2d0a1a 30%, #1a0510 60%, #0d0508 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   FLOATING HEART PARTICLES
   ============================================ */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.heart {
  position: absolute;
  bottom: -50px;
  font-size: var(--size, 18px);
  opacity: var(--opacity, 0.25);
  color: var(--color, #ff6b8a);
  left: var(--left, 50%);
  animation: floatUp var(--duration, 12s) var(--delay, 0s) linear infinite;
  filter: blur(var(--blur, 0px));
  z-index: 0;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 0;
  }

  5% {
    opacity: var(--opacity, 0.25);
  }

  50% {
    transform: translateY(-50vh) translateX(var(--sway, 30px)) rotate(180deg);
  }

  95% {
    opacity: var(--opacity, 0.25);
  }

  100% {
    transform: translateY(-110vh) translateX(calc(var(--sway, 30px) * -1)) rotate(360deg);
    opacity: 0;
  }
}

/* Night-sky star particles */
.star {
  position: absolute;
  width: var(--size, 3px);
  height: var(--size, 3px);
  border-radius: 50%;
  background: var(--color, #fff);
  left: var(--left, 50%);
  top: var(--top, 50%);
  opacity: var(--opacity, 0.6);
  pointer-events: none;
  z-index: 0;
  animation: twinkle var(--duration, 3s) var(--delay, 0s) ease-in-out infinite;
  box-shadow:
    0 0 calc(var(--size, 3px) * 2) rgba(255, 255, 255, 0.4),
    0 0 calc(var(--size, 3px) * 4) rgba(255, 200, 220, 0.15);
}

/* 4-point cross glint via pseudo-elements */
.star::before,
.star::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
}

.star::before {
  width: calc(var(--size, 3px) * 3);
  height: 1px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.star::after {
  width: 1px;
  height: calc(var(--size, 3px) * 3);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes twinkle {

  0%,
  100% {
    opacity: var(--opacity, 0.6);
    transform: scale(1);
  }

  50% {
    opacity: calc(var(--opacity, 0.6) * 0.2);
    transform: scale(0.6);
  }
}

/* ============================================
   BOOK CONTAINER
   ============================================ */
#book-container {
  z-index: 1;
  position: relative;
  width: 94vw;
  max-width: 580px;
  height: 85vh;
  height: 85svh;
  height: calc(var(--app-height, 100svh) * 0.85);
  max-height: 820px;
  margin: 0 auto;
  touch-action: pan-x;
}

#book {
  width: 100%;
  height: 100%;
  touch-action: pan-x;
}

#book .stf__parent,
#book .stf__wrapper {
  top: 0 !important;
  left: 0 !important;
}

/* ============================================
   PAGE BASE STYLES
   ============================================ */
.page {
  background: #1a0a0e;
  overflow: hidden;
}

.page-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  position: relative;
}

/* ============================================
   COVER PAGE
   ============================================ */
.cover-front {
  background: linear-gradient(160deg,
      #2d0a1a 0%,
      #4a1028 25%,
      #6b1838 50%,
      #4a1028 75%,
      #2d0a1a 100%);
  text-align: center;
}

.cover-ornament {
  font-size: 2.5rem;
  color: #ff8fa3;
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
  text-shadow: 0 0 20px rgba(255, 107, 138, 0.6);
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.15);
    opacity: 0.8;
  }
}

.cover-title {
  font-family: 'Great Vibes', cursive;
  font-size: 3.5rem;
  font-weight: 400;
  color: #ffd6e0;
  text-shadow: 0 2px 15px rgba(255, 143, 163, 0.5), 0 0 40px rgba(255, 107, 138, 0.2);
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
}

.cover-subtitle {
  font-size: 1.2rem;
  font-weight: 300;
  font-style: italic;
  color: #e8a0b0;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.cover-date {
  font-size: 0.95rem;
  color: #c08090;
  letter-spacing: 2px;
  margin-bottom: 2.5rem;
}

.turn-hint {
  position: absolute;
  bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #a06070;
  font-style: italic;
  animation: hintFade 2.5s ease-in-out infinite;
}

.turn-hint .arrow {
  display: inline-block;
  animation: slideRight 1.5s ease-in-out infinite;
}

@keyframes hintFade {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

@keyframes slideRight {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(6px);
  }
}

/* ============================================
   STANZA PAGES
   ============================================ */
.page-stanza .page-content {
  overflow: hidden;
  isolation: isolate;
  background-color: var(--fallback, #2d0a1a);
}

.page-stanza .page-content::before {
  content: '';
  position: absolute;
  inset: var(--stanza-bg-padding, 16px);
  background: var(--bg, none) center / cover no-repeat;
  filter: blur(var(--stanza-bg-blur, 0px));
  border-radius: var(--stanza-bg-radius, 14px);
  z-index: 0;
}

.page-stanza .page-content::after {
  content: '';
  position: absolute;
  inset: var(--stanza-bg-padding, 16px);
  background: linear-gradient(to bottom,
      rgba(20, 5, 10, 0.4) 0%,
      rgba(20, 5, 10, 0.25) 30%,
      rgba(20, 5, 10, 0.25) 70%,
      rgba(20, 5, 10, 0.5) 100%);
  border: var(--stanza-bg-border-width, 1px) solid var(--stanza-bg-border-color, rgba(255, 214, 224, 0.28));
  border-radius: var(--stanza-bg-radius, 14px);
  z-index: 1;
}

.page-stanza .page-content>* {
  z-index: 2;
}

.stanza-content {
  text-align: center;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stanza-text {
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 2.2;
  color: #fff;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.8),
    0 0 20px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
  max-width: 90%;
}

.page-stanza .page-content .stanza-number {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--stanza-bg-padding, 16px) + 0.75rem);
  font-size: 0.85rem;
  color: rgba(255, 200, 210, 0.5);
  letter-spacing: 4px;
  font-style: italic;
}

/* ============================================
   GIFT CARD PAGE
   ============================================ */
.gift-page {
  background: linear-gradient(160deg,
      #1a0510 0%,
      #2d0a1a 30%,
      #3d1028 50%,
      #2d0a1a 70%,
      #1a0510 100%);
  text-align: center;
  gap: 0;
}

.gift-hearts {
  font-size: 1.5rem;
  color: #ff6b8a;
  margin-bottom: 1rem;
  letter-spacing: 8px;
  text-shadow: 0 0 15px rgba(255, 107, 138, 0.5);
}

.gift-title {
  font-family: 'Great Vibes', cursive;
  font-size: 2.2rem;
  font-weight: 400;
  color: #ffd6e0;
  text-shadow: 0 2px 12px rgba(255, 143, 163, 0.4);
  margin-bottom: 0.4rem;
}

.gift-subtitle {
  font-size: 1rem;
  font-weight: 300;
  font-style: italic;
  color: #c08090;
  margin-bottom: 1.8rem;
}

/* Gift Button */
.gift-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 2.2rem;
  border: 2px solid #ff6b8a;
  border-radius: 50px;
  background: transparent;
  color: #ffd6e0;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.4s ease;
}

.gift-btn:hover {
  background: rgba(255, 107, 138, 0.15);
  border-color: #ff8fa3;
  transform: scale(1.05);
  box-shadow: 0 0 25px rgba(255, 107, 138, 0.3);
}

.gift-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.15),
      transparent);
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 200%;
  }
}

.gift-btn-icon {
  font-size: 1.3rem;
}

.gift-btn.clicked {
  display: none;
}

/* Gift Card Reveal */
.gift-card {
  margin-top: 1.2rem;
  transition: all 0.8s ease;
  width: 100%;
  max-width: 392px;
}

.gift-card.hidden {
  opacity: 0;
  transform: translateY(15px) scale(0.95);
  pointer-events: none;
  max-height: 0;
  overflow: hidden;
}

.gift-card.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  max-height: 400px;
}

.gift-card-inner {
  width: 100%;
  aspect-ratio: 1.586 / 1;
  background: linear-gradient(to bottom,
      #121418 0%,
      #121418 24%,
      #ffffff 24%,
      #ffffff 43%,
      #121418 43%,
      #121418 63%,
      #ffffff 63%,
      #ffffff 82%,
      #121418 82%,
      #121418 100%);
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.2);
}

.gift-card-brand {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  color: #ffffff;
  font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  text-transform: uppercase;
  line-height: 1;
  position: absolute;
  top: 53%;
  transform: translateY(-50%);
  width: 100%;
  text-align: center;
}

.gift-card-code {
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: #edd6df;
  background: rgba(0, 0, 0, 0.15);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  margin-top: 0.8rem;
  font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  word-break: break-all;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}

.gift-card-note {
  font-size: 0.75rem;
  color: #999;
  letter-spacing: 1px;
}

.gift-footer {
  margin-top: 1.2rem;
  font-size: 0.9rem;
  font-style: italic;
  color: #a06070;
}

/* ============================================
   SECRET PAGE
   ============================================ */
.secret-page {
  background: linear-gradient(160deg,
      #1a0510 0%,
      #2d0a1a 30%,
      #3d1028 50%,
      #2d0a1a 70%,
      #1a0510 100%);
  text-align: center;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.secret-prompt.hidden,
.secret-reveal.hidden {
  display: none;
}

.secret-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: min(360px, 100%);
  margin: 0 auto;
  opacity: 1;
  transition: opacity 0.45s ease;
}

.secret-prompt.is-fading-out {
  opacity: 0;
}

.secret-label {
  font-size: 1.2rem;
  color: #ffd6e0;
}

.secret-input {
  width: min(280px, 100%);
  max-width: 100%;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 143, 163, 0.5);
  background: rgba(20, 5, 10, 0.6);
  color: #ffd6e0;
  text-align: center;
  font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  outline: none;
}

.secret-input:focus {
  border-color: #ff8fa3;
}

.secret-image {
  width: 100%;
  border-radius: 12px;
  display: block;
}

.secret-reveal {
  position: relative;
  width: min(360px, 90%);
  opacity: 0;
  transition: opacity 0.45s ease;
}

.secret-reveal.is-visible {
  opacity: 1;
}

.secret-overlay-text {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  color: #fff;
  font-size: 1.15rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
}

/* ============================================
   NAVIGATION BUTTONS
   ============================================ */
.nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(255, 107, 138, 0.1);
  border: 1px solid rgba(255, 107, 138, 0.25);
  color: #ff8fa3;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-btn:hover {
  background: rgba(255, 107, 138, 0.25);
  border-color: rgba(255, 107, 138, 0.5);
  box-shadow: 0 0 20px rgba(255, 107, 138, 0.2);
}

.nav-prev {
  left: 1rem;
}

.nav-next {
  right: 1rem;
}

/* ============================================
   PAGE INDICATOR
   ============================================ */
#page-indicator {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.75rem;
  color: rgba(200, 150, 160, 0.5);
  letter-spacing: 2px;
  font-style: italic;
}

/* ============================================
   UNBLUR TOGGLE
   ============================================ */
.unblur-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 107, 138, 0.25);
  background: rgba(255, 107, 138, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ff8fa3;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}

.unblur-toggle.visible {
  opacity: 1;
  pointer-events: auto;
}

.unblur-toggle:hover {
  background: rgba(255, 107, 138, 0.25);
  border-color: rgba(255, 107, 138, 0.5);
  box-shadow: 0 0 20px rgba(255, 107, 138, 0.2);
}

.unblur-toggle.active {
  background: rgba(255, 107, 138, 0.35);
  border-color: rgba(255, 107, 138, 0.6);
  box-shadow: 0 0 12px rgba(255, 107, 138, 0.3);
}

/* Unblur-mode overrides on stanza pages */
.unblur-active .stanza-text,
.unblur-active .stanza-number {
  opacity: 0 !important;
  transition: opacity 0.35s ease;
}

.unblur-active .page-stanza .page-content::before {
  filter: blur(0px) !important;
  transition: filter 0.35s ease;
}

.unblur-active .page-stanza .page-content::after {
  opacity: 0 !important;
  transition: opacity 0.35s ease;
}

/* ============================================
   ENTRANCE ANIMATION
   ============================================ */
body {
  animation: fadeIn 1.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
  .cover-title {
    font-size: 2.5rem;
  }

  .cover-subtitle {
    font-size: 0.95rem;
    letter-spacing: 2px;
  }

  .stanza-text {
    font-size: 1.05rem;
    line-height: 2;
  }

  .gift-title {
    font-size: 1.8rem;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
    font-size: 1.6rem;
  }

  .nav-prev {
    left: 0.5rem;
  }

  .nav-next {
    right: 0.5rem;
  }
}

@media (max-width: 400px) {
  .page-content {
    padding: 1.5rem;
  }

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

  .stanza-text {
    font-size: 0.95rem;
    line-height: 1.9;
  }

  .gift-card-brand {
    font-size: 1rem;
    letter-spacing: 0.2em;
  }

  .gift-card-code {
    font-size: 0.82rem;
    letter-spacing: 1px;
  }
}