/* ===========================
   Accessibility utilities
=========================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===========================
   Variables & Theme
=========================== */
:root {
  --primary-color: #ad1417;
  --secondary-color: #aa7274;
  --bg-color: #fff;
  --text-color: #000;
  --text-color-light: #6e6e6e;
  --primary-outline-color: #e8e0d8;
  --secondary-outline-color: #d5c9c0;
}




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

html {
  height: 100%;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===========================
   Header
=========================== */
.site-header {
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--primary-outline-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.logo {
  max-width: 100%;
}

.main-nav ul {
  display: flex;
  gap: 1.5rem;
}

.main-nav a {
  font-size: 0.95rem;
  color: var(--text-color);
  font-weight: 500;
  transition: color 0.2s;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--primary-color);
}

/* ===========================
   Hero
=========================== */
.hero {
  background-color: var(--primary-color);
  color: var(--bg-color);
  padding: 4rem 0;
  text-align: center;
}


.hero p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.search-bar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-bar input {
  width: 360px;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
}

.search-bar button {
  padding: 0.75rem 1.5rem;
  background-color: var(--bg-color);
  color: var(--primary-color);
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s;
}

.search-bar button:hover {
  background-color: var(--bg-color);
}

/* ===========================
   Category Filter
=========================== */
.category-filter {
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--primary-outline-color);
  padding: 0.75rem 0;
  overflow: visible;
  position: sticky;
  top: 69px;
  z-index: 99;
}

.category-filter .container {
  overflow: visible;
  max-width: none;
}

.filter-inner-wrap {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /*position: relative;*/
}

.filter-inner-wrap.dropdown-open {
  overflow: visible;
}

.filter-toggle-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--text-color-light);
  cursor: pointer;
  padding: 0.2rem 0 0;
  text-align: center;
  transition: color 0.2s;
}

.filter-toggle-btn:hover {
  color: var(--primary-color);
}

/* Ensure the hidden attribute always wins over display:block */
.filter-toggle-btn[hidden] {
  display: none;
}

.filter-btn {
  padding: 0.4rem 1rem;
  border: 2px solid var(--primary-outline-color);
  border-radius: 20px;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  color: #555;
  transition: background-color 0.2s, color 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
  background-color: #ad1417;
  color: var(--bg-color);
  border-color: #ad1417;
}

/* Sort dropdown */
.sort-dropdown {
  position: relative;
  margin-left: 0.25rem;
  z-index: 120;
}

.sort-dropdown-toggle {
  min-width: 170px;
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  border: 1px solid var(--primary-outline-color);
  border-radius: 20px;
  background: var(--bg-color);
  font-size: 0.9rem;
  color: #555;
  cursor: pointer;
  text-align: left;
  font-family: 'Noto Sans Symbols 2', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  position: relative;
  display: flex;
  align-items: center;
}

#sort-dropdown-text {
  transform: translateY(2px);
}

.sort-dropdown-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 10px;
  width: 14px;
  height: 14px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(-4px) translateY(-65%) rotate(45deg);
  transition: transform 0.2s;
}

.sort-dropdown-toggle[aria-expanded="true"]::after {
  transform: translateX(-4px) translateY(calc(-35% + 2px)) rotate(-135deg);
}

.sort-dropdown-toggle:hover,
.sort-dropdown-toggle:focus {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.sort-dropdown-toggle:focus {
  outline: none;
}

.sort-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 100%;
  background: var(--bg-color);
  border: 1px solid var(--primary-outline-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 0.25rem;
  z-index: 110;
}

.sort-dropdown-option {
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #555;
  cursor: pointer;
}

.sort-dropdown-option:hover,
.sort-dropdown-option:focus,
.sort-dropdown-option.is-selected {
  background: #f7efea;
  color: var(--primary-color);
  outline: none;
}

/* Time range slider */
.time-filter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.15rem 0;
  min-height: 32px;
}

.time-filter-label {
  font-size: 0.9rem;
  color: #555;
  white-space: nowrap;
  width: 6em;
}

.range-track-wrap {
  position: relative;
  width: 200px;
  min-width: 200px;
  height: 20px;
  cursor: default;
  flex: 0 0 200px;
}

.range-track-bg {
  position: absolute;
  top: 50%;
  left: 9px;
  right: 9px;
  height: 4px;
  background: #d5c9c0;
  border-radius: 2px;
  transform: translateY(-50%);
  z-index: 1;
}

.range-track-fill {
  position: absolute;
  top: 50%;
  left: 9px;
  width: calc(100% - 18px);
  height: 4px;
  background: var(--primary-color);
  border-radius: 2px;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
}

.range-thumb {
  position: absolute;
  left: 9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid var(--bg-color);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
  top: 50%;
  transform: translateY(-50%);
  cursor: grab;
  z-index: 3;
  touch-action: none;
}

#time-max-thumb {
  left: calc(100% - 9px);
}

.range-thumb:active {
  cursor: grabbing;
}

/* ===========================
   Stuck filter bar (inverted)
=========================== */
.category-filter {
  transition: background-color 0.25s, border-color 0.25s;
}

.category-filter.is-stuck {
  background-color: var(--primary-color);
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.category-filter.is-stuck .filter-btn,
.category-filter.is-stuck .sort-dropdown-toggle,
.category-filter.is-stuck .sort-dropdown-menu {
  background-color: var(--bg-color);
  color: var(--primary-color);
}

.category-filter.is-stuck .filter-btn:hover {
  background-color: var(--secondary-color);
  color: var(--bg-color);
  border-color: var(--bg-color);
}

.category-filter.is-stuck .filter-btn.active {
  background-color: var(--primary-color);
  color: var(--bg-color);
  border-color: var(--bg-color);
}

.category-filter.is-stuck .sort-dropdown-toggle,
.category-filter.is-stuck .sort-dropdown-menu {
  background-color: var(--bg-color);
  color: var(--primary-color);
  border-color: var(--bg-color);
}

.category-filter.is-stuck .sort-dropdown-toggle:hover,
.category-filter.is-stuck .sort-dropdown-toggle:focus {
  border-color: rgba(255, 255, 255, 0.8);
}

.category-filter.is-stuck .sort-dropdown-option:hover,
.category-filter.is-stuck .sort-dropdown-option:focus,
.category-filter.is-stuck .sort-dropdown-option.is-selected {
  background: rgba(173, 20, 23, 0.08);
}

.category-filter.is-stuck .range-track-fill {
  background: var(--bg-color);
}

.category-filter.is-stuck .time-filter-label {
  color: rgba(255, 255, 255, 0.85);
}

.category-filter.is-stuck .range-track-bg {
  background: rgba(255, 255, 255, 0.35);
}

.category-filter.is-stuck .range-thumb {
  border-color: var(--bg-color);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}

.category-filter.is-stuck .filter-toggle-btn {
  color: rgba(255, 255, 255, 0.75);
}

.category-filter.is-stuck .filter-toggle-btn:hover {
  color: var(--bg-color);
}

/* ===========================
   Main Content / Recipe Grid
=========================== */
.main-content {
  padding: 2.5rem 0;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
}

/* ===========================
   Recipe Card
=========================== */
.recipe-card {
  background-color: var(--bg-color);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  border: 2px solid #e8e0d8;
  position: relative;
  cursor: pointer;
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.12),
    0 8px 32px rgba(180, 120, 60, 0.13),
    0 2px 8px rgba(120, 80, 40, 0.08);
}

.card-img-placeholder {
  width: 100%;
  height: 180px;
  background-color: #e8e0d8;
}

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

.card-first14-marker {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  border: 2px solid var(--bg-color);
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--bg-color);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 2;
  pointer-events: none;
  transition: transform 0.2s;
}

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

.category-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-color);
  letter-spacing: 0.05em;
}

.recipe-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-color);
}

.recipe-description {
  font-size: 0.9rem;
  color: #666;
  flex: 1;
}

.card-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: #888;
  margin-top: 0.25rem;
}



/* ===========================
   Hidden (filtered out)
=========================== */
.recipe-card.hidden {
  display: none;
}

/* ===========================
   Loading / error states
=========================== */
.loading, .no-results, .error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 0;
  color: #888;
  font-size: 1rem;
}
.error { color: #ad1417; }

/* ===========================
   Back link
=========================== */
.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: #ad1417;
  font-size: 0.95rem;
  font-weight: 500;
}
.back-link:hover { text-decoration: underline; }

/* ===========================
   Recipe detail page
=========================== */
.recipe-detail { max-width: 800px; margin: 0 auto; }

.recipe-header {
  display: grid;
  grid-template-columns: 336px 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
  align-items: start;
}
@media (max-width: 680px) {
  .recipe-header { grid-template-columns: 1fr; }
}

.recipe-header-img {
  width: 100%;
  background-color: #e8e0d8;
  border-radius: 10px;
  overflow: hidden;
}

.recipe-header-img img {
  width: 100%;
  height: auto;
  display: block;
}

/* Carousel */
.recipe-header-img.carousel {
  position: relative;
  display: grid;
  overflow: hidden;
}

.carousel-slide {
  grid-area: 1 / 1;
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.45s ease;
  will-change: transform;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.4);
  color: var(--bg-color);
  border: none;
  font-size: 2rem;
  line-height: 1;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  z-index: 2;
  transition: background 0.2s;
}
.carousel-btn:hover { background: rgba(0, 0, 0, 0.65); }
.carousel-prev { left: 0.5rem; }
.carousel-next { right: 0.5rem; }

.carousel-dots {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  z-index: 2;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.2s;
}
.carousel-dot.active { background: var(--bg-color); }

.recipe-detail-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #222;
  margin-bottom: 0.5rem;
}
.recipe-detail-desc {
  color: #555;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}
.recipe-detail-meta {
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.tag {
  background-color: #f0e8e4;
  color: #ad1417;
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.recipe-section {
  margin-bottom: 2.5rem;
}

.recipe-body-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 2fr;
  gap: 0 3rem;
  align-items: start;
}
@media (max-width: 680px) {
  .recipe-body-grid { grid-template-columns: 1fr; }
}
.recipe-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #222;
  border-bottom: 2px solid #e8e0d8;
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}
.recipe-section h2 small {
  font-size: 0.85rem;
  font-weight: 400;
  color: #888;
  margin-left: 0.5rem;
}

.ingredient-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.4rem 1.5rem;
}
.ingredient-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0e8e4;
  font-size: 0.95rem;
  color: #333;
}
.ingredient-amount {
  font-weight: 600;
  color: #ad1417;
  margin-right: 0.25rem;
}

.step-list {
  counter-reset: step;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.step-list li {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.step-list li::before {
  counter-increment: step;
  content: counter(step);
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  background-color: var(--primary-color);
  color: var(--bg-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  margin-top: 0.1rem;
}
.step-list li p { margin: 0; line-height: 1.65; color: #333; }

.recipe-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.nutrition-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 0.5rem;
  margin-top: 0;
}

.nutrition-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: max-content;
  text-align: center;
  padding: 0.4rem 0.25rem;
  background: #f9f4f1;
  border-radius: 8px;
}

.nutrition-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  margin-bottom: 0.15rem;
}

.meta-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 0.1rem;
}

.nutrition-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.nutrition-val {
  font-size: 0.88rem;
  color: #222;
  font-weight: 600;
  margin-top: 0.1rem;
}

/* ===========================
   Footer
=========================== */
.site-footer {
  background-color: #2c2c2c;
  color: #aaa;
  text-align: center;
  padding: 1.5rem 0;
  font-size: 0.9rem;
  margin-top: auto;
  /*margin-top: 3rem;*/
}

/* ===========================
   Responsive
=========================== */
@media (max-width: 600px) {
  .site-header .container {
    flex-direction: column;
    gap: 0.75rem;
  }

  .search-bar input {
    width: 100%;
  }
}
