.cddtc-library-category-description {
    flex-direction: column;
    gap: 22px;
}

.cddtc-library-latest-article {
    max-width: 440px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
}

.cddtc-library-latest-label {
    display: block;
    margin-bottom: 5px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.cddtc-library-latest-title {
    display: block;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
}

.cddtc-library-front-door {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px;
    width: 100%;
}

.cddtc-library-category-card {
    display: block;
    overflow: hidden;
    border-radius: 10px;
    color: #ffffff;
    text-decoration: none;
    background: #4f5551;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease;
}

.cddtc-library-category-card:hover,
.cddtc-library-category-card:focus,
.cddtc-library-category-card:focus-visible {
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-4px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

.cddtc-library-category-image {
    position: relative;
    min-height: 340px;
    overflow: hidden;
    background-color: #5c625e;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

/*
 * This separate layer gives us a gentle zoom without
 * enlarging the whole card.
 */
.cddtc-library-category-image::before {
    content: "";
    position: absolute;
    inset: -4%;
    z-index: 0;
    background: inherit;
    background-position: center;
    background-size: cover;
    transition:
        transform 0.55s ease,
        filter 0.4s ease;
}

.cddtc-library-category-card:hover
.cddtc-library-category-image::before,
.cddtc-library-category-card:focus
.cddtc-library-category-image::before,
.cddtc-library-category-card:focus-visible
.cddtc-library-category-image::before {
    transform: scale(1.06);
    filter: grayscale(100%);
}

.cddtc-library-category-shade {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.05) 15%,
        rgba(0, 0, 0, 0.18) 55%,
        rgba(0, 0, 0, 0.76) 100%
    );
    transition: background 0.4s ease;
}

.cddtc-library-category-card:hover
.cddtc-library-category-shade,
.cddtc-library-category-card:focus
.cddtc-library-category-shade,
.cddtc-library-category-card:focus-visible
.cddtc-library-category-shade {
    background: rgba(25, 28, 26, 0.78);
}

.cddtc-library-category-description {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 34px 30px 92px;
    text-align: center;
    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity 0.35s ease,
        transform 0.35s ease;
}

.cddtc-library-category-description p {
    max-width: 440px;
    margin: 0;
    color: #ffffff;
    font-size: 1rem;
    line-height: 1.55;
}

.cddtc-library-category-card:hover
.cddtc-library-category-description,
.cddtc-library-category-card:focus
.cddtc-library-category-description,
.cddtc-library-category-card:focus-visible
.cddtc-library-category-description {
    opacity: 1;
    transform: translateY(0);
}

.cddtc-library-category-footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    background: rgba(0, 0, 0, 0.7);
}

.cddtc-library-category-heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cddtc-library-category-name {
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.25;
}

.cddtc-library-category-count {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.8rem;
    line-height: 1.3;
}

.cddtc-library-category-more {
    flex: 0 0 auto;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    transition: transform 0.3s ease;
}

.cddtc-library-category-more::after {
    content: " \2192";
}

.cddtc-library-category-card:hover
.cddtc-library-category-more,
.cddtc-library-category-card:focus
.cddtc-library-category-more {
    transform: translateX(4px);
}

/*
 * Used when neither a featured image nor category
 * Facebook thumbnail is available.
 */
.cddtc-library-category-card--no-image
.cddtc-library-category-image,
.cddtc-library-category-card--no-image
.cddtc-library-category-image::before {
    background:
        linear-gradient(
            135deg,
            #53635b 0%,
            #29342f 100%
        );
}

/* Tablet */

@media (max-width: 1024px) {

    .cddtc-library-front-door {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/*
 * Touchscreens do not have reliable hover behaviour,
 * so the description remains visible.
 */
@media (hover: none) {

    .cddtc-library-category-shade {
        background: rgba(25, 28, 26, 0.58);
    }

    .cddtc-library-category-description {
        opacity: 1;
        transform: none;
    }
}

/* Mobile */

@media (max-width: 650px) {

    .cddtc-library-front-door {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .cddtc-library-category-image {
        min-height: 300px;
    }

    .cddtc-library-category-description {
        padding: 28px 24px 94px;
    }

    .cddtc-library-category-footer {
        padding: 16px 18px;
    }
}

/* Respect reduced-motion accessibility settings */

@media (prefers-reduced-motion: reduce) {

    .cddtc-library-category-card,
    .cddtc-library-category-image::before,
    .cddtc-library-category-description,
    .cddtc-library-category-more {
        transition: none;
    }
}