/**
 * Affiliate CTA card — port of the rejsefix.dk card (Tailwind → plain CSS).
 *
 * Markup comes from aoptimizeRenderAffiliateCtaCard() in
 * includes/affiliate-cta/cta.php. Colours go through CSS variables so a theme
 * can override them from the :root vars printed by aoptimizeGetThemeCssVars().
 *
 * ── Palette (baby blue, 1.42.24) ────────────────────────────────────────────
 * The card used to be a dark navy gradient with a yellow button. It is now a
 * light baby-blue gradient with a deep petrol button: dark-on-light for the
 * copy, and the one dark element on the card is the thing you are meant to
 * click. Every value is WCAG AA verified against the DARKER gradient stop
 * (#a5d4ea) — the lighter stop only improves the ratio:
 *
 *   #0d3550 on #a5d4ea →  8.04:1   (title)
 *   #1c4c6b on #a5d4ea →  5.75:1   (description, body text ≥ 4.5:1)
 *   #ffffff on #0f4c63 →  9.40:1   (button)
 *   #374151 on #ffffff → 10.31:1   (logo badge)
 */

.aopt-cta {
    margin: 2rem 0;
    padding: 1.5rem;
    border-radius: 1rem;
    background: linear-gradient(
        to bottom right,
        var(--aoptimize-cta-bg-from, #cfe9f7),
        var(--aoptimize-cta-bg-to, #a5d4ea)
    );
    /* The card is light now, so it needs its own edge against a white article. */
    box-shadow: 0 1px 2px rgba(13, 53, 80, .08), 0 8px 24px rgba(13, 53, 80, .10);
    color: var(--aoptimize-cta-ink, #0d3550);
}

.aopt-cta__inner {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.aopt-cta__text {
    min-width: 0;
}

.aopt-cta__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.375;
    letter-spacing: -0.025em;
    color: var(--aoptimize-cta-ink, #0d3550);
}

.aopt-cta__desc {
    margin: 0.5rem 0 0;
    font-size: 16px;
    line-height: 1.625;
    color: var(--aoptimize-cta-ink-muted, #1c4c6b);
}

/* Themes style links globally, so the card link opts out explicitly. */
.aopt-cta__link {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
    text-decoration: none !important;
}

/*
 * Logo badge (1.42.26). It holds the partner's LOCAL brand logo — shipped in
 * images/partners/logos/ by scripts/download-partner-logos.ts — and falls back to
 * the partner name as text when the file is missing. PHP decides which one
 * (aoptimizeAffiliateCtaLogoMarkup), so there is no hidden fallback element and the
 * name appears exactly once per card.
 *
 * The white box keeps its hairline border: against the light gradient it would
 * otherwise dissolve into the card instead of reading as a badge. Its height is
 * explicit rather than min-height only, because `height: 100%` on the image needs a
 * definite height to resolve against; border-box keeps the padding inside it.
 */
.aopt-cta__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 3.5rem;
    min-height: 3.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(13, 53, 80, .12);
    border-radius: 0.75rem;
    background: #fff;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
}

.aopt-cta__logo picture {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-width: 100%;
}

/* Fill the badge's height, keep the aspect ratio, never overflow it sideways. */
.aopt-cta__logo img {
    display: block;
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.aopt-cta__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    background: var(--aoptimize-cta-accent, #0f4c63);
    color: var(--aoptimize-cta-accent-ink, #ffffff);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

/* A dark button on a light card lightens on hover — darkening reads as disabled. */
.aopt-cta__link:hover .aopt-cta__button {
    filter: brightness(1.12);
}

/* The ring is the ink colour: a white ring is invisible on the light gradient. */
.aopt-cta__link:focus-visible {
    outline: none;
}

.aopt-cta__link:focus-visible .aopt-cta__button {
    outline: 2px solid var(--aoptimize-cta-ink, #0d3550);
    outline-offset: 2px;
}

.aopt-cta__arrow {
    width: 1rem;
    height: 1rem;
    flex: none;
}

@media (min-width: 640px) {
    .aopt-cta {
        padding: 1.75rem;
    }

    .aopt-cta__title {
        font-size: 22px;
    }
}

@media (min-width: 768px) {
    .aopt-cta__inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 2rem;
    }

    .aopt-cta__text {
        flex: 1;
    }

    .aopt-cta__link {
        width: auto;
        flex: none;
        align-items: center;
    }
}
