/*
  ================================================
  Love Letter & Timeline - Midnight Glow Edition
  ================================================
  Features:
  - Deep dark mode with neon pink accents
  - iOS-style "squircle" rounded corners
  - Luminous glow effects instead of shadows
  - Fluid, dynamic, and enhanced animations
  - High-contrast, moody, and modern aesthetic
*/

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;800&display=swap');

:root{
  /* Palette */
  --primary-glow: #ff6fb5;
  --secondary-glow: #ff89c8;
  --bg-start: #1a1a2e;
  --bg-end: #2a202c;
  
  --card-bg: rgba(40, 32, 45, 0.5);
  --glass-border: rgba(255, 255, 255, 0.08);

  --text-primary: #f0e8f4;
  --text-secondary: rgba(240, 232, 244, 0.6);

  /* Effects */
  --glow-shadow: 0 0 40px rgba(255, 111, 181, 0.25);
  --easing: cubic-bezier(0.6, 0.01, 0.2, 1);
  --soft-radius: 28px; /* Softer, "squircle" corners */
}

/* ==================
   BASE & BACKGROUND
   ================== */
* { box-sizing: border-box; }
html,body{ height:100%; margin:0; }
body{
  font-family: 'Poppins', sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-start);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  overflow: hidden;
}

/* Center stage for envelope */
.center-stage{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  padding: 36px;
  position:relative;
  overflow:hidden;
  transition: opacity .8s ease;
}

/* Animated Aurora Background (Dark Mode) */
.aurora {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  pointer-events: none;
}
.aurora::before, .aurora::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px); /* Increased blur for softer glows */
  will-change: transform, opacity;
}
.aurora::before {
  width: 70vw;
  height: 70vw;
  max-width: 800px;
  max-height: 800px;
  background: radial-gradient(circle, rgba(255, 111, 181, 0.15), transparent 60%);
  top: 10%; left: 10%;
  animation: drift 18s ease-in-out infinite alternate;
}
.aurora::after {
  width: 60vw;
  height: 60vw;
  max-width: 700px;
  max-height: 700px;
  background: radial-gradient(circle, rgba(255, 182, 213, 0.1), transparent 70%);
  bottom: 15%; right: 5%;
  animation: drift 24s ease-in-out -7s infinite alternate;
}

@keyframes drift {
  from { transform: translate(-20%, -10%) scale(1); opacity: 0.9; }
  to   { transform: translate(20%, 10%) scale(1.3); opacity: 0.6; }
}

/* ==================
   LOVE ENVELOPE
   ================== */
.envelope-container{
  display:flex;
  flex-direction:column;
  gap: 18px;
  transform: rotate(-5deg) scale(1);
  transition: transform 0.8s var(--easing);
  cursor: pointer;
  perspective: 1000px;
}
.envelope-container:hover { transform: rotate(0deg) scale(1.05); }
.envelope-container:active{ transform: rotate(0deg) scale(1.02); }

.envelope{
  width: 240px;
  height: 160px;
  position:relative;
  transform-style:preserve-3d;
  box-shadow: var(--glow-shadow);
  border-radius: var(--soft-radius);
  background: linear-gradient(170deg, #2f2638, #241d2a);
  border: 1px solid var(--glass-border);
}

.flap{
  position:absolute;
  top: 0; left: 0;
  width: 100%;
  height: 55%;
  background: linear-gradient(200deg, var(--primary-glow), var(--secondary-glow));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  border-radius: 18px 18px 0 0;
  z-index: 3;
  transition: transform 1.2s var(--easing);
  will-change: transform;
}

.letter{
  position:absolute;
  bottom: 0;
  left: 50%;
  transform:translateX(-50%);
  font-size: 52px;
  z-index: 2;
  transition: transform 1.2s var(--easing), opacity .8s ease;
  text-shadow: 0 0 20px var(--primary-glow);
}

.click-text{
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  user-select: none;
  opacity: 0;
  animation: fadeIn 1s 1s forwards;
  transition: opacity 0.5s ease;
}

/* Envelope Opening State */
.envelope.opening .flap{
  transform: rotateX(-180deg);
  transition-duration: 1.2s;
}
.envelope.opening .letter{ 
  transform: translate(-50%, -100px) scale(1.1);
  opacity: 0;
}
.envelope-container.shrink{
  transform: translateY(-40px) scale(.8) rotate(-3deg);
  opacity: 0;
  transition: transform 0.8s var(--easing), opacity .8s ease;
}

/* Options after opening */
.options{
  display: flex;
  gap: 16px;
  transition: opacity .6s ease .5s, transform .6s var(--easing) .5s;
}

.option-btn{
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 14px 24px;
  border-radius: 999px; /* Pill shape */
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  color: var(--text-primary);
  font-weight:600;
  cursor:pointer;
  font-size:16px;
  transition: all .3s var(--easing);
  position: relative;
  overflow: hidden;
}
.option-btn:hover:not(:disabled){
  transform: translateY(-6px) scale(1.05);
  box-shadow: var(--glow-shadow);
  background: rgba(255,111,181,0.1);
  color: #fff;
}
.option-btn.ghost{
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}
.option-btn.ghost:hover:not(:disabled){
  border-color: rgba(255,111,181,0.4);
  background: rgba(255,111,181,0.05);
}
.option-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--text-secondary);
}

/* ==================
   FLOATING HEARTS
   ================== */
.float-heart{
  position:fixed;
  pointer-events:none;
  font-size: 22px;
  color: var(--primary-glow);
  text-shadow: 0 0 15px var(--primary-glow);
  animation: loveSway 4s linear forwards;
  will-change: transform, opacity;
  z-index: 100;
}
@keyframes loveSway{
  0% { 
    transform: translateY(0) translateX(0) rotate(0deg) scale(1);
    opacity:1; 
  }
  100% {
    transform: translateY(-350px) translateX(calc(sin(var(--i, 0) * 3.14 / 2) * 80px)) rotate(20deg) scale(1.4);
    opacity:0; 
  }
}

/* ==================
   TIMELINE PAGE
   ================== */
.timeline-bg{
  min-height:100vh;
  padding: 40px 28px;
  overflow-y: auto;
  overflow-x:hidden;
}
.timeline-container{
  max-width:900px;
  margin: 0 auto;
  position:relative;
}

.timeline-page{
  min-height: 80vh;
  display: none; /* Controlled by JS */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 24px;
  border-radius: var(--soft-radius);
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glow-shadow);
  transform-origin: center;
}
.timeline-page.active{
  display:flex;
  animation: pageIn 1.2s var(--easing);
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(.98) rotateX(-5deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0deg);
  }
}

.images{
  display:flex;
  gap: 16px;
  flex-wrap:wrap;
  justify-content:center;
  width:100%;
}
.images img{
  width:160px;
  height:120px;
  object-fit:cover;
  border-radius: 18px; /* Softer corners */
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  border: 3px solid rgba(255,255,255,0.1);
  opacity:0;
  transform: translateY(20px) scale(.95);
  transition: transform .8s var(--easing), opacity .6s, box-shadow .4s, border-color .4s;
}
.images img:hover{
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 0 25px rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
}
.images img.visible{ transform: translateY(0) scale(1); opacity:1; }

.text{
  max-width: 700px;
  text-align:center;
  font-size:18px;
  color: var(--text-secondary);
  line-height:1.7; /* More readable */
  transform: translateY(10px);
  opacity: 0;
  animation: fadeIn 1s .4s forwards;
}

@keyframes fadeIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Navigation */
.timeline-nav{
  margin-top: 28px;
  display:flex;
  justify-content:center;
  gap:16px;
}
.timeline-nav button {
  padding: 12px 20px;
}

/* ==================
   UTILITY & RESPONSIVE
   ================== */
.hidden { display: none !important; }

@media (max-width:720px){
  :root { --soft-radius: 20px; }
  .envelope{ width:200px; height:133px; }
  .images img{ width: 120px; height: 90px; border-radius: 12px; }
  .text{ font-size:16px; }
  .timeline-page { padding: 24px; }
  .timeline-bg { padding: 20px 14px; }
  .option-btn, .timeline-nav button { padding: 12px 18px; font-size: 14px; }
}