.page-ads {
    --page-ad-accent: #1971c2;
    --page-ad-dark: #0f3562;
    --page-ad-light: #62a9e8;
    --page-ad-duration: 8000ms;
    --page-ad-max-width: calc(100vw - 16px);
    --page-ad-max-height: calc(100dvh - 16px);
    position: fixed;
    top: 100px;
    left: 8px;
    /* Keep movable ads below the shared header (900) and its notifications. */
    z-index: 850;
    display: flex;
    flex-direction: column;
    isolation: isolate;
    box-sizing: border-box;
    width: min(330px, var(--page-ad-max-width));
    max-width: var(--page-ad-max-width);
    max-height: var(--page-ad-max-height);
    margin: 0;
    padding: 12px;
    overflow: hidden;
    border: 2px solid rgba(92, 147, 194, 0.76);
    border-radius: 20px;
    color: #172b4d;
    background:
        radial-gradient(circle at 100% 0%, rgba(98, 169, 232, 0.18), transparent 42%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.995), rgba(238, 247, 255, 0.98));
    box-shadow: 0 20px 48px rgba(13, 55, 94, 0.18), 0 4px 12px rgba(17, 62, 104, 0.08);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.page-ad-boundary {
    position: fixed;
    z-index: 849;
    box-sizing: border-box;
    border: 0;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
}

.page-ad-boundary.is-active { opacity: 0; }

.page-ads .page-ad-drag-handle {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    margin: 0 0 8px;
    padding: 5px 8px;
    border: 1px solid rgba(25, 113, 194, 0.2);
    border-radius: 9px;
    color: var(--page-ad-dark);
    background: rgba(224, 239, 252, 0.8);
    box-shadow: none;
    cursor: grab;
    touch-action: none;
    user-select: none;
    font: 700 12px/1.3 Inter, "Segoe UI", Arial, sans-serif;
    text-align: left;
}

.page-ads .page-ad-drag-handle:hover,
.page-ads .page-ad-drag-handle:focus-visible {
    color: var(--page-ad-dark);
    background: #d7eafa;
    box-shadow: none;
    transform: none;
}

.page-ads.is-dragging,
.page-ads.is-dragging * { cursor: grabbing; }

.page-ad-screen-reader {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.page-ads::before {
    position: absolute;
    inset: 0 0 auto;
    z-index: -1;
    height: 5px;
    background: linear-gradient(90deg, var(--page-ad-dark), var(--page-ad-accent) 68%, var(--page-ad-light));
    content: "";
}

.page-ads::after {
    position: absolute;
    top: -78px;
    right: -68px;
    z-index: -1;
    width: 170px;
    height: 170px;
    border: 1px solid rgba(25, 113, 194, 0.08);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    content: "";
    pointer-events: none;
}

.page-ads-count {
    min-width: 39px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 999px;
    color: #fff;
    background: rgba(8, 31, 55, 0.7);
    box-shadow: 0 3px 10px rgba(4, 18, 31, 0.2);
    backdrop-filter: blur(8px);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.page-ads-overlay-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.page-ads .page-ad-pause {
    display: inline-grid;
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: #fff;
    background: rgba(8, 31, 55, 0.7);
    box-shadow: 0 3px 10px rgba(4, 18, 31, 0.2);
    cursor: pointer;
    place-items: center;
    font: 800 11px/1 Arial, sans-serif;
}

.page-ads .page-ad-pause:hover,
.page-ads .page-ad-pause:focus-visible {
    color: #fff;
    background: var(--page-ad-accent);
    box-shadow: none;
    transform: none;
}

.page-ads .page-ad-pause:focus-visible,
.page-ads .page-ad-control:focus-visible,
.page-ads .page-ad-dot:focus-visible,
.page-ads .page-ad-drag-handle:focus-visible {
    outline: 3px solid #8bc6f7;
    outline-offset: 2px;
}

.page-ads-frame {
    position: relative;
    flex: 1 1 auto;
    aspect-ratio: 16 / 10;
    min-height: 0;
    max-height: max(0px, calc(var(--page-ad-max-height) - 116px));
    overflow: hidden;
    border: 1px solid rgba(112, 143, 172, 0.42);
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 15%, rgba(47, 114, 157, 0.36), transparent 62%),
        #0b1726;
    box-shadow: 0 10px 24px rgba(8, 30, 50, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.page-ad-slide {
    position: relative;
    display: none;
    width: 100%;
    height: 100%;
    margin: 0;
}

.page-ad-slide.is-active {
    display: grid;
    place-items: center;
    animation: pageAdFade 0.35s ease;
}

.page-ad-slide img,
.page-ad-slide video {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
}

.page-ad-slide img { background: linear-gradient(135deg, #edf4fa, #dfeaf4); }
.page-ad-slide video { background: #0d1727; }

.page-ad-destination {
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: pointer;
}
.page-ad-destination.is-video { bottom: 44px; }
.page-ad-destination:focus-visible { outline: 3px solid #8bc6f7; outline-offset: -4px; }

.page-ads .page-ad-control {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: grid;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    color: #fff;
    background: rgba(8, 24, 40, 0.7);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    opacity: 0.9;
    place-items: center;
    backdrop-filter: blur(7px);
    transform: translateY(-50%);
    transition: opacity 160ms ease, background 160ms ease, transform 160ms ease;
    font-size: 20px;
    line-height: 1;
}

.page-ads .page-ad-control:hover,
.page-ads .page-ad-control:focus-visible {
    border-color: rgba(255, 255, 255, 0.85);
    background: linear-gradient(135deg, rgba(15, 53, 98, 0.98), rgba(25, 113, 194, 0.98));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    opacity: 1;
    transform: translateY(-50%) scale(1.05);
}

.page-ad-previous { left: 8px; }
.page-ad-next { right: 8px; }

.page-ad-progress {
    flex: 0 0 auto;
    height: 4px;
    margin: 11px 4px 0;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(187, 205, 221, 0.68);
}

.page-ad-progress-bar {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--page-ad-dark), var(--page-ad-accent) 68%, var(--page-ad-light));
    transform: scaleX(0);
    transform-origin: left center;
}

.page-ad-progress-bar.is-running {
    animation: pageAdProgress var(--page-ad-duration) linear forwards;
}

.page-ads.is-paused .page-ad-progress-bar { animation-play-state: paused; }

.page-ad-dots {
    display: flex;
    flex: 0 0 auto;
    min-height: 20px;
    gap: 2px;
    padding-top: 5px;
    align-items: center;
    justify-content: center;
}

.page-ads .page-ad-dot {
    position: relative;
    width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.page-ads .page-ad-dot::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #a8b7c6;
    content: "";
    transform: translate(-50%, -50%);
    transition: width 180ms ease, background 180ms ease;
}

.page-ads .page-ad-dot:hover,
.page-ads .page-ad-dot:focus-visible {
    background: rgba(25, 113, 194, 0.08);
    box-shadow: none;
    transform: none;
}

.page-ads .page-ad-dot:hover::before,
.page-ads .page-ad-dot:focus-visible::before { background: #60758f; }

.page-ads .page-ad-dot.is-active::before {
    width: 18px;
    background: var(--page-ad-accent);
}

@media (hover: hover) {
    .page-ads {
        transition: border-color 180ms ease, box-shadow 180ms ease;
    }

    .page-ads:hover {
        border-color: rgba(92, 147, 194, 0.72);
        box-shadow: 0 24px 56px rgba(13, 55, 94, 0.22), 0 5px 14px rgba(17, 62, 104, 0.1);
    }
}

@keyframes pageAdFade {
    from { opacity: 0; transform: scale(0.99); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pageAdProgress {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* Leave the page's actions accessible when there is no spare desktop gutter. */
@media (min-width: 768px) and (max-width: 1439px) {
    .page-ads.is-inline {
        position: relative;
        top: auto;
        left: auto;
        z-index: auto;
        flex: 0 0 auto;
        width: min(440px, calc(100% - 48px));
        max-width: calc(100% - 48px);
        max-height: none;
        margin: 20px auto;
        cursor: auto;
        touch-action: pan-y;
        user-select: auto;
    }

    .page-ads.is-inline .page-ads-frame {
        max-height: none;
    }

    .page-ads.is-inline .page-ad-drag-handle {
        opacity: 1;
        cursor: default;
        touch-action: pan-y;
    }

    .page-ad-boundary { display: none; }

    /* Keep announcement media aligned with the forecast column. */
    body.announcements-page .page-ads.is-inline {
        width: min(100%, 330px);
        max-width: 100%;
        margin: 20px auto 0;
    }
}

@media (max-width: 767px) {
    .page-ads {
        position: relative;
        top: auto;
        left: auto;
        z-index: auto;
        flex: 0 0 auto;
        width: calc(75% - 30px);
        max-width: 360px;
        max-height: none;
        margin: 12px auto;
        padding: 6px;
        border-radius: 18px;
        cursor: auto;
        touch-action: pan-y;
        user-select: auto;
    }

    .page-ad-boundary { display: none; }

    .page-ads .page-ads-frame {
        aspect-ratio: 16 / 9;
        min-height: 132px;
        max-height: none;
    }

    .page-ads .page-ads-overlay-actions { top: 4px; right: 4px; }

    .page-ads .page-ad-drag-handle,
    .page-ads .page-ad-drag-handle:disabled {
        min-height: 28px;
        margin-bottom: 4px;
        opacity: 1;
        cursor: default;
        touch-action: pan-y;
    }

    .page-ads .page-ad-progress { margin: 6px 4px 0; }

    .page-ads .page-ad-dots { flex-wrap: wrap; padding-top: 2px; }

    .page-ads .page-ad-dot { flex: 0 0 24px; }
}

@media (max-width: 380px) {
    .page-ads { border-radius: 16px; }
}

.page-ads.is-compact { padding: 6px; border-radius: 12px; }
.page-ads.is-compact .page-ad-drag-handle { min-height: 28px; margin-bottom: 4px; }
.page-ads.is-compact .page-ads-frame { max-height: max(0px, calc(var(--page-ad-max-height) - 48px)); }
.page-ads.is-compact .page-ad-progress,
.page-ads.is-compact .page-ad-dots { display: none; }

@media print {
    .page-ads,
    .page-ad-boundary { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .page-ad-slide.is-active { animation: none; }
    .page-ad-progress { display: none; }
    .page-ads .page-ad-dot { transition: none; }
}
