/* 
 * index.css - Main stylesheet for the Birthday Wish Site
 * Author: Sagarithm
 * Description: Handles calculations for animations, 3D book effects, 
 *              settings modal, and overall layout.
 */

/* ==========================================================================
   Base Styles
   ========================================================================== */

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Arial', sans-serif;
    position: relative;
}

/* ==========================================================================
   Orientation Lock (Mobile Support)
   ========================================================================== */

#orientation-lock {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.96);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    color: #fff;
    text-align: center;
    font-family: 'Arial', sans-serif;
    font-size: 18px;
    display: none; /* Controlled via JavaScript */
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#orientation-lock .phone-icon {
    font-size: 64px;
    opacity: 0.92;
    animation: phone-bounce-smooth 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    filter: drop-shadow(0 4px 16px rgba(255, 255, 255, 0.2));
}

@keyframes phone-bounce-smooth {
    0%   { transform: rotate(-45deg) scale(1);    opacity: 0.8; }
    20%  { transform: rotate(-45deg) scale(1.05); opacity: 1;   }
    40%  { transform: rotate(45deg)  scale(1.1);  opacity: 1;   }
    60%  { transform: rotate(45deg)  scale(1.1);  opacity: 1;   }
    80%  { transform: rotate(-45deg) scale(1.05); opacity: 1;   }
    100% { transform: rotate(-45deg) scale(1);    opacity: 0.8; }
}

/* ==========================================================================
   Background Effects (Matrix, Stars)
   ========================================================================== */

#matrix-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 104%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    display: none;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 2s infinite;
}

.star.large  { width: 4px; height: 4px; box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }
.star.medium { width: 3px; height: 3px; box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);  }
.star.small  { width: 2px; height: 2px; box-shadow: 0 0 4px rgba(255, 255, 255, 0.4);  }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1);   }
    50%      { opacity: 1;   transform: scale(1.2); }
}

/* ==========================================================================
   Celebration Elements
   ========================================================================== */

/* Main Text Display (Paper Style) */
.content-display {
    position: fixed;
    top: 2%;
    left: 50%;
    transform: translateX(-50%);
    width: 85vw;
    max-width: 650px;
    min-height: 160px;
    max-height: 230px;
    background: linear-gradient(145deg, #ffffff 0%, #fefefe 100%);
    border-radius: 20px;
    padding: 40px 35px;
    box-shadow: 0 20px 60px rgba(255, 105, 180, 0.15), 0 10px 30px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(20px);
    opacity: 0;
    display: none;
    pointer-events: none;
    font-family: 'Crimson Text', serif;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 105, 180, 0.3) transparent;
    scroll-behavior: smooth;
    box-sizing: border-box;
    z-index: 10;
    transition: all 0.5s ease;
}

.content-display.show {
    display: block;
    opacity: 1 !important;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.98) !important;
}

.content-display::after {
    content: '💕';
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    opacity: 0.6;
    animation: heartbeat 2s ease-in-out infinite;
}

.content-display p {
    margin: 0;
    color: #2c1810;
    font-size: clamp(18px, 3vw, 24px);
    line-height: 2.2;
    text-align: center;
    font-weight: 400;
    font-family: 'Dancing Script', cursive;
    text-shadow: 0 1px 2px rgba(255, 105, 180, 0.1);
    background: linear-gradient(45deg, #8b4513, #a0522d, #8b4513, #6b3410);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: romanticText 8s ease-in-out infinite;
}

/* Floating Heart Effect */
.heart {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    animation: float-heart 4s ease-in-out forwards;
}

.heart img {
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

@keyframes float-heart {
    0%   { transform: translateY(0) scale(0);   opacity: 0; }
    10%  { transform: translateY(-20px) scale(1); opacity: 1; }
    90%  { opacity: 1; }
    100% { transform: translateY(-700px) scale(0); opacity: 0; }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1);   opacity: 0.6; }
    50%      { transform: scale(1.2); opacity: 0.9; }
}

/* Gift Celebration */
#gift-image {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    max-width: 80vw;
    max-height: 80vh;
    animation: giftCelebration 1s ease forwards;
}

@keyframes giftCelebration {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* ==========================================================================
   3D Book System
   ========================================================================== */

.book-container {
    perspective: 2000px;
    position: relative;
    display: none;
    opacity: 0;
    transform: scale(0.8) translateY(50px);
    transition: opacity 1s ease, transform 1s ease;
}

.book-container.show {
    display: block;
    opacity: 1;
    transform: scale(1) translateY(80px);
}

.book {
    width: 600px;
    height: 400px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
    cursor: grab;
    user-select: none;
}

.page {
    width: 300px;
    height: 400px;
    position: absolute;
    top: 0;
    right: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8), 0 10px 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    touch-action: pan-x;
    z-index: var(--page-z-index, 1);
}

.page-front,
.page-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    overflow: hidden;
    border: 2px solid #ddd;
    border-radius: 0 8px 8px 0;
    background: white;
}

.page-back {
    transform: rotateY(180deg);
    border-radius: 8px 0 0 8px;
}

.page-front img,
.page-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.page.flipped {
    transform: rotateY(-180deg);
    z-index: var(--page-flipped-z-index, 1);
}

.page.flipping {
    transform: rotateY(-90deg);
}

.empty-page {
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 14px;
    font-style: italic;
    height: 100%;
}

/* ==========================================================================
   UI Controls
   ========================================================================== */

/* Floating Settings Button */
.settings-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.settings-button:hover {
    transform: scale(1.05) rotate(90deg);
    background: rgba(255, 255, 255, 0.15);
}

/* Music Control */
.music-control {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10001;
    box-shadow: 0 4px 15px rgba(250, 250, 250, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: rgb(205, 202, 202);
}

.music-control.playing { animation: musicPulse 1.5s infinite; }

@keyframes musicPulse {
    0%, 100% { transform: scale(1);   box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4); }
    50%      { transform: scale(1.05); box-shadow: 0 8px 25px rgba(255, 107, 157, 0.8); }
}

/* ==========================================================================
   Settings Modal
   ========================================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 11000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    animation: fadeIn 0.3s ease-in-out;
}

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

.modal-content {
    background: rgba(20, 5, 25, 0.95);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    border: 1px solid rgba(147, 112, 219, 0.3);
    width: 90%;
    max-width: 450px;
    max-height: 85vh;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    color: #fff;
}

.modal-header {
    background: linear-gradient(to right, rgba(20, 5, 25, 0.95), rgba(40, 10, 50, 0.9));
    padding: 20px 25px;
    border-bottom: 1px solid rgba(147, 112, 219, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.close {
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover { color: #fff; }

.modal-body {
    padding: 25px;
    overflow-y: auto;
}

/* Settings Form Groups */
.settings-section {
    margin-bottom: 25px;
}

.settings-section h3 {
    margin: 0 0 15px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #e6e6fa;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
}

input[type="text"], 
select {
    width: 100%;
    padding: 12px 15px;
    background: rgba(80, 40, 90, 0.6) !important;
    border: 1px solid rgba(147, 112, 219, 0.3);
    border-radius: 10px;
    color: #fff !important;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

input[type="text"]:focus, 
select:focus {
    background: rgba(100, 50, 110, 0.4);
    border-color: #9370db;
    box-shadow: 0 0 10px rgba(147, 112, 219, 0.2);
}

option { background: #2a1a3a; color: #fff; }

/* Color Theme Buttons */
.color-theme-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.color-theme-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 70px;
    background: rgba(0,0,0,0.3);
}

.color-theme-btn[data-theme="pink"]   { background: linear-gradient(135deg, #ff1493, #ff69b4); }
.color-theme-btn[data-theme="blue"]   { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.color-theme-btn[data-theme="purple"] { background: linear-gradient(135deg, #9b59d0, #b388ff); }
.color-theme-btn[data-theme="green"]  { background: linear-gradient(135deg, #39ff14, #00ff41); }
.color-theme-btn[data-theme="custom"] { background: linear-gradient(135deg, #ff6b9d, #ffa5c7); }

.color-theme-btn.active {
    transform: scale(1.05);
    border: 2px solid #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.color-theme-btn span {
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.color-preview { display: none; }

.apply-settings-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #6a0dad, #4b0082);
    color: #fff;
    border: 1px solid rgba(147, 112, 219, 0.3);
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(75, 0, 130, 0.4);
}

.apply-settings-btn:hover {
    background: linear-gradient(135deg, #7b1fa2, #6a0dad);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 31, 162, 0.6);
}

/* ==========================================================================
   Responsiveness
   ========================================================================== */

/* Landscape Mobile Overrides */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .book-container.show { transform: scale(1) translateY(10px); }
    
    .book {
        width: 300px;
        height: 200px;
        transform: scale(0.7);
    }
    
    .page { width: 150px; height: 200px; }
    
    .content-display {
        width: 45vw;
        min-height: 50px;
        max-height: 80px;
        padding: 5px 8px;
        top: 10px;
    }
    
    .content-display p { font-size: 13px !important; }
    
    .modal-content {
        width: 89%;
        height: 88vh;
    }
    
    .modal-header h2 { display: none; }
    
    .apply-settings-btn {
        margin-bottom: 20px !important;
        padding: 7px !important;
    }
}

/* Copyright Footer */
.copyright {
    position: fixed;
    bottom: 10px;
    right: 15px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    z-index: 5000;
    pointer-events: none;
    user-select: none;
}
