/*
 * Course cards for the course catalog (courses/course/card.html).
 * Grid of up to three cards per row; card style follows eversports: hairline divider,
 * almost invisible shadow, small radius only from 640px, compact neutral typography.
 */

.course-grid {
    --cc-gap: 1.5rem;
    /* columns of at least 18rem, but never more than three per row */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(max(18rem, (100% - 2 * var(--cc-gap)) / 3), 1fr));
    gap: var(--cc-gap);
    margin-bottom: 2rem;
}

.course-card {
    position: relative;
    /*
     * every card has the same fixed height, however much it holds (features, audience line) and however many
     * cards are shown (a filter leaves one alone in its row); details and footer take what they need,
     * the picture gets the rest
     */
    display: flex;
    flex-direction: column;
    height: 21rem;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--pico-card-background-color);
    border-bottom: 1px solid var(--pico-muted-border-color);
    box-shadow: var(--cf-shadow-sm);
    /* course color as a slim accent on the left */
    border-left: 4px solid var(--course-color, var(--pico-primary));
    transition: box-shadow 0.15s ease;
}

.course-card:hover {
    box-shadow: var(--cf-shadow-md);
}

/* picture on a light tint of the course color, filling the space the details leave */
.course-card__media {
    position: relative;
    flex: 1 1 auto;
    min-height: 5rem;
    background: color-mix(in srgb, var(--course-color, var(--pico-primary)) 18%, white);
}

.course-card__media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-card__body {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem;
    font-size: var(--cf-text-md);
    color: var(--pico-color);
}

.course-card__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5rem;
}

/* two lines in the list, the full text is on the detail page */
.course-card__description {
    margin: 0;
    font-size: var(--cf-text-xs);
    line-height: 1rem;
    color: var(--pico-muted-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* plain facts separated by dots */
.course-card__facts {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    font-size: var(--cf-text-xs);
}

.course-card__facts li {
    list-style: none;
    margin: 0;
}

.course-card__facts li + li::before {
    content: "·";
    margin: 0 0.5rem;
    color: var(--pico-muted-color);
}

/* features as small pills */
.course-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.2rem 0 0;
    padding: 0;
}

.course-card__tags li {
    list-style: none;
    margin: 0;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--cf-sage-100);
    color: var(--cf-sage-900);
    font-size: var(--cf-text-2xs);
    font-weight: 600;
}

/* price and action at the bottom of the card, aligned across a row because the body grows */
.course-card__footer {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-top: 1px solid var(--pico-muted-border-color);
}

/* the whole card is clickable: the title link covers the card with a pseudo element */
.course-card__link {
    color: inherit;
    text-decoration: none;
}

.course-card__link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.course-card:has(.course-card__link) {
    cursor: pointer;
}

/* keyboard focus marks the whole card instead of only the title */
.course-card__link:focus-visible {
    outline: none;
}

.course-card:has(.course-card__link:focus-visible) {
    outline: 2px solid var(--pico-primary);
    outline-offset: 2px;
}

.course-card__inactive {
    font-size: var(--cf-text-xs);
    color: var(--pico-muted-color);
}

@media (min-width: 640px) {
    .course-card {
        border-radius: var(--cf-radius-sm);
    }
}
