/**
 * Public CSS for HLS Ad Popper
 * 
 * @package    HLS_Ad_Popper
 * @author     Omar Martin, Higher Level Strategies, Inc.
 */

/* Container Base Styles */
.hls-ad-popper {
    position: fixed !important;
    z-index: 999999 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Position Variants - Desktop */
.hls-position-top-left {
    top: 20px;
    left: 20px;
}

.hls-position-top-right {
    top: 20px;
    right: 20px;
}

.hls-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.hls-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

/* Banner (Collapsed State) - 315 x 75px */
.hls-ad-banner {
    position: relative;
    width: 315px !important;
    height: 75px !important;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: scale(1);
}

.hls-ad-banner.hls-hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

.hls-ad-banner img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.hls-ad-popper:hover .hls-ad-banner img {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Expanded Content */
.hls-ad-expanded {
    position: absolute;
    opacity: 0 !important;
    transform: scale(0.9) !important;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none !important;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    background: #fff;
    max-width: 600px;
    max-height: 600px;
    display: none !important;
}

.hls-ad-expanded.hls-visible {
    display: block !important;
    opacity: 1 !important;
    transform: scale(1) !important;
    pointer-events: auto !important;
}

/* Position-specific expanded placement */
.hls-position-top-left .hls-ad-expanded,
.hls-position-bottom-left .hls-ad-expanded {
    left: 0;
}

.hls-position-top-right .hls-ad-expanded,
.hls-position-bottom-right .hls-ad-expanded {
    right: 0;
}

.hls-position-top-left .hls-ad-expanded,
.hls-position-top-right .hls-ad-expanded {
    top: 0;
}

.hls-position-bottom-left .hls-ad-expanded,
.hls-position-bottom-right .hls-ad-expanded {
    bottom: 0;
}

/* Expanded Content - Images */
.hls-ad-expanded img {
    display: block !important;
    width: 100% !important;
    max-width: 600px !important;
    height: auto !important;
    cursor: pointer !important;
}

/* Expanded Content - Video */
.hls-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.hls-video-container iframe,
.hls-video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Expanded Content - HTML */
.hls-html-container {
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
}

/* Dismiss Link */
.hls-dismiss-container {
    text-align: center;
    padding: 2.5px;
    background: rgba(0, 0, 0, 0.05);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.hls-dismiss-link {
    font-size: 12px;
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.hls-dismiss-link:hover {
    color: #333;
    text-decoration: underline;
}

/* Countdown Timer */
.hls-countdown {
    position: absolute;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-align: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

/* Countdown Positions on Banner */
.hls-ad-banner .hls-countdown-position-top-left {
    top: 8px;
    left: 8px;
}

.hls-ad-banner .hls-countdown-position-top-center {
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.hls-ad-banner .hls-countdown-position-top-right {
    top: 8px;
    right: 8px;
}

.hls-ad-banner .hls-countdown-position-bottom-left {
    bottom: 8px;
    left: 8px;
}

.hls-ad-banner .hls-countdown-position-bottom-center {
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.hls-ad-banner .hls-countdown-position-bottom-right {
    bottom: 8px;
    right: 8px;
}

/* Countdown Positions on Expanded */
.hls-ad-expanded .hls-countdown-position-top-left {
    top: 12px;
    left: 12px;
}

.hls-ad-expanded .hls-countdown-position-top-center {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
}

.hls-ad-expanded .hls-countdown-position-top-right {
    top: 12px;
    right: 12px;
}

.hls-ad-expanded .hls-countdown-position-bottom-left {
    bottom: 12px;
    left: 12px;
}

.hls-ad-expanded .hls-countdown-position-bottom-center {
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
}

.hls-ad-expanded .hls-countdown-position-bottom-right {
    bottom: 12px;
    right: 12px;
}

/* Mobile Styles */
@media screen and (max-width: 768px) {
    /* Mobile: Ad takes up footer area, max 30% of screen */
    .hls-ad-mobile {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 30vh !important;
        z-index: 999999;
    }
    
    .hls-ad-mobile .hls-ad-banner {
        width: 100%;
        height: auto;
        max-height: 30vh;
    }
    
    .hls-ad-mobile .hls-ad-banner img {
        width: 100%;
        height: auto;
        border-radius: 0;
    }
    
    .hls-ad-mobile .hls-ad-expanded {
        position: relative;
        max-width: 100%;
        max-height: 30vh;
        border-radius: 0;
        bottom: auto;
        left: auto;
        right: auto;
        top: auto;
    }
    
    .hls-ad-mobile .hls-ad-expanded img {
        max-height: 25vh;
        object-fit: contain;
    }
    
    .hls-ad-mobile .hls-video-container {
        max-height: 25vh;
        padding-bottom: 0;
        height: 25vh;
    }
    
    /* Non-mobile ads on mobile screens */
    .hls-ad-popper:not(.hls-ad-mobile) {
        max-width: 90vw;
    }
    
    .hls-ad-popper:not(.hls-ad-mobile) .hls-ad-banner {
        width: 250px;
        height: 60px;
    }
    
    .hls-ad-popper:not(.hls-ad-mobile) .hls-ad-expanded {
        max-width: 90vw;
        max-height: 70vh;
    }
    
    .hls-position-top-left,
    .hls-position-bottom-left {
        left: 10px;
    }
    
    .hls-position-top-right,
    .hls-position-bottom-right {
        right: 10px;
    }
    
    .hls-position-top-left,
    .hls-position-top-right {
        top: 10px;
    }
    
    .hls-position-bottom-left,
    .hls-position-bottom-right {
        bottom: 10px;
    }
}

/* Accessibility */
.hls-ad-popper:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Animation for entrance */
@keyframes hlsSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hls-ad-popper {
    animation: hlsSlideIn 0.5s ease-out;
}

/* Smooth scrollbar for HTML content */
.hls-html-container::-webkit-scrollbar {
    width: 8px;
}

.hls-html-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.hls-html-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.hls-html-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Ensure dismiss link is always visible */
.hls-dismiss-container {
    position: relative;
    z-index: 11;
}
