/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #b45309;        /* warm amber — fits food */
  --accent-light: #fef3c7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --font: 'Georgia', 'Times New Roman', serif;
  --sans: system-ui, -apple-system, sans-serif;
  --max-w: 1100px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  white-space: nowrap;
}

.search-wrap { flex: 1; max-width: 400px; }

#search {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: .9rem;
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}
#search:focus { border-color: var(--accent); }

/* ── Tag nav ─────────────────────────────────────────────────────────────────── */
#tag-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .75rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tag-btn {
  padding: .25rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.tag-btn:hover, .tag-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Recipe grid ─────────────────────────────────────────────────────────────── */
main { max-width: var(--max-w); margin: 0 auto; padding: 2rem; }

#recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}
.card-img.placeholder { background: var(--accent-light); }

.card-body { padding: .875rem 1rem; }
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .25rem;
  font-family: var(--font);
}
.card-meta {
  font-family: var(--sans);
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.card-tag {
  background: var(--accent-light);
  color: var(--accent);
  padding: .1rem .45rem;
  border-radius: 999px;
}

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty {
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
  font-family: var(--sans);
  padding: 4rem 0;
}

/* ── Recipe detail ───────────────────────────────────────────────────────────── */
#recipe-detail-view { max-width: 860px; margin: 0 auto; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 1.5rem;
  background: none;
  border: none;
  padding: 0;
}
.back-btn:hover { color: var(--accent); }

.detail-hero {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.detail-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: .5rem;
}

.detail-meta {
  font-family: var(--sans);
  font-size: .875rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.detail-tags { display: flex; flex-wrap: wrap; gap: .35rem; }
.detail-tag {
  background: var(--accent-light);
  color: var(--accent);
  padding: .2rem .6rem;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: .75rem;
}

.detail-description {
  font-size: .95rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 2.5rem;
  align-items: start;
}

@media (max-width: 640px) {
  .detail-columns { grid-template-columns: 1fr; }
  header { padding: .75rem 1rem; }
  main { padding: 1.25rem; }
  #tag-nav { padding: .5rem 1rem; }
}

/* Ingredients */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: var(--sans);
  color: var(--muted);
  margin-bottom: .75rem;
}

.ingredient-group + .ingredient-group { margin-top: 1rem; }
.group-name {
  font-size: .85rem;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--accent);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ingredient-list { list-style: none; }
.ingredient-list li {
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
}
.ingredient-list li:last-child { border-bottom: none; }
.ing-amount { color: var(--muted); font-family: var(--sans); font-size: .85rem; white-space: nowrap; }
.ing-note { font-style: italic; color: var(--muted); font-size: .85rem; }

/* Instructions */
.instructions-list { list-style: none; counter-reset: steps; }
.instructions-list li {
  counter-increment: steps;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: .75rem;
  margin-bottom: 1.25rem;
  font-size: .975rem;
  line-height: 1.65;
}
.instructions-list li::before {
  content: counter(steps);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-family: var(--sans);
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: .1rem;
}

/* Nutrition facts */
.nutrition-box {
  border: 2px solid var(--text);
  padding: .75rem;
  margin-top: 2rem;
  font-family: var(--sans);
  max-width: 280px;
}
.nf-title { font-size: 1.5rem; font-weight: 900; border-bottom: 8px solid var(--text); padding-bottom: .25rem; margin-bottom: .25rem; }
.nf-servings { font-size: .8rem; border-bottom: 1px solid var(--text); padding-bottom: .25rem; margin-bottom: .25rem; }
.nf-calories-row { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 4px solid var(--text); padding-bottom: .25rem; margin-bottom: .25rem; }
.nf-calories-label { font-size: .8rem; font-weight: 700; }
.nf-calories-value { font-size: 2rem; font-weight: 900; }
.nf-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: .2rem 0; font-size: .8rem; }
.nf-row.indent { padding-left: 1rem; }
.nf-row.thick { border-bottom-width: 4px; border-bottom-color: var(--text); }
.nf-bold { font-weight: 700; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap {
  grid-column: 1/-1;
  display: flex;
  justify-content: center;
  padding: 4rem 0;
}
