/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    color: #4a3c31; /* Warm dark brown text */
    overflow-x: hidden;
    scroll-behavior: smooth;
}

h1, h2, h3, .quran-verse {
    font-family: 'Amiri', serif;
}

/* Fixed Background Image */
.fixed-bg {
    position: fixed;
    top: -5%; /* Prevent white edges during pan */
    left: -5%;
    width: 110%; /* Extra width for panning */
    height: 110%;
    background-image: url('img/buharita_sunset.jpg');
    background-size: cover;
    background-position: center;
    z-index: -1;
    animation: romanticPan 25s ease-in-out infinite alternate;
}

@keyframes romanticPan {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.08) translate(-1%, 2%); }
}

/* Scroll Container */
.scroll-container {
    padding: 20px;
    padding-top: 50px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Glassmorphism Card Style */
.glass-card {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 30px 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
    
    /* Scroll Animation Initial State */
    opacity: 0;
    transform: translateY(60px);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy elegant curve */
}

/* Scroll Animation Visible State */
.glass-card.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Typography inside cards */
.elegant-title {
    font-size: 2.5rem;
    color: #6a4a3a;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1rem;
    color: #7a5c4d;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.8rem;
    color: #6a4a3a;
    margin-bottom: 20px;
}

.divider {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.divider-icon {
    width: 30px;
    height: 30px;
    margin: 10px;
    opacity: 0.8;
}

.quran-verse {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #553a2b;
    margin: 20px 0;
    padding: 0 10px;
}

.invitation-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #5c4a40;
    margin-top: 15px;
}

/* Calendar Styling */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px 5px;
    font-size: 0.9rem;
    color: #6a4a3a;
    margin-bottom: 20px;
    direction: ltr; /* Keeping calendar numbers LTR but days Arabic */
}

.day-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: #8c6e5f;
    margin-bottom: 10px;
}

.highlight-day {
    background: #d4af37; /* Gold accent */
    color: white;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.4);
}

.time-box {
    margin: 20px 0;
    color: #553a2b;
}

.time-box p {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.time-box h3 {
    font-family: 'Cairo', sans-serif;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.save-date-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #d4af37;
    color: #6a4a3a;
    padding: 10px 20px;
    border-radius: 25px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.save-date-btn:hover {
    background: #d4af37;
    color: white;
}

/* Countdown Styling */
.countdown-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    direction: ltr;
}

.countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
}

.countdown-item span:first-child {
    font-size: 1.8rem;
    font-weight: bold;
    color: #6a4a3a;
}

.label {
    font-size: 0.8rem;
    color: #8c6e5f;
}

.separator {
    font-size: 1.8rem;
    font-weight: bold;
    color: #d4af37;
    margin-bottom: 15px;
}

/* Gallery (Polaroid) */
.gallery-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.polaroid-frame {
    width: 90%;
    background: #fff;
    padding: 15px 15px 50px 15px; 
    box-shadow: 0 15px 25px rgba(0,0,0,0.1);
    border-radius: 4px;
}

.right-tilt { transform: rotate(3deg); }
.left-tilt { transform: rotate(-3deg); }

.real-photo {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    border-radius: 2px;
    filter: sepia(10%) contrast(105%);
}

/* Bottom Navigation Bar */
.nav-spacer {
    height: 80px; /* Space for the bottom nav */
}

.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 30px;
    display: flex;
    justify-content: space-around;
    padding: 10px 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.nav-item {
    text-decoration: none;
    color: #8c6e5f;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    transition: all 0.3s ease;
}

.nav-item ion-icon {
    font-size: 1.4rem;
}

.nav-item.active {
    color: #6a4a3a;
    transform: translateY(-2px);
}

.nav-item.active ion-icon {
    color: #d4af37; /* Highlight active icon */
}

/* Lock scrolling while envelope is closed */
body.locked {
    overflow: hidden;
    height: 100vh;
}

#buharita-layout {
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.5s ease;
    height: 100vh;
    overflow: hidden;
}

#buharita-layout.reveal {
    opacity: 1;
    pointer-events: auto;
    height: auto;
    overflow: auto;
}

/* 1. THE FULL-SCREEN ENVELOPE */
.envelope-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1500px;
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 1.5s ease;
    background-color: #111;
}

.env-full-back {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
    background-color: #f7f4ee; /* Creamy off-white interior */
    box-shadow: inset 0 0 30px rgba(0,0,0,0.05); /* Slight inner shadow for depth */
}

.textured {
    background-color: #6c7c5b; /* Lighter Olive green */
    background-image: url('img/texture.png');
    background-blend-mode: multiply;
    background-size: cover;
    background-position: center;
}

/* Flaps */
.flap-container {
    position: absolute;
    top: -2%; left: -2%; 
    width: 104%; height: 104%; /* Slight overflow to prevent gaps at edges */
}
.flap-shape {
    width: 100%; height: 100%;
}

.left-flap {
    z-index: 2;
    filter: drop-shadow(5px 0 15px rgba(0,0,0,0.7));
}
.clip-left { clip-path: polygon(0 0, 55% 50%, 0 100%); }

.right-flap {
    z-index: 2;
    filter: drop-shadow(-5px 0 15px rgba(0,0,0,0.7));
}
.clip-right { clip-path: polygon(100% 0, 45% 50%, 100% 100%); }

.bottom-flap {
    z-index: 3;
    filter: drop-shadow(0 -5px 15px rgba(0,0,0,0.7));
}
.clip-bottom { clip-path: polygon(0 100%, 50% 45%, 100% 100%); }

.top-flap {
    z-index: 4;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.8));
    transform-origin: top center;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.clip-top { clip-path: polygon(0 0, 100% 0, 50% 55%); }

.inner-flap {
    position: absolute;
    top: 0; left: 0;
    background: #f7f4ee; /* Creamy off-white for inside of flap */
    transform: rotateX(180deg) translateZ(-1px);
    backface-visibility: hidden;
}

.wax-seal {
    position: absolute;
    top: 55%; /* Align with the tip of the top flap */
    left: 50%;
    transform: translate(-50%, -50%) translateZ(2px);
    width: 65px;
    height: 65px;
    background: radial-gradient(circle at 30% 30%, #f9d976, #e9b646 40%, #c48b29 80%, #8a5a19);
    border-radius: 50%;
    box-shadow: 
        0 4px 10px rgba(0,0,0,0.4),
        inset 0 0 5px rgba(255,255,255,0.6),
        inset 0 0 15px rgba(138, 90, 25, 0.8);
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseSeal 2s infinite;
}

.seal-icon {
    width: 32px;
    height: 32px;
    opacity: 0.85;
    filter: drop-shadow(0px 1px 1px rgba(255,255,255,0.4)) drop-shadow(0px -1px 1px rgba(0,0,0,0.5));
}

.wax-seal::after {
    content: '';
    position: absolute;
    top: 6px; left: 6px; right: 6px; bottom: 6px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2), 0 2px 4px rgba(255,255,255,0.3);
}

@keyframes pulseSeal {
    0% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(212, 175, 55, 0); }
    100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

.wax-seal:hover {
    transform: translate(-50%, -50%) scale(1.1) translateZ(2px);
}

/* 2. THE ANIMATION SEQUENCE (.open state) */
.envelope-fullscreen.open .top-flap {
    transform: rotateX(180deg);
}
.envelope-fullscreen.open .wax-seal {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1.5) translateZ(2px); /* Scales up before fading out */
    transition: all 0.5s ease-out;
}
.envelope-fullscreen.slide-down {
    transform: translateY(120vh); /* Move down off screen */
    opacity: 0;
    pointer-events: none;
}

/* Fade in Text Animation */
.fade-text {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fade-text.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Hero Arch Design */
.arch-container {
    display: flex;
    justify-content: center;
    margin: 20px 0 40px 0;
}
.arch-border {
    position: relative;
    padding: 12px; 
    border: 1.5px solid #8a7b6a;
    border-radius: 160px 160px 0 0;
    border-bottom: none;
    width: 280px;
}
.arch-border::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.5px;
    background-color: #8a7b6a;
}
.arch-image {
    width: 100%;
    height: 340px;
    border-radius: 150px 150px 0 0;
    overflow: hidden;
    background-color: #f7f4ee;
}
.arch-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.diamond-left, .diamond-right {
    position: absolute;
    top: 50%;
    width: 9px;
    height: 9px;
    background-color: #8a7b6a;
    transform: translateY(-50%) rotate(45deg);
}
.diamond-left { left: -5.5px; }
.diamond-right { right: -5.5px; }

/* Elegant Date Layout */
.elegant-date-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 25px 0;
    color: #555;
    font-family: 'Amiri', serif;
}
.elegant-date-layout .month, .elegant-date-layout .year {
    font-size: 1.2rem;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: #777;
}
.elegant-date-layout .date-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
}
.elegant-date-layout .date-num {
    font-size: 3.5rem;
    color: #8a7b6a;
    line-height: 1;
}
.elegant-date-layout .day, .elegant-date-layout .time {
    font-size: 1.1rem;
    letter-spacing: 1.5px;
    color: #666;
}
.elegant-date-layout .divider-line {
    font-weight: 300;
    color: #ccc;
    font-size: 2rem;
    line-height: 1;
}


/* Butterfly Animation */
#butterfly-container {
    position: absolute;
    top: 50vh;
    left: 50vw;
    transform: translate(-50%, -50%) scale(0);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
}
#flying-butterfly {
    width: 60px;
    height: 60px;
    transform-origin: center;
}

body:not(.locked) #butterfly-container {
    opacity: 1;
    animation: 
        flyOutAndSettle 3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
        hoverSettle 4s ease-in-out infinite alternate 3s;
}

body:not(.locked) #flying-butterfly {
    animation: flutterWings 0.15s infinite alternate ease-in-out;
}

@keyframes flyOutAndSettle {
    0% {
        transform: translate(-50%, -50%) scale(0.2) rotate(-30deg);
        top: 50vh; left: 50vw;
    }
    40% {
        transform: translate(-20vw, -30vh) scale(1.5) rotate(20deg);
    }
    70% {
        transform: translate(10vw, -45vh) scale(1.2) rotate(-10deg);
    }
    100% {
        top: 15vh;
        left: 80vw;
        transform: translate(-50%, -50%) scale(0.8) rotate(15deg);
    }
}

@keyframes flutterWings {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0.2); }
}

@keyframes hoverSettle {
    0% {
        top: 15vh; left: 80vw;
        transform: translate(-50%, -50%) scale(0.8) rotate(15deg);
    }
    100% {
        top: 18vh; left: 78vw;
        transform: translate(-50%, -50%) scale(0.85) rotate(5deg);
    }
}

/* Developer Badge */
.developer-badge {
    position: relative;
    margin: 40px auto 20px 20px;
    width: fit-content;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-family: sans-serif;
    text-decoration: none;
    z-index: 10;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}
.developer-badge:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
