/* ===== Luxury Refined Recipe Finder ===== */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif&family=DM+Sans:wght@300;400;500;600;700&display=swap');

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --font-display: 'Instrument Serif', serif;
  --font-body: 'DM Sans', sans-serif;

  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-border: #e8e4df;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-accent: #c45d3a;
  --color-accent-hover: #a34d30;
  --color-accent-light: rgba(196, 93, 58, 0.08);
  --color-success: #3d8c40;
  --color-warning: #c49a3a;
  --color-error: #c43a3a;
  --color-overlay: rgba(26, 26, 26, 0.6);

  --space-xs: 0.375rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3.5rem;
  --space-2xl: 6rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-xl: 0 24px 60px rgba(0,0,0,0.12);

  --duration-fast: 120ms;
  --duration-normal: 220ms;
  --duration-slow: 350ms;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ===== Hero Section ===== */
.hero {
  position: relative;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(170deg, #2c1810 0%, #1a1a1a 60%, #0d0d0d 100%);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('https://images.pexels.com/photos/7956504/pexels-photo-7956504.jpeg?auto=compress&cs=tinysrgb&h=650&w=940') center/cover no-repeat;
  opacity: 0.3;
  mix-blend-mode: luminosity;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: linear-gradient(to top, var(--color-bg), transparent);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 680px;
  padding: var(--space-2xl) var(--space-lg);
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-md);
  background: rgba(196, 93, 58, 0.12);
  padding: 6px 16px;
  border-radius: var(--radius-full);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  font-weight: 400;
  color: #ffffff;
  line-height: 1.1;
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}

.hero p {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.6);
  max-width: 480px;
  margin: 0 auto var(--space-xl);
  font-weight: 300;
  line-height: 1.7;
}

/* ===== Search Bar ===== */
.search-container {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

.search-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--duration-normal) ease;
}

.search-wrapper:focus-within {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 4px rgba(196, 93, 58, 0.15);
}

.search-icon {
  padding-left: var(--space-md);
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 16px var(--space-md);
  font-family: var(--font-body);
  font-size: 1rem;
  color: #ffffff;
  width: 100%;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.search-btn {
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  margin: 6px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  white-space: nowrap;
}

.search-btn:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}

.search-btn:active {
  transform: translateY(0);
}

.search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== Category Pills ===== */
.categories-section {
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--color-text);
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  white-space: nowrap;
}

.category-pill:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
  transform: translateY(-1px);
}

.category-pill.active {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}

.category-pill img {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

/* ===== Results Section ===== */
.results-section {
  padding: var(--space-md) var(--space-lg) var(--space-2xl);
  max-width: 1200px;
  margin: 0 auto;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.results-count {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ===== Recipe Grid ===== */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

/* ===== Recipe Card ===== */
.recipe-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--duration-slow) cubic-bezier(0.23, 1, 0.32, 1);
}

.recipe-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.recipe-card:hover .card-image img {
  transform: scale(1.06);
}

.card-image {
  position: relative;
  height: 220px;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) cubic-bezier(0.23, 1, 0.32, 1);
}

.card-badge {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  background: rgba(26, 26, 26, 0.7);
  backdrop-filter: blur(10px);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

.card-fav {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  color: var(--color-text-muted);
}

.card-fav:hover,
.card-fav.active {
  color: var(--color-error);
  background: #ffffff;
  transform: scale(1.1);
}

.card-fav.active svg {
  fill: var(--color-error);
}

.card-body {
  padding: var(--space-md);
}

.card-category {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin-bottom: 6px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: var(--space-sm);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-meta-item svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-sm);
}

.card-tag {
  font-size: 0.7rem;
  padding: 3px 10px;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ===== Loading States ===== */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.skeleton-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.skeleton-image {
  height: 220px;
  background: linear-gradient(110deg, #f0ece8 30%, #f7f4f0 50%, #f0ece8 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-body {
  padding: var(--space-md);
}

.skeleton-line {
  height: 14px;
  background: linear-gradient(110deg, #f0ece8 30%, #f7f4f0 50%, #f0ece8 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.skeleton-line:nth-child(1) { width: 40%; height: 10px; }
.skeleton-line:nth-child(2) { width: 80%; height: 18px; }
.skeleton-line:nth-child(3) { width: 60%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Empty / Error States ===== */
.state-message {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  max-width: 440px;
  margin: 0 auto;
}

.state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.state-message h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: var(--space-sm);
}

.state-message p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ===== Modal / Detail View ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  max-width: 840px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--duration-slow) cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: var(--shadow-xl);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-hero {
  position: relative;
  height: 340px;
  overflow: hidden;
}

.modal-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 60%);
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  z-index: 2;
  color: var(--color-text);
}

.modal-close:hover {
  background: #ffffff;
  transform: scale(1.1);
}

.modal-hero-info {
  position: absolute;
  bottom: var(--space-lg);
  left: var(--space-lg);
  right: var(--space-lg);
  z-index: 2;
}

.modal-hero-info .card-badge {
  position: static;
  display: inline-block;
  margin-bottom: var(--space-sm);
}

.modal-hero-info h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 400;
  color: #ffffff;
  line-height: 1.2;
}

.modal-hero-info .card-meta {
  color: rgba(255, 255, 255, 0.7);
  margin-top: var(--space-sm);
}

.modal-hero-info .card-meta-item svg {
  opacity: 0.8;
}

.modal-body {
  padding: var(--space-xl);
}

.modal-section {
  margin-bottom: var(--space-xl);
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

/* Ingredients */
.ingredients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-sm);
}

.ingredient-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  transition: all var(--duration-fast) ease;
}

.ingredient-item:hover {
  background: var(--color-accent-light);
}

.ingredient-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.ingredient-name {
  font-weight: 500;
  color: var(--color-text);
}

.ingredient-measure {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

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

.instruction-step {
  counter-increment: step;
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
}

.instruction-step:last-child {
  border-bottom: none;
}

.step-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--color-accent);
  color: #ffffff;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 2px;
}

.step-text {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--color-text);
}

/* Source link */
.source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--duration-normal) ease;
}

.source-link:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* ===== Favorites Section ===== */
.favorites-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  z-index: 50;
  transform: translateY(100%);
  transition: transform var(--duration-slow) cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.08);
}

.favorites-bar.visible {
  transform: translateY(0);
}

.favorites-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.favorites-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.favorites-label svg {
  width: 16px;
  height: 16px;
}

.favorites-scroll {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}

.favorites-scroll::-webkit-scrollbar {
  display: none;
}

.fav-thumb {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--duration-normal) ease;
}

.fav-thumb:hover {
  border-color: var(--color-accent);
  transform: scale(1.08);
}

.fav-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-xl);
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero {
    min-height: 440px;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .search-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .search-icon {
    display: none;
  }

  .search-input {
    padding: 14px var(--space-md);
  }

  .search-btn {
    margin: 0 6px 6px;
  }

  .recipe-grid,
  .skeleton-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    max-height: 100vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-hero {
    height: 240px;
  }

  .modal-body {
    padding: var(--space-lg);
  }

  .ingredients-grid {
    grid-template-columns: 1fr;
  }

  .categories-section,
  .results-section {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

@media (max-width: 480px) {
  .category-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: var(--space-xs);
  }

  .category-pills::-webkit-scrollbar {
    display: none;
  }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.recipe-card {
  animation: fadeInUp var(--duration-slow) ease both;
}

.recipe-card:nth-child(1) { animation-delay: 0ms; }
.recipe-card:nth-child(2) { animation-delay: 60ms; }
.recipe-card:nth-child(3) { animation-delay: 120ms; }
.recipe-card:nth-child(4) { animation-delay: 180ms; }
.recipe-card:nth-child(5) { animation-delay: 240ms; }
.recipe-card:nth-child(6) { animation-delay: 300ms; }
.recipe-card:nth-child(7) { animation-delay: 360ms; }
.recipe-card:nth-child(8) { animation-delay: 420ms; }
.recipe-card:nth-child(9) { animation-delay: 480ms; }

/* Scrollbar styling */
.modal::-webkit-scrollbar {
  width: 6px;
}

.modal::-webkit-scrollbar-track {
  background: transparent;
}

.modal::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.modal::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}
