* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Amiri Regular */
@font-face {
    font-family: 'Amiri';
    src: url('fonts/Amiri/Amiri-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Amiri Bold */
@font-face {
    font-family: 'Amiri';
    src: url('fonts/Amiri/Amiri-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Tajawal Regular */
@font-face {
    font-family: 'Tajawal';
    src: url('fonts/Tajawal/Tajawal-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Tajawal Bold */
@font-face {
    font-family: 'Tajawal';
    src: url('fonts/Tajawal/Tajawal-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

body {
    font-family: 'Amiri', 'Tajawal', serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.invitation-container {
    background: white;
    max-width: 600px;
    width: 100%;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
    /* Simplified background pattern for better mobile performance */
    background-image:
        radial-gradient(circle at 25px 25px, rgba(212, 175, 55, 0.04) 1px, transparent 1px),
        radial-gradient(circle at 75px 75px, rgba(212, 175, 55, 0.04) 1px, transparent 1px);
    background-size: 100px 100px;
    background-position: 0 0, 50px 50px;
}

/* Arabic letter background pattern with 3D effect */
.invitation-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* SVG pattern with Arabic letters and enhanced 3D shadows */
    background-image: url('pattern.svg');
    background-repeat: repeat;
    background-size: 600px 600px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.invitation-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Simplified decorative pattern for better mobile performance */
    background-image:
        radial-gradient(ellipse 30px 40px at 20% 20%, transparent 48%, rgba(212, 175, 55, 0.02) 50%, transparent 52%),
        radial-gradient(ellipse 30px 40px at 80% 80%, transparent 48%, rgba(212, 175, 55, 0.02) 50%, transparent 52%);
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

.invitation-container>* {
    position: relative;
    z-index: 2;
}

.ornament {
    width: 120px;
    height: 2px;
    background: linear-gradient(to right, transparent, #b58346, transparent);
    margin: 20px auto;
    position: relative;
}

/* Musnad-style decorative dots */
.ornament::before,
.ornament::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #d4af37;
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
}

.ornament::before {
    left: -15px;
}

.ornament::after {
    right: -15px;
}

h1 {
    font-size: 2.5em;
    color: #d4af37;
    margin-bottom: 20px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.family-name {
    font-size: 3em;
    color: #2c3e50;
    margin: 20px 0;
    font-weight: 700;
    line-height: 1.3;
}

.couple-names {
    font-size: 1.8em;
    color: #34495e;
    margin: 20px 0;
    font-weight: 400;
    line-height: 1.5;
}

.date-info {
    font-size: 1.8em;
    color: #34495e;
    margin: 30px 0;
    font-weight: 400;
    direction: rtl;
    unicode-bidi: bidi-override;
}

/* Countdown Timer Styles - Outside Flip Card */
.countdown {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: nowrap;
    direction: rtl;
    unicode-bidi: bidi-override;
    margin: 30px 0;
}

.countdown-item {
    background: white;
    padding: 20px;
    border-radius: 10px;
    min-width: 80px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.countdown-number {
    font-size: 2.5em;
    font-weight: 700;
    color: #d4af37;
    display: block;
}

.countdown-label {
    font-size: 1em;
    color: #7f8c8d;
    margin-top: 5px;
}

/* Flip Card Container */
.flip-card-container {
    -webkit-perspective: 1000px;
    perspective: 1000px;
    margin: 30px 0;
    cursor: pointer;
    position: relative;
    height: 480px;
    min-height: 480px;
    max-height: 480px;
    /* Safari iOS touch optimization */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s ease;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-perspective: 1000px;
}

.flip-card-container.flipped .flip-card-inner {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    top: 0;
    left: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: opacity 0.5s ease, transform 0.8s ease;
    height: 480px;
    min-height: 480px;
    max-height: 480px;
    box-sizing: border-box;
    width: 100%;
}

.flip-card-front {
    background: linear-gradient(135deg, #fdfbfb 0%, #f8f6f3 100%);
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    z-index: 2;
    opacity: 1;
    pointer-events: auto;
}

.flip-card-back {
    background: linear-gradient(135deg, #fdfbfb 0%, #f8f6f3 100%);
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    overflow: hidden;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

.flip-card-container.flipped .flip-card-front {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.flip-card-container.flipped .flip-card-back {
    opacity: 1;
    pointer-events: auto;
    z-index: 2;
}

.flip-card-back::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background:
        radial-gradient(circle at 30% 30%, rgba(212, 175, 55, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(212, 175, 55, 0.1) 0%, transparent 50%);
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

/* Message Container (Front) */
.message-container {
    position: relative;
    z-index: 1;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    flex: 1;
}

.message-title {
    font-family: 'Amiri', serif;
    font-size: 1.8em;
    color: #d4af37;
    margin-bottom: 20px;
    margin-top: 0;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.1em;
    text-align: center;
}

.message {
    font-family: 'Tajawal', 'Amiri', serif;
    font-size: 1.4em;
    line-height: 1.8;
    color: #2c3e50;
    margin: 0 auto;
    max-width: 400px;
}

.message-verse {
    margin: 10px 0;
    position: relative;
}

.message-decoration {
    width: 60px;
    height: 1px;
    background: linear-gradient(to right, transparent, #d4af37, transparent);
    margin: 15px auto;
}

/* Map Container (Back) */
.map-container {
    position: relative;
    z-index: 1;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 0;
}

.map-preview {
    width: 100%;
    margin-bottom: 15px;
}

.map-preview iframe {
    width: 100%;
    /* Safari iOS iframe fix */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    /* Make iframe non-interactive */
    pointer-events: none;
}

.map-button {
    display: inline-block;
    background: linear-gradient(135deg, #d4af37 0%, #b58346 100%);
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    text-decoration: none;
    font-family: 'Tajawal', sans-serif;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    margin-top: 10px;
}

.map-button:hover {
    background: linear-gradient(135deg, #b58346 0%, #d4af37 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.map-button:active {
    transform: translateY(0);
}

.map-title {
    font-family: 'Amiri', serif;
    font-size: 1.8em;
    color: #d4af37;
    margin-bottom: 5px;
    margin-top: 0;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.1em;
    text-align: center;
}

.map-address {
    font-family: 'Tajawal', sans-serif;
    font-size: 1.2em;
    color: #2c3e50;
    margin-bottom: 10px;
    margin-top: 0;
    text-align: center;
}

.map-decoration {
    width: 60px;
    height: 1px;
    background: linear-gradient(to right, transparent, #d4af37, transparent);
    margin: 8px auto 15px;
}

.click-hint {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9em;
    color: #7f8c8d;
    opacity: 0.7;
    font-family: 'Tajawal', sans-serif;
    z-index: 2;
}

.footer-text {
    font-size: 1.2em;
    color: #7f8c8d;
    margin-top: 15px;
    /* Reduce space here */
    font-style: italic;
}

/* Instagram icon styles - small and subtle */
.social-media {
    margin-top: 15px;
    text-align: center;
}

.whatsapp-link {
    display: inline-block;
    color: #d4af37;
    transition: all 0.3s ease;
    text-decoration: none;
    opacity: 0.6;
    line-height: 0;
}

.whatsapp-link svg {
    width: 24px;
    height: 24px;
}

.whatsapp-link:hover {
    color: #b58346;
    opacity: 1;
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .invitation-container {
        padding: 30px 20px;
    }

    h1 {
        font-size: 2em;
    }

    .family-name {
        font-size: 2.2em;
    }

    .couple-names {
        font-size: 1.5em;
    }

    .date-info {
        font-size: 1.5em;
    }

    .countdown-item {
        min-width: 60px;
        padding: 12px 8px;
    }

    .countdown-number {
        font-size: 1.8em;
    }

    .countdown-label {
        font-size: 0.9em;
    }

    .countdown {
        gap: 10px;
    }

    .message {
        font-size: 1.2em;
    }

    .message-title,
    .map-title {
        font-size: 1.5em;
    }
    
    .map-address {
        font-size: 1em;
    }

    .flip-card-container {
        height: 420px;
        min-height: 420px;
        max-height: 420px;
    }
    
    .flip-card-front,
    .flip-card-back {
        height: 420px;
        min-height: 420px;
        max-height: 420px;
    }
    
    .map-preview iframe {
        height: 180px;
    }
    
    .map-button {
        font-size: 1em;
        padding: 10px 20px;
    }

    .click-hint {
        bottom: 0px;
    }

    /* Video popup mobile styles */
    .video-container {
        width: 95%;
        max-width: none;
        /* Remove max width on mobile */
        padding: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .video-close {
        top: 5px;
        right: 5px;
        padding: 6px 10px;
        font-size: 12px;
    }

    .video-wrapper {
        padding: 0;
    }

    .video-wrapper div {
        padding: 15px;
    }

    .video-wrapper h3 {
        font-size: 1.1em;
        margin-bottom: 10px;
        line-height: 1.3;
    }

    .video-wrapper p {
        font-size: 0.85em;
        margin-bottom: 10px;
        line-height: 1.4;
    }

    .video-wrapper a {
        display: inline-block;
        background: #d4af37;
        color: white;
        padding: 8px 16px;
        text-decoration: none;
        border-radius: 5px;
        font-size: 0.85em;
        margin: 10px auto;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .family-name {
        font-size: 1.8em;
    }

    .couple-names {
        font-size: 1.3em;
    }

    .countdown-item {
        min-width: 50px;
        padding: 8px 5px;
    }

    .countdown-number {
        font-size: 1.5em;
    }

    .countdown-label {
        font-size: 0.8em;
    }

    .countdown {
        gap: 8px;
    }

    .message {
        font-size: 1em;
    }
    
    .message-title,
    .map-title {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    
    .map-address {
        font-size: 0.9em;
        margin-bottom: 8px;
    }
    
    .message-decoration,
    .map-decoration {
        margin: 5px auto 10px;
    }
    
    .message-verse {
        margin: 8px 0;
    }

    .flip-card-container {
        height: 400px;
        min-height: 400px;
        max-height: 400px;
    }
    
    .flip-card-front,
    .flip-card-back {
        padding: 20px;
        height: 400px;
        min-height: 400px;
        max-height: 400px;
    }
    
    .map-preview iframe {
        height: 160px;
    }
    
    .map-button {
        font-size: 0.9em;
        padding: 8px 16px;
    }

    /* Extra small mobile adjustments */
    .video-container {
        padding: 8px;
    }

    .video-wrapper h3 {
        font-size: 1em;
    }

    .video-wrapper p {
        font-size: 0.8em;
    }

    .video-wrapper a {
        font-size: 0.8em;
        padding: 6px 12px;
    }
}

/* YouTube Video Container */
.video-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    /* Smaller for better UI on PC */
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 20px;
    z-index: 1000;
    display: none;
}

.video-container.show {
    display: block;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.video-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #d4af37;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Tajawal', sans-serif;
}

.video-close:hover {
    background: #b58346;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 10px;
}

.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: none;
}

.video-overlay.show {
    display: block;
}

/* PC View */
@media (min-width: 769px) {
    .message {
        font-size: 1.3em;
        line-height: 1.7;
    }

    /* Video popup PC styles */
    .video-wrapper a {
        display: inline-block;
        background: #d4af37;
        color: white;
        padding: 12px 30px;
        text-decoration: none;
        border-radius: 5px;
        font-size: 1.1em;
        margin: 15px auto;
        text-align: center;
        transition: background 0.3s ease;
    }

    .video-wrapper a:hover {
        background: #b58346;
        transform: translateY(-1px);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    .video-wrapper h3 {
        font-size: 1.6em;
    }

    .video-wrapper p {
        font-size: 1.1em;
    }
}