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

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2d2a26;
  --text-muted: #7a7570;
  --accent: #c2553a;
  --accent-light: #f0d9d2;
  --border: #e8e2db;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
  --radius: 12px;
  --max-width: 1100px;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ===== Controls: Search + Filters ===== */
.controls {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem 1rem;
}

.search-box {
  margin-bottom: 0.75rem;
}

.search-box input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  direction: rtl;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--accent);
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pill.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pill-tag {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
}

/* ===== Recipe Grid ===== */
.grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  flex: 1;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-image {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--border);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5efe8, #ebe4db);
  font-size: 2.5rem;
}

.card-body {
  padding: 0.6rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-body h3 {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
}

.star {
  color: #e6a817;
  margin-left: 0.2rem;
}

.card-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== Recipe Page ===== */
.recipe-page header {
  max-width: 700px;
  margin: 0 auto;
  text-align: start;
  padding: 1.5rem 1rem 0.5rem;
}

.recipe-page header h1 {
  font-size: 1.6rem;
  text-align: start;
}

.back {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.back:hover { text-decoration: underline; }

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.tag {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
}

.credit {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

.recipe-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  flex: 1;
}

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

.recipe-body h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--accent-light);
}

.recipe-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1rem 0 0.4rem;
  color: var(--accent);
}

.recipe-body p {
  margin: 0.5rem 0;
}

.recipe-body ul {
  padding-right: 1.2rem;
  margin: 0.4rem 0;
}

.recipe-body ul li {
  margin: 0.3rem 0;
  line-height: 1.5;
}

.recipe-body ol {
  padding-right: 1.2rem;
  margin: 0.4rem 0;
  counter-reset: step;
  list-style: none;
}

.recipe-body ol li {
  counter-increment: step;
  margin: 0.6rem 0;
  line-height: 1.6;
  position: relative;
  padding-right: 2rem;
}

.recipe-body ol li::before {
  content: counter(step);
  position: absolute;
  right: 0;
  top: 0.1rem;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.recipe-body blockquote {
  border-right: 3px solid var(--accent);
  padding: 0.5rem 1rem 0.5rem 0;
  margin: 0.75rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: rgba(194, 85, 58, 0.04);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.recipe-body blockquote p {
  margin: 0.2rem 0;
}

.source-link {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
}

.source-link:hover { text-decoration: underline; }

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ===== Responsive ===== */
@media (min-width: 480px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (min-width: 768px) {
  header h1 { font-size: 2.2rem; }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
  }
  .card-body h3 { font-size: 0.95rem; }
  .recipe-page header h1 { font-size: 2rem; }
  .recipe-hero { max-height: 500px; }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}
