/* ============================================
   Cookidoo-Style Recipe Website — CSS
   ============================================ */

:root {
  --green-primary: #5a8a3e;
  --green-dark:    #3d6228;
  --green-light:   #e8f4e0;
  --green-mid:     #8fc067;
  --orange:        #e87c3a;
  --orange-light:  #fdf0e6;
  --text-dark:     #1a1a1a;
  --text-mid:      #555;
  --text-light:    #888;
  --border:        #e0e8d8;
  --white:         #ffffff;
  --radius:        12px;
  --shadow:        0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover:  0 6px 20px rgba(0,0,0,0.14);
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: #f6f8f3;
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Navigation ── */
.navbar {
  background: var(--white);
  border-bottom: 2px solid var(--green-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-brand .logo-icon {
  font-size: 28px;
  line-height: 1;
}

.navbar-brand .logo-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--green-primary);
  letter-spacing: -0.5px;
}

.navbar-brand .logo-sub {
  font-size: 11px;
  color: var(--text-light);
  display: block;
  margin-top: -4px;
}

.navbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.navbar-search input {
  width: 100%;
  padding: 8px 16px 8px 40px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: var(--green-light);
}

.navbar-search input:focus {
  border-color: var(--green-primary);
  background: var(--white);
}

.navbar-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--green-primary);
  font-size: 16px;
}

.nav-links {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-mid);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  background: var(--green-light);
  color: var(--green-dark);
}

/* ── Container ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-dark) 100%);
  border-radius: var(--radius);
  padding: 48px 40px;
  color: var(--white);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.hero h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
}

.hero p {
  font-size: 16px;
  opacity: 0.85;
}

.hero-stats {
  display: flex;
  gap: 32px;
  margin-top: 20px;
}

.hero-stat {
  text-align: center;
}

.hero-stat strong {
  display: block;
  font-size: 28px;
  font-weight: 800;
}

.hero-stat span {
  font-size: 13px;
  opacity: 0.8;
}

/* ── Section ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 22px;
  background: var(--green-primary);
  border-radius: 2px;
}

.section-link {
  font-size: 13px;
  color: var(--green-primary);
  text-decoration: none;
  font-weight: 500;
}

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

/* ── Collections Grid ── */
.collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.collection-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  border: 1.5px solid var(--border);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.collection-card:hover {
  border-color: var(--green-primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.collection-icon {
  font-size: 36px;
}

.collection-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
}

.collection-count {
  font-size: 12px;
  color: var(--text-light);
  background: var(--green-light);
  padding: 2px 10px;
  border-radius: 10px;
}

/* ── Recipe Card ── */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.recipe-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  border: 1.5px solid var(--border);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.recipe-card:hover {
  border-color: var(--green-primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.recipe-card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--green-light);
  display: block;
}

.recipe-card-img-placeholder {
  width: 100%;
  height: 160px;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.recipe-card-body {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recipe-card-collection {
  font-size: 11px;
  color: var(--green-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recipe-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.4;
}

.recipe-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  font-size: 12px;
  color: var(--text-mid);
}

.recipe-card-meta .difficulty {
  background: var(--orange-light);
  color: var(--orange);
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
}

.recipe-card-meta .time {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Filter Bar ── */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  border: 1.5px solid var(--border);
}

.filter-label {
  font-size: 13px;
  color: var(--text-mid);
  font-weight: 600;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-mid);
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:hover, .filter-chip.active {
  background: var(--green-primary);
  color: var(--white);
  border-color: var(--green-primary);
}

/* Collection more dropdown */
#coll-more-wrapper {
  position: relative;
}

#coll-more-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-mid);
  transition: all 0.15s;
}

#coll-more-btn:hover {
  border-color: var(--green-primary);
  color: var(--green-primary);
}

.coll-more-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-hover);
  z-index: 50;
  min-width: 220px;
  max-height: 300px;
  overflow-y: auto;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-search {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  background: var(--green-light);
}

.filter-search input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 13px;
  color: var(--text-dark);
}

/* Device chip color variant */
#device-chips .filter-chip[data-device="TM7"].active {
  background: #3d6228;
  border-color: #3d6228;
}

#device-chips .filter-chip[data-device="TM6"].active {
  background: #5a8a3e;
  border-color: #5a8a3e;
}

#device-chips .filter-chip[data-device="TM5"].active {
  background: #8fc067;
  border-color: #8fc067;
}

/* ── Recipe Detail ── */
.detail-header {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  border: 1.5px solid var(--border);
}

.detail-hero {
  position: relative;
  height: 320px;
  background: var(--green-light);
  overflow: hidden;
}

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

.detail-hero-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  background: linear-gradient(135deg, var(--green-light), #d0e8c0);
}

.detail-hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: white;
}

.detail-hero-overlay h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-badge {
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-sidebar {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  border: 1.5px solid var(--border);
  height: fit-content;
}

.detail-sidebar h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--green-dark);
  border-bottom: 2px solid var(--green-light);
  padding-bottom: 8px;
}

.sidebar-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.sidebar-item:last-child { border-bottom: none; }

.sidebar-item .label { color: var(--text-mid); }

.sidebar-item .value { font-weight: 600; color: var(--text-dark); }

.detail-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  border: 1.5px solid var(--border);
}

.detail-section h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 14px;
  border-bottom: 2px solid var(--green-light);
  padding-bottom: 8px;
}

.ingredient-list, .instruction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ingredient-list li {
  font-size: 14px;
  padding: 8px 12px;
  background: var(--green-light);
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ingredient-list li::before {
  content: '🥗';
  flex-shrink: 0;
}

.instruction-list li {
  font-size: 14px;
  line-height: 1.7;
  padding: 10px 14px;
  border-left: 3px solid var(--green-primary);
  background: #fafcfa;
  border-radius: 0 8px 8px 0;
  counter-increment: step;
}

.instruction-list li::before {
  content: counter(step);
  background: var(--green-primary);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-right: 10px;
}

.tips-box {
  background: var(--orange-light);
  border-left: 4px solid var(--orange);
  padding: 14px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  color: var(--text-dark);
}

.tips-box::before {
  content: '💡 小提示';
  font-weight: 700;
  color: var(--orange);
  display: block;
  margin-bottom: 6px;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--green-light);
  color: var(--green-dark);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--green-light);
  color: var(--green-dark);
  border-radius: 20px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
  transition: all 0.15s;
}

.back-btn:hover {
  background: var(--green-primary);
  color: var(--white);
}

/* ── No results ── */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.no-results .emoji { font-size: 48px; margin-bottom: 12px; }
.no-results h3 { font-size: 18px; margin-bottom: 6px; color: var(--text-mid); }
.no-results p { font-size: 14px; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-light);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; }
  .navbar-brand .logo-sub { display: none; }
  .nav-links { display: none; }
  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 24px; }
  .hero-stats { gap: 20px; }
  .detail-body { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-divider { width: 100%; height: 1px; }
  .filter-search { width: 100%; }
}

@media (max-width: 480px) {
  .collections-grid { grid-template-columns: repeat(2, 1fr); }
  .recipes-grid { grid-template-columns: 1fr; }
}

/* Nutrition Grid */
.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.nutrition-item {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.nutrient-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}
.nutrient-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #3d6228;
}
