/* Ad Styling for Google AdSense */

/* Ad Container Styles */
.ad-container {
    display: block;
    text-align: center;
    margin: 2rem 0;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    min-height: 90px;
}

.ad-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

/* Header Ad - Leaderboard (728x90) or Mobile Banner (320x50) */
.ad-header {
    margin: 1rem auto;
    max-width: 728px;
}

@media (max-width: 768px) {
    .ad-header {
        max-width: 320px;
        min-height: 50px;
    }
}

/* Sidebar Ad - Medium Rectangle (300x250) */
.ad-sidebar {
    margin: 1.5rem 0;
    max-width: 300px;
}

@media (max-width: 1024px) {
    .ad-sidebar {
        display: none; /* Hide sidebar ads on smaller screens */
    }
}

/* In-Content Ad - Large Rectangle (336x280) or Medium Rectangle (300x250) */
.ad-content {
    margin: 2rem auto;
    max-width: 336px;
    clear: both;
}

@media (max-width: 768px) {
    .ad-content {
        max-width: 300px;
    }
}

/* Footer Ad - Leaderboard (728x90) */
.ad-footer {
    margin: 2rem auto 1rem;
    max-width: 728px;
}

@media (max-width: 768px) {
    .ad-footer {
        max-width: 320px;
        min-height: 50px;
    }
}

/* Responsive Ad Unit */
.ad-responsive {
    display: block;
    width: 100%;
    height: auto;
    min-height: 90px;
}

/* Ad Placeholder (before AdSense approval) */
.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(59, 130, 246, 0.1);
    border: 2px dashed var(--primary-color);
    color: var(--text-light);
    font-size: 0.875rem;
    font-style: italic;
    min-height: 90px;
    border-radius: 0.375rem;
}

.ad-placeholder::before {
    content: "Advertisement Space";
}

/* Article Sidebar Layout with Ads */
.article-with-sidebar {
    display: grid;
    grid-template-columns: 1fr 336px;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.article-main-content {
    min-width: 0; /* Prevent grid overflow */
}

.article-sidebar {
    position: sticky;
    top: 80px;
    height: fit-content;
}

@media (max-width: 1024px) {
    .article-with-sidebar {
        grid-template-columns: 1fr;
    }
    
    .article-sidebar {
        position: static;
        max-width: 336px;
        margin: 0 auto;
    }
}

/* Ad Spacing Between Content */
.content-section .ad-container:first-child {
    margin-top: 0;
}

.content-section .ad-container:last-child {
    margin-bottom: 0;
}

/* Hide ads in print */
@media print {
    .ad-container,
    .ad-header,
    .ad-sidebar,
    .ad-content,
    .ad-footer,
    .ad-placeholder {
        display: none !important;
    }
}

/* Accessibility: Ensure ads don't interfere with content flow */
.ad-container[aria-hidden="true"] {
    display: none;
}

/* Loading state for ads */
.ad-container.loading {
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.02) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0.02) 100%
    );
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
