/* Card.TitleDescriptionImageButton - white feature card.
   Desktop (≥1024): vertical 3-up — title/desc centered, image, button bottom.
   Tablet (878–1023): full-width — title/desc/button left, image right.
   Mobile (≤877): vertical — title/desc left, image, button centered.
   Add class "card-tdib--left" via the widget's CSS Classes field to force
   left-aligned title (e.g. title/description-only cards). */

.card-tdib {
    background-color: var(--color-white);
    padding: 40px 40px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    height: 100%;
}

.card-tdib__title {
    color: var(--color-near-black);
    font-family: var(--font-family-bold);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.03px;
    line-height: 26px;
    text-align: center;
    margin: 0 0 16px;
    max-width: 100%;
}

.card-tdib__description {
    color: var(--color-near-black);
    font-family: var(--font-family-medium);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 27px;
    text-align: center;
    margin: 0 0 28px;
    width: 100%;
}

.card-tdib__description:last-child {
    margin: 0;
}

.card-tdib__description p {
    margin: 0 0 1em;
}

.card-tdib__description p:last-child {
    margin-bottom: 0;
}

.card-tdib__figure {
    width: 100%;
    max-width: 332px;
    margin: 0 0 40px;
}

.card-tdib__image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* Colour, typography, radius and hover come from .btn-primary (common.css) -
   the markup is `class="btn-primary card-tdib__button card-tdib__link"`. What
   stays here is this card's geometry, plus one deliberate deviation.

   text-transform: the shared button system has `text-transform: uppercase`
   commented out, so it is restated here to keep these CTAs reading "LEARN MORE"
   rather than "Learn more". That is a copy-casing decision, not a style one -
   drop this line if design wants the cards to match the rest of the system. */
.card-tdib__button {
    min-width: 141px;
    height: 52px;
    margin-top: auto;
    text-transform: uppercase;
}

/* Clickable card: the CTA anchor is stretched over the whole card so a click
   anywhere follows the link, while keeping a single tab stop. */
.card-tdib--clickable {
    position: relative;
    cursor: pointer;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card-tdib--clickable .card-tdib__link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* No CTA label: the anchor is nothing but the invisible overlay */
.card-tdib__link--bare {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.card-tdib--clickable .card-tdib__link--bare::after {
    content: none;
}

/* Cards with a visible CTA button show the rollover effect on the button
   only, not the whole card - the button-scoped rules below handle that.
   A card with no button (the bare overlay case) still lifts on hover /
   keyboard focus so there's some indication it's clickable. */
.card-tdib--clickable:has(.card-tdib__link--bare):hover,
.card-tdib--clickable:has(.card-tdib__link--bare):focus-within {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card-tdib--clickable:hover .card-tdib__button,
.card-tdib--clickable:focus-within .card-tdib__button {
    background-color: var(--color-secondary-blue);
    color: var(--color-white);
}

@media (prefers-reduced-motion: reduce) {

    .card-tdib--clickable,
    .card-tdib__button {
        transition: none;
    }

    .card-tdib--clickable:has(.card-tdib__link--bare):hover,
    .card-tdib--clickable:has(.card-tdib__link--bare):focus-within {
        transform: none;
    }
}

/* Keyboard focus rings the whole card, since the card is what gets activated */
.card-tdib--clickable:has(.card-tdib__link:focus-visible) {
    outline: 2px solid var(--color-dark-blue);
    outline-offset: 3px;
}

/* The card itself carries the focus ring, so the stretched anchor drops its own */
.card-tdib--clickable .card-tdib__link:focus-visible {
    outline: none;
}

.card-tdib--left {
    align-items: flex-start;
    height: 100%;
}

.card-tdib--left .card-tdib__title,
.card-tdib--left .card-tdib__description {
    text-align: left;
}

.card-tdib--left .card-tdib__title {
    max-width: 335px;
}

/* Tablet: text column left, image right (card-tdib--with-image from the view) */
@media (min-width: 878px) and (max-width: 1023px) {
    .card-tdib--with-image {
        display: grid;
        grid-template-columns: 1fr minmax(200px, 42%);
        grid-template-areas:
            "title image"
            "desc image"
            "button image";
        column-gap: 40px;
        row-gap: 16px;
        align-items: start;
        align-content: center;
        padding: 40px;
        max-width: 100%;
    }

    .card-tdib--with-image .card-tdib__title {
        grid-area: title;
        text-align: left;
        margin-bottom: 0;
        align-self: end;
    }

    .card-tdib--with-image .card-tdib__description {
        grid-area: desc;
        text-align: left;
        max-width: none;
        margin: 0;
        align-self: start;
    }

    .card-tdib--with-image .card-tdib__figure {
        grid-area: image;
        max-width: none;
        margin: 0;
        align-self: center;
        justify-self: end;
        width: 100%;
    }

    .card-tdib--with-image .card-tdib__button {
        grid-area: button;
        margin-top: 8px;
        justify-self: start;
        align-self: start;
    }

    /* No image: vertical stack, left-aligned copy */
    .card-tdib:not(.card-tdib--with-image) {
        align-items: flex-start;
        padding: 40px;
        max-width: 100%;
    }

    .card-tdib:not(.card-tdib--with-image) .card-tdib__title,
    .card-tdib:not(.card-tdib--with-image) .card-tdib__description {
        text-align: left;
        max-width: none;
    }
}

/* Mobile: stacked, left-aligned copy, centered CTA */
@media (max-width: 877px) {
    .card-tdib {
        align-items: stretch;
        padding: 40px 32px 48px;
    }

    .card-tdib__title {
        text-align: left;
    }

    .card-tdib__description {
        text-align: left;
        max-width: 100%;
        margin-bottom: 32px;
    }

    .card-tdib__figure {
        max-width: 100%;
        margin: 0 0 40px;
        align-self: center;
        width: 100%;
    }

    .card-tdib__button {
        align-self: center;
        margin-top: 0;
    }
}
