/* ============================================
   CSS VARIABLES & DESIGN TOKENS
   ============================================ */
:root {
    /* Tulip Pink Color Palette */
    --primary-pink: #FFB6D9;
    --light-pink: #FFCCE5;
    --soft-pink: #FFE5F0;
    --pastel-pink: #FFF0F7;
    --deep-pink: #FF9AC9;
    --rose-pink: #FF80B8;

    /* Accent Colors */
    --accent-purple: #E8B4F0;
    --accent-peach: #FFD4C4;
    --white: #FFFFFF;
    --text-dark: #5A4B5F;
    --text-soft: #8B7B8F;

    /* Shadows & Effects */
    --shadow-soft: 0 8px 32px rgba(255, 182, 217, 0.3);
    --shadow-medium: 0 12px 48px rgba(255, 182, 217, 0.4);
    --shadow-strong: 0 16px 64px rgba(255, 182, 217, 0.5);

    /* Typography */
    --font-main: 'Quicksand', sans-serif;
    --font-fancy: 'Dancing Script', cursive;

    /* Animations */
    --transition-smooth: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg,
            var(--pastel-pink) 0%,
            var(--soft-pink) 50%,
            var(--light-pink) 100%);
    min-height: 100vh;
    overflow: hidden;
    color: var(--text-dark);
    position: relative;
}

/* ============================================
   FLOATING HEARTS BACKGROUND
   ============================================ */
.hearts-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.heart {
    position: absolute;
    font-size: 20px;
    opacity: 0;
    animation: floatHeart 8s infinite;
    filter: drop-shadow(0 2px 8px rgba(255, 182, 217, 0.4));
}

@keyframes floatHeart {
    0% {
        transform: translateY(100vh) scale(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-20vh) scale(1.5) rotate(360deg);
        opacity: 0;
    }
}

/* ============================================
   FLOATING EMOJIS
   ============================================ */
.emoji-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.floating-emoji {
    position: absolute;
    font-size: 24px;
    opacity: 0;
    animation: floatEmoji 10s infinite;
    filter: drop-shadow(0 2px 8px rgba(255, 182, 217, 0.3));
}

@keyframes floatEmoji {
    0% {
        transform: translateY(100vh) translateX(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(-20vh) translateX(100px) rotate(180deg);
        opacity: 0;
    }
}

/* ============================================
   MAIN CONTAINER
   ============================================ */
.main-container {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ============================================
   ENVELOPE STYLES
   ============================================ */
.envelope-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: fadeInScale 1s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.envelope {
    position: relative;
    width: 280px;
    height: 180px;
    cursor: pointer;
    transition: var(--transition-smooth);
    filter: drop-shadow(var(--shadow-medium));
}

.envelope:hover {
    transform: translateY(-10px) scale(1.05);
    filter: drop-shadow(var(--shadow-strong));
}

.envelope-body {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 140px;
    background: linear-gradient(135deg, var(--primary-pink) 0%, var(--light-pink) 100%);
    border-radius: 8px;
    border: 3px solid var(--white);
    box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.5);
}

.envelope-flap {
    position: absolute;
    top: 25px;
    left: 0;
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, var(--deep-pink) 0%, var(--primary-pink) 100%);
    clip-path: polygon(0% 15%, 50% 100%, 100% 15%);
    transform-origin: 50% 15%;
    transition: var(--transition-bounce);
    z-index: 2;
}

.envelope.opening .envelope-flap {
    transform: rotateX(180deg) translateY(-5px);
}

.envelope-seal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, var(--white) 0%, var(--light-pink) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--rose-pink);
    box-shadow: 0 4px 16px rgba(255, 154, 201, 0.4);
    z-index: 3;
    transition: var(--transition-smooth);
    line-height: 1;
}

.envelope:hover .envelope-seal {
    transform: translate(-50%, -50%) scale(1.1) rotate(15deg);
}

.seal-emoji {
    font-size: 32px;
    animation: pulse 2s infinite;
    display: block;
    line-height: 1;
    text-align: center;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.tap-hint {
    font-family: var(--font-fancy);
    font-size: 24px;
    color: var(--deep-pink);
    text-shadow: 0 2px 8px rgba(255, 182, 217, 0.5);
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ============================================
   LETTER STYLES
   ============================================ */
.letter-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: opacity 0.6s ease;
}

.letter-container.active {
    opacity: 1;
    pointer-events: all;
}

.letter {
    background: var(--white);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-strong);
    position: relative;
    transform: scale(0.5) translateY(100px);
    transition: var(--transition-bounce);
    border: 4px solid var(--light-pink);
}

.letter-container.active .letter {
    transform: scale(1) translateY(0);
}

/* Custom Scrollbar */
.letter::-webkit-scrollbar {
    width: 8px;
}

.letter::-webkit-scrollbar-track {
    background: var(--pastel-pink);
    border-radius: 4px;
}

.letter::-webkit-scrollbar-thumb {
    background: var(--primary-pink);
    border-radius: 4px;
}

.letter::-webkit-scrollbar-thumb:hover {
    background: var(--deep-pink);
}

/* Letter Header */
.letter-header {
    text-align: center;
    margin-bottom: 30px;
}

.tulip-decoration {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 32px;
    margin-bottom: 15px;
    animation: sway 3s infinite ease-in-out;
}

@keyframes sway {

    0%,
    100% {
        transform: rotate(-3deg);
    }

    50% {
        transform: rotate(3deg);
    }
}

.letter-title {
    font-family: var(--font-fancy);
    font-size: 48px;
    color: var(--rose-pink);
    margin-bottom: 10px;
    text-shadow: 0 2px 12px rgba(255, 128, 184, 0.3);
}

.sparkle-line {
    font-size: 18px;
    color: var(--primary-pink);
    letter-spacing: 3px;
}

/* Letter Content */
.letter-content {
    line-height: 1.8;
    color: var(--text-dark);
    font-size: 18px;
}

.greeting {
    font-family: var(--font-fancy);
    font-size: 28px;
    color: var(--deep-pink);
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.letter-content p {
    margin-bottom: 20px;
    text-align: justify;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

/* Letter Footer */
.letter-footer {
    margin-top: 40px;
    text-align: center;
}

.signature-line {
    width: 150px;
    height: 2px;
    background: linear-gradient(90deg,
            transparent 0%,
            var(--primary-pink) 50%,
            transparent 100%);
    margin: 0 auto 20px;
}

.emoji-signature {
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 28px;
    animation: twinkle 2s infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Close Button */
.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--light-pink);
    background: var(--white);
    color: var(--deep-pink);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(255, 182, 217, 0.3);
}

.close-button:hover {
    background: var(--light-pink);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 16px rgba(255, 182, 217, 0.5);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Large Tablets and Small Desktops (1024px and below) */
@media (max-width: 1024px) {
    body {
        padding: 10px;
    }

    .letter {
        max-width: 90%;
        padding: 35px 30px;
    }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
    .envelope {
        width: 240px;
        height: 150px;
    }

    .envelope-body {
        height: 120px;
    }

    .envelope-flap {
        top: 20px;
        height: 100px;
    }

    .envelope-seal {
        width: 50px;
        height: 50px;
    }

    .seal-emoji {
        font-size: 26px;
    }

    .tap-hint {
        font-size: 20px;
    }

    .letter {
        padding: 30px 25px;
        max-height: 85vh;
        max-width: 95%;
    }

    .letter-title {
        font-size: 36px;
    }

    .tulip-decoration {
        font-size: 28px;
        gap: 10px;
    }

    .sparkle-line {
        font-size: 16px;
    }

    .letter-content {
        font-size: 16px;
        line-height: 1.7;
    }

    .greeting {
        font-size: 24px;
    }

    .emoji-signature {
        font-size: 24px;
        gap: 10px;
    }

    .close-button {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
}

/* Mobile Landscape & Small Tablets (640px and below) */
@media (max-width: 640px) {
    .main-container {
        padding: 15px;
    }

    .envelope {
        width: 220px;
        height: 140px;
    }

    .envelope-body {
        height: 110px;
    }

    .envelope-flap {
        top: 18px;
        height: 90px;
    }

    .letter {
        padding: 25px 20px;
        border-width: 3px;
    }

    .letter-title {
        font-size: 32px;
    }

    .tulip-decoration {
        font-size: 24px;
    }

    .letter-content {
        font-size: 15px;
    }

    .greeting {
        font-size: 22px;
    }
}

/* Mobile Portrait (480px and below) */
@media (max-width: 480px) {
    .main-container {
        padding: 10px;
    }

    .envelope {
        width: 200px;
        height: 130px;
    }

    .envelope-body {
        height: 100px;
    }

    .envelope-flap {
        top: 15px;
        height: 80px;
    }

    .envelope-seal {
        width: 45px;
        height: 45px;
    }

    .seal-emoji {
        font-size: 22px;
    }

    .tap-hint {
        font-size: 18px;
    }

    .letter {
        padding: 20px 18px;
        max-height: 88vh;
    }

    .letter-title {
        font-size: 28px;
        margin-bottom: 8px;
    }

    .tulip-decoration {
        font-size: 22px;
        gap: 8px;
        margin-bottom: 12px;
    }

    .sparkle-line {
        font-size: 14px;
        letter-spacing: 2px;
    }

    .letter-content {
        font-size: 14px;
        line-height: 1.6;
    }

    .letter-content p {
        margin-bottom: 15px;
    }

    .greeting {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .emoji-signature {
        font-size: 20px;
        gap: 8px;
    }

    .signature-line {
        width: 120px;
    }

    .close-button {
        width: 32px;
        height: 32px;
        font-size: 18px;
        top: 10px;
        right: 10px;
    }

    /* Reduce floating elements on small screens */
    .heart,
    .floating-emoji {
        font-size: 18px;
    }
}

/* Very Small Mobile (360px and below) */
@media (max-width: 360px) {
    .envelope {
        width: 180px;
        height: 120px;
    }

    .envelope-body {
        height: 90px;
    }

    .envelope-flap {
        top: 12px;
        height: 70px;
    }

    .letter {
        padding: 18px 15px;
        max-height: 90vh;
    }

    .letter-title {
        font-size: 26px;
    }

    .tulip-decoration {
        font-size: 20px;
    }

    .letter-content {
        font-size: 13px;
    }

    .greeting {
        font-size: 18px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets for mobile */
    .envelope {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .close-button {
        min-width: 44px;
        min-height: 44px;
    }

    /* Disable hover effects on touch devices */
    .envelope:hover {
        transform: none;
        filter: drop-shadow(var(--shadow-medium));
    }

    .close-button:hover {
        background: var(--white);
        transform: none;
    }
}

/* Landscape Orientation on Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .letter {
        max-height: 95vh;
        padding: 15px;
    }

    .letter-header {
        margin-bottom: 15px;
    }

    .letter-footer {
        margin-top: 20px;
    }

    .tulip-decoration {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .letter-title {
        font-size: 24px;
        margin-bottom: 5px;
    }

    .letter-content {
        font-size: 13px;
        line-height: 1.5;
    }

    .letter-content p {
        margin-bottom: 12px;
    }
}

/* ============================================
   ANIMATIONS & EFFECTS
   ============================================ */
.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* Sparkle effect on hover */
@keyframes sparkle {

    0%,
    100% {
        opacity: 0;
        transform: scale(0);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}