@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&family=Poppins:wght@300;400;600;700&display=swap');

:root {
    --glass-bg: rgba(10, 20, 45, 0.3);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: rgba(0, 0, 0, 0.5);
    --text-color: #ffffff;
}

* {
    box-sizing: border-box;
}

html {
    background-color: #020111; /* Prevents white bar at bottom of mobile browsers */
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Poppins', sans-serif;
    /* Night dark blue/black animated gradient */
    background: linear-gradient(-45deg, #020111, #0b132b, #1c2541, #040814);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    touch-action: manipulation; /* Disables double-tap to zoom */
    user-select: none; /* Disable text copying globally */
    -webkit-user-select: none; /* Safari */
}

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

.css-moon {
    position: absolute;
    top: 8%;
    right: 12%;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: transparent;
    box-shadow: -20px 15px 0 0 #fff5ba;
    filter: drop-shadow(0 0 20px rgba(255, 245, 186, 0.8));
    animation: floatMoon 8s ease-in-out infinite;
    z-index: 1;
}

@keyframes floatMoon {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

.container {
    position: relative;
    width: 100%;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.glass-card {
    margin: auto 0;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    box-sizing: border-box;
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    text-align: center;
    max-width: 600px;
    width: 100%;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    transition: opacity 1s ease, transform 1s ease;
}

.wide-card {
    max-width: 1000px;
}

/* Initial States for switching */
#countdown-view {
    display: block;
    opacity: 1;
    transform: scale(1);
}

#birthday-view {
    display: none;
    opacity: 0;
    transform: scale(0.8);
}

.title {
    font-size: 2.2rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.highlight-name {
    font-family: 'Dancing Script', cursive;
    color: #fdfd96; /* Pastel yellow */
    font-size: 1.2em;
    font-weight: 700;
    letter-spacing: 2px;
    animation: sparkleTwinkle 3s infinite;
}

@keyframes sparkleTwinkle {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 10px rgba(253, 253, 150, 0.8), 0 0 20px rgba(253, 253, 150, 0.6);
        color: #fdfd96;
    }
    10% {
        opacity: 0.8;
        text-shadow: 0 0 5px rgba(253, 253, 150, 0.5);
    }
    20% {
        opacity: 1;
        text-shadow: 0 0 15px #ffffff, 0 0 30px #ffffff, 0 0 40px #fdfd96;
        color: #ffffff;
    }
    30% {
        opacity: 0.9;
        text-shadow: 0 0 10px rgba(253, 253, 150, 0.8);
        color: #fdfd96;
    }
    50% {
        opacity: 0.7;
        text-shadow: 0 0 5px rgba(253, 253, 150, 0.4);
    }
    65% {
        opacity: 1;
        text-shadow: 0 0 12px #ffffff, 0 0 25px #fdfd96;
        color: #ffffe0;
    }
    80% {
        opacity: 0.6;
        text-shadow: 0 0 5px rgba(253, 253, 150, 0.3);
        color: #fdfd96;
    }
}

.happy-bday {
    color: #e0e6ed;
    font-size: 3rem;
    font-weight: 700;
    text-shadow: 0 0 15px rgba(224, 230, 237, 0.8), 0 0 30px rgba(100, 150, 255, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.message {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-style: italic;
    font-weight: 300;
    opacity: 0.9;
}

.countdown-timer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.time-box {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 1rem;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.time-box span:first-child {
    font-size: 2.5rem;
    font-weight: 700;
}

.label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.8;
    margin-top: 5px;
}

/* Letter Container - Old School Paper */
.letter-container {
    background-color: #fdf5e6; /* Old paper ivory/cream */
    background-image: 
        radial-gradient(#d2b48c 1px, transparent 1px), /* subtle texture */
        radial-gradient(#d2b48c 1px, transparent 1px);
    background-position: 0 0, 2px 2px;
    background-size: 4px 4px;
    border-radius: 4px; /* Paper corners */
    padding: 2.5rem 2rem;
    flex: 1;
    height: 100%;
    max-height: 55vh; /* Absolute limit to force the scrollbar */
    overflow-y: auto;
    border: 1px solid #c8a165;
    text-align: left;
    box-shadow: 5px 5px 20px rgba(0,0,0,0.5), inset 0 0 40px rgba(139, 69, 19, 0.15); /* Paper drop shadow and edge darkening */
}

.letter-text {
    white-space: pre-wrap; 
    line-height: 1.8;
    font-size: 1.15rem;
    margin: 0;
    font-family: 'Georgia', serif; /* Classic typewriter/book font */
    font-weight: 400;
    color: #3e2723; /* Dark brown ink */
    text-shadow: none; /* Remove any glow */
}

/* Make scrollbar look nicer against paper */
.letter-container::-webkit-scrollbar {
    width: 14px;
}
.letter-container::-webkit-scrollbar-track {
    background: rgba(139, 69, 19, 0.15);
    border-radius: 7px;
}
.letter-container::-webkit-scrollbar-thumb {
    background: rgba(139, 69, 19, 0.6);
    border-radius: 7px;
    border: 3px solid #fdf5e6;
}
.letter-container::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 69, 19, 0.8);
}

/* Layout for Birthday View */
.birthday-layout {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    align-items: stretch;
    margin-top: 2rem;
    flex: 1;
    min-height: 0;
}

.birthday-sidebar {
    flex: 0 0 auto;
}

.birthday-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Photo Section */
.photo-gallery {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.photo-gallery.vertical {
    flex-direction: column;
}

.photo-gallery img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border: 3px solid rgba(255, 255, 255, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.photo-gallery img:hover {
    transform: scale(1.1) rotate(3deg);
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    z-index: 2;
}

/* Animations */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.8;
    animation: float 10s infinite linear;
    box-shadow: 0 0 15px 2px rgba(255, 255, 255, 0.9);
}

@keyframes float {
    0% { transform: translateY(110vh) scale(0); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 0.8; }
    100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .css-moon {
        width: 50px;
        height: 50px;
        top: 5%;
        right: 15%;
        box-shadow: -15px 10px 0 0 #fff5ba;
    }
}

@media (max-width: 500px) {
    .title { font-size: 1.8rem; }
    .happy-bday { font-size: 2.2rem; }
    .time-box span:first-child { font-size: 2rem; }
    .glass-card { padding: 1.5rem; }
}

/* Background Vehicles */
.vehicle {
    position: absolute;
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
}

.plane {
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.5));
    animation: flyRight linear forwards;
}

@keyframes flyRight {
    0% { transform: translateX(-10vw) translateY(0); }
    100% { transform: translateX(110vw) translateY(-5vh); }
}

/* --- Dog Assistant --- */
.dog-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    transition: all 1s ease-in-out;
}

.dog-container.center-mode {
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%);
    align-items: center;
}

.dog-sprite {
    width: 90px;
    height: auto;
    cursor: pointer;
    animation: dogBounce 3s ease-in-out infinite;
    user-select: none;
    position: relative;
    transition: transform 0.3s ease, width 1s ease-in-out;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
}

.dog-container.center-mode .dog-sprite {
    width: 140px;
}

@media (max-width: 600px) {
    .dog-sprite {
        width: 80px;
    }
}

.dog-sprite:hover {
    transform: scale(1.1);
}

.dog-sprite.sleeping {
    animation: none;
    transform: rotate(30deg) translateY(20px);
    cursor: default;
}

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

.speech-bubble {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 15px 20px;
    border-radius: 20px;
    border-bottom-right-radius: 5px;
    margin-bottom: 10px;
    max-width: 250px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    font-size: 0.95rem;
    position: relative;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.speech-bubble p {
    margin: 0 0 10px 0;
    line-height: 1.4;
    min-height: 1.4em;
    white-space: pre-wrap;
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.5) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

#dog-interaction-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dog-btn {
    background: #6495ed;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.dog-btn:hover {
    background: #4169e1;
}

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

.dog-input {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    font-size: 16px; /* Prevents iOS auto-zoom on click */
    user-select: text; /* Re-enable selection for typing */
    -webkit-user-select: text;
}

.zzz-animation {
    position: absolute;
    top: -20px;
    right: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    animation: floatZzz 3s infinite;
}

@keyframes floatZzz {
    0% { opacity: 0; transform: translateY(0) scale(0.8); }
    50% { opacity: 1; transform: translateY(-20px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-40px) scale(1); }
}

@media (max-width: 800px) {
    .birthday-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .photo-gallery.vertical {
        flex-direction: row;
        margin-bottom: 1.5rem;
    }
    
    .photo-gallery img {
        width: 100px;
        height: 100px;
    }
    
    .letter-container {
        max-height: 45vh; /* Force the scrollbar to appear securely inside the screen on mobile */
    }
}
