/* Recipe card styles — global (not Astro-scoped) on purpose: RecipeCard.astro
   is rendered from more than one page (homepage, library) and its classes
   must resolve to the same rules everywhere. Relies on the design tokens on
   :root in src/layouts/Base.astro and the .chips/.chip primitives in
   site.css. */

.recipe-card {
  position: relative;
  display: flex;
  flex-direction: column;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border2);
  box-shadow: var(--shadow-sm);
  transition:
    transform 200ms ease,
    box-shadow 200ms ease,
    border-color 200ms ease;
}
.recipe-card:hover,
.recipe-card:focus-within {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.card-image {
  position: relative;
  background: var(--imgph);
  width: 100%;
  overflow: hidden;
}
/* The frame takes the photo's aspect ratio (at least 4:5), so the photo fills it. */
.card-image img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.recipe-card:hover .card-image img {
  transform: scale(1.025);
}
.rc-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a0f05;
  font-size: 10.5px;
  font-weight: 760;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 14px 15px;
}

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text1);
}
.card-link {
  color: inherit;
}
.card-link:hover {
  color: inherit;
}
/* Stretched link: the title's anchor covers the whole card. */
.card-link::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}
.card-link:focus-visible {
  outline: none;
}
.recipe-card:has(.card-link:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.card-meta {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text4);
}
.card-maker {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.card-likes {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.card-likes[hidden] {
  display: none;
}

/* Featured: the one big card on the homepage. From 720px the photo (whole,
   at its own shape) is on the left and fills the card's height, the text is
   centred on the right. The height is 460px, lower when a wide photo would
   push the text column under 320px (100cqw = width of .featured-wrap). Under
   720px it stacks: photo on top, text below. */
.rc-featured {
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}
.rc-featured:hover,
.rc-featured:focus-within {
  box-shadow: var(--shadow-lg);
}
.rc-featured .card-content {
  padding: 18px 20px 20px;
  gap: 5px;
}
.rc-featured .card-title {
  font-size: 22px;
  letter-spacing: -0.025em;
}
.rc-featured .card-meta {
  font-size: 14px;
}
/* Settings under the maker line: the same labels and order as the recipe page. */
.rc-rule {
  width: 48px;
  height: 3px;
  margin: 10px 0 8px;
  border-radius: 3px;
  background: var(--accent);
}
.rc-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  margin: 0;
}
.rc-setting {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.rc-setting-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text5);
}
.rc-setting-value {
  margin: 0;
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.012em;
  color: var(--text1);
  overflow-wrap: anywhere;
}
@media (min-width: 480px) {
  .rc-featured .rc-settings {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Side by side from 720px, unless home.js finds the text does not fit next
   to the photo (it then adds .is-stacked and the card stacks like on a
   phone). The photo is H high (460px up to 520px, lower when a wide photo
   would leave the text column under 360px; 100cqw = width of
   .featured-wrap); the text column is at least that high and grows if needed. */
@media (min-width: 720px) {
  .rc-featured:not(.is-stacked) {
    --h: min(520px, calc((100cqw - 360px) / var(--ar)));
    flex-direction: row;
    align-items: flex-start;
  }
  .rc-featured:not(.is-stacked) .card-image {
    flex: none;
    width: calc(var(--h) * var(--ar));
    height: var(--h);
    aspect-ratio: auto;
  }
  .rc-featured:not(.is-stacked) .card-content {
    flex: 1 1 0;
    min-width: 0;
    min-height: var(--h);
    box-sizing: border-box;
    justify-content: center;
    gap: 8px;
    padding: 24px 36px;
  }
  .rc-featured:not(.is-stacked) .card-title {
    font-size: 28px;
    line-height: 1.15;
  }
  .rc-featured:not(.is-stacked) .card-meta {
    font-size: 15px;
  }
  .rc-featured:not(.is-stacked) .card-maker {
    justify-content: flex-start;
    gap: 14px;
  }
  .rc-featured:not(.is-stacked) .rc-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* home.js adds .is-dense when two columns of settings are too tall. */
  .rc-featured.is-dense:not(.is-stacked) .rc-settings {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Masonry columns built by home.js (the homepage's New uploads). */
.masonry-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (hover: none) {
  .recipe-card:hover {
    transform: none;
  }
  .recipe-card:hover .card-image img {
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .recipe-card:hover,
  .recipe-card:focus-within {
    transform: none;
  }
  .recipe-card:hover .card-image img {
    transform: none;
  }
}
