/**
 * Novara — Ad Styles (v6.10.0)
 *
 * CLS-safe, responsive ad rendering. The container reserves its space via
 * aspect-ratio + min-height so layout doesn't shift when the ad loads.
 *
 * @package Novara
 * @since 6.10.0
 */

/* ===================================================================
   Base container — reserved space via inline style (set by PHP)
   =================================================================== */

.novara-ad {
    display: block;
    margin: 24px auto;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: var(--bg-secondary, #f6f7f8);
    border-radius: 8px;
    /* Smooth fade-in when ad loads */
    transition: opacity 0.3s ease;
}

.novara-ad__label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted, #888);
    padding: 4px 0 6px;
    font-weight: 600;
    opacity: 0.7;
}

.novara-ad__slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: inherit;
}

/* Make AdSense iframes responsive within the slot */
.novara-ad__slot ins,
.novara-ad__slot iframe,
.novara-ad__slot .adsbygoogle {
    max-width: 100% !important;
    margin: 0 auto !important;
}

/* ===================================================================
   Position variants
   =================================================================== */

/* Header banner (full-width, above hero) */
.novara-ad--header {
    margin: 16px auto 24px;
    max-width: 970px;
}

/* Sidebar ads */
.novara-ad--sidebar {
    margin-bottom: 24px;
}

/* Content top/bottom */
.novara-ad--content-top {
    margin: 12px auto 28px;
}
.novara-ad--content-bottom {
    margin: 32px auto 16px;
}

/* In-content (auto-injected mid-article) */
.novara-ad--in-content,
.novara-ad--injected {
    margin: 32px auto;
    clear: both;
    max-width: 100%;
}

/* ===================================================================
   Sticky bottom (mobile)
   =================================================================== */

.novara-ad--sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-radius: 0;
    border-top: 1px solid var(--border-color, #e5e7eb);
    z-index: 100;
    background: var(--bg-primary, #fff);
    padding-bottom: env(safe-area-inset-bottom);
    max-width: 100%;
}
.novara-ad--sticky .novara-ad__label {
    display: none;        /* save space on small viewport */
}

/* ===================================================================
   Mobile/desktop visibility
   =================================================================== */

@media (max-width: 768px) {
    .novara-ad--desktop-only { display: none !important; }
    /* Header banner becomes mobile-banner sized on small screens */
    .novara-ad--header {
        max-width: 100%;
        margin: 8px auto 16px;
    }
}
@media (min-width: 769px) {
    .novara-ad--mobile-only { display: none !important; }
    .novara-ad--sticky:not(.novara-ad--mobile-only) { /* nothing */ }
}

/* ===================================================================
   Lazy-load placeholder shimmer (before render)
   =================================================================== */

.novara-ad--lazy:not([data-novara-ad-loaded="1"]) .novara-ad__slot::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.03) 0%,
        rgba(0, 0, 0, 0.06) 50%,
        rgba(0, 0, 0, 0.03) 100%
    );
    background-size: 200% 100%;
    animation: novara-ad-shimmer 1.6s ease-in-out infinite;
    border-radius: inherit;
    pointer-events: none;
}

@keyframes novara-ad-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .novara-ad--lazy:not([data-novara-ad-loaded="1"]) .novara-ad__slot::before {
        animation: none;
    }
}

/* ===================================================================
   Dark mode adjustments
   =================================================================== */

[data-theme="dark"] .novara-ad {
    background: #1a1a22;
}
[data-theme="dark"] .novara-ad--sticky {
    background: #1a1a22;
    border-top-color: #2a2a36;
}
[data-theme="dark"] .novara-ad__label {
    color: rgba(255, 255, 255, 0.5);
}

/* ===================================================================
   When ads are disabled
   =================================================================== */

[data-novara-ads-disabled="1"] .novara-ad,
[data-novara-ads-disabled="1"] .novara-mobile-ad-sticky {
    display: none !important;
}
