/**
 * WebCreator - card grid (markup: docs/page-editor-blocks.md)
 *
 * Loaded only on pages that contain a card grid (div.wc-cards, see wc_block_assets()). No script.
 * Colours, radius, shadow and fonts come from the theme variables (docs/themes.md, 4 and 7), with fallbacks:
 *   card surface   --color-bg (the page colour; every ring colour of the contract holds on it) + --color-border
 *   text           --wc-text, quiet text --color-text-muted      button  --wc-primary / --wc-on-primary (like .btn-primary)
 *   ring           --wc-focus-ring        shape  --wc-radius, --wc-btn-radius, --wc-shadow
 * Layout: flex, not grid, so that an incomplete last row can be centred (data-wc-center="on"). Cards in a row are
 * equally high (the default; data-wc-equal="off" lets each card keep its own height). 1 column on a phone, at most 2 on a tablet.
 */
.wc-cards {
    --wcc-cols: 3;
    --wcc-gap: clamp(1rem, 2.5vw, 1.75rem);
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: stretch;
    gap: var(--wcc-gap);
    box-sizing: border-box;
    margin: 1.5rem 0;
    padding: 0;
}
.wc-cards[data-wc-columns="2"] { --wcc-cols: 2; }
.wc-cards[data-wc-columns="3"] { --wcc-cols: 3; }
.wc-cards[data-wc-columns="4"] { --wcc-cols: 4; }
.wc-cards[data-wc-center="on"] { justify-content: center; }
.wc-cards[data-wc-equal="off"] { align-items: flex-start; }
@media (max-width: 60rem) {
    .wc-cards[data-wc-columns="3"],
    .wc-cards[data-wc-columns="4"] { --wcc-cols: 2; }
}
@media (max-width: 40rem) {
    .wc-cards,
    .wc-cards[data-wc-columns] { --wcc-cols: 1; }
}

.wc-cards > .wc-card {
    position: relative;   /* the link of a clickable card stretches over it */
    box-sizing: border-box;
    flex: 0 0 auto;
    width: calc((100% - (var(--wcc-cols) - 1) * var(--wcc-gap)) / var(--wcc-cols));
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--wc-radius, 8px);
    background: var(--color-bg, #fff);
    color: var(--wc-text, var(--color-text, #111827));
    box-shadow: var(--wc-shadow, 0 1px 3px rgba(0, 0, 0, 0.12));
    text-align: left;
    line-height: 1.5;
}

/* image: a fixed ratio, so the cards have their final size before the pictures are loaded */
.wc-cards .wc-card > img.wc-card-image {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    /* the card is rounded and clips the picture: the photo look of a theme (rounded corners, an offset colour block, a shadow, a paper
       frame with padding and a border, an outline, a slight tilt) is for loose photos */
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    border: 0;
    outline: 0;
    background: none;
    transform: none;
}
.wc-cards[data-wc-ratio="4-3"] .wc-card > img.wc-card-image { aspect-ratio: 4 / 3; }
.wc-cards[data-wc-ratio="1-1"] .wc-card > img.wc-card-image { aspect-ratio: 1 / 1; }
.wc-cards[data-wc-ratio="natural"] .wc-card > img.wc-card-image { aspect-ratio: auto; }

.wc-cards .wc-card > .wc-card-body {
    box-sizing: border-box;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: clamp(1rem, 2.5vw, 1.5rem);
}
.wc-cards .wc-card .wc-card-title {
    margin: 0 0 0.5rem;
    padding: 0;
    color: inherit;
    font-family: var(--font-family-heading, inherit);
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--wc-heading-weight, 700);
    line-height: 1.25;
    text-transform: none;
    letter-spacing: normal;
    overflow-wrap: anywhere;
}
.wc-cards .wc-card .wc-card-text {
    margin: 0 0 1rem;
    color: inherit;
    font-size: var(--font-size-base, 1rem);
    line-height: 1.55;
}
.wc-cards .wc-card .wc-card-text:last-child { margin-bottom: 0; }

/* the button sits at the bottom of the card, whatever the length of the text */
.wc-cards .wc-card .wc-card-body a.wc-card-button {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    box-sizing: border-box;
    min-height: 2.75rem;
    margin-top: auto;
    padding: 0.55rem 1.2rem;
    border: 0;
    border-radius: var(--wc-btn-radius, var(--radius-md, 6px));
    background: var(--wc-primary, var(--color-primary, #27ae60));
    color: var(--wc-on-primary, #111111);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease);
}
.wc-cards .wc-card .wc-card-body a.wc-card-button:hover {
    background: var(--wc-primary-hover, var(--color-primary-dark, var(--wc-primary, #1e8449)));
    color: var(--wc-on-primary-hover, var(--wc-on-primary, #111111));
}

/* the whole card is one link: the title link, stretched over the card (one link, no nested links) */
.wc-cards .wc-card .wc-card-title a.wc-card-link {
    color: inherit;
    text-decoration: none;
}
.wc-cards .wc-card[data-wc-link="card"] .wc-card-title a.wc-card-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}
.wc-cards .wc-card[data-wc-link="card"] .wc-card-title a.wc-card-link:hover { text-decoration: underline; }
@media (hover: hover) {
    .wc-cards .wc-card[data-wc-link="card"] { transition: box-shadow var(--transition-normal, 0.2s ease), transform var(--transition-normal, 0.2s ease); }
    .wc-cards .wc-card[data-wc-link="card"]:hover { box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.16)); transform: translateY(-2px); }
}

/* focus: the ring of the page colour (--wc-focus-ring) around the link or button; a clickable card also gets a ring-coloured border */
.wc-cards .wc-card a:focus-visible {
    outline: 3px solid var(--wc-focus-ring, var(--color-primary, #27ae60));
    outline-offset: 3px;
}
.wc-cards .wc-card[data-wc-link="card"]:has(a.wc-card-link:focus-visible) { border-color: var(--wc-focus-ring, var(--color-primary, #27ae60)); }
@media (prefers-reduced-motion: reduce) {
    .wc-cards .wc-card,
    .wc-cards .wc-card .wc-card-body a.wc-card-button { transition: none; transform: none; }
}

/* price and details list (optional parts of a card, in this order: title, texts, price, list, button) */
.wc-cards .wc-card .wc-card-price {
    margin: 0 0 0.75rem;
    padding: 0;
    color: var(--wc-primary-text, var(--color-primary, #1e8449));   /* the readable variant of the brand colour on the page */
    font-family: var(--font-family-heading, inherit);
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.wc-cards .wc-card .wc-card-list {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    font-size: var(--font-size-sm, 0.9375rem);
    line-height: 1.45;
}
.wc-cards .wc-card .wc-card-list:last-child,
.wc-cards .wc-card .wc-card-price:last-child { margin-bottom: 0; }
.wc-cards .wc-card .wc-card-list > li {
    margin: 0;
    padding: 0.5rem 0;
    list-style: none;
    overflow-wrap: anywhere;
}
.wc-cards .wc-card .wc-card-list > li + li { border-top: 1px dotted var(--color-text-muted, #94a3b8); }
.wc-cards .wc-card .wc-card-list > li::before { content: none; }

/* soft style: a calm tinted box instead of a white card with a border and shadow */
.wc-cards[data-wc-style="soft"] > .wc-card {
    border-color: transparent;
    background: var(--color-bg-secondary, #f5f7f6);
    box-shadow: none;
}
@supports (background: color-mix(in srgb, red 5%, white)) {
    .wc-cards[data-wc-style="soft"] > .wc-card {
        background: color-mix(in srgb, var(--wc-primary, var(--color-primary, #27ae60)) 5%, var(--color-bg, #fff));
    }
}
.wc-cards[data-wc-style="soft"] .wc-card > .wc-card-body { padding: clamp(1.25rem, 3vw, 1.9rem); }
.wc-cards[data-wc-style="soft"][data-wc-center="on"] .wc-card-body { text-align: center; }
.wc-cards[data-wc-style="soft"][data-wc-center="on"] .wc-card-body > a.wc-card-button { align-self: center; }
/* narrow cards (4 columns, or 3 on a small desktop): a smaller price so it does not wrap in the middle; at <= 60rem the grid has 2 columns or fewer */
@media (min-width: 60.0625rem) {
    .wc-cards[data-wc-columns="4"] .wc-card .wc-card-price { font-size: 1.2rem; }
}
@media (min-width: 60.0625rem) and (max-width: 75rem) {
    .wc-cards[data-wc-columns="3"] .wc-card .wc-card-price { font-size: 1.3rem; }
}
.wc-cards .wc-card .wc-card-price { text-wrap: balance; }
