/**
 * MCN Promo Popup - Frontend Styles
 *
 * @package MCN_Promo_Popup
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --mcn-popup-z-index: 999999;
}

/* ============================================
   Popup Overlay
   ============================================ */
.mcn-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--mcn-popup-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.mcn-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Popup Container
   ============================================ */
.mcn-popup-container {
    position: relative;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.mcn-popup-overlay.active .mcn-popup-container {
    transform: scale(1);
}

/* Smart Auto-Sizing Mode */
.mcn-popup-overlay.mcn-size-auto .mcn-popup-container {
    max-width: none;
    width: auto;
    max-height: 95vh;
}

.mcn-popup-overlay.mcn-size-auto .mcn-popup-image img {
    max-width: 95vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Fit Mode */
.mcn-popup-overlay.mcn-size-fit .mcn-popup-image img {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}

/* Cover Mode */
.mcn-popup-overlay.mcn-size-cover .mcn-popup-image img {
    width: 100%;
    height: 100%;
    max-height: 80vh;
    object-fit: cover;
}

/* Scroll Mode */
.mcn-popup-overlay.mcn-size-scroll .mcn-popup-container {
    max-height: 90vh;
    overflow-y: auto;
}

.mcn-popup-overlay.mcn-size-scroll .mcn-popup-image img {
    width: 100%;
    height: auto;
    max-height: none;
}

/* ============================================
   Close Button
   ============================================ */
.mcn-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mcn-popup-close:hover {
    background: #ffffff;
    transform: scale(1.1);
}

.mcn-popup-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.mcn-popup-close svg {
    width: 50%;
    height: 50%;
    stroke-width: 2.5;
}

/* Close Button Outside */
.mcn-close-outside .mcn-popup-close {
    top: -40px;
    right: -40px;
    background: #ffffff;
}

@media (max-width: 767px) {
    .mcn-close-outside .mcn-popup-close {
        top: -44px;
        right: 0;
    }
}

/* ============================================
   Popup Content
   ============================================ */
.mcn-popup-content {
    overflow: hidden;
}

/* ============================================
   Popup Image
   ============================================ */
.mcn-popup-image {
    line-height: 0;
}

.mcn-popup-image a {
    display: block;
    text-decoration: none;
}

.mcn-popup-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}

/* ============================================
   Popup Text
   ============================================ */
.mcn-popup-text {
    padding: 24px;
    font-size: 16px;
    line-height: 1.6;
    color: #1d2327;
}

.mcn-popup-text p:first-child {
    margin-top: 0;
}

.mcn-popup-text p:last-child {
    margin-bottom: 0;
}

.mcn-popup-text h1,
.mcn-popup-text h2,
.mcn-popup-text h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #1d2327;
}

.mcn-popup-text a {
    color: #2271b1;
}

.mcn-popup-text a:hover {
    color: #135e96;
}

/* ============================================
   Countdown
   ============================================ */
.mcn-popup-countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.05);
    font-size: 13px;
    color: #50575e;
}

.mcn-countdown-timer {
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

/* ============================================
   Animations
   ============================================ */

/* Fade */
.mcn-animation-fade .mcn-popup-container {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.mcn-animation-fade.active .mcn-popup-container {
    opacity: 1;
    transform: scale(1);
}

/* Slide Down */
.mcn-animation-slide-down .mcn-popup-container {
    opacity: 0;
    transform: translateY(-50px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.mcn-animation-slide-down.active .mcn-popup-container {
    opacity: 1;
    transform: translateY(0);
}

/* Slide Up */
.mcn-animation-slide-up .mcn-popup-container {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.mcn-animation-slide-up.active .mcn-popup-container {
    opacity: 1;
    transform: translateY(0);
}

/* Zoom */
.mcn-animation-zoom .mcn-popup-container {
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mcn-animation-zoom.active .mcn-popup-container {
    opacity: 1;
    transform: scale(1);
}

/* Bounce */
.mcn-animation-bounce .mcn-popup-container {
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.mcn-animation-bounce.active .mcn-popup-container {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   Closing Animation
   ============================================ */
.mcn-popup-overlay.closing {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mcn-popup-overlay.closing .mcn-popup-container {
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

/* ============================================
   RTL Support
   ============================================ */
[dir="rtl"] .mcn-popup-close {
    right: auto;
    left: 10px;
}

[dir="rtl"] .mcn-close-outside .mcn-popup-close {
    right: auto;
    left: -40px;
}

@media (max-width: 767px) {
    [dir="rtl"] .mcn-close-outside .mcn-popup-close {
        left: 0;
    }
}

[dir="rtl"] .mcn-popup-text {
    text-align: right;
}

/* ============================================
   Accessibility
   ============================================ */
.mcn-popup-overlay:focus {
    outline: none;
}

.mcn-popup-container:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Screen reader only */
.mcn-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Body scroll lock
   ============================================ */
body.mcn-popup-open {
    overflow: hidden;
    padding-right: var(--mcn-scrollbar-width, 0);
}

/* ============================================
   Print
   ============================================ */
@media print {
    .mcn-popup-overlay {
        display: none !important;
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
    .mcn-popup-close {
        background: #ffffff;
        border: 2px solid #000000;
    }

    .mcn-popup-container {
        border: 2px solid #000000;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .mcn-popup-overlay,
    .mcn-popup-container,
    .mcn-popup-close {
        transition: none !important;
        animation: none !important;
    }
}

/* ============================================
   Mobile Optimizations
   ============================================ */
@media (max-width: 767px) {
    .mcn-popup-overlay {
        padding: 16px;
    }

    .mcn-popup-container {
        max-width: 92%;
        max-height: 85vh;
    }

    .mcn-popup-close {
        width: 36px;
        height: 36px;
        top: 8px;
        right: 8px;
    }

    .mcn-popup-text {
        padding: 20px;
        font-size: 15px;
    }

    .mcn-popup-countdown {
        padding: 10px 14px;
        font-size: 12px;
    }
}

/* ============================================
   Tablet
   ============================================ */
@media (min-width: 768px) and (max-width: 1024px) {
    .mcn-popup-container {
        max-width: 80%;
    }
}

/* ============================================
   Very Small Screens
   ============================================ */
@media (max-width: 320px) {
    .mcn-popup-overlay {
        padding: 10px;
    }

    .mcn-popup-container {
        max-width: 95%;
    }

    .mcn-popup-text {
        padding: 16px;
        font-size: 14px;
    }
}

/* ============================================
   Landscape Mobile
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .mcn-popup-container {
        max-height: 90vh;
    }

    .mcn-popup-image img {
        max-height: 60vh;
    }
}

/* ============================================
   Admin Preview Specific
   ============================================ */
.mcn-preview-active {
    position: relative;
    opacity: 1;
    visibility: visible;
    background: transparent;
    height: 100%;
    min-height: 400px;
}

.mcn-preview-active .mcn-popup-container {
    transform: scale(1);
    position: relative;
}
