.recipe-list-item {
  display: block;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}
.recipe-list-item:hover { background: var(--accent-soft); }
.recipe-list-item h3 { margin-top: 0; margin-bottom: 0; }

.recipe-list {
  display: grid;
  gap: 14px;
  isolation: isolate;
}

.recipe-list-item {
  display: grid;
  gap: 16px;
  align-items: flex-start;
  grid-template-areas: "body tags";
  grid-template-columns: minmax(0, 1fr) minmax(160px, min(320px, 44%));
  justify-content: space-between;
  overflow: visible;
  position: relative;
  cursor: pointer;
}

.recipe-list-item:hover,
.recipe-list-item:focus-within,
.recipe-list-item.is-tag-popover-open {
  z-index: 30;
}

.recipe-card-link {
  border-radius: inherit;
  inset: 0;
  position: absolute;
  z-index: 1;
}

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

.recipe-list-body {
  grid-area: body;
  min-width: 0;
}

.recipe-list-body {
  display: grid;
  gap: 12px;
}

.recipe-list-body p {
  margin: 0;
}

.pill {
  border-radius: 999px;
  background: var(--accent-soft);
  padding: 8px 12px;
  white-space: nowrap;
}

.recipe-card-tags {
  align-self: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  grid-area: tags;
  justify-self: end;
  justify-content: flex-end;
  max-width: 100%;
  min-width: 160px;
  position: relative;
  width: 100%;
  z-index: 2;
}

.recipe-card-tags:empty {
  display: none;
}

/* Decorative tags and empty tag-area space should reach the card link. */
.recipe-list-item .recipe-card-tags {
  pointer-events: none;
}

.recipe-list-item .recipe-card-tags button,
.recipe-list-item .recipe-card-tags a {
  pointer-events: auto;
}

.recipe-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  line-height: 1.2;
  padding: 8px 12px;
  white-space: nowrap;
}

.recipe-tag.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--panel);
}

button.recipe-tag {
  cursor: pointer;
}

.recipe-tag-overflow {
  display: inline-flex;
  position: relative;
}

.recipe-tag-popover {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  max-width: min(240px, 70vw);
  min-width: max-content;
  opacity: 0;
  padding: 10px;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  visibility: hidden;
  z-index: 40;
}

.recipe-tag-popover .recipe-tag {
  background: var(--accent-soft);
}

.recipe-tag-popover .recipe-tag.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--panel);
}

.recipe-tag-overflow:hover .recipe-tag-popover,
.recipe-tag-overflow:focus-within .recipe-tag-popover,
.recipe-tag-overflow.is-open .recipe-tag-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

@media (max-width: 680px) {
  .recipe-list-item {
    grid-template-areas:
      "body"
      "tags";
    grid-template-columns: 1fr;
  }

  .recipe-card-tags {
    align-self: start;
    justify-self: start;
    justify-content: flex-start;
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .recipe-tag-popover {
    left: 0;
    right: auto;
  }
}

.recipe-page {
  display: grid;
  gap: 16px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.meta-item {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.meta-item dt {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.meta-item dd {
  margin: 0;
}

.recipe-page ul,
.recipe-page ol {
  margin: 0;
}

.recipe-page ul li + li,
.recipe-page ol li + li {
  margin-top: 8px;
}

.ingredient-group + .ingredient-group,
.note-card + .note-card {
  margin-top: 16px;
}

.inline-ref-link,
.recipe-page a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.14em;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.inline-ref-link:hover,
.inline-ref-link:focus-visible,
.recipe-page a:hover,
.recipe-page a:focus-visible {
  background: var(--border);
  border-radius: 6px;
  outline: none;
}

.inline-ref-link:visited,
.recipe-page a:visited {
  color: var(--muted);
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.search-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 24px;
}

.search-controls,
.search-results-panel {
  min-width: 0;
}

.tag-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-filter-button {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
}

.tag-filter-button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--panel);
}

.useful-links-layout {
  align-items: start;
}

.useful-link-controls,
.useful-link-results-panel {
  min-width: 0;
}

.useful-link-controls h1,
.useful-link-results-panel h2,
.useful-link-card-body h3,
.useful-link-card-body h4 {
  margin: 0;
}

.useful-link-controls .text-input {
  width: 100%;
}

.affiliate-disclosure {
  margin-block-start: 1.7em;
}

.useful-link-summary {
  min-height: 1.7em;
}

.useful-link-grid {
  display: grid;
  gap: 16px;
}

.useful-link-card.has-useful-link-image {
  grid-template-areas:
    "body image"
    "tags action";
  grid-template-columns: minmax(0, 1fr) minmax(132px, 180px);
  align-items: center;
  column-gap: 22px;
}

[data-useful-link-card].is-hash-highlighted {
  animation: useful-link-card-breath 1.15s ease-out 1;
}

.useful-link-card-body {
  display: grid;
  gap: 12px;
}

.has-useful-link-image .useful-link-card-body {
  align-self: end;
  grid-area: body;
}

.useful-link-card-body p,
.useful-link-card-body ul {
  margin: 0;
}

.useful-link-card-body ul {
  padding-left: 20px;
}

.useful-link-card-tags {
  max-width: 100%;
  width: 100%;
}

.has-useful-link-image .useful-link-card-tags {
  grid-area: tags;
}

.useful-link-image-frame {
  align-self: end;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-sizing: border-box;
  display: inline-flex;
  grid-area: image;
  align-items: center;
  justify-content: center;
  justify-self: center;
  max-width: 100%;
  padding: 10px;
}

.useful-link-image {
  display: block;
  height: auto;
  max-height: 158px;
  max-width: 158px;
  object-fit: contain;
  width: auto;
}

@keyframes useful-link-card-breath {
  0% {
    border-color: var(--border);
    box-shadow: var(--shadow);
  }

  45% {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
  }

  100% {
    border-color: var(--border);
    box-shadow: var(--shadow);
  }
}

.useful-link-amazon-button {
  justify-self: start;
  text-decoration: none;
}

.has-useful-link-image .useful-link-amazon-button {
  grid-area: action;
  justify-self: center;
}

@media (max-width: 780px) {
  .useful-link-card.has-useful-link-image {
    grid-template-areas:
      "body"
      "tags"
      "image"
      "action";
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: 16px;
  }

  .useful-link-image-frame {
    align-self: start;
    justify-self: center;
    padding: 8px;
  }

  .useful-link-image {
    max-height: 164px;
    max-width: min(164px, 100%);
  }

  .has-useful-link-image .useful-link-card-body,
  .has-useful-link-image .useful-link-card-tags {
    justify-self: stretch;
  }

  .has-useful-link-image .useful-link-amazon-button {
    margin-top: -4px;
  }
}

@media (max-width: 980px) {
  .search-layout, .useful-links-layout { grid-template-columns: 1fr; }
}

