/* ==============================================================================
   CARDS BLOCK

   No box, no shadow, no rounded corners (doc/07: a drawing has none). A
   tile is its photo, its name in the title face and its use and place
   under it; the photo's own edge is the only frame. A card without a
   photo (a person on the CV page) hangs from a rule instead, the way a
   drawing separates one entry of a list from the next.
   ============================================================================== */

.block-cards > h2 {
  margin-bottom: var(--spacing-lg);
  font-size: var(--font-size-xl);
}

/* As many columns as fit at 19rem or wider: three in the 72rem content
   column, two on a tablet, one on a phone, without a breakpoint. The
   row gap is twice the column gap so a tile's caption reads as its
   own, never as the top of the tile below. */
.cards__grid {
  display: grid;
  gap: var(--space-7) var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  min-width: 0;
}

.card__media {
  margin-bottom: var(--spacing-sm);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--paper-secondary-bg);
}

/* object-fit crops every photo to the same 4:3 box, so a square render
   and a wide view line up in the same row. */
.card__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card__title {
  margin: 0;
  color: var(--text-primary);
  font-size: var(--font-size-xl);
  line-height: 1.05;
  text-wrap: balance;
}

.card__text {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Tile: the title's link is stretched over the whole card by its ::after,
   so the photo and the caption are one target with one tab stop. The
   card is the positioned ancestor that box fills.
   -------------------------------------------------------------------------- */
.card__link {
  color: inherit;
  text-decoration: none;
}

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

/* The keyboard ring goes around the whole tile, where the click target
   really is, instead of around the title's text alone. */
.card__link:focus-visible {
  outline: none;
}

.card__link:focus-visible::after {
  outline: 3px solid var(--focus-ring);
  outline-offset: 4px;
}

/* Hover says "this is one link" with as little as possible: the name
   underlined in the accent and the photo moving in a few percent. main.css's
   reduced-motion guard keeps the underline and drops the movement's
   transition. */
.card--tile:hover .card__link,
.card__link:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--accent-blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

.card--tile:hover .card__image {
  transform: scale(1.03);
}

/* --------------------------------------------------------------------------
   A card without a photo: a rule on top, its text at reading length and
   the link at its foot, pinned there even when a neighbour's text runs
   longer and stretches the row.
   -------------------------------------------------------------------------- */
.card--text {
  gap: var(--spacing-sm);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

.card--text .card__text {
  flex-grow: 1;
  max-width: var(--measure);
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  line-height: 1.6;
}

.card__action {
  align-self: flex-start;
  padding-block: var(--spacing-xs);
  color: var(--accent-blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
