/* =========================================================
   Nadines Kochbuch – Stylesheet
   Mobile-first, responsive, mit Farbwelt aus dem Logo.
   ========================================================= */

:root {
  /* Markenfarben (abgeleitet aus dem Logo) */
  --color-primary: #E8542B;        /* warmes Koralle-Orange */
  --color-primary-dark: #C8401B;
  --color-accent: #6BA536;         /* frisches Grün */
  --color-accent-dark: #538029;

  --color-bg: #FBF7EF;             /* cremeweiß */
  --color-surface: #FFFFFF;
  --color-surface-alt: #F4EEE2;

  --color-text: #2C2A26;
  --color-text-muted: #6E6A61;
  --color-border: #E7E0D2;

  --color-favorite: #E8542B;

  /* Tag-Farben */
  --tag-bg: #EFEAE0;
  --tag-text: #5A554B;

  --shadow-sm: 0 1px 3px rgba(44, 42, 38, 0.08);
  --shadow-md: 0 4px 16px rgba(44, 42, 38, 0.12);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --header-height: 132px;
  --bottom-nav-height: 64px;

  --max-width: 1100px;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  /* Platz für fixierten Header oben und Navigation unten */
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
}

img { max-width: 100%; display: block; }

button { font-family: inherit; cursor: pointer; }

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.4em; }

/* ---------------------------------------------------------
   Kopfbereich
   --------------------------------------------------------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: env(safe-area-inset-top, 0px) 16px 12px;
}

.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-top: 8px;
}

.app-header__logo { height: 56px; width: auto; }

.app-header__install {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.85rem;
}

.app-header__update {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  line-height: 1;
  opacity: 0.7;
}
.app-header__update:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.app-header__update:disabled { opacity: 0.4; cursor: not-allowed; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--max-width);
  margin: 10px auto 0;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 10px 16px;
}

.search-bar__icon { font-size: 1rem; opacity: 0.7; }

.search-bar__input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  outline: none;
  color: var(--color-text);
}

/* ---------------------------------------------------------
   Hauptbereich
   --------------------------------------------------------- */
.app-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  outline: none;
}

.section-title {
  font-size: 1.25rem;
  margin: 4px 0 12px;
}

.section-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: -6px 0 16px;
}

/* ---------------------------------------------------------
   Rezeptkarten-Raster
   --------------------------------------------------------- */
.recipe-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 560px) {
  .recipe-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .recipe-grid { grid-template-columns: repeat(3, 1fr); }
}

.recipe-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.recipe-card:active { transform: scale(0.99); }
@media (hover: hover) {
  .recipe-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
}

.recipe-card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--color-surface-alt);
}

.recipe-card__media img { width: 100%; height: 100%; object-fit: cover; }

.recipe-card__fav {
  position: absolute;
  top: 10px; right: 10px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-sm);
  line-height: 1;
}
.recipe-card__fav[aria-pressed="true"] { color: var(--color-favorite); }

.recipe-card__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.recipe-card__title { font-size: 1.05rem; margin: 0; }

.recipe-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}
.recipe-card__meta span { display: inline-flex; align-items: center; gap: 4px; }

.protein-pill {
  align-self: flex-start;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------------------------------------------------------
   Tags / Chips
   --------------------------------------------------------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------------------------------------------------------
   Filter-Chips
   --------------------------------------------------------- */
.filter-group { margin-bottom: 18px; }
.filter-group__label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

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

.chip {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.chip[aria-pressed="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.filter-summary__count { font-weight: 700; }

.btn-text {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 6px;
}

/* Kompakte Filterleiste auf der Startseite */
.quick-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.quick-filter::-webkit-scrollbar { display: none; }
.quick-filter .chip { flex: 0 0 auto; }

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  width: 100%;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:active { background: var(--color-primary-dark); }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border: 1.5px solid var(--color-border); }
.btn--accent { background: var(--color-accent); color: #fff; }
.btn--accent:active { background: var(--color-accent-dark); }
.btn[aria-pressed="true"].btn--fav { background: var(--color-favorite); color: #fff; }

.icon-btn {
  background: none;
  border: none;
  font-size: 1rem;
  padding: 8px;
}

/* ---------------------------------------------------------
   Rezept-Detailseite
   --------------------------------------------------------- */
.detail__hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 11;
  background: var(--color-surface-alt);
  margin-bottom: 16px;
}
.detail__hero img { width: 100%; height: 100%; object-fit: cover; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.detail__title { font-size: 1.5rem; }

.detail__facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0;
}
@media (min-width: 560px) { .detail__facts { grid-template-columns: repeat(4, 1fr); } }

.fact {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.fact__value { font-weight: 800; font-size: 1.05rem; display: block; }
.fact__label { font-size: 0.75rem; color: var(--color-text-muted); }

.card-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.servings-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.servings-control__btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-size: 1.3rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.servings-control__value { font-weight: 700; min-width: 90px; text-align: center; }

.ingredient-list, .step-list, .tip-list { margin: 0; padding: 0; list-style: none; }

.ingredient-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.ingredient-list li:last-child { border-bottom: none; }
.ingredient-list .amount { font-weight: 700; color: var(--color-primary); white-space: nowrap; }

.step-list { counter-reset: step; display: flex; flex-direction: column; gap: 14px; }
.step-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.step-list li::before {
  counter-increment: step;
  content: counter(step);
  flex: 0 0 auto;
  width: 28px; height: 28px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.tip-block {
  background: #F0F6E9;
  border: 1px solid #D4E6BF;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.tip-block__title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-accent-dark);
  font-size: 1.05rem;
}
.tip-list li { padding: 6px 0 6px 22px; position: relative; }
.tip-list li::before { content: "🌱"; position: absolute; left: 0; }

.detail__actions {
  position: sticky;
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
  display: flex;
  gap: 10px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: 0 -2px 12px rgba(44, 42, 38, 0.06);
}
.detail__actions .btn { width: auto; flex: 1; }
.detail__actions .btn--share { flex: 0 0 auto; font-size: 1.2rem; }

.disclaimer {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 18px 8px 4px;
}

/* ---------------------------------------------------------
   Einkaufsliste
   --------------------------------------------------------- */
.shopping-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--color-border);
}
.shopping-item:last-child { border-bottom: none; }
.shopping-item__check {
  width: 26px; height: 26px;
  flex: 0 0 auto;
  accent-color: var(--color-accent);
}
.shopping-item__name { flex: 1; }
.shopping-item--done .shopping-item__name { text-decoration: line-through; color: var(--color-text-muted); }
.shopping-item__amount { font-weight: 700; color: var(--color-primary); white-space: nowrap; }
.shopping-item__remove { color: var(--color-text-muted); font-size: 1.1rem; }

.list-toolbar {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.list-toolbar .btn { width: auto; flex: 1; }

/* ---------------------------------------------------------
   Leerer Zustand
   --------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-muted);
}
.empty-state__emoji { font-size: 3rem; margin-bottom: 8px; }
.empty-state__title { color: var(--color-text); font-size: 1.2rem; margin-bottom: 6px; }

/* ---------------------------------------------------------
   Bottom-Navigation
   --------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}

.bottom-nav__item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 6px 0;
}
.bottom-nav__icon { font-size: 1.35rem; line-height: 1; filter: grayscale(0.3); }
.bottom-nav__item.is-active { color: var(--color-primary); }
.bottom-nav__item.is-active .bottom-nav__icon { filter: none; transform: translateY(-1px); }

.bottom-nav__badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  background: var(--color-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

/* Am Desktop: Navigation an die linke Seite */
@media (min-width: 1024px) {
  body { padding-left: 96px; }
  .bottom-nav {
    top: var(--header-height);
    bottom: 0;
    right: auto;
    width: 96px;
    height: auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 16px;
    border-top: none;
    border-right: 1px solid var(--color-border);
  }
  .bottom-nav__item { flex: 0 0 auto; padding: 12px 0; }
  .bottom-nav__badge { top: 6px; right: 22px; }
}

/* ---------------------------------------------------------
   Toast
   --------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-height) + 20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------------------------------------------------------
   Hilfsklassen
   --------------------------------------------------------- */
.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;
}
.fade-in { animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------------------------------------------------------
   Button-Varianten / Startseiten-Einstieg
   --------------------------------------------------------- */
.home-add-btn { margin-bottom: 14px; }
.btn--small { width: auto; padding: 8px 14px; font-size: 0.9rem; align-self: flex-start; }
.btn--danger { color: var(--color-primary-dark); border-color: #e3c4bd; margin-top: 8px; }
.cook-start-btn { margin-bottom: 14px; }

/* ---------------------------------------------------------
   Rezept-Formular (eigene Rezepte anlegen)
   --------------------------------------------------------- */
.recipe-form { display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field__label, .form-label { font-weight: 600; font-size: 0.9rem; }
.form-label { margin-top: 4px; }

.form-input {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}
.form-input:focus { outline: none; border-color: var(--color-primary); }
textarea.form-input { resize: vertical; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(3, 1fr); } }

.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checkbox-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px; font-size: 0.9rem;
}
.checkbox-item input { width: 20px; height: 20px; accent-color: var(--color-primary); flex: 0 0 auto; }

.ingredient-rows { display: flex; flex-direction: column; gap: 8px; }
.ingredient-row { display: grid; grid-template-columns: 68px 80px 1fr auto; gap: 8px; align-items: center; }
.ingredient-row .form-input { padding: 10px; }

.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions .btn { flex: 1; width: auto; }

.form-error {
  color: var(--color-primary-dark);
  font-weight: 600;
  background: #FBEAE6;
  border: 1px solid #E3C4BD;
  border-radius: var(--radius-sm);
  padding: 10px;
}

/* ---------------------------------------------------------
   Wochenplaner
   --------------------------------------------------------- */
.plan-day {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.plan-day__head { display: flex; align-items: center; justify-content: space-between; }
.plan-day__name { font-weight: 700; }
.plan-day__empty { color: var(--color-text-muted); font-size: 0.9rem; margin: 6px 0 0; }
.plan-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.plan-item__link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.plan-item__link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-item__thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }

/* ---------------------------------------------------------
   Rezept-Auswahl (Overlay / Bottom-Sheet)
   --------------------------------------------------------- */
.picker-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 720px) { .picker-overlay { align-items: center; } }
.picker {
  background: var(--color-bg);
  width: 100%; max-width: 560px; max-height: 80vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
@media (min-width: 720px) { .picker { border-radius: var(--radius-lg); } }
.picker__title { font-weight: 700; font-size: 1.1rem; }
.picker__list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.picker__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; text-align: left; font-size: 0.95rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------
   Einkaufsliste – Kategorie-Überschriften
   --------------------------------------------------------- */
.shopping-group__title {
  font-weight: 700; font-size: 0.95rem;
  padding: 2px 0 8px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 4px;
}

/* ---------------------------------------------------------
   Kochmodus (Vollbild)
   --------------------------------------------------------- */
.cook-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--color-bg);
  overflow-y: auto;
}
.cook {
  max-width: 700px; margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.cook__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cook__title { font-weight: 700; font-size: 1.05rem; }
.cook__close { background: none; border: none; font-size: 1.4rem; padding: 8px; line-height: 1; }

.cook__ingredients {
  margin: 12px 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
}
.cook__ingredients summary { font-weight: 600; cursor: pointer; padding: 6px 0; }
.cook__ing-list { list-style: none; margin: 0; padding: 0; }
.cook__ing-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.cook__ing-list li:last-child { border-bottom: none; }
.cook__ing-list label { display: flex; align-items: center; gap: 10px; }
.cook__ing-list input { width: 22px; height: 22px; accent-color: var(--color-accent); }
.cook__ing-list .amount { font-weight: 700; color: var(--color-primary); white-space: nowrap; }

.cook__progress { height: 6px; background: var(--color-surface-alt); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.cook__progress-bar { display: block; height: 100%; width: 0; background: var(--color-accent); transition: width 0.25s ease; }
.cook__counter { color: var(--color-text-muted); font-weight: 600; margin: 4px 0; }
.cook__step { flex: 1; font-size: 1.5rem; line-height: 1.45; padding: 12px 0 20px; }

.cook__timer {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px; text-align: center; margin-bottom: 16px;
}
.cook__timer-display { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cook__timer-actions { display: flex; gap: 10px; margin-top: 10px; }
.cook__timer-actions .btn { flex: 1; width: auto; }

.cook__nav {
  display: flex; gap: 10px;
  position: sticky; bottom: 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--color-bg);
}
.cook__nav .btn { flex: 1; width: auto; }
