/* ============================================================
   Hearth & Home Bites! — Main Stylesheet
   A warm, modern food blog design
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,800;1,400&family=Inter:wght@300;400;500;600;700&display=swap');

/* --- CSS Variables --- */
:root {
  --cream: #FDF8F0;
  --warm-white: #FFFBF5;
  --terracotta: #C4734F;
  --terracotta-light: #E8A87C;
  --terracotta-dark: #A0523D;
  --sage: #7C9A6D;
  --sage-light: #A8C69F;
  --sage-dark: #5C7A4D;
  --charcoal: #3D342B;
  --charcoal-light: #6B5E52;
  --gold: #D4A853;
  --gold-light: #F0D89C;
  --red-accent: #D9534F;
  --red-light: #F8D7DA;
  --shadow-sm: 0 2px 8px rgba(61, 52, 43, 0.08);
  --shadow-md: 0 4px 16px rgba(61, 52, 43, 0.12);
  --shadow-lg: 0 8px 32px rgba(61, 52, 43, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--cream);
  color: var(--charcoal);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--charcoal);
}

a {
  color: var(--terracotta);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--terracotta-dark); }

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Header / Nav --- */
.site-header {
  background: var(--warm-white);
  border-bottom: 1px solid rgba(61, 52, 43, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(255, 251, 245, 0.92);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--terracotta-dark);
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.logo span {
  color: var(--sage-dark);
}

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
  align-items: center;
}

.nav-links a {
  color: var(--charcoal-light);
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
  padding: 4px 0;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--terracotta);
  transition: width var(--transition);
}
.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--terracotta);
}

.nav-cta {
  background: var(--terracotta) !important;
  color: #fff !important;
  padding: 10px 20px !important;
  border-radius: 50px !important;
  font-weight: 600 !important;
  transition: all var(--transition) !important;
}
.nav-cta::after { display: none !important; }
.nav-cta:hover {
  background: var(--terracotta-dark) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* --- Hero Section --- */
.hero {
  background: linear-gradient(135deg, var(--terracotta-dark) 0%, var(--terracotta) 40%, var(--gold) 100%);
  padding: 80px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  color: #fff;
  padding: 8px 20px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  color: #fff;
  margin-bottom: 16px;
  font-weight: 800;
  letter-spacing: -1px;
}

.hero p {
  font-size: 1.15rem;
  color: rgba(255,255,255,0.9);
  max-width: 500px;
  margin: 0 auto 32px;
  font-weight: 400;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 14px 32px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: #fff;
  color: var(--terracotta-dark);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-outline {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.6);
}
.btn-outline:hover {
  background: rgba(255,255,255,0.15);
  border-color: #fff;
}

/* --- Section Common --- */
.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 72px 24px;
}

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-header h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  color: var(--charcoal);
  margin-bottom: 12px;
}

.section-header p {
  color: var(--charcoal-light);
  font-size: 1.05rem;
  max-width: 550px;
  margin: 0 auto;
}

.section-divider {
  width: 60px;
  height: 3px;
  background: var(--terracotta);
  margin: 16px auto 0;
  border-radius: 2px;
}

/* --- Ingredient Selector ("What to Cook Tonight?") --- */
.ingredient-selector {
  background: var(--warm-white);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(61, 52, 43, 0.06);
}

.ingredient-selector h3 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.ingredient-selector .subtitle {
  color: var(--charcoal-light);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.ingredient-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.85rem;
  border-radius: 50px;
  border: 1.5px solid var(--terracotta-light);
  background: transparent;
  color: var(--terracotta);
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.btn-sm:hover {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}

.ingredient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 32px;
}

.ingredient-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid #E8DDD4;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem;
  user-select: none;
}
.ingredient-chip:hover {
  border-color: var(--terracotta-light);
  background: #FFF5EF;
}
.ingredient-chip.checked {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
  font-weight: 600;
}
.ingredient-chip.checked::before {
  content: '✓';
  font-weight: 700;
  font-size: 0.8rem;
}

.ingredient-chip input[type="checkbox"] {
  display: none;
}

/* Spice chip variant */
.ingredient-chip.spice-chip {
  border-color: #D4C5A0;
  background: #FDF8EC;
}
.ingredient-chip.spice-chip:hover {
  border-color: var(--gold);
  background: #FBF3E0;
}
.ingredient-chip.spice-chip.checked {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}

/* Category headings */
.ingredient-category {
  margin-bottom: 24px;
}

.ingredient-category:last-of-type {
  margin-bottom: 32px;
}

.category-heading {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-heading.spice-heading {
  color: #8B7332;
}

.category-heading.main-heading {
  color: var(--charcoal);
}

.category-hint {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--charcoal-light);
  font-style: italic;
}

/* Sub-category styles */
.ingredient-subcategory {
  margin-bottom: 20px;
}

.ingredient-subcategory:last-child {
  margin-bottom: 0;
}

.subcategory-heading {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--charcoal-light);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #F0EBE3;
}

.subcategory-grid {
  margin-bottom: 0;
}

/* --- Results Section --- */
.results-container {
  border-top: 1px solid #E8DDD4;
  padding-top: 28px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.results-header h4 {
  font-size: 1.2rem;
}

.results-count {
  font-size: 0.9rem;
  color: var(--charcoal-light);
  background: #F0EBE3;
  padding: 6px 16px;
  border-radius: 50px;
  font-weight: 500;
}

.no-results {
  text-align: center;
  padding: 48px 24px;
  color: var(--charcoal-light);
}

.no-results .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.result-group {
  margin-bottom: 32px;
}

.result-group-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-group-title.perfect {
  color: var(--sage-dark);
}

.result-group-title.partial {
  color: var(--terracotta-dark);
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.result-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid #E8DDD4;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.result-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--terracotta-light);
}

.result-card .match-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 50px;
}
.match-badge.full {
  background: #D4EDDA;
  color: #2D6A3F;
}
.match-badge.partial-badge {
  background: #FFF3CD;
  color: #856404;
}

.result-card h5 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  padding-right: 60px;
}

.result-card .card-date {
  font-size: 0.8rem;
  color: var(--charcoal-light);
  margin-bottom: 10px;
}

.result-card .missing-ingredients {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--charcoal-light);
}

.result-card .missing-ingredients span {
  color: var(--red-accent);
  font-weight: 600;
}

/* --- Recipe Grid (All Recipes) --- */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
}

.recipe-card {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  cursor: pointer;
  border: 1px solid rgba(61, 52, 43, 0.06);
}
.recipe-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.recipe-card-image {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: linear-gradient(135deg, #F0EBE3, #E8DDD4);
}
.recipe-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.recipe-card:hover .recipe-card-image img {
  transform: scale(1.06);
}

.recipe-card-image .no-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--terracotta-light);
}

.recipe-card-tags {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.recipe-card-tags .tag {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  color: var(--charcoal);
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recipe-card-body {
  padding: 20px 24px 24px;
}

.recipe-card-body h3 {
  font-size: 1.2rem;
  margin-bottom: 6px;
  line-height: 1.4;
}

.recipe-card-body .card-date {
  font-size: 0.82rem;
  color: var(--charcoal-light);
  margin-bottom: 12px;
}

.recipe-card-body .ingredient-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recipe-card-body .ingredient-preview .mini-chip {
  background: #F5F0EA;
  color: var(--charcoal-light);
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 52, 43, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: #fff;
  border-radius: var(--radius-xl);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-image {
  height: 280px;
  overflow: hidden;
  background: linear-gradient(135deg, #F0EBE3, #E8DDD4);
}
.modal-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.modal-image .no-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  color: var(--terracotta-light);
}

.modal-body {
  padding: 32px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 10;
}
.modal-close:hover {
  background: #fff;
  transform: scale(1.1);
}

.modal-body .modal-date {
  font-size: 0.85rem;
  color: var(--charcoal-light);
  margin-bottom: 4px;
}

.modal-body h2 {
  font-size: 1.8rem;
  margin-bottom: 16px;
}

.modal-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.modal-tags .tag {
  background: #F5F0EA;
  color: var(--terracotta);
  padding: 5px 14px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-section {
  margin-bottom: 24px;
}

.modal-section h3 {
  font-size: 1.15rem;
  margin-bottom: 12px;
  color: var(--terracotta-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ingredients-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.ingredients-list li {
  background: #F9F5EF;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--charcoal);
}

.instructions-list {
  list-style: none;
  counter-reset: step;
}

.instructions-list li {
  counter-increment: step;
  padding: 12px 0 12px 48px;
  position: relative;
  border-bottom: 1px solid #F0EBE3;
  line-height: 1.6;
}
.instructions-list li:last-child {
  border-bottom: none;
}

.instructions-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 12px;
  width: 32px;
  height: 32px;
  background: var(--terracotta);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

/* --- Footer --- */
.site-footer {
  background: var(--charcoal);
  color: rgba(255,255,255,0.7);
  text-align: center;
  padding: 40px 24px;
  font-size: 0.9rem;
}

.site-footer .footer-brand {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 8px;
}

.site-footer a {
  color: var(--terracotta-light);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  .nav-links {
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .nav-links a {
    font-size: 0.85rem;
  }
  .hero {
    padding: 56px 20px;
  }
  .section {
    padding: 48px 16px;
  }
  .ingredient-selector {
    padding: 24px 20px;
  }
  .ingredient-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
  }
  .ingredient-chip {
    padding: 8px 10px;
    font-size: 0.82rem;
    gap: 6px;
  }
  .recipe-grid {
    grid-template-columns: 1fr;
  }
  .result-cards {
    grid-template-columns: 1fr;
  }
  .modal {
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }
  .modal-body {
    padding: 20px;
  }
  .modal-body h2 {
    font-size: 1.4rem;
  }
  .modal-image {
    height: 200px;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.8rem;
  }
  .hero p {
    font-size: 1rem;
  }
  .btn {
    padding: 12px 24px;
    font-size: 0.9rem;
  }
  .ingredient-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .recipe-card-image {
    height: 180px;
  }
}