/* ============================================================
   card.css — the card family
   ============================================================
   Generic content card: a bordered, rounded surface for grouped
   content. .card handles the container only — use the sibling
   classes (.card-heading, .card-text, .card-link, .card-media, …)
   for what's inside. The .card--cover variant (full-bleed image on
   top) is STANDALONE — apply it alone, never together with .card.
   Hover, focus and press states are baked in, no extra class needed.
   Conventions: _shared/bricks-builder/css-conventions.md

   Contents
     1. Shared container, states and focus ring
     2. Text parts — heading, subtitle, text, link
     3. Media — flat, round and icon variants
     4. Meta row, content column
     5. Cover variant — full-bleed image on top

   Last updated: 2026-10-12 (auto-stamped by the pre-commit hook)
   ============================================================ */


/* --- 1. Shared container, states and focus ring --------------- */

/* Shared by .card and .card--cover; the variant block further down
   overrides gap and padding. */
:is(.card, .card--cover) {
    position: relative;               /* context for the stretched link */

    display: grid;
    gap: var(--space-s);
    padding: var(--space-m);

    background-color: var(--surface-base);
    border: var(--border-width-base) solid var(--border-panel);
    border-radius: var(--radius-3);

    transition: box-shadow var(--transition-base), transform var(--transition-base);

    text-align: left;                 /* stay left even in a centred section */
}

/* Flat card is a flex column so the illustration + link can pin to the
   bottom (margin-block-start:auto): in a deck of equal-height cards the
   images bottom-align and the links line up, and the leftover space
   from shorter text hides between text and image instead. Without an
   illustration the link carries the pin; with one, the link's auto
   margin is cancelled so the free space isn't split between the two. */
.card {
    display: flex;
    flex-direction: column;
}
.card > :is(.card-media, .card-link) {
    margin-block-start: auto;
}
.card > .card-media ~ .card-link {
    margin-block-start: 0;
}

/* Makes the whole card one clickable link: the heading's own <a> is
   stretched to cover the card ("stretched link" pattern), so the heading
   text stays the link's accessible name. */
:is(.card, .card--cover) .card-heading a::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* If the card has a SECOND link or button inside (e.g. a linked tag),
   lift it above the whole-card link so it stays clickable. The heading
   link must stay excluded — position:relative on it would break the
   whole-card link. */
:is(.card, .card--cover) :is(a, button):not(.card-heading a) {
    position: relative;
    z-index: 2;
}

/* Interaction states fire ONLY when the card has the stretched link
   (:has) — a linkless card stays static (no shadow, no pointer, no
   lift/press), so it never signals "click me" when there's nothing to
   click (house rule: shadow = clickable, ratified 15-07-2026). */
:is(.card, .card--cover):has(.card-heading a) {
    cursor: pointer;
    box-shadow: var(--elevation-card);
    /* Dark mode lightens the surface per elevation level (tokens.css §1);
       `none` in light mode. */
    background-image: var(--elevation-overlay-card);
}
:is(.card, .card--cover):has(.card-heading a):hover {
    box-shadow: var(--elevation-card-hover);
    background-image: var(--elevation-overlay-card-hover);
    transform: translateY(calc(-1 * var(--lift-hover)));   /* rises with the shadow (tokens.css §6) */
}
:is(.card, .card--cover):has(.card-heading a):active {
    box-shadow: var(--elevation-card);
    background-image: var(--elevation-overlay-card);
    transform: none;   /* pressed: settles back into the page */
}

/* Keyboard focus on the whole-card link: the card lifts and wears the
   house ring (§6.5) on its own edge, so the ring marks the same area
   that is clickable. Only the stretched link triggers it — another
   focusable child (a linked tag) keeps its own ring. */
:is(.card, .card--cover):has(.card-heading a:focus-visible) {
    box-shadow: var(--elevation-card-hover);
    background-image: var(--elevation-overlay-card-hover);
    transform: translateY(calc(-1 * var(--lift-hover)));
    outline: var(--border-width-strong) solid var(--text-strong);
    outline-offset: 2px;
}

/* Reduced motion: the shadow still deepens, the card stays put. */
@media (prefers-reduced-motion: reduce) {
    :is(.card, .card--cover):has(.card-heading a):hover,
    :is(.card, .card--cover):has(.card-heading a:focus-visible) {
        transform: none;
    }
}

/* The ring is MOVED to the card above, not removed. The one place the
   house rule allows switching off Bricks' Focus outline field: the
   link's own box is just the heading text, which is smaller than what
   the link actually covers. */
:is(.card, .card--cover) .card-heading a:focus-visible {
    outline: none;
}

/* --- 2. Text parts — heading, subtitle, text, link ------------ */

.card-heading,
.card-subtitle,
.card-text,
.card-meta > * {
    margin: 0;
}

/* Proximity: the subtitle belongs to its heading, so it sits at
   space-2xs — the negative margin eats the difference from the card's
   space-s gap. Only fires right after a heading. */
:is(.card, .card--cover) .card-heading + .card-subtitle {
    margin-block-start: calc(var(--space-2xs) - var(--space-s));
}

.card-heading {
    /* Smaller than section titles, to sit in a card grid. */
    font-size: var(--title-5);
    color: var(--text-heading);
}

.card-subtitle {
    font-size: var(--text-m);
    font-weight: 600;
    color: var(--text-heading);
}

/* Hide an empty subtitle so the grid gap doesn't reserve space.
   (Cleaner: a Bricks "Dynamic data is not empty" render condition.) */
.card-subtitle:empty {
    display: none;
}

.card-text {
    color: var(--text-base);
}

.card-link {
    color: var(--text-link);
    font-weight: 600;
}

.card-link:hover {
    color: var(--text-link-hover);
}

/* --- 3. Media — flat, round and icon variants ----------------- */

.card-media {
    width: 100%;
}

/* Inside the flat card the illustration sits within the card padding —
   rounded one step tighter than the card, like the dropdown rows.
   (.card--cover's media stays square: full-bleed, clipped by the card's
   own radius.) */
.card > .card-media {
    border-radius: var(--radius-2);
}

/* Round media variant. STANDALONE (not with .card-media); set the size
   with a width utility. */
.card-media--round {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-full);
    border: var(--border-width-base) solid var(--border-subtle);
}

/* Icon variant. STANDALONE (not with .card-media): put the class on the
   Icon element itself. A bare feature icon at the top of the card.
   Default colour is brand blue; the component's "Icon colour" select
   overrides it with a .text-* utility (utility-classes.css loads after
   this file, so the utility wins). The icon is a house SVG file inlined
   by Bricks; the Icon element puts its classes ON the <svg>, so the
   1em box is set on the element itself (and on a nested <svg>, should
   the icon ever sit in a wrapper). Without it an inline SVG with no
   width has no size of its own. */
.card-media--icon {
    color: var(--text-highlight-primary);
    font-size: var(--icon-xl);
}
svg.card-media--icon,
.card-media--icon svg {
    block-size: 1em;
    inline-size: auto;
}

/* --- 4. Meta row, content column ---------------------------- */

/* Cover-card meta row. Children forced to auto width below, or Bricks'
   full-width default stacks them onto separate lines even in a row. */
.card-meta {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-s);
    width: 100%;
    font-size: var(--text-s);
    color: var(--text-secondary);
}

.card-meta > * {
    width: auto;
}

/* Grows to fill the card so the link can sit at the bottom. */
.card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: var(--space-s);
    padding: var(--space-m);
}

/* --- 5. Cover variant — full-bleed image on top --------------- */

/* Cover variant — full-bleed image on top, padded content below. */
.card--cover {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;                 /* clip the image to the radius */
}

/* Fixed-ratio container; the image sits inside, so the gradient backdrop
   shows through transparent areas of a PNG. */
.card--cover .card-media {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: var(--grey-400);         /* fallback under the gradient */
    background-image: var(--gradient-neutral);
}

.card--cover .card-media > * {
    width: 100%;
    height: 100%;
}

/* Wrapped shape only: an img INSIDE a .card-media wrapper fills it.
   (Deliberately NOT applied when .card-media is the img itself — there
   the 16:9 aspect-ratio above already sizes the box, and height:100%
   would stretch it to the full card.) */
.card--cover .card-media img {
    width: 100%;
    height: 100%;
}

/* `cover` crops — for a mockup/logo image that should show in full on
   the gradient backdrop, use the `.object-contain` utility instead
   (the Card — Cover component exposes this as the "Image fit" select).
   Bricks usually puts .card-media on the <img> ITSELF (no wrapper), so
   both DOM shapes are matched; :where() keeps specificity at one class,
   so the utilities and per-element Bricks settings can override. */
.card--cover :where(img.card-media, .card-media img) {
    object-fit: cover;
    display: block;
}

/* Pin the tags + link to the bottom as one footer zone, so pills and
   CTAs line up across the deck; shorter text leaves its slack between
   the text and the footer. Same idiom as the flat card's media+link
   pinning in section 1 above: auto margin on the first footer element, zeroed on the
   link when a visible tag row precedes it. When the tag row is hidden
   (no chips, chip.css §1), the link keeps the auto margin and is pinned alone. */
.card--cover :is(.chip-list, .card-link) {
    margin-block-start: auto;
}
.card--cover .chip-list:has(.chip--subtle) ~ .card-link {
    margin-block-start: 0;
}
