/* ==========================================================================
   Recipes — css/recipes.css
   Styles for: recipes listing page, individual recipe pages, Recipe Builder.
   Uses the same colour/size tokens as css/style.css (loaded first).
   ========================================================================== */

/* ---------------------------- Listing page ---------------------------- */
.recipes-hero { padding-bottom: 40px; }

.recipe-filters {
  max-width: 980px;
  margin: 0 auto 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.recipe-search { max-width: 520px; width: 100%; margin: 0 auto; }
.recipe-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.recipe-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.recipe-chip:hover { border-color: var(--brand); color: var(--brand); }
.recipe-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.recipes-section { padding: 48px 0 64px; background: var(--surface); }

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
@media (max-width: 900px) { .recipe-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
@media (max-width: 560px) { .recipe-grid { grid-template-columns: 1fr; } }

.recipe-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  color: inherit;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.recipe-card:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.recipe-card-img { aspect-ratio: 4 / 3; background: var(--surface-sunken); overflow: hidden; }
.recipe-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.recipe-card-body h3 { margin: 0; font-size: 1.15rem; line-height: 1.25; color: var(--ink); }
.recipe-card-body p { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.recipe-card-meta {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 0.8rem;
  color: var(--ink-faint);
  font-weight: 600;
}

.recipe-cat {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.recipes-status {
  text-align: center;
  color: var(--ink-faint);
  padding: 40px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
}
.recipes-more { display: block; margin: 32px auto 0; width: auto; padding: 12px 28px; }

/* ---------------------------- Recipe page ---------------------------- */
.recipe-wrap { max-width: 780px; padding-top: 28px; padding-bottom: 64px; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--ink-faint);
  margin-bottom: 22px;
}
.breadcrumb a { color: var(--ink-soft); }

.recipe-header h1 { margin: 6px 0 12px; }
.recipe-lead { font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 10px; }
.recipe-byline { font-size: 0.86rem; color: var(--ink-faint); margin-bottom: 22px; }
.recipe-byline strong { color: var(--ink-soft); }

.recipe-hero { margin: 0 0 24px; }
.recipe-hero img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
  display: block;
  background: var(--surface-sunken);
}

.recipe-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 28px;
}
.recipe-fact { display: flex; flex-direction: column; gap: 2px; min-width: 88px; }
.recipe-fact-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.recipe-fact-value { font-size: 1rem; font-weight: 700; color: var(--ink); }

.recipe-intro p { font-size: 1.04rem; line-height: 1.75; }

.recipe-section { margin-top: 36px; }
.recipe-section h2 { margin-bottom: 14px; }

.recipe-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 560px) { .recipe-gallery { grid-template-columns: 1fr; } }

.recipe-figure { margin: 14px 0 0; }
.recipe-figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
  background: var(--surface-sunken);
}
.recipe-figure figcaption { font-size: 0.82rem; color: var(--ink-faint); margin-top: 6px; }
.recipe-gallery .recipe-figure { margin: 0; }
.recipe-gallery .recipe-figure img { aspect-ratio: 4 / 3; object-fit: cover; }

.recipe-ingredients {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.recipe-ingredients li {
  position: relative;
  padding: 11px 14px 11px 40px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.recipe-ingredients li::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--brand);
}

.recipe-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 22px; }
.recipe-steps > li { counter-increment: step; position: relative; padding-left: 52px; }
.recipe-steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.recipe-steps p { color: var(--ink); line-height: 1.7; margin-bottom: 0.6em; }

.recipe-notes {
  background: var(--brand-tint);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
}
.recipe-notes p { color: var(--brand-dark); }
.recipe-notes p:last-child { margin-bottom: 0; }

.recipe-nutrition { width: 100%; max-width: 420px; border-collapse: collapse; font-size: 0.94rem; }
.recipe-nutrition th, .recipe-nutrition td { padding: 10px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.recipe-nutrition th { font-weight: 600; color: var(--ink); }
.recipe-nutrition td { text-align: right; color: var(--ink-soft); }
.recipe-small { font-size: 0.8rem; color: var(--ink-faint); margin-top: 8px; }

.recipe-cta {
  margin: 40px 0 24px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.recipe-cta h2 { font-size: 1.2rem; margin-bottom: 10px; }
.recipe-cta p:last-child { margin-bottom: 0; }

.recipe-back { margin-top: 28px; font-weight: 600; }

/* ---------------------------- Recipe Builder ---------------------------- */
.rb-wrap { max-width: 860px; margin: 0 auto; padding: 36px 24px 72px; }
.rb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.rb-card h2 { font-size: 1.25rem; margin-bottom: 4px; }
.rb-help { font-size: 0.84rem; color: var(--ink-faint); margin: 0 0 16px; }
.rb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.rb-grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .rb-grid, .rb-grid.three { grid-template-columns: 1fr; } }
.rb-card .form-group { margin-bottom: 16px; }
.rb-card .form-group:last-child { margin-bottom: 0; }
.rb-card textarea, .rb-card select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
.rb-card textarea:focus, .rb-card select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
  outline: none;
}
.rb-card input[type="file"] { font-size: 0.88rem; max-width: 100%; }
.rb-counter { font-size: 0.78rem; color: var(--ink-faint); margin-top: 4px; }
.rb-counter.warn { color: var(--high); }

.rb-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface-sunken);
}
.rb-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 700; font-size: 0.9rem; }
.rb-item-actions { display: flex; gap: 6px; }
.rb-mini {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: var(--font-body);
}
.rb-mini:hover { border-color: var(--brand); color: var(--brand); }
.rb-mini.danger:hover { border-color: var(--high); color: var(--high); }
.rb-filename { font-size: 0.82rem; color: var(--ink-faint); margin-top: 6px; word-break: break-all; }

.rb-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.rb-actions .calc-btn { width: auto; flex: 1; min-width: 200px; margin-top: 0; }
.calc-btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.calc-btn.secondary:hover { background: var(--surface-sunken); }

.rb-status { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 18px; background: var(--surface-sunken); color: var(--ink-soft); }
.rb-status.ok { background: var(--low-tint); color: var(--low); }
.rb-status.error { background: var(--high-tint); color: var(--high); }
.rb-errors { margin: 8px 0 0; padding-left: 20px; }

.rb-steps-after { background: var(--brand-tint); border-left: 4px solid var(--brand); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 18px 22px; }
.rb-steps-after ol { margin: 8px 0 0; padding-left: 20px; color: var(--brand-dark); }
.rb-steps-after li { margin-bottom: 6px; }
.rb-details summary { cursor: pointer; font-weight: 600; color: var(--ink-soft); }
