/* ========================================
   CSS Variables & Theme
   ======================================== */

:root {
    /* Colors */
    --primary-pink: #FFB6D9;
    --light-pink: #FFE5F0;
    --rose: #E75480;
    --peach: #FFCBA4;
    --white: #FFFFFF;
    --black: #0a0a0a;
    --gray: #8a8a8a;
    
    /* Gradients */
    --gradient-main: linear-gradient(135deg, #FFB6D9 0%, #FFE5F0 50%, #FFCBA4 100%);
    --gradient-alt: linear-gradient(45deg, #FFB6D9 0%, #E75480 100%);
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 3rem;
    --spacing-xl: 4rem;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-serif: 'Georgia', serif;
    
    /* Transitions */
    --transition-fast: 0.3s ease;
    --transition-normal: 0.5s ease;
    --transition-slow: 1s ease;
}

/* ========================================
   Global Styles
   ======================================== */

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

html {
    scroll-behavior: smooth;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    color: var(--black);
    background: #000;
}

/* Scrollbar Styling */
.page-content::-webkit-scrollbar {
    width: 6px;
}

.page-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.page-content::-webkit-scrollbar-thumb {
    background: rgba(255, 182, 217, 0.5);
    border-radius: 10px;
}

.page-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 182, 217, 0.8);
}

/* ========================================
   Background & Decorations
   ======================================== */

.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.gradient-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--gradient-main);
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(10deg); }
    100% { filter: hue-rotate(0deg); }
}

.floating-decorations {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Floating elements */
.floating-element {
    position: absolute;
    font-size: 2rem;
    opacity: 0.3;
    animation: floatUp 20s infinite linear;
}

.floating-element:nth-child(1) { left: 10%; animation-delay: 0s; }
.floating-element:nth-child(2) { left: 20%; animation-delay: 2s; }
.floating-element:nth-child(3) { left: 30%; animation-delay: 4s; }
.floating-element:nth-child(4) { left: 40%; animation-delay: 6s; }
.floating-element:nth-child(5) { left: 50%; animation-delay: 8s; }
.floating-element:nth-child(6) { left: 60%; animation-delay: 10s; }
.floating-element:nth-child(7) { left: 70%; animation-delay: 12s; }
.floating-element:nth-child(8) { left: 80%; animation-delay: 14s; }
.floating-element:nth-child(9) { left: 90%; animation-delay: 16s; }

@keyframes floatUp {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ========================================
   Music Control
   ======================================== */

.music-control {
    position: fixed;
    top: var(--spacing-md);
    right: var(--spacing-md);
    z-index: 1000;
}

.music-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--white);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.music-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.music-btn:active {
    transform: scale(0.95);
}

.music-btn.muted .music-icon::before {
    content: '🔇';
    position: absolute;
}

/* ========================================
   Pages Container
   ======================================== */

.pages-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.page {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.page.active {
    opacity: 1;
    pointer-events: all;
}

.page-content {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    padding-bottom: 150px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ========================================
   Page 1: Opening Story
   ======================================== */

.opening-container {
    position: relative;
    text-align: center;
    z-index: 10;
}

.typing-text {
    font-family: var(--font-serif);
    font-size: clamp(2.5rem, 10vw, 5rem);
    font-weight: 700;
    color: var(--white);
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
    animation: typing 3s steps(20, end) forwards, textGlow 2s ease-in-out 3s infinite;
    overflow: hidden;
    white-space: nowrap;
}

@keyframes typing {
    0% {
        width: 0;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        width: 100%;
        opacity: 1;
    }
}

@keyframes textGlow {
    0%, 100% { text-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
    50% { text-shadow: 0 10px 40px rgba(255, 182, 217, 0.6); }
}

.confetti-container,
.fireworks-container,
.floating-hearts-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* ========================================
   Page 2: Photo & Info
   ======================================== */

.glass-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    padding: var(--spacing-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.8s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.photo-placeholder {
    width: 200px;
    height: 200px;
    margin: 0 auto var(--spacing-lg);
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-pink);
    box-shadow: 0 10px 30px rgba(255, 182, 217, 0.3);
    animation: photoFloat 3s ease-in-out infinite;
    flex-shrink: 0;
}

.photo-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 768px) {
    .photo-placeholder {
        width: 180px;
        height: 180px;
    }
}

@media (max-width: 480px) {
    .photo-placeholder {
        width: 140px;
        height: 140px;
        margin-bottom: var(--spacing-md);
    }
}

@keyframes photoFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.person-name {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    color: var(--rose);
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
}

.birth-date,
.birthday-message {
    color: var(--gray);
    margin-bottom: var(--spacing-sm);
    line-height: 1.6;
}

.birthday-message {
    font-style: italic;
    color: var(--black);
}

.floating-decorations-page2 {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* ========================================
   Page 3: Split Layout
   ======================================== */

.split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    width: 100%;
    max-width: 900px;
    align-items: start;
    animation: slideUp 0.8s ease-out;
    padding: var(--spacing-md);
    margin-top: 80px;
}

@media (max-width: 768px) {
    .split-container {
        margin-top: 80px;
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
        padding: var(--spacing-sm);
        
    }
}

.split-image {
    position: relative;
    margin-top: 80px;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.split-image img {
    margin-top: 80px;
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: imageFloat 4s ease-in-out infinite;
}

@keyframes imageFloat {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.02) translateY(-10px); }
}

.split-text {
    padding: var(--spacing-md);
}

.split-text h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--rose);
    margin-bottom: var(--spacing-md);
    font-weight: 700;
}

.split-text p {
    color: var(--black);
    line-height: 1.8;
    font-size: 1.1rem;
    margin-bottom: var(--spacing-md);
}

.animated-hearts {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-top: var(--spacing-md);
}

.animated-hearts::before,
.animated-hearts::after {
    content: '❤️';
    font-size: 1.5rem;
    animation: heartBeat 1s ease-in-out infinite;
}

.animated-hearts::before {
    animation-delay: 0s;
}

.animated-hearts::after {
    animation-delay: 0.3s;
}

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

.floating-elements-page3,
.floating-butterflies {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

@media (max-width: 768px) {
    .split-container {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Page 4: Memory Gallery
   ======================================== */

.memory-gallery {
    margin-top: 60px;
    width: 100%;
    max-width: 600px;
    animation: slideUp 0.8s ease-out;
}

.memory-main {
    margin-top: 60px;
    width: 100%;
    height: 400px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin-bottom: var(--spacing-lg);
}

.memory-main img {
    margin-top: 40px;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.memory-texts {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.memory-text {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: var(--spacing-md);
    color: var(--black);
    line-height: 1.6;
    font-size: 1.05rem;
}

.memory-text.fade-in {
    opacity: 0;
    animation: fadeInScale 0.8s ease-out forwards;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.page-particles,
.floating-flowers {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* ========================================
   Page 5: Final Letter
   ======================================== */

.night-sky {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: linear-gradient(180deg, rgba(20, 20, 50, 0.8) 0%, rgba(50, 20, 60, 0.6) 100%);
    z-index: 1;
}

.stars,
.moon,
.fireflies {
    position: absolute;
    width: 100%;
    height: 100%;
}

.letter-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-letter {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: var(--spacing-xl);
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: letterAppear 1.5s ease-out;
    max-height: 100%;
    overflow-y: auto;
}

@keyframes letterAppear {
    0% {
        opacity: 0;
        transform: scale(0.9) rotateY(20deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

.letter-content h2 {
    font-family: var(--font-serif);
    font-size: clamp(1.5rem, 4vw, 2rem);
    color: var(--rose);
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.letter-text {
    color: var(--white);
    line-height: 1.8;
    font-size: 1.05rem;
    font-family: var(--font-serif);
}

.floating-hearts-final {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: none;
}

/* ========================================
   Navigation Buttons
   ======================================== */

.page-navigation {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--spacing-md);
    z-index: 100;
    background: rgba(255, 182, 217, 0.1);
    backdrop-filter: blur(10px);
    padding: var(--spacing-md);
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 50px;
    border: 2px solid var(--white);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: var(--black);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(255, 182, 217, 0.4);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

/* ========================================
   Animations Library
   ======================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   Accessibility
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-color-scheme: dark) {
    .split-text p,
    .memory-text {
        color: rgba(255, 255, 255, 0.9);
    }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    :root {
        --spacing-lg: 2rem;
        --spacing-xl: 2.5rem;
    }

    .page-content {
        padding-bottom: 180px;
    }

    .page-navigation {
        flex-direction: column;
        gap: var(--spacing-sm);
        width: 90%;
        max-width: 300px;
        bottom: var(--spacing-sm);
    }

    .btn {
        width: 100%;
        text-align: center;
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .glass-card {
        padding: var(--spacing-md);
        max-width: 95%;
    }

    .photo-placeholder {
        width: 150px;
        height: 150px;
        margin-bottom: var(--spacing-md);
    }

    .memory-gallery {
        max-width: 100%;
        padding: 0 var(--spacing-sm);
    }

    .memory-main {
        height: 250px;
    }

    .memory-text {
        padding: var(--spacing-sm);
        font-size: 0.95rem;
    }

    .split-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .split-image {
        aspect-ratio: 1;
    }

    .split-text {
        padding: var(--spacing-sm);
    }

    .split-text h2 {
        font-size: 1.5rem;
    }

    .letter-container {
        width: 95%;
        margin: auto;
        max-height: calc(100vh - 250px);
    }

    .glass-letter {
        padding: var(--spacing-md);
        max-height: 100%;
        border-radius: 15px;
    }

    .letter-text {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    :root {
        --spacing-md: 1.5rem;
        --spacing-lg: 1.5rem;
    }

    .music-control {
        top: var(--spacing-sm);
        right: var(--spacing-sm);
    }

    .music-btn {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }

    .typing-text {
        font-size: clamp(1.2rem, 6vw, 2rem);
    }

    .page-content {
        padding: var(--spacing-sm);
        padding-bottom: 200px;
    }

    .glass-card {
        max-width: 98%;
        padding: var(--spacing-md);
        border-radius: 15px;
    }

    .photo-placeholder {
        width: 120px;
        height: 120px;
        margin-bottom: var(--spacing-md);
    }

    .person-name {
        font-size: 1.5rem;
    }

    .birth-date,
    .birthday-message {
        font-size: 0.95rem;
    }

    .page-navigation {
        flex-direction: column;
        gap: var(--spacing-xs);
        width: 95%;
        max-width: 100%;
        padding: var(--spacing-sm);
        bottom: var(--spacing-xs);
    }

    .btn {
        font-size: 0.9rem;
        padding: var(--spacing-xs) var(--spacing-md);
    }

    .split-text h2 {
        font-size: 1.3rem;
    }

    .split-text p {
        font-size: 0.95rem;
    }

    .memory-main {
        height: 200px;
    }

    .memory-text {
        font-size: 0.9rem;
        padding: var(--spacing-sm);
        line-height: 1.5;
    }

    .glass-letter {
        padding: var(--spacing-md);
        border-radius: 12px;
    }

    .letter-content h2 {
        font-size: 1.3rem;
    }

    .letter-text {
        font-size: 0.9rem;
    }

    .opening-container {
        padding: var(--spacing-md) 0;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .music-control,
    .page-navigation {
        display: none;
    }
}