/* Resteküche – Design für index.html und app.js */
:root {
  --gruen: #385441;
  --gruen-dunkel: #263d30;
  --gruen-hell: #edf2e9;
  --hintergrund: #f6f5f1;
  --weiss: #fffefa;
  --text: #252a25;
  --grau: #687168;
  --rand: #e3e5de;
  --radius: 12px;
  --schatten: 0 3px 16px rgba(35,45,34,.035);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.55 Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--hintergrund);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:where(button, input, select, .rezept-karte):focus-visible {
  outline: 2px solid var(--gruen);
  outline-offset: 3px;
}

/* Kopfbereich */
header {
  background: var(--gruen-dunkel);
  color: var(--weiss);
  border-bottom: 3px solid #a2ac86;
  padding: 33px max(24px, calc((100% - 1300px) / 2));
}
header h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 3vw, 40px);
  line-height: 1.2;
  letter-spacing: -.055em;
}
header p { max-width: 660px; margin: 3px 0; color: #e0e8dc; font-size: 14px; }
header p:last-child { opacity: .82; }

/* Zweispaltiges Layout: Zutaten und Filter links, Rezepte rechts */
main {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  /* Zwei kompakte Reihen links; lange Rezeptliste nutzt die dritte Reihe. */
  grid-template-rows: max-content max-content minmax(0, 1fr);
  align-items: start;
  gap: 20px 24px;
  max-width: 1340px;
  margin: 34px auto 70px;
  padding: 0 20px;
}
main > section {
  min-width: 0;
  padding: 25px;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--weiss);
  box-shadow: var(--schatten);
}
section h2 { margin: 0 0 17px; font-size: 21px; line-height: 1.3; letter-spacing: -.035em; }
section h3 { margin: 25px 0 12px; font-size: 15px; }
#zutaten-bereich { grid-column: 1; grid-row: 1; }
#filter-bereich { grid-column: 1; grid-row: 2; }
#rezepte-bereich { grid-column: 2; grid-row: 1 / span 3; min-height: 400px; }

/* Zutatenformular */
#zutaten-bereich > p { margin: 0 0 21px; color: var(--grau); font-size: 13px; }
#zutaten-formular { display: flex; flex-direction: column; gap: 9px; }
#zutaten-formular label, #filter-formular > label { font-size: 13px; font-weight: 600; }
#zutat-eingabe, #filter-formular select, #portionen-eingabe {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #d7ddd4;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
#zutat-eingabe::placeholder { color: #919991; }
#zutat-eingabe:focus, #filter-formular select:focus, #portionen-eingabe:focus { border-color: var(--gruen); }
#zutaten-formular button {
  padding: 11px 15px;
  border: 1px solid var(--gruen);
  border-radius: 8px;
  background: var(--gruen);
  color: #fff;
  font-weight: 600;
  transition: background-color .15s ease;
}
#zutaten-formular button:hover { background: var(--gruen-dunkel); }
#zutaten-formular button:disabled { opacity: .55; cursor: not-allowed; }

/* Suchvorschläge – werden durch app.js als Listeneinträge mit Buttons erzeugt */
#zutaten-vorschlaege {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
}
#zutaten-vorschlaege:empty { display: none; }
#zutaten-vorschlaege button {
  padding: 6px 10px;
  border: 1px solid #dae3d5;
  border-radius: 7px;
  background: #f4f7f1;
  color: var(--gruen-dunkel);
  font-size: 12px;
  text-align: left;
}
#zutaten-vorschlaege button:hover { border-color: #a9bea2; background: var(--gruen-hell); }

/* Vorhandene Zutaten */
#zutaten-bereich h3 { margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--rand); }
#ausgewaehlte-zutaten { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
#ausgewaehlte-zutaten li {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 4px;
  padding: 6px 9px;
  border: 1px solid #d9e4d4;
  border-radius: 7px;
  background: var(--gruen-hell);
  color: var(--gruen-dunkel);
  font-size: 13px;
  overflow-wrap: anywhere;
}
/* Das erste Listenelement ist bei leerer Auswahl nur ein Hinweistext. */
#ausgewaehlte-zutaten li:only-child:not(:has(button)) {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--grau);
  font-size: 13px;
}
#ausgewaehlte-zutaten .zutat-entfernen {
  padding: 0 3px;
  margin-left: 3px;
  border: 0;
  background: transparent;
  color: #5d7560;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}
#ausgewaehlte-zutaten .zutat-entfernen:hover { color: #a44438; }
#zutaten-loeschen {
  width: 100%;
  margin-top: 21px;
  padding: 10px 12px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: transparent;
  color: #5b645b;
  font-size: 13px;
}
#zutaten-loeschen:hover { background: #f4f5f0; border-color: #c7d0c4; }

/* Filter */
#filter-formular { display: flex; flex-direction: column; gap: 12px; }
#filter-formular fieldset { min-width: 0; margin: 0 0 9px; padding: 0 0 18px; border: 0; border-bottom: 1px solid var(--rand); }
#filter-formular legend { padding: 0; margin-bottom: 10px; font-weight: 700; font-size: 13px; }
#filter-formular fieldset label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  color: #495249;
  font-size: 13px;
  cursor: pointer;
}
#filter-formular input[type="radio"] { flex: 0 0 auto; width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--gruen); cursor: pointer; }
#filter-formular > label { margin-top: 3px; }
#filter-formular select { cursor: pointer; }
#filter-formular select:hover { border-color: #aebcab; }

/* Rezeptübersicht – Karten aus app.js haben aktuell KEIN Bild */
#rezept-anzahl { margin: -4px 0 20px; color: var(--grau); font-size: 13px; }
#rezept-liste {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
  gap: 15px;
}
.rezept-karte {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  padding: 19px 20px 17px;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.rezept-karte:hover, .rezept-karte:focus-visible {
  border-color: #adc1a8;
  box-shadow: 0 7px 20px rgba(38,61,48,.07);
  transform: translateY(-1px);
}
.rezept-karte h3 { margin: 0 0 9px; font-size: 17px; line-height: 1.35; letter-spacing: -.02em; }
.rezept-karte p { margin: 0 0 9px; font-size: 13px; color: var(--grau); overflow-wrap: anywhere; }
.rezept-karte p:nth-of-type(2) { color: #3e5240; font-weight: 600; }
/* app.js erzeugt den Rezeptstatus als <p class="match"> oder <p class="match-teilweise"> */
.rezept-karte p.match, .rezept-karte p.match-teilweise {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: auto 0 0;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.rezept-karte .match { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.rezept-karte .match-teilweise { background: #f8f1e4; color: #806329; }
#keine-rezepte { padding: 25px; border: 1px dashed #d6dcd2; border-radius: 8px; background: #f8f8f4; color: var(--grau); text-align: center; font-size: 14px; }

/* Detailansicht: app.js blendet die anderen Bereiche aus.
   Daher erhält das Detail die ganze Breite statt leerer linker Spalte. */
main:has(#rezept-details:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
#rezept-details { grid-column: 1 / -1; grid-row: 1; max-width: 940px; width: 100%; margin-inline: auto; }
#zurueck-button {
  padding: 9px 13px;
  margin-bottom: 23px;
  border: 1px solid #d7e4d1;
  border-radius: 7px;
  background: var(--gruen-hell);
  color: var(--gruen-dunkel);
  font-size: 13px;
}
#zurueck-button:hover { background: #dfe9d8; }
#rezept-titel { margin: 0 0 12px; font-size: clamp(25px,3vw,33px); letter-spacing: -.04em; line-height: 1.24; }
#rezept-zeit { margin: 0 0 22px; color: var(--grau); font-size: 14px; }
#rezept-bild { display: block; width: 100%; max-height: 340px; margin: 16px 0 20px; object-fit: cover; border-radius: 9px; }
#portionen-steuerung {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 390px;
  padding: 15px 17px;
  border: 1px solid var(--rand);
  border-radius: 9px;
  background: #f8f9f5;
}
#portionen-steuerung label { font-size: 14px; font-weight: 600; }
#portionen-eingabe { width: 94px; padding: 8px 10px; text-align: center; }
#rezept-details h3 { margin: 30px 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--rand); font-size: 17px; }
#rezept-zutaten { margin: 0; padding-left: 20px; }
#rezept-zutaten li { padding: 6px 0; font-size: 14px; }
#rezept-anleitung { margin: 0; padding-left: 25px; }
#rezept-anleitung li { padding: 8px 0; line-height: 1.65; font-size: 14px; }
#rezept-anleitung li::marker { color: var(--gruen); font-weight: 700; }
#rezept-video { width: 100%; max-width: 100%; margin-top: 24px; border-radius: 9px; }

/* Fehleransicht */
main:has(#fehler-bereich:not([hidden])) { grid-template-columns: minmax(0,1fr); }
#fehler-bereich { grid-column: 1 / -1; grid-row: 1; background: #fff9f6; border-color: #e8cac2; }
#fehler-bereich h2 { color: #9b4637; }
#fehler-text { color: #714f49; }
#erneut-laden { padding: 10px 15px; border: 0; border-radius: 7px; background: #9b4637; color: #fff; font-weight: 600; }
#erneut-laden:hover { background: #813a2e; }

/* Fußbereich */
footer { padding: 30px 20px; border-top: 1px solid var(--rand); background: #f0f0eb; color: var(--grau); font-size: 12px; text-align: center; }
footer p { margin: 4px 0; }

/* Mittlere Displays */
@media (max-width: 1000px) {
  main { grid-template-columns: minmax(250px, 300px) minmax(0,1fr); gap: 18px; }
  main > section { padding: 22px; }
  #rezept-liste { grid-template-columns: 1fr; }
}

/* Mobile Ansicht */
@media (max-width: 760px) {
  header { padding: 28px 20px; }
  header h1 { font-size: 31px; }
  main { grid-template-columns: minmax(0,1fr); gap: 16px; margin-top: 20px; padding: 0 14px; }
  #zutaten-bereich, #filter-bereich, #rezepte-bereich, #rezept-details:not([hidden]), #fehler-bereich {
    grid-column: 1;
    grid-row: auto;
  }
  #rezepte-bereich { min-height: 240px; }
  #rezept-liste { grid-template-columns: repeat(auto-fit, minmax(min(100%,260px),1fr)); }
  main > section { padding: 20px; }
  #rezept-bild { max-height: 240px; }
}
@media (max-width: 420px) {
  header h1 { font-size: 28px; }
  section h2 { font-size: 19px; }
  #rezept-liste { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
