/* iOS Safari and Opera Ad Compatibility Fixes */

/* Fix for iOS Safari ad blocking and rendering issues */
/* These fixes address common iOS Safari problems with banner ads */

/* Top banner ad fixes */
#top_space {
    /* Force hardware acceleration for better iOS rendering */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    
    /* Ensure proper display in iOS Safari */
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-justify-content: center !important;
    justify-content: center !important;
    -webkit-align-items: center !important;
    align-items: center !important;
    
    /* iOS Safari specific fixes */
    -webkit-box-sizing: border-box !important;
    box-sizing: border-box !important;
    
    /* Prevent iOS Safari from hiding the container */
    min-height: 90px !important;
    max-height: 90px !important;
    
    /* Force visibility in iOS Safari */
    opacity: 1 !important;
    visibility: visible !important;
    
    /* Prevent iOS Safari from collapsing the container */
    position: relative !important;
    z-index: 10 !important;
}

#top_space a {
    /* iOS Safari link compatibility */
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    
    /* Force hardware acceleration */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    
    /* Ensure proper display */
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-align-items: center !important;
    align-items: center !important;
    -webkit-justify-content: center !important;
    justify-content: center !important;
    
    /* Prevent iOS Safari from hiding links */
    opacity: 1 !important;
    visibility: visible !important;
}

#top_space img {
    /* iOS Safari image rendering fixes */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    
    /* Prevent iOS Safari from blocking images */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    
    /* iOS Safari object-fit support */
    -webkit-object-fit: contain !important;
    object-fit: contain !important;
    -webkit-object-position: center !important;
    object-position: center !important;
    
    /* Ensure image loads in iOS Safari */
    max-width: 100% !important;
    height: auto !important;
    
    /* Force image rendering */
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: auto !important;
}

/* Chart area banner ad fixes */
#box_space {
    /* Force hardware acceleration */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    
    /* iOS Safari display fixes */
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-align-items: center !important;
    align-items: center !important;
    -webkit-justify-content: center !important;
    justify-content: center !important;
    
    /* Prevent iOS Safari from hiding the container */
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 5 !important;
}

#box_space_google2 {
    /* iOS Safari container fixes */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    
    /* Ensure proper display */
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-align-items: center !important;
    align-items: center !important;
    -webkit-justify-content: center !important;
    justify-content: center !important;
    
    /* Force visibility */
    opacity: 1 !important;
    visibility: visible !important;
}

#box_space_google2 img {
    /* iOS Safari image fixes for chart area ad */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    
    /* Prevent iOS Safari from blocking images */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    
    /* iOS Safari object-fit support */
    -webkit-object-fit: contain !important;
    object-fit: contain !important;
    -webkit-object-position: center !important;
    object-position: center !important;
    
    /* Force image rendering */
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: auto !important;
}

/* Specific iOS Safari and Opera fixes */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    /* iOS Safari specific fixes */
    #top_space, #box_space {
        /* Force rendering in iOS Safari */
        -webkit-appearance: none !important;
        -webkit-user-select: none !important;
        
        /* Prevent iOS Safari optimizations that might hide ads */
        -webkit-optimize-contrast: auto !important;
        -webkit-font-smoothing: antialiased !important;
    }
    
    #top_space img, #box_space_google2 img {
        /* iOS Safari image loading fixes */
        -webkit-user-select: none !important;
        -webkit-user-drag: none !important;
        -webkit-touch-callout: none !important;
        
        /* Force image display */
        pointer-events: auto !important;
        -webkit-tap-highlight-color: transparent !important;
    }
}

/* Opera specific fixes */
@media screen and (-o-min-device-pixel-ratio: 1) {
    #top_space, #box_space {
        /* Opera rendering fixes */
        -o-transform: translateZ(0) !important;
        -o-backface-visibility: hidden !important;
    }
    
    #top_space img, #box_space_google2 img {
        /* Opera image rendering */
        -o-object-fit: contain !important;
        -o-object-position: center !important;
    }
}

/* Mobile Safari specific fixes */
@media screen and (max-width: 750px) and (-webkit-min-device-pixel-ratio: 1) {
    #top_space {
        /* Mobile Safari container fixes */
        min-height: 70px !important;
        height: 70px !important;
        padding: 5px !important;
        
        /* Prevent Mobile Safari from collapsing */
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-direction: row !important;
        flex-direction: row !important;
    }
    
    #top_space img {
        /* Mobile Safari image fixes */
        max-height: 60px !important;
        width: auto !important;
        max-width: calc(100vw - 40px) !important;
        
        /* Force Mobile Safari to show images */
        -webkit-transform: scale(1) !important;
        transform: scale(1) !important;
    }
}

/* Prevent ad blockers from hiding based on common patterns */
#top_space:not(.hidden),
#box_space:not(.hidden) {
    /* Anti-ad-blocker techniques for iOS Safari */
    content: "" !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force ads to be visible even if content blockers try to hide them */
[id*="top_space"]:not([style*="display: none"]),
[id*="box_space"]:not([style*="display: none"]) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Additional iOS Safari compatibility */
@supports (-webkit-appearance: none) {
    #top_space, #box_space {
        /* WebKit specific rendering */
        -webkit-appearance: none !important;
        will-change: transform !important;
    }
    
    #top_space img, #box_space_google2 img {
        /* WebKit image optimization */
        will-change: transform !important;
        -webkit-optimize-contrast: auto !important;
    }
}

/* Forced ad container styles for persistent iOS Safari blocking */
.ad-container-forced {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 100 !important;
    
    /* Force hardware acceleration */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    
    /* Prevent any hiding */
    min-height: 50px !important;
    min-width: 50px !important;
}

.ad-container-forced img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: 100% !important;
    height: auto !important;
    
    /* Force image rendering */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    image-rendering: auto !important;
}

/* Fallback for ads with data-ad-visible attribute */
[data-ad-visible="true"] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
}

[data-ad-visible="true"] img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
