/* ========================================================================
   READYAIMRETIRE IN-ARTICLE ADS (src/components/ArticleAd.astro)
   From the "ReadyAimRetire Article Ads" Claude Design mockup. The card sizes
   itself to the article column with a container query: side by side when
   there's room, stacked (text, then image) on phones. Selectors are scoped
   under .rar-ad so insights-article.css link/paragraph rules don't leak in.
   ======================================================================== */

.rar-ad {
    container-type: inline-size;
    margin: 2.75rem 0;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.rar-ad a.rar-ad__link {
    display: block;
    position: relative;
    overflow: hidden;
    border: 1px solid #dde5ea;
    border-radius: 14px;
    background: var(--rar-ad-bg);
    box-shadow: 0 4px 18px rgba(20, 40, 60, 0.07);
    color: #16202b;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.rar-ad a.rar-ad__link:hover {
    background: var(--rar-ad-bg);
    border-bottom-color: #dde5ea;
    transform: translateY(-3px);
    box-shadow: 0 16px 40px rgba(20, 40, 60, 0.16);
}
.rar-ad a.rar-ad__link:focus-visible {
    outline: 3px solid #23a998;
    outline-offset: 3px;
}
.rar-ad--dark a.rar-ad__link,
.rar-ad--teal a.rar-ad__link,
.rar-ad--dark a.rar-ad__link:hover,
.rar-ad--teal a.rar-ad__link:hover {
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.rar-ad--dark a.rar-ad__link,
.rar-ad--teal a.rar-ad__link { box-shadow: 0 4px 18px rgba(20, 40, 60, 0.12); }

.rar-ad__row { display: flex; flex-direction: column; }

.rar-ad__text {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 20px 18px;
    min-width: 0;
}

/* Brand row: logo mark, wordmark, AD label */
.rar-ad__brand { display: flex; align-items: center; gap: 8px; }
.rar-ad__mark { width: 38px; height: auto; }
.rar-ad__mark-tile {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 10px; background: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.rar-ad__mark-tile img { width: 30px; height: auto; }
.rar-ad__wordmark { height: 30px; width: auto; }
.rar-ad__label {
    margin-left: auto;
    font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
    color: #98a3ad; border: 1px solid #e2e7ec; border-radius: 4px; padding: 2px 6px;
}
.rar-ad--dark .rar-ad__label,
.rar-ad--teal .rar-ad__label { color: rgba(255, 255, 255, 0.7); border-color: rgba(255, 255, 255, 0.32); }

.rar-ad__eyebrow {
    font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
    margin-bottom: -4px;
}

.rar-ad__headline {
    font-size: 20px; font-weight: 800; line-height: 1.2; letter-spacing: -0.3px;
    color: #16202b;
}
.rar-ad--dark .rar-ad__headline,
.rar-ad--teal .rar-ad__headline { color: #fff; }

.rar-ad__body { font-size: 14px; line-height: 1.55; color: #5d6b78; }
.rar-ad__body em { font-style: italic; }
.rar-ad--dark .rar-ad__body { color: rgba(255, 255, 255, 0.82); }
.rar-ad--teal .rar-ad__body { color: rgba(255, 255, 255, 0.9); }

.rar-ad__cta {
    align-self: flex-start;
    display: inline-block;
    margin-top: 2px;
    background: var(--rar-ad-cta-bg);
    color: var(--rar-ad-cta-color);
    font-size: 14px; font-weight: 700; line-height: 1.35;
    border-radius: 8px; padding: 10px 18px;
}

/* Media */
.rar-ad__media { display: flex; align-items: center; justify-content: center; padding: 0 18px 18px; }
.rar-ad__img { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 40, 60, 0.16); }
.rar-ad__img--framed { border-radius: 8px; border: 1px solid #e2e7ec; box-shadow: 0 6px 22px rgba(20, 40, 60, 0.18); }
.rar-ad--dark .rar-ad__img { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35); }
.rar-ad__img--cutout { border-radius: 0; box-shadow: none; filter: drop-shadow(0 14px 26px rgba(20, 40, 60, 0.22)); }

.rar-ad__slides {
    position: relative; display: block; width: 100%;
    aspect-ratio: 880 / 577; border-radius: 10px; overflow: hidden;
    filter: drop-shadow(0 8px 22px rgba(20, 40, 60, 0.18));
}
.rar-ad--dark .rar-ad__slides,
.rar-ad--teal .rar-ad__slides { filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.3)); }
.rar-ad__slides img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

/* Pure-CSS crossfade: 5 slides x 4s = 20s cycle (delays set inline) */
@keyframes rarAdFade {
    0% { opacity: 0; }
    4% { opacity: 1; }
    20% { opacity: 1; }
    26% { opacity: 0; }
    100% { opacity: 0; }
}
.rar-ad__slides .rar-ad__slide { opacity: 0; animation: rarAdFade 20s infinite; }

/* Side by side when the article column has room */
@container (min-width: 560px) {
    .rar-ad__row { flex-direction: row; align-items: stretch; }
    .rar-ad__text { flex: 1; justify-content: center; padding: 24px 8px 24px 26px; }
    .rar-ad__media { width: var(--rar-ad-media-w); flex-shrink: 0; padding: 16px 18px 16px 0; }
    .rar-ad--media-left .rar-ad__row { flex-direction: row-reverse; }
    .rar-ad--media-left .rar-ad__text { padding: 24px 26px 24px 20px; }
    .rar-ad--media-left .rar-ad__media { padding: 16px 0 16px 18px; }
    .rar-ad__headline { font-size: clamp(19px, 3.2cqi, 24px); }
    .rar-ad__cta { font-size: 13.5px; padding: 10px 16px; }
}

/* ---- "Pop" treatment (showcase 4a) ---- */
@keyframes rarAdEdge { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
.rar-ad__edge {
    display: block; height: 4px;
    background: linear-gradient(90deg, #23a998, #2b5fc0, #3fae5c, #23a998);
    background-size: 200% 100%;
    animation: rarAdEdge 6s linear infinite;
}

@keyframes rarAdShine {
    0% { transform: translateX(-140%) skewX(-16deg); }
    42% { transform: translateX(340%) skewX(-16deg); }
    100% { transform: translateX(340%) skewX(-16deg); }
}
.rar-ad__cta--shine { position: relative; overflow: hidden; }
.rar-ad__cta--shine::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transform: translateX(-140%) skewX(-16deg);
    animation: rarAdShine 3.2s ease-in-out infinite;
}

@keyframes rarAdKenBurns { 0% { transform: scale(1) translateX(0); } 100% { transform: scale(1.06) translateX(-1.5%); } }
.rar-ad--showcase .rar-ad__slides .rar-ad__slide { animation: rarAdFade 20s infinite, rarAdKenBurns 20s ease-in-out infinite; }

.rar-ad__ring-row { display: flex; align-items: center; gap: 12px; }
.rar-ad__ring { flex-shrink: 0; }
@keyframes rarAdRing { from { stroke-dashoffset: 113; } to { stroke-dashoffset: 4.5; } }
.rar-ad__ring-arc {
    stroke-dasharray: 113; stroke-dashoffset: 113;
    animation: rarAdRing 1.6s cubic-bezier(0.2, 0.8, 0.3, 1) 0.6s forwards;
}

/* Rise in as the card scrolls into view (browsers with scroll-driven animations;
   others just show it). Uses `translate`, not `transform`, so the hover lift still works. */
@keyframes rarAdRise { from { opacity: 0; translate: 0 26px; } to { opacity: 1; translate: 0 0; } }
@supports (animation-timeline: view()) {
    .rar-ad a.rar-ad__link {
        animation: rarAdRise linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 55%;
    }
    .rar-ad__ring-arc {
        animation: rarAdRing linear both;
        animation-timeline: view();
        animation-range: entry 40% cover 45%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rar-ad a.rar-ad__link,
    .rar-ad__edge,
    .rar-ad__cta--shine::after { animation: none; }
    .rar-ad a.rar-ad__link:hover { transform: none; }
    .rar-ad__slides .rar-ad__slide { display: none; }
    .rar-ad__ring-arc { animation: none; stroke-dashoffset: 4.5; }
}
