.recipe-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-3);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform var(--normal) var(--ease), box-shadow var(--normal) var(--ease),
    border-color var(--normal) var(--ease);
}

.recipe-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: var(--shadow-2);
}

.recipe-card:has(.recipe-card__title:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.recipe-card__media {
  position: relative;
  overflow: hidden;
  background: var(--placeholder-bg);
}

/* The background shows through when the remote image fails: no inline onerror handler. */
.recipe-card__image {
  position: relative;
  display: block;
  width: 100%;
  height: 168px;
  object-fit: cover;
  background: var(--placeholder);
  transition: transform 320ms var(--ease);
}

/* Only drawn for a failed photo: hides the broken-image icon behind the loading placeholder. */
.recipe-card__image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--placeholder);
}

.recipe-card:hover .recipe-card__image {
  transform: scale(1.04);
}

/* What the recipe is missing, over the photo: it is why the card ranks where it does. */
.recipe-card__match {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  margin: 0;
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--card-bg) 94%, transparent);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.recipe-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  padding: var(--space-4);
}

.recipe-card__category {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.recipe-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  text-wrap: pretty;
}

/* The title link stretches over the whole card: one focusable element, named by the title. */
.recipe-card__title::after {
  content: "";
  position: absolute;
  inset: 0;
}

.recipe-card:hover .recipe-card__title {
  color: var(--accent);
}

.recipe-card__title:focus-visible {
  outline: none;
}

.recipe-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-1) 0 0;
}

.recipe-card__author {
  margin: auto 0 0;
  padding-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
}
