/* style.css */
:root {
    --text-light: #FDFBF7;
    --text-accent: #FFDDE1; 
    --font-storybook: 'Alice', serif; 
}

* { 
    margin: 0; padding: 0; box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body, html {
    width: 100%; 
    height: 100vh; 
    height: 100dvh; 
    background-color: #050505;
    font-family: var(--font-storybook); 
    overflow: hidden; 
    display: flex; justify-content: center; align-items: center;
    user-select: none; -webkit-user-select: none;
    touch-action: manipulation; 
}

/* --- Backgrounds & Overlays --- */
#bg-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center;
    opacity: 0; filter: blur(20px); transform: scale(1.1);
    transition: opacity 3s ease, filter 4s ease-out, transform 5s ease-out;
    z-index: 1;
}
#bg-layer.active { opacity: 0.6; filter: blur(0px); transform: scale(1); }

#dim-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.8) 100%);
    opacity: 0; transition: opacity 2s ease;
    z-index: 2;
}
#dim-overlay.active { opacity: 1; }

.start-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100dvh; 
    background-color: #050505; z-index: 99999; 
    display: flex; justify-content: center; align-items: center;
    color: var(--text-light); font-size: 1.4rem; letter-spacing: 2px;
    cursor: pointer; transition: opacity 0.5s ease;
}
.start-overlay.hidden { opacity: 0; pointer-events: none; }

/* --- Typography & Text Positioning --- */
#story-container {
    position: relative; z-index: 10; width: 90%; max-width: 400px; height: 100vh;
    display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
.story-text {
    position: absolute; color: var(--text-light); opacity: 0; filter: blur(10px); transform: translateY(15px);
    transition: all 1.5s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: none; text-shadow: 0px 4px 15px rgba(0,0,0,0.5);
}
.story-text.show { opacity: 1; filter: blur(0px); transform: translateY(0); }
.story-text.exit { opacity: 0; filter: blur(10px); transform: translateY(-15px); animation: none !important; }

.story-group { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 20px; pointer-events: none; }
.story-group .story-text { position: relative; }

.cinematic { font-size: 3rem; }
.personal { font-size: 3rem; }
.hint-text { font-size: 1.1rem; letter-spacing: 2px; color: #EBEBEB; opacity: 0.8; }
.soothing { font-size: 1.4rem; letter-spacing: 3px; opacity: 0.8; }
.buildup { font-size: 2.2rem; line-height: 1.5; }

/* --- Animations & Interactions --- */
.rotate-icon { width: 28px; height: 48px; border: 2px solid #EBEBEB; border-radius: 6px; margin-top: 15px; transform-origin: center; }
#tilt-screen.show .rotate-icon { animation: rotatePhone 2.5s infinite ease-in-out 1.5s; }
@keyframes rotatePhone {
    0%, 15% { transform: rotate(0deg); opacity: 1; }
    45%, 55% { transform: rotate(-90deg); opacity: 1; }
    85%, 100% { transform: rotate(0deg); opacity: 1; }
}

.landscape-group { width: 85vh; max-width: 800px; transform: rotate(90deg); text-align: center; }
.interactive-group.active { pointer-events: auto; cursor: pointer; }
.pulsing-cta { position: relative; font-size: 1.6rem; color: var(--text-accent); margin-top: 15px; letter-spacing: 2px; }
.pulsing-cta.show { animation: gentlePulse 2s infinite alternate ease-in-out 1.5s; }
@keyframes gentlePulse {
    0% { opacity: 1; transform: scale(1); text-shadow: 0px 4px 15px rgba(0,0,0,0.5); }
    100% { opacity: 0.6; transform: scale(0.95); text-shadow: 0px 0px 15px rgba(255,221,225,0.6); }
}

/* =========================================
   MUSIC CARD INTEGRATION
   ========================================= */
.landscape-card {
    position: absolute; z-index: 20; width: 85vh; max-width: 850px; height: 85vw; max-height: 450px;
    transform: rotate(90deg) scale(0.9); opacity: 0; pointer-events: none;
    transition: all 1.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    background-color: #4a0d0d; border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.05);
    display: flex; overflow: hidden;
}
.landscape-card.active { opacity: 1; pointer-events: auto; transform: rotate(90deg) scale(1); }



/* --- Section 1: Canvas --- */
.canvas-section {
    flex: 1; position: relative; display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,0.05);
    background-image: linear-gradient(to bottom, rgba(0,0,0,0.4), rgba(0,0,0,0.8)); background-size: cover; background-position: center;
}
.lyric-mask {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
}
.lyric-wrapper { position: absolute; top: 0; left: 0; width: 100%; padding: 200px 40px; transition: transform 1s cubic-bezier(0.25, 0.8, 0.25, 1); }

.lyric-line {
    font-size: 1.5rem; line-height: 1.6; text-align: center; margin-bottom: 25px; text-shadow: 0 2px 10px rgba(0,0,0,0.9);
    opacity: 0.4; filter: blur(3px); transform: translateY(30px) scale(0.9); transition: all 1.2s cubic-bezier(0.25, 0.8, 0.25, 1); will-change: transform, opacity, filter;
}
.lyric-line.active { opacity: 1; filter: blur(0px); transform: translateY(0) scale(1.05); color: #ffffff; }
.lyric-line.passed { opacity: 0.4; filter: blur(3px); transform: translateY(-30px) scale(0.9); }

/* --- Section 2: Controls --- */
.control-section { width: 320px; padding: 40px 30px; display: flex; flex-direction: column; justify-content: space-between; }
.device-info { font-size: 0.8rem; color: #b57b7b; text-transform: uppercase; letter-spacing: 2px; text-align: right; margin-bottom: 20px; }
.song-info { text-align: right; margin-bottom: 30px; }
.song-title { font-size: 2.2rem; font-weight: normal; margin-bottom: 5px; color: #ffffff; }
.artist-name { font-size: 1.2rem; color: #b57b7b; }

.progress-container { margin-bottom: 30px; }
.time-labels { display: flex; justify-content: space-between; font-size: 0.85rem; color: #b57b7b; margin-bottom: 8px; }
.progress-bar-bg { width: 100%; height: 6px; background-color: rgba(255,255,255,0.1); border-radius: 10px; }
.progress-bar-fill { height: 100%; width: 0%; background-color: #ffffff; border-radius: 10px; position: relative; transition: width 0.1s linear; }
.progress-bar-fill::after { content: ''; position: absolute; right: -5px; top: -4px; width: 14px; height: 14px; background-color: #ffffff; border-radius: 50%; box-shadow: 0 0 10px rgba(255,255,255,0.5); }
.controls { display: flex; justify-content: center; align-items: center; gap: 30px; }
.controls button { background: none; border: none; cursor: pointer; color: #f8e3e3; display: flex; justify-content: center; align-items: center; transition: 0.2s; }
.controls button:hover { transform: scale(1.1); color: #ffffff; }
.controls button svg { fill: currentColor; }
.btn-play { width: 60px; height: 60px; }
.btn-skip { width: 35px; height: 35px; color: #b57b7b; }
.typing-cursor::after { content: '|'; animation: blink 0.8s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* =========================================
   NEW: CINEMATIC ROMANTIC REVEAL
   ========================================= */

/* A. Depth Perspective & Base Transformations */
body {
    /* Important for clean Z-axis depth visual without breaking layout */
    perspective: 1500px; 
}

/* 1. The Music Card (Go Behind Transition) */
.music-card-container {
    transition: transform 3s cubic-bezier(0.2, 0.8, 0.3, 1), filter 2.5s ease-in-out, opacity 3s ease-in-out;
    transform-style: preserve-3d;
}
.music-card-container.active.confession-active { 
    /* Depth move, scale down, blur, dimmer */
    transform: translateZ(-500px) scale(0.7); 
    filter: blur(8px); 
    opacity: 0.2; 
}

/* 2. The Black Background & Cinematic Overlay */
.romantic-reveal-overlay {
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; 
    height: 100%; 
    /* REMOVED the rotation and translation. This restores natural vertical mode! */
    transform: none; 
    
    background-color: rgba(0, 0, 0, 0); 
    z-index: 999999; 
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    font-family: var(--font-storybook);
    text-align: center; overflow: hidden;
    opacity: 0; pointer-events: none;
    transition: opacity 2.5s ease-in-out, background-color 2.5s ease-in-out;
}
.romantic-reveal-overlay.active { 
    opacity: 1; pointer-events: auto; 
    /* Fades to pure black, completely covering the landscape music card behind it */
    background-color: rgba(0, 0, 0, 1); 
}
/* B. Background Video (Slow Fade & Frosted Glass Effect - IN PORTRAIT) */
.bg-video {
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; 
    height: 100%; 
    /* REMOVED transform translate because top:0/left:0 perfectly fits portrait */
    transform: none; 
    
    object-fit: cover; 
    z-index: -1; 
    transition: opacity 4s ease-in-out, filter 4s ease-in-out;
}
.bg-video.faded-out { 
    opacity: 0; 
    filter: blur(25px); 
}
.bg-video.show { 
    opacity: 0.5; 
    filter: blur(8px); 
}

/* C. Cinematic Text Styling & Transitions (Slower, Elegant Focus) */
.reveal-container { 
    display: grid; 
    place-items: center; 
    width: 100%; 
    padding: 0 30px; 
    transition: transform 3s ease; 
    perspective: 1000px; 
}
.reveal-container.hidden { display: none; }
.reveal-container.shift-up { transform: translateY(-40px); } 

.reveal-line { 
    grid-area: 1 / 1; 
    margin: 0; 
    text-align: center;
    /* We now use pure transitions for flawless back-and-forth movement */
    transition: transform 3.5s cubic-bezier(0.25, 0.8, 0.25, 1), 
                filter 3.5s ease-in-out, 
                opacity 3.5s ease-in-out, 
                scale 3.5s ease-in-out, 
                visibility 3.5s ease-in-out, 
                text-shadow 3.5s ease-in-out; 
    /* Base starting state */
    opacity: 0; visibility: hidden; filter: blur(10px); scale: 0.8; transform: translateZ(-100px); text-shadow: 0 0 0 rgba(255, 221, 225, 0); 
}

/* Cinematic Text Glow Styles */
.cinematic-text-glow { font-size: 1.8rem; color: #FFDDE1; letter-spacing: 1px; }
.bold-love-text-glow { font-size: 4.5rem; color: #ffffff; margin-top: 10px; }

/* Text Line Appear (Smooth, Slow Centered Focus via Transition) */
.reveal-line.appear {
    opacity: 1; 
    visibility: visible; 
    filter: blur(0px); 
    scale: 1; 
    transform: translateZ(0px);
    text-shadow: 0 0 25px rgba(255, 221, 225, 0.7);
}

/* Text Line Go Behind (Fully vanishes into the depth) */
.reveal-line.go-behind {
    transform: translateZ(-500px); 
    scale: 0.7;
    filter: blur(20px);
    opacity: 0; 
    text-shadow: 0 0 0 rgba(255, 221, 225, 0); 
    visibility: hidden; 
}
/* D. Buttons & Take Time Styling (Nearing bottom of overlay) */
.cta-container {
    position: absolute; bottom: 15%; display: flex; flex-direction: column; gap: 20px; align-items: center; width: 100%;
}
.cta-container.hidden { display: none; }

.btn-primary {
    background: linear-gradient(135deg, #ff3b30, #c40018);
    color: white; padding: 16px 40px; border-radius: 50px; border: none; font-size: 1.2rem;
    font-family: system-ui, sans-serif; font-weight: 600; cursor: pointer;
    box-shadow: 0 10px 25px rgba(255, 59, 48, 0.4);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 15px 35px rgba(255, 59, 48, 0.6); }

.btn-secondary {
    background: transparent; color: #FFDDE1; padding: 12px 30px; border-radius: 50px; border: 1px solid rgba(255, 221, 225, 0.3);
    font-size: 1rem; font-family: system-ui, sans-serif; cursor: pointer; transition: all 0.3s ease;
}
.btn-secondary:hover { background: rgba(255, 221, 225, 0.1); border-color: #FFDDE1; }

/* Simple fade-in for buttons */
.anim-fade-in { animation: simpleFade 1.5s ease-in-out forwards; opacity: 0; }
@keyframes simpleFade { 0% { opacity: 0; transform: translateY(15px); } 100% { opacity: 1; transform: translateY(0); } }

.take-time-msg {
    position: absolute; bottom: 20%; color: #FFDDE1; font-size: 1.3rem; font-style: italic; opacity: 0; transition: opacity 1.5s ease;
}
.take-time-msg.show { opacity: 1; }

/* E. Magical Word-by-Word Reveal */
.word-reveal {
    display: inline-block;
    opacity: 0;
    filter: blur(12px);
    transform: translateY(15px) scale(0.9);
    /* 2.5s duration for a slow, gentle materialization */
    animation: magicalWordFade 2.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes magicalWordFade {
    to {
        opacity: 1;
        filter: blur(0px);
        transform: translateY(0) scale(1);
    }
}