/* ===== CSS Variables / Palette ===== */
:root {
  --cream: #fdf6ec;
  --cream-light: #fffbf5;
  --terracotta: #c45b3c;
  --terracotta-dark: #a8482c;
  --terracotta-light: #e07a5f;
  --olive: #6b8e23;
  --olive-light: #8cb84b;
  --olive-dark: #4a6520;
  --warm-brown: #8b6f5c;
  --dark: #2c1810;
  --dark-soft: #4a3728;
  --text: #3d2c1f;
  --text-light: #7a6b5f;
  --card-bg: #ffffff;
  --shadow: 0 2px 12px rgba(44, 24, 16, 0.08);
  --shadow-hover: 0 8px 30px rgba(44, 24, 16, 0.15);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
  color: var(--dark);
}

/* ===== Hero Section ===== */
.hero {
  background: linear-gradient(135deg, var(--dark) 0%, var(--terracotta-dark) 100%);
  color: #fff;
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 40px;
  background: var(--cream);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 300;
  margin-bottom: 2rem;
  font-style: italic;
  font-family: 'Playfair Display', serif;
}

/* ===== Search ===== */
.search-wrapper {
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  pointer-events: none;
  opacity: 0.5;
}

#search-input {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 3rem;
  border: 2px solid transparent;
  border-radius: 50px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  outline: none;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}

#search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#search-input:focus {
  background: rgba(255, 255, 255, 0.25);
  border-color: var(--terracotta-light);
}

/* ===== Main Content Area ===== */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ===== Section Header ===== */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.6rem;
}

.recipe-count {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 400;
}

/* ===== Recipe Grid ===== */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* ===== Recipe Card ===== */
.recipe-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

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

.recipe-card:active {
  transform: translateY(-1px);
}

.card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  background: #f0e8d8;
}

.card-image-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, #f5ede2, #e8dccc);
}

.card-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.3;
  color: var(--dark);
}

.card-meta {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-top: auto;
}

.card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* ===== Empty State ===== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ===== Loading Spinner ===== */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid #e8dccc;
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Detail View ===== */
.detail-view {
  display: none;
  animation: fadeSlideUp 0.4s ease;
}

.detail-view.active {
  display: block;
}

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

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--terracotta);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
  transition: color var(--transition);
  font-family: 'Inter', sans-serif;
}

.back-btn:hover {
  color: var(--terracotta-dark);
}

.detail-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.detail-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.detail-images img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
  background: #f0e8d8;
}

.detail-images img.placeholder-img {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, #f5ede2, #e8dccc);
  object-fit: none;
}

.detail-body {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
}

.ingredients-section h2,
.directions-section h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--terracotta);
}

.ingredients-list {
  list-style: none;
  padding: 0;
}

.ingredients-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0e8d8;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.ingredients-list li::before {
  content: '•';
  color: var(--olive);
  font-weight: bold;
  flex-shrink: 0;
}

.directions-text {
  white-space: pre-line;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ===== List View Transitions ===== */
.list-view {
  transition: opacity 0.3s ease;
}

.list-view.hidden {
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .recipe-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .hero {
    padding: 3rem 1.25rem 2.5rem;
  }

  .main-content {
    padding: 1.5rem 1rem 3rem;
  }

  .recipe-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .detail-images {
    grid-template-columns: 1fr;
  }

  .detail-images img {
    height: 240px;
  }

  .detail-body {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .card-image {
    height: 180px;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.6rem;
  }

  .card-body {
    padding: 1rem;
  }

  .card-body h3 {
    font-size: 1.05rem;
  }
}
