/* Reset & Base Styles */
:root {
    --bg-color: #FDFBF7;
    --envelope-color: #f0e6d2;
    --envelope-shadow: rgba(0, 0, 0, 0.1);
    --heart-color: #C0392B;
    --text-color: #4a4a4a;
    --accent-pink: #FFD1DC;
}

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

body {
    background-color: var(--bg-color);
    font-family: 'Lato', sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    align-items: center;
    z-index: 2;
    /* Ensure container is above background */
}

/* Background Overlay */
.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/images/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 2s ease;
    z-index: 1;
    pointer-events: none;
}

.background-overlay.visible {
    opacity: 1;
}

/* Envelope Styles */
.envelope-wrapper {
    position: relative;
    cursor: pointer;
    transition: transform 0.5s ease, opacity 0.5s ease;
    z-index: 10;
}

.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    background-color: var(--envelope-color);
    box-shadow: 0 10px 20px var(--envelope-shadow);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The Flap */
.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 110px solid #e6d8c0;
    transform-origin: top;
    transition: transform 0.6s ease 0.2s;
    z-index: 2;
}

/* The Body (Triangle folds) */
.body {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-bottom: 100px solid #ece0cc;
    z-index: 1;
}

/* Side folds */
.envelope::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid #e0d4c0;
    border-bottom: 100px solid transparent;
    border-top: 100px solid transparent;
    z-index: 1;
}

.envelope::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-right: 150px solid #e0d4c0;
    border-bottom: 100px solid transparent;
    border-top: 100px solid transparent;
    z-index: 1;
}

/* Wax Seal */
.seal {
    position: absolute;
    top: 40px;
    z-index: 3;
    width: 50px;
    height: 50px;
    background-color: var(--heart-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.heart {
    color: #8a261c;
    font-size: 24px;
    user-select: none;
}

/* Hover Effect */
.envelope-wrapper:hover .seal {
    transform: scale(1.1);
}

/* Animations */
@keyframes vibration {
    0% {
        transform: translate(0);
    }

    10% {
        transform: translate(-1px, 1px);
    }

    20% {
        transform: translate(-1px, -1px);
    }

    30% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(-2px, -2px);
    }

    50% {
        transform: translate(-3px, 3px);
    }

    60% {
        transform: translate(3px, -3px);
    }

    70% {
        transform: translate(-4px, 4px);
    }

    80% {
        transform: translate(4px, -4px);
    }

    85% {
        transform: translate(-5px, 5px);
    }

    90% {
        transform: translate(5px, -5px);
    }

    95% {
        transform: translate(-3px, 3px);
    }

    100% {
        transform: translate(0);
    }
}

.vibrate {
    animation: vibration 1.5s ease-in-out;
}

.open .flap {
    transform: rotateX(180deg);
    z-index: 0;
}

.open .seal {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.envelope-wrapper.fade-out {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

/* Confetti Animation */
@keyframes confettiFall {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) rotate(var(--rotation));
        opacity: 0;
    }
}

/* Content Styles */
.content {
    position: absolute;
    width: 90%;
    max-width: 600px;
    height: 80vh;
    background: white;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s ease 0.5s, transform 0.8s ease 0.5s;
    overflow: hidden;
    /* Hide overflow on container, scroll wrapper handles it */
    text-align: center;
    z-index: 100;
}

.scroll-wrapper {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    /* Scrollable content */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 40px;
    padding-bottom: 20px;
    /* Space for bottom nav */
}

.card {
    width: 100%;
    min-height: 100%;
}

.content.visible {
    opacity: 1;
    transform: translateY(0);
}

.hidden {
    display: none;
}

/* Typography & Layout */
h1 {
    font-family: 'Great Vibes', cursive;
    font-size: 3rem;
    color: var(--heart-color);
    margin-bottom: 20px;
}

h2 {
    font-family: 'Great Vibes', cursive;
    font-size: 2.5rem;
    color: var(--heart-color);
    margin-bottom: 20px;
}

p {
    font-size: 1.0rem;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: justify;
}

.signature {
    font-family: 'Great Vibes', cursive;
    font-size: 2rem;
    margin-top: 30px;
}

/* Photo Grid Layouts */
.photo-grid {
    display: grid;
    gap: 20px;
    margin: 30px 0;
    width: 100%;
}

/* Page 1: floating images with text wrap */
.float-left {
    float: left;
    margin: 0 20px 15px 0;
    max-width: 45%;
}

.float-right {
    float: right;
    margin: 0 0 15px 20px;
    max-width: 45%;
}

/* Floating animation for page 1 photos */
@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* Sparkle animation */
@keyframes sparkle {

    0%,
    100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }

    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

/* Glow animation */
@keyframes glow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.1);
    }
}

/* Page 1 photos get floating animation and shadow */
#page-1 .photo-frame {
    animation: float 3s ease-in-out infinite;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Sparkles on hover */
#page-1 .photo-frame::before,
#page-1 .photo-frame::after {
    content: '✨';
    position: absolute;
    font-size: 20px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

#page-1 .photo-frame::before {
    top: 10%;
    right: 10%;
}

#page-1 .photo-frame::after {
    bottom: 10%;
    left: 10%;
}

#page-1 .photo-frame:hover::before {
    animation: sparkle 1.5s ease-in-out infinite;
}

#page-1 .photo-frame:hover::after {
    animation: sparkle 1.5s ease-in-out infinite 0.75s;
}

/* Glowing aura on hover */
#page-1 .photo-frame:hover {
    box-shadow:
        0 8px 16px rgba(0, 0, 0, 0.2),
        0 0 20px rgba(255, 215, 0, 0.4),
        0 0 40px rgba(255, 215, 0, 0.3),
        0 0 60px rgba(255, 215, 0, 0.2);
    animation: float 3s ease-in-out infinite, glow 2s ease-in-out infinite;
}

/* Clearfix for letter section */
.letter::after {
    content: "";
    display: table;
    clear: both;
}

/* Page 2: 3 photos */
.page-2-photos {
    grid-template-columns: repeat(3, 1fr);
}

/* Page 2 photos get the same floating animation and shadow as page 1 */
#page-2 .photo-frame {
    animation: float 3s ease-in-out infinite;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Sparkles on hover for page 2 */
#page-2 .photo-frame::before,
#page-2 .photo-frame::after {
    content: '';
    position: absolute;
    font-size: 20px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

#page-2 .photo-frame::before {
    top: 10%;
    right: 10%;
}

#page-2 .photo-frame::after {
    bottom: 10%;
    left: 10%;
}

#page-2 .photo-frame:hover::before {
    animation: sparkle 1.5s ease-in-out infinite;
}

#page-2 .photo-frame:hover::after {
    animation: sparkle 1.5s ease-in-out infinite 0.75s;
}

/* Glowing aura on hover for page 2 */
#page-2 .photo-frame:hover {
    box-shadow:
        0 8px 16px rgba(0, 0, 0, 0.2),
        0 0 20px rgba(255, 215, 0, 0.4), 0 0 40px rgba(255, 215, 0, 0.3),
        0 0 60px rgba(255, 215, 0, 0.2);
    animation: float 3s ease-in-out infinite, glow 2s ease-in-out infinite;
}


/* Ensure all page 2 photos are exactly the same size */
#page-2 .photo-frame img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

/* Page 3: 1 photo centered */
.page-3-photos {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 20px auto;
}

.photo-frame {
    position: relative;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: visible;
    transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.photo-frame:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.photo-frame img {
    width: 100%;
    height: auto;
    min-height: 150px;
    max-height: 200px;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE OPTIMIZATIONS
   ======================================== */

/* Mobile - All phones up to 600px */
@media (max-width: 600px) {

    /* Content card adjustments for mobile */
    .content {
        width: 95%;
        height: 85vh;
        padding: 0;
        /* Remove padding from container, move to wrapper if needed */
    }

    .scroll-wrapper {
        padding: 20px;
    }

    /* Envelope - standard mobile size */
    .envelope {
        width: 260px;
        height: 180px;
    }

    .flap {
        border-left-width: 130px;
        border-right-width: 130px;
    }

    .body {
        border-left-width: 130px;
        border-right-width: 130px;
    }

    .envelope::before,
    .envelope::after {
        border-left-width: 130px;
        border-right-width: 130px;
    }

    /* Typography adjustments */
    h1 {
        font-size: 2.2rem;
        margin-bottom: 15px;
    }

    h2 {
        font-size: 1.8rem;
        margin-bottom: 15px;
    }

    p {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 15px;
    }

    .signature {
        font-size: 1.6rem;
        margin-top: 20px;
    }

    /* Stack floated images on mobile */
    .float-left,
    .float-right {
        float: none;
        max-width: 100%;
        margin: 20px auto;
    }

    /* Stack photos on mobile */
    .page-2-photos {
        grid-template-columns: 1fr;
    }

    /* Larger touch targets for navigation */
    .corner-nav {
        width: 80px;
        height: 80px;
    }

    /* Adjust photo frame sizes for mobile */
    .photo-frame {
        margin-bottom: 15px;
    }

    #page-2 .photo-frame img {
        height: 200px;
    }

    /* Page layout adjustments */
    .page {
        padding: 10px;
    }
}

/* Small phones - iPhone SE, older Androids (320px - 375px) */
@media (max-width: 375px) {

    /* Further reduce content padding */
    .content {
        padding: 0;
        width: 98%;
    }

    .scroll-wrapper {
        padding: 15px;
    }

    /* Smaller envelope for tiny screens */
    .envelope {
        width: 220px;
        height: 150px;
    }

    .flap {
        border-left-width: 110px;
        border-right-width: 110px;
    }

    .body {
        border-left-width: 110px;
        border-right-width: 110px;
    }

    .envelope::before,
    .envelope::after {
        border-left-width: 110px;
        border-right-width: 110px;
    }

    /* Smaller typography for small screens */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    p {
        font-size: 0.95rem;
    }

    .signature {
        font-size: 1.4rem;
    }

    /* Adjust photo sizes */
    #page-2 .photo-frame img {
        height: 180px;
    }
}

/* Large phones & small tablets - iPhone Pro Max, Galaxy S series (601px - 768px) */
@media (min-width: 601px) and (max-width: 768px) {
    .content {
        padding: 30px;
        max-width: 90%;
    }

    h1 {
        font-size: 2.8rem;
    }

    h2 {
        font-size: 2.2rem;
    }
}

/* Page Layout */
.page {
    display: none;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

.page.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Corner Navigation */
.corner-nav {
    position: absolute;
    width: 80px;
    height: 80px;
    cursor: pointer;
    z-index: 1000;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.corner-triangle {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 50%, #e0d4c0 50%);
    box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.1);
    transition: background 0.3s ease;
}

/* Next Page - Top Right */
.next-page {
    top: 0;
    right: 0;
}

.next-page .corner-triangle {
    background: linear-gradient(225deg, transparent 50%, #e6d8c0 50%);
    box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.15);
}

.next-page:hover {
    transform: scale(1.1);
}

/* Prev Page - Bottom Left */
.prev-page {
    bottom: 0;
    left: 0;
}

.prev-page .corner-triangle {
    background: linear-gradient(45deg, transparent 50%, #e6d8c0 50%);
    box-shadow: 2px -2px 5px rgba(0, 0, 0, 0.15);
}

.prev-page:hover {
    transform: scale(1.1);
}

/* Hide navigation if not applicable */
.corner-nav.hidden {
    display: none;
}