*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #1a1a1a;
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

article.recipe {
  max-width: 680px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid #ddd;
  padding-bottom: 0.75rem;
  margin-bottom: 2rem;
}

nav { display: flex; gap: 0.5rem; align-items: center; }
nav a { text-decoration: none; color: #555; }
nav a:hover { color: #000; }
nav span { color: #ccc; }

#search-wrap { position: relative; }
#search-input {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  width: 180px;
}
#search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  min-width: 240px;
  list-style: none;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
#search-results li a {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: #1a1a1a;
  font-size: 0.9rem;
}
#search-results li a:hover { background: #f5f5f5; }

.recipe-photo {
  float: right;
  width: 280px;
  max-width: 45%;
  border-radius: 8px;
  margin: 0 0 1rem 1.5rem;
  object-fit: cover;
}
@media (max-width: 500px) {
  .recipe-photo { float: none; width: 100%; max-width: 100%; margin: 0 0 1rem 0; }
}

.recipe-photos {
  float: right;
  margin: 0 0 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.recipe-photos .recipe-photo {
  float: none;
  margin: 0;
}
@media (max-width: 500px) {
  .recipe-photos { float: none; width: 100%; margin: 0 0 1rem 0; }
}

h1 { font-size: 1.75rem; margin-bottom: 1rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; color: #333; }

.description { color: #555; margin-bottom: 1.25rem; }

dl.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  width: fit-content;
}
dl.meta dt { font-weight: 600; color: #666; }

.taxonomy { font-size: 0.875rem; color: #666; margin-bottom: 0.4rem; }
.taxonomy a { color: #555; text-decoration: none; }
.taxonomy a:hover { text-decoration: underline; }

.ingredients { padding-left: 1.5rem; }
.ingredients li { margin-bottom: 0.3rem; }

.instructions { padding-left: 1.5rem; }
.instructions li { margin-bottom: 0.75rem; }

.notes {
  margin-top: 2rem;
  padding: 1rem;
  background: #f9f9f9;
  border-left: 3px solid #ddd;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
}
.notes h2 { margin-top: 0; }

.source { font-size: 0.8rem; color: #999; margin-top: 1.5rem; }
.source a { color: #999; }

/* ── Card grid ─────────────────────────────────────── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.recipe-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 4px rgba(0,0,0,.09);
  transition: box-shadow .15s, transform .15s;
}
.recipe-card:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,.14);
  transform: translateY(-3px);
}

.recipe-card__img {
  height: 155px;
  flex-shrink: 0;
  overflow: hidden;
}
.recipe-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.recipe-card__placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #f5f0e8, #e0d8cd);
}

.recipe-card__body {
  padding: 0.75rem 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}
.recipe-card__title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  color: #1a1a1a;
  margin: 0;
}
.recipe-card__time {
  font-size: 0.72rem;
  color: #aaa;
  font-weight: 500;
}
.recipe-card__desc {
  font-size: 0.78rem;
  color: #666;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Plain recipe list (unused but kept for fallback) ─ */
.recipe-list { list-style: none; }
.recipe-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}
.recipe-list li:last-child { border-bottom: none; }
.recipe-list a { font-weight: 500; text-decoration: none; color: #1a1a1a; }
.recipe-list a:hover { text-decoration: underline; }
.meta { font-size: 0.8rem; color: #999; margin-left: 0.5rem; }
.desc { color: #666; font-size: 0.875rem; }

.term-list { list-style: none; }
.term-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid #eee;
}
.term-list a { text-decoration: none; color: #1a1a1a; text-transform: capitalize; }
.term-list a:hover { text-decoration: underline; }

/* ── Nutrition summary table on recipe pages ─────────────────── */
.nutrition-summary { margin-top: 2rem; }
.nutrition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}
.nutrition-table th,
.nutrition-table td {
  padding: 0.35rem 0.6rem;
  border: 1px solid #e0e0e0;
  text-align: left;
}
.nutrition-table thead th {
  background: #f5f5f5;
  font-weight: 600;
  color: #444;
}
.nutrition-table tfoot .totals-row td {
  background: #f0f4f0;
  border-top: 2px solid #bbb;
}
.nutrition-table .row--optional { opacity: 0.65; font-style: italic; }
.nutrition-table .no-data { color: #aaa; text-align: center; }
.nutrition-note { font-size: 0.78rem; color: #999; margin-top: 0.5rem; }

/* ── Ingredient enhancements ─────────────────────────────────── */
.product-link {
  font-size: 0.75rem;
  color: #999;
  text-decoration: none;
  margin-left: 0.4rem;
}
.product-link::before { content: "("; }
.product-link::after  { content: ")"; }
.product-link:hover { color: #444; text-decoration: underline; }
.optional-note { font-size: 0.8rem; color: #aaa; margin-left: 0.25rem; }
.ingredient--optional { opacity: 0.75; }
.alternatives { display: block; font-size: 0.8rem; color: #777; margin-top: 0.1rem; }

/* ── Product detail page ─────────────────────────────────────── */
.product-page { max-width: 520px; }
.product-brand { color: #666; font-size: 0.9rem; margin-top: -0.5rem; margin-bottom: 1.25rem; }
.breadcrumb { font-size: 0.8rem; color: #999; margin-bottom: 1rem; }
.breadcrumb a { color: #999; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.nutrition-label {
  border: 2px solid #1a1a1a;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  max-width: 300px;
  font-size: 0.875rem;
}
.nutrition-label__header {
  font-size: 1.5rem;
  font-weight: 900;
  border-bottom: 8px solid #1a1a1a;
  padding-bottom: 0.25rem;
  margin-bottom: 0.25rem;
}
.nutrition-label__serving {
  border-bottom: 4px solid #1a1a1a;
  padding-bottom: 0.4rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  color: #333;
}
.nutrition-label__table { width: 100%; border-collapse: collapse; }
.nutrition-label__table tr { border-top: 1px solid #ccc; }
.nutrition-label__table th { font-weight: normal; text-align: left; padding: 0.15rem 0; }
.nutrition-label__table td { text-align: right; padding: 0.15rem 0; }
.nutrition-label__calories th,
.nutrition-label__calories td { font-size: 1.5rem; font-weight: 700; padding: 0.35rem 0; border-top: 4px solid #1a1a1a; }
.nutrition-label__indent th { padding-left: 1rem; }
.nutrition-label__indent2 th { padding-left: 2rem; }
.product-notes { margin-top: 1.5rem; font-size: 0.9rem; color: #555; }

/* ── Product listing page ────────────────────────────────────── */
.product-list { list-style: none; padding: 0; }
.product-list li { padding: 0.4rem 0; border-bottom: 1px solid #eee; }
.product-list a { text-decoration: none; color: #1a1a1a; }
.product-list a:hover { text-decoration: underline; }
.product-list .product-brand { font-size: 0.8rem; color: #999; margin-left: 0.5rem; }
