/**
 * Interstitial Ad Styles
 * Add this to your theme's style.css or enqueue as a separate stylesheet
 */

/* Keyframes for fade-in animation */
@keyframes interstitial-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes interstitial-scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Main modal container */
.interstitial-ad-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    animation: interstitial-fade-in 0.3s ease-out;
}

/* Dark backdrop with blur effect */
.interstitial-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 1;
}

/* Centered window container */
/* Replace these styles in your CSS */

.interstitial-window {
    position: relative;
    display: flex;
    align-items: flex-start; /* Changed from center to flex-start */
    justify-content: center;
    width: 100%;
    height: 100%;
    z-index: 2;
    padding: 60px 20px 20px; /* Added top padding for close button */
    box-sizing: border-box;
    overflow-y: auto; /* Allow scrolling if ad is very tall */
}

.interstitial-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100vw;
    max-height: calc(100vh - 80px); /* Constrain height */
    animation: interstitial-scale-in 0.3s ease-out;
}

.interstitial-ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    overflow: hidden;
    max-height: calc(100vh - 80px); /* Constrain ad height */
}

.interstitial-ad-slot iframe {
    display: block;
    border: 0;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px); /* Leave room for close button */
    object-fit: contain;
}

/* Close button - now positioned fixed at top right of modal */
.interstitial-close-btn {
    position: fixed; /* Changed from absolute to fixed */
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    padding: 8px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.95);
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    transition: background-color 0.2s ease, transform 0.2s ease;
    z-index: 999999; /* Ensure it's above everything */
}

.interstitial-close-btn:hover {
    background-color: #ffffff;
    transform: scale(1.1);
}

.interstitial-close-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.interstitial-close-btn svg {
    width: 24px;
    height: 24px;
}

[dir="rtl"] .interstitial-close-btn {
    right: auto;
    left: 15px;
}

@media (max-width: 768px) {
    .interstitial-window {
        padding: 50px 10px 10px;
    }
    
    .interstitial-close-btn {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }
    
    .interstitial-close-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .interstitial-ad-slot iframe {
        max-height: calc(100vh - 60px);
    }
}

/* Prevent body scroll when modal is open */
body.interstitial-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Loading state for ad slot */
.interstitial-ad-slot.loading {
    min-width: 300px;
    min-height: 250px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.interstitial-ad-slot.loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: interstitial-spin 0.8s linear infinite;
}

@keyframes interstitial-spin {
    to {
        transform: rotate(360deg);
    }
}
