/* ============================================================================
   Advertisement Management System — ad slot rendering + Rewarded Ads widget.
   Scoped under .pn-ad-slot / .pn-rewarded, built from the existing --pn-*
   design tokens (site.css) — no new colors/fonts introduced.
   ============================================================================ */

.pn-ad-slot {
    position: relative;
    margin: 20px auto;
    max-width: 100%;
    border: 1px solid var(--pn-border);
    border-radius: var(--pn-radius-md);
    background: var(--pn-bg-surface);
    overflow: hidden;
}
.pn-ad-slot__label {
    display: block;
    font-family: var(--pn-font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pn-text-muted);
    padding: 4px 10px;
    border-bottom: 1px solid var(--pn-border);
    opacity: 0.7;
}
.pn-ad-slot__body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    padding: 8px;
    text-align: center;
}
.pn-ad-slot__body :is(img, iframe) { max-width: 100%; height: auto; }

/* Direct Link ads: no embeddable creative, just a labeled clickthrough
   button styled from the existing design tokens (same family as .pn-btn). */
.pn-ad-slot__direct-link {
    display: inline-block;
    padding: 10px 22px;
    border-radius: var(--pn-radius-full);
    background: var(--pn-turf-bright);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: opacity 0.15s ease;
}
.pn-ad-slot__direct-link:hover { opacity: 0.88; }

/* Placement-specific sizing hints (the ad network's own code controls the
   actual creative size — these just keep layout from jumping). */
.pn-ad-slot--pl-header, .pn-ad-slot--pl-footer { margin: 0 auto 16px; }
.pn-ad-slot--pl-sidebar { margin: 0 0 16px; }
.pn-ad-slot--in_content { margin: 28px auto; }

/* Sticky ads pin to the bottom of the viewport, well under any modal
   overlay (site.css tops out at z-index: 200). */
.pn-ad-slot--sticky {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}
.pn-ad-slot--sticky .pn-ad-slot__label { display: none; }
.pn-ad-slot__close {
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 1;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    line-height: 1;
    font-size: 16px;
    cursor: pointer;
}

/* ---- Rewarded Ads widget (dashboard card that triggers a rewarded ad) ---- */
.pn-rewarded-card {
    background: var(--pn-bg-glass);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid var(--pn-border);
    border-radius: var(--pn-radius-lg);
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 20px 0;
}
.pn-rewarded-card__info h3 {
    margin: 0 0 4px;
    font-family: var(--pn-font-display);
    font-size: 1.05rem;
}
.pn-rewarded-card__info p {
    margin: 0;
    color: var(--pn-text-secondary);
    font-size: 0.85rem;
}
.pn-rewarded-card__meta {
    font-family: var(--pn-font-mono);
    font-size: 0.72rem;
    color: var(--pn-text-muted);
    margin-top: 6px;
}
.pn-rewarded-card__status {
    font-size: 0.82rem;
    color: var(--pn-amber);
    margin-top: 6px;
}

.pn-rewarded-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 210;
    background: rgba(8, 6, 20, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pn-rewarded-modal {
    background: var(--pn-bg-surface-2);
    border: 1px solid var(--pn-border-strong);
    border-radius: var(--pn-radius-lg);
    max-width: 480px;
    width: 100%;
    padding: 24px;
    text-align: center;
}
.pn-rewarded-modal__body {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
}

@media (max-width: 600px) {
    .pn-rewarded-card { flex-direction: column; align-items: stretch; text-align: center; }
}

/* Device targeting — server already filters which ad resolves, this is
   defense-in-depth in case a viewport is resized after page load or the
   viewer's UA classification was ambiguous. */
@media (max-width: 767px) {
    .pn-ad-slot--device-desktop { display: none !important; }
}
@media (min-width: 768px) {
    .pn-ad-slot--device-mobile { display: none !important; }
}

/* ---- Popup ads (client-engine controlled, frequency-capped) ---- */
.pn-ad-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 205;
    background: rgba(8, 6, 20, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pn-ad-popup {
    position: relative;
    background: var(--pn-bg-surface-2);
    border: 1px solid var(--pn-border-strong);
    border-radius: var(--pn-radius-lg);
    max-width: 520px;
    width: 100%;
    padding: 20px;
    text-align: center;
}
.pn-ad-popup__body {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
}
.pn-ad-popup__close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    line-height: 1;
    font-size: 18px;
    cursor: pointer;
    z-index: 1;
}

/* ---- Interstitial ads (full-screen, closable after a short countdown) ---- */
.pn-ad-interstitial-overlay {
    position: fixed;
    inset: 0;
    z-index: 206;
    background: rgba(6, 4, 16, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pn-ad-interstitial {
    background: var(--pn-bg-surface-2);
    border: 1px solid var(--pn-border-strong);
    border-radius: var(--pn-radius-lg);
    max-width: 640px;
    width: 100%;
    padding: 20px;
}
.pn-ad-interstitial__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.pn-ad-interstitial__body {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Rewarded modal action row + status tones + success burst ---- */
.pn-rewarded-modal__actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}
.pn-rewarded-card__status--error { color: var(--pn-crimson, #e5484d); }
.pn-rewarded-card__status--success { color: var(--pn-turf-glow, #4ade80); }

.pn-rewarded-burst {
    position: absolute;
    top: -6px;
    right: 8px;
    font-size: 1.4rem;
    pointer-events: none;
    animation: pn-rewarded-burst-pop 1.3s ease forwards;
}
.pn-rewarded-burst span { display: inline-block; margin: 0 1px; }
.pn-rewarded-card { position: relative; }
@keyframes pn-rewarded-burst-pop {
    0% { opacity: 0; transform: translateY(6px) scale(0.8); }
    25% { opacity: 1; transform: translateY(-6px) scale(1.15); }
    70% { opacity: 1; transform: translateY(-14px) scale(1); }
    100% { opacity: 0; transform: translateY(-22px) scale(0.9); }
}

@media (max-width: 600px) {
    .pn-ad-interstitial__head { flex-wrap: wrap; }
}
