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

:root {
  --clr-bg: #f5ede0;
  --clr-surface: #faf6ef;
  --clr-primary: #8b2500;
  --clr-primary-hover: #6e1d00;
  --clr-accent: #c8a96e;
  --clr-text: #3b2f2f;
  --clr-text-muted: #7a6a5e;
  --clr-border: #d4c4a8;
  --clr-border-dark: #b8a88c;
  --clr-tag-bg: #eddfc6;
  --clr-tag-text: #6b4226;
  --radius: 4px;
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.08);
  --shadow-md: 0 3px 12px rgba(60, 40, 20, 0.1);
  --shadow-lg: 0 6px 24px rgba(60, 40, 20, 0.12);
  --font-body: "Lora", "Georgia", serif;
  --font-display: "Playfair Display", "Georgia", serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--clr-bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(200, 169, 110, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 37, 0, 0.04) 0%, transparent 50%);
  color: var(--clr-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 4rem;
}

/* ── Views ────────────────────────────────────────────────────────── */
.view {
  display: none;
  width: 100%;
  max-width: 700px;
  animation: fadeUp 0.4s ease;
}

.view.active {
  display: block;
}

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

/* ── Hero ─────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 2.2rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--clr-primary);
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.hero-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 0.7rem 0;
}

.hero-rule::before,
.hero-rule::after {
  content: "";
  flex: 1;
  max-width: 120px;
  height: 1px;
  background: var(--clr-border-dark);
}

.rule-ornament {
  color: var(--clr-accent);
  font-size: 1rem;
}

.hero p {
  margin-top: 0.3rem;
  color: var(--clr-text-muted);
  font-size: 1.05rem;
  font-style: italic;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  position: relative;
}

/* ── Form ─────────────────────────────────────────────────────────── */
.form-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.field label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--clr-text);
  letter-spacing: 0.3px;
}

.range-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.range-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--clr-primary);
  height: 6px;
}

.range-wrap output {
  min-width: 60px;
  text-align: right;
  font-weight: 700;
  color: var(--clr-primary);
  font-size: 1rem;
}

/* ── Cuisine Picker ───────────────────────────────────────────────── */
.cuisine-picker {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-bg);
  padding: 0.7rem 1rem;
}

.cuisine-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.1rem;
}

.crumb {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-primary);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius);
  transition: background 0.15s;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.crumb:hover {
  background: var(--clr-tag-bg);
}

.crumb.active {
  font-weight: 700;
  background: var(--clr-primary);
  color: #faf6ef;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  cursor: default;
  text-decoration: none;
}

.crumb.active:hover {
  background: var(--clr-primary);
}

.crumb-sep {
  color: var(--clr-text-muted);
  font-size: 0.8rem;
  opacity: 0.5;
}

.cuisine-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.cuisine-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--clr-border-dark);
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--clr-surface);
  color: var(--clr-text);
}

.cuisine-pill:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  background: var(--clr-tag-bg);
}

.cuisine-hint {
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  margin-top: 0.45rem;
  font-style: italic;
}

.cuisine-hint strong {
  color: var(--clr-primary);
  font-weight: 700;
  font-style: normal;
}

.cuisine-hint.final strong {
  font-size: 0.9rem;
}

/* ── Selected Summary ─────────────────────────────────────────────── */
.selected-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
  min-height: 28px;
}

.summary-empty {
  color: var(--clr-text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--clr-tag-bg);
  color: var(--clr-tag-text);
  padding: 0.22rem 0.55rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--clr-border);
}

.tag button {
  background: none;
  border: none;
  color: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
}

.tag button:hover {
  opacity: 1;
}

/* ── Category Panels ──────────────────────────────────────────────── */
.categories {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--clr-bg);
}

.cat-panel + .cat-panel {
  border-top: 1px solid var(--clr-border);
}

.cat-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--clr-text);
  text-align: left;
  transition: background 0.15s;
}

.cat-header:hover {
  background: rgba(139, 37, 0, 0.04);
}

.cat-label {
  flex: 1;
}

.cat-count {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--clr-border);
  color: var(--clr-text-muted);
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  min-width: 22px;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}

.cat-count.has-items {
  background: var(--clr-primary);
  color: #fff;
}

.cat-chevron {
  font-size: 0.7rem;
  color: var(--clr-text-muted);
  transition: transform 0.2s;
}

.cat-panel.open .cat-chevron {
  transform: rotate(180deg);
}

.cat-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 1rem;
}

.cat-panel.open .cat-body {
  max-height: 600px;
  padding: 0.6rem 1rem 1rem;
}

/* ── Pill Grid ────────────────────────────────────────────────────── */
.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--clr-border-dark);
  border-radius: 3px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--clr-surface);
  color: var(--clr-text);
  user-select: none;
}

.pill input[type="checkbox"] {
  display: none;
}

.pill:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

.pill.active {
  background: var(--clr-primary);
  color: #faf6ef;
  border-color: var(--clr-primary);
}

/* ── Custom Add Row ───────────────────────────────────────────────── */
.custom-add {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.custom-input {
  flex: 1;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--clr-surface);
  color: var(--clr-text);
  outline: none;
}

.custom-input:focus {
  border-color: var(--clr-primary);
}

.btn-add {
  width: 32px;
  height: 32px;
  border: 1px solid var(--clr-primary);
  border-radius: var(--radius);
  background: transparent;
  color: var(--clr-primary);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}

.btn-add:hover {
  background: var(--clr-primary);
  color: #faf6ef;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1rem;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.btn.primary {
  background: var(--clr-primary);
  color: #faf6ef;
  padding: 0.8rem 1.8rem;
  font-weight: 600;
  font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--clr-primary-hover);
}

.btn.primary:hover {
  background: var(--clr-primary-hover);
  box-shadow: var(--shadow-md);
}

.btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: var(--clr-primary);
  padding: 0.5rem 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  font-family: var(--font-body);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.btn.ghost:hover {
  background: var(--clr-tag-bg);
  text-decoration-style: solid;
}

/* ── Suggestions Grid ─────────────────────────────────────────────── */
.suggestions {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.suggestion-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.suggestion-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  background-color: var(--clr-border);
}

.suggestion-text {
  padding: 1.2rem 1.4rem;
}

.suggestion-card h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
  color: var(--clr-primary);
}

.suggestion-card p {
  color: var(--clr-text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* ── Shimmer placeholder ─────────────────────────────────────────── */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(250, 246, 239, 0.45) 50%,
    transparent 100%
  );
  animation: shimmerSlide 1.6s ease-in-out infinite;
}

@keyframes shimmerSlide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ── Recipe Detail ────────────────────────────────────────────────── */
.recipe-detail {
  overflow: hidden;
  padding: 0;
}

.recipe-image-wrap {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--clr-border);
  overflow: hidden;
  position: relative;
}

.recipe-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: opacity 0.4s ease;
}

.recipe-image.loading::after {
  content: "Generating image\2026";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--clr-text-muted);
  font-size: 0.95rem;
  font-style: italic;
  background: var(--clr-border);
}

.recipe-body {
  padding: 2rem;
}

.recipe-body h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
  color: var(--clr-primary);
}

.recipe-meta {
  display: flex;
  gap: 1.2rem;
  color: var(--clr-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--clr-border-dark);
}

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

.recipe-body h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 1.4rem 0 0.6rem;
  color: var(--clr-primary);
  letter-spacing: 0.3px;
}

.recipe-body ul,
.recipe-body ol {
  padding-left: 1.3rem;
  line-height: 1.75;
}

.recipe-body li {
  margin-bottom: 0.35rem;
}

.recipe-body li::marker {
  color: var(--clr-accent);
}

/* ── Loader Overlay ───────────────────────────────────────────────── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 237, 224, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.25s ease;
}

.loader-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--clr-border-dark);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-overlay p {
  margin-top: 1rem;
  color: var(--clr-text-muted);
  font-size: 1rem;
  font-style: italic;
}

/* ── Error Toast ──────────────────────────────────────────────────── */
.error-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #8b2500;
  color: #faf6ef;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ── Footer ───────────────────────────────────────────────────────── */
.site-footer {
  margin-top: 3rem;
  padding: 1.2rem 0 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  border-top: 1px solid var(--clr-border);
  width: 100%;
  max-width: 700px;
}

/* ── Touch-friendly range slider ─────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--clr-border);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--clr-primary);
  border: 2px solid var(--clr-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--clr-primary);
  border: 2px solid var(--clr-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* ── Responsive ───────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 680px) {
  body {
    padding: 2rem 0.75rem 3rem;
  }

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

  .hero p {
    font-size: 0.95rem;
    max-width: 360px;
  }

  .card {
    padding: 1.5rem;
  }

  .suggestion-text {
    padding: 1rem 1.2rem;
  }

  .recipe-body {
    padding: 1.5rem;
  }

  .recipe-body h2 {
    font-size: 1.5rem;
  }
}

/* Phone */
@media (max-width: 480px) {
  body {
    padding: 1.5rem 0.6rem 2.5rem;
  }

  .hero {
    margin-bottom: 1.5rem;
  }

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

  .hero p {
    font-size: 0.9rem;
    max-width: 300px;
  }

  .hero-rule::before,
  .hero-rule::after {
    max-width: 70px;
  }

  .card {
    padding: 1.1rem;
  }

  .form-card {
    gap: 1.2rem;
  }

  .field label {
    font-size: 0.9rem;
  }

  /* Larger touch targets for pills */
  .pill {
    padding: 0.4rem 0.7rem;
    font-size: 0.82rem;
    min-height: 36px;
  }

  .cuisine-pill {
    padding: 0.4rem 0.7rem;
    font-size: 0.82rem;
    min-height: 36px;
  }

  .crumb {
    padding: 0.25rem 0.45rem;
    font-size: 0.82rem;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  .crumb.active {
    padding: 0.25rem 0.6rem;
  }

  .tag {
    font-size: 0.78rem;
    padding: 0.25rem 0.5rem;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
  }

  .tag button {
    min-width: 20px;
    min-height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Category accordion */
  .cat-header {
    padding: 0.8rem 0.9rem;
    min-height: 48px;
  }

  .cat-panel.open .cat-body {
    padding: 0.5rem 0.9rem 0.9rem;
  }

  /* Custom input */
  .custom-input {
    font-size: 1rem;
    padding: 0.4rem 0.6rem;
    min-height: 40px;
  }

  .btn-add {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
  }

  /* Buttons */
  .btn.primary {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    text-align: center;
  }

  .btn.ghost {
    padding: 0.6rem 0.6rem;
  }

  /* Suggestions */
  .suggestion-img {
    aspect-ratio: 16 / 10;
  }

  .suggestion-text {
    padding: 0.9rem 1rem;
  }

  .suggestion-card h3 {
    font-size: 1.1rem;
  }

  .suggestion-card p {
    font-size: 0.88rem;
  }

  /* Recipe detail */
  .recipe-image-wrap {
    aspect-ratio: 4 / 3;
  }

  .recipe-body {
    padding: 1.1rem;
  }

  .recipe-body h2 {
    font-size: 1.4rem;
  }

  .recipe-body h3 {
    font-size: 1rem;
  }

  .recipe-meta {
    gap: 0.8rem;
    font-size: 0.85rem;
  }

  /* Footer */
  .site-footer {
    margin-top: 2rem;
    font-size: 0.75rem;
  }
}

/* Small phone */
@media (max-width: 360px) {
  .hero h1 {
    font-size: 1.7rem;
  }

  .pill {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
  }

  .cuisine-pill {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
  }
}
