/* ============================================================================
   Love Album — a draggable 3D memory gallery.

   Two stages + a modal, driven by /love-album/album.js through data-stage:

     body[data-stage="intro"]     the intro card is on stage
     body[data-stage="gallery"]   the deck is on stage
     .card.is-flipped             card back is showing
     .la-final.is-visible         the reveal threshold is met
   ========================================================================= */

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.la {
  font-family: 'Montserrat', system-ui, sans-serif;
  color: #674a7a;
  touch-action: manipulation;
}

.la-previewbadge {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 300;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 77, 141, 0.12);
  border: 1px solid rgba(255, 77, 141, 0.35);
  color: #ff4d8d;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.la-btn {
  font-family: 'Dancing Script', cursive;
  background: linear-gradient(145deg, #ff9ebd, #ff7eb3);
  color: #fff;
  border: none;
  padding: 15px 40px;
  font-size: 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(255, 105, 180, 0.3), 0 6px 6px rgba(255, 105, 180, 0.2), inset 0 -2px 5px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.la-btn:hover { transform: translateY(-5px) scale(1.05); box-shadow: 0 15px 25px rgba(255, 105, 180, 0.4), 0 10px 10px rgba(255, 105, 180, 0.2), inset 0 -2px 5px rgba(0, 0, 0, 0.1); }
.la-btn:focus-visible { outline: 3px solid rgba(255, 77, 141, 0.5); outline-offset: 2px; }

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

.la-intro {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vmin, 40px);
  background: linear-gradient(135deg, #ffd1e3 0%, #f8c1ff 50%, #e3d7ff 100%);
  opacity: 1;
  transition: opacity 0.8s ease, visibility 0s linear 0s;
}
body[data-stage="gallery"] .la-intro { opacity: 0; visibility: hidden; transition: opacity 0.8s ease, visibility 0s linear 0.8s; pointer-events: none; }

.la-intro__card {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 640px;
  text-align: center;
  animation: la-fadein 2s ease both;
}
@keyframes la-fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.la-intro__text {
  font-family: 'Dancing Script', cursive;
  color: #ff4d8d;
  font-size: clamp(1.6rem, 5.4vmin, 2.5rem);
  font-weight: 500;
  line-height: 1.5;
  margin: 0;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(255, 105, 180, 0.4);
}

.la-intro__sig {
  margin: 0;
  font-size: 0.95rem;
  color: #a4628a;
}

/* Falling hearts on the intro (pure CSS animation, spawned by JS) */
.la-intro__hearts { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.la-heartfall {
  position: absolute;
  top: -40px;
  animation: la-fall linear forwards;
  opacity: 0;
}
@keyframes la-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 0; }
  10% { opacity: 0.8; }
  100% { transform: translateY(105vh) rotate(360deg); opacity: 0; }
}

/* ---------------------------------------------------------------- gallery */

.la-gallery {
  position: fixed;
  inset: 0;
  background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
  background-size: 400% 400%;
  animation: la-gradient 15s ease infinite;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}
body[data-stage="gallery"] .la-gallery { opacity: 1; visibility: visible; transition: opacity 0.8s ease 0.2s, visibility 0s linear 0.2s; }
body[data-stage="gallery"] { overflow: hidden; }

@keyframes la-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.la-gallery__heading {
  position: absolute;
  top: clamp(18px, 4vmin, 36px);
  left: 0; right: 0;
  text-align: center;
  z-index: 200;
  pointer-events: none;
  padding: 0 16px;
}
.la-gallery__heading h1 {
  font-family: 'Dancing Script', cursive;
  color: #fff;
  font-size: clamp(2rem, 8vmin, 4rem);
  margin: 0 0 8px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 182, 222, 0.4), 0 0 30px rgba(213, 166, 230, 0.3);
  animation: la-float 3s ease-in-out infinite;
}
.la-gallery__heading p {
  color: #fff;
  font-size: clamp(0.85rem, 2.6vmin, 1.2rem);
  font-weight: 300;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  margin: 0 auto;
}
@keyframes la-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* The 3D deck */
.la-deck {
  position: absolute;
  left: 50%;
  top: 55%;
  width: min(92vw, 900px);
  height: min(70vh, 620px);
  transform: translate(-50%, -50%);
  perspective: 1500px;
  z-index: 10;
  touch-action: none;
}

.la-card {
  position: absolute;
  width: min(66vw, 300px);
  height: min(88vh, 400px);
  left: calc(50% - min(33vw, 150px));
  top: calc(50% - min(44vh, 200px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 15px rgba(255, 255, 255, 0.5);
  cursor: grab;
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.la-card.is-dragging { cursor: grabbing; z-index: 250 !important; box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.7); }
.la-card.is-read { /* touched at least once — the reveal counter counts these */ }

.la-card__front, .la-card__back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  overflow: hidden;
}
.la-card__front img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; border-radius: 20px; }
.la-card__back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #fff6f9, #f8e6ff);
  padding: 24px;
  text-align: center;
  color: #674a7a;
  box-shadow: inset 0 0 15px rgba(213, 166, 230, 0.5);
}
.la-card__back p {
  margin: 0;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.3rem, 4.6vmin, 1.8rem);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.la-card.is-flipped .la-card__front { transform: rotateY(180deg); }
.la-card.is-flipped .la-card__back { transform: rotateY(0deg); }

.la-card__hint {
  position: absolute;
  bottom: 10px;
  left: 0; right: 0;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(103, 74, 122, 0.55);
  z-index: 5;
}

/* Bubbles + sparkles */
.la-bubble {
  position: fixed;
  bottom: -80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  z-index: 1;
  animation: la-rise linear infinite;
  pointer-events: none;
}
@keyframes la-rise {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  10% { opacity: 0.6; }
  100% { transform: translateY(-110vh) scale(1.3); opacity: 0; }
}
.la-sparkle {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  z-index: 2;
  pointer-events: none;
  animation: la-twinkle 3s ease-in-out infinite;
}
@keyframes la-twinkle { 0%, 100% { opacity: 0.1; transform: scale(0.6); } 50% { opacity: 0.9; transform: scale(1.4); } }

/* Particles on drag/flip */
.la-particle {
  position: fixed;
  z-index: 400;
  pointer-events: none;
  opacity: 0;
}
.la-particle--heart { font-size: 18px; }

/* Final button */
.la-final {
  position: fixed;
  bottom: clamp(18px, 4vmin, 36px);
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  z-index: 220;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.la-final.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.la-final .la-btn { font-size: clamp(1.1rem, 3.6vmin, 1.5rem); padding: 12px 28px; }

/* ------------------------------------------------------------- letter */

dialog.la-letter {
  border: 0;
  border-radius: 20px;
  padding: clamp(24px, 5vmin, 40px);
  width: min(92vw, 600px);
  max-width: 92vw;
  background: linear-gradient(135deg, #fff6f9, #f8e6ff);
  color: #674a7a;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
  text-align: center;
  position: relative;
  overflow: hidden;
}
dialog.la-letter::backdrop { background: rgba(0, 0, 0, 0.7); }
.la-letter h2 {
  margin: 0 0 16px;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2rem, 7vmin, 3rem);
  font-weight: 700;
  color: #674a7a;
}
.la-letter p {
  margin: 0 0 26px;
  font-size: clamp(1rem, 3.2vmin, 1.5rem);
  line-height: 1.7;
}
.la-letter__hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: space-around;
  justify-content: space-around;
  opacity: 0.4;
  font-size: 18px;
  z-index: 0;
}
.la-letter h2, .la-letter p, .la-letter .la-btn { position: relative; z-index: 1; }

/* ------------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  .la-gallery, .la-gallery__heading h1 { animation: none; }
  .la-intro__card { animation-duration: 0.3s; }
  .la-heartfall, .la-bubble, .la-sparkle { display: none; }
  .la-card { transition: transform 0.2s ease; }
}
