/* =========================================================
   ROOT VARIABLEN
   ========================================================= */

:root {
  --green: #2e7d32;
  --green-light: #66bb6a;
  --green-soft: #e8f5e9;

  --gray-bg: #f3f4f6;
  --gray-border: #e0e0e0;
  --gray-text: #666;

  --text: #222;
  --card-radius: 16px;
}

/* =========================================================
   GLOBAL RESET
   ========================================================= */

* {
  box-sizing: border-box;
}

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

body {
  background: var(--gray-bg);
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text);
  line-height: 1.5;
}

input,
textarea,
select {
  font-size: 16px;
}

/* =========================================================
   APP CONTAINER
   ========================================================= */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* -------------------------
   Login Seite
--------------------------*/

.loginContainer{
  max-width:420px;
  margin:140px auto;
  padding:30px;
  text-align:center;
}

.loginLogo{
  width:180px;
  margin-bottom:35px;
}

.loginField{
  position: relative;
}

.loginInput{
  width:100%;
  padding:14px 16px;
  border-radius:12px;
  border:1px solid var(--gray-border);
  font-size:20px;
}

.breadBurst{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  font-size:22px;
  pointer-events:none;
  opacity:0;
}

.breadBurst.show{
  animation: breadPop 0.6s ease forwards;
}

@keyframes breadPop{
  0%{
    transform:translate(-50%, -40%) scale(0.4);
    opacity:0;
  }
  40%{
    opacity:1;
  }
  100%{
    transform:translate(-50%, -120%) scale(1.2);
    opacity:0;
  }
}

.loginButton{
  margin-top:18px;
  padding:12px 20px;
  font-size:16px;
  border-radius:10px;
  border:1px solid var(--green-light);
  background: var(--green-soft);
  color:var(--green);
  cursor:pointer;
}

.loginButton:hover{
  opacity:0.9;
}

.loginError{
  margin-bottom:18px;
  color:#c33;
  font-size:14px;
}

/* =========================================================
   OVERLAY
   ========================================================= */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.overlayContent {
  background: white;
  width: 90%;
  max-width: 700px;
  max-height: 80%;
  overflow: auto;
  padding: 20px;
  border-radius: 10px;
}

.hidden {
  display: none;
}

#closeOverlay {
  float: right;
}

/* =========================================================
   HEADER
   ========================================================= */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  border-bottom: 1px solid var(--gray-border);

  display: flex;
  justify-content: center; /* Header-Inhalt zentrieren */
}

.header-inner {
  width: 100%;
  max-width: 820px;
  padding: 4px 20px;
  display: flex;
  align-items: center;
  justify-content: center; 
  gap: 14px;
  flex-wrap: nowrap;
}

.app-logo {
  height: 70px;
  width: auto;
  display: block;
}

/* Rezeptanzahl */
.result-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  color: var(--gray-text);
  min-width: 42px;
}

.count-number {
  font-size: 20px;
  font-weight: 600;
}

.count-label {
  font-size: 10px;
  letter-spacing: 0.3px;
}

.result-count.bump {
  animation: countBump 0.35s ease;
}

@keyframes countBump {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.25); }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* Suchfeld */
#searchInput {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--gray-border);
  font-size: 16px;
  min-width: 120px;
}

.search-wrapper {
  position: relative;
  flex: 0 1 220px;   /* übernimmt dein flex-Verhalten */
}

.search-wrapper.disabled #searchInput {
  background-color: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.7;
}

.search-wrapper.disabled .search-clear {
  cursor: not-allowed;
  opacity: 0.5;
}

.search-wrapper input {
  width: 100%;
  padding-right: 28px;   /* Platz für das X */
}

.search-wrapper.active #searchInput {
  background-color: #fff9c4;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  display: none;
  color: var(--gray-text);
}

.search-wrapper.active .search-clear {
  display: block;
}

/* Buttons kompakt */
header button {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--gray-border);
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

header button:hover {
  background: var(--green-soft);
  border-color: var(--green);
}

@media (max-width: 600px) {

  .app-logo {
    height: 60px;
  }

  .search-wrapper {
    flex: 0 1 140px;
  }

  #searchInput {
    font-size: 16px; /* wichtig gegen iOS Zoom */
    padding: 6px 8px;
  }

  .header-inner {
    gap: 8px;
  }

}

/* =========================================================
   MAIN BEREICH
   ========================================================= */

main {
  flex: 1;
  padding: 20px 16px 40px 16px;
  position: relative;
}

/* =========================================================
   REZEPT-KARTE
   ========================================================= */

.card {
  max-width: 820px;
  margin: 0 auto;
  background: white;
  border-radius: var(--card-radius);
  padding: 24px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.05);
  transition: transform 0.22s ease, opacity 0.22s ease;
  transform-origin: center center;
}

.card.bump {
  transform: scale(1.015);
  transition: transform 0.18s ease;
}

/* =========================================================
   HERO-BEREICH
   ========================================================= */

.hero h1 {
  font-family: "DancingScript", cursive;
  font-size: 36px;
  margin: 0 0 2px 0;
  padding-right: 60px;
}

.hero .subline {
  font-family: "DancingScript", cursive;
  font-size: 20px;
  color: var(--gray-text);
  margin-top: -6px;   
  margin-bottom: 10px;
}

.hero-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 16px;
  display: block;
}

.hero .description {
  font-size: 15px;
  line-height: 1.5;
}

.hero {
  position: relative;
}

.favorite-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 36px;
  cursor: pointer;
  opacity: 0.35;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.favorite-btn:hover {
  opacity: 0.6;
}

.favorite-btn.active {
  opacity: 1;
  transform: scale(1.25);
}

@media (min-width: 900px) {

  .hero-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
  }

  .hero-image {
    width: 55%;
    max-height: 420px;
    object-fit: cover;
    margin-bottom: 0;
  }

  .hero .description {
    width: 45%;
    font-size: 16px;
  }
}

/* =========================================================
   ZUTATEN
   ========================================================= */

.ingredients-amount {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1rem;
}

.ingredients h2 {
  margin-bottom: 0.15rem;
}

.ingredients-base,
.ingredients-variant {
  list-style: none;      
  padding-left: 0;
  margin: 0;
}
.ingredients-variants {
  margin-top: 12px;
  padding-left: 0;
}

.ingredient-item {
  margin: 4px 0;
}

.ingredient-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ingredient-checkbox {
  accent-color: var(--green);  
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.either-label,
.or-label {
  margin: 8px 0 6px 14px;   /* leicht eingerückt */
  color: var(--gray-text);
  font-weight: 600;
}

/* =========================================================
   ZUBEREITUNG
   ========================================================= */

/* Überschrift */
.steps h2 {
  margin-top: 0;
}

/* Abschnittstitel */
.step-section-title {
  margin-top: 20px;
  font-size: 18px;
  color: var(--green);
}

/* Einzelner Schritt-Container */
.step-block {
  margin-bottom: 20px;
  padding: 12px;
  border-left: 4px solid var(--green-soft);
  background: #fafafa;
  border-radius: 8px;
  width: 100%;          
  box-sizing: border-box;
}

.step-block.completed {
  opacity: 0.5;
  filter: grayscale(0.3);
}

/* Kopfzeile eines Steps */
.step-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  width: 100%;
}

.highlight-step {
  outline: 3px solid var(--green);
  transition: outline 0.3s ease;
}

/* Schrittnummer (Kreis) */
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: bold;
  flex-shrink: 0; /* darf nicht schrumpfen */
}

/* Uhrzeit */
.step-time {
  font-weight: bold;
  color: var(--green);
  font-size: 15px;
  flex-shrink: 0; /* bleibt kompakt */
}

/* Pfeil zum Kopf und Fuß der Zubereitung */
.time-jump-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  margin-left: 8px;
  opacity: 0.6;
}

.time-jump-btn:hover {
  opacity: 1;
}

/* Dauer-Eingabefeld */
.duration-input {
  width: 70px;
  padding: 4px 6px;
  font-size: 16px;
  border-radius: 6px;
  border: 1px solid var(--gray-border);
  flex-shrink: 0; /* bleibt stabil */
}

.duration-invalid {
  outline: 2px solid #e53935;
}

/* Typ-Badge */
.step-type {
  margin-left: auto; 
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}

/* Tätigkeit */
.step-type.t-type {
  background: #e8f5e9;
  color: var(--green);
}

/* Wartezeit */
.step-type.w-type {
  background: #f0f0f0;
  color: #666;
}

/* Backzeit */
.step-type.b-type {
  background: #fff3e0;
  color: #b26a00;
}

/* Footer-Bereich */
.step-footer {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons: erledigt und timer */
.step-complete-btn,
.step-timer-btn {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--green-light);
  background: white;
  cursor: pointer;
  color: #000;
}

.step-timer-btn.timer-running {
  background: var(--green);
  color: white;
  cursor: pointer;
}

.step-complete-btn:hover {
  background: var(--green-soft);
}

/* Zutaten-Box innerhalb eines Steps */
.step-ingredients {
  margin: 10px 0 8px 0;
  padding: 8px 10px;
  background: #eaf4ee;
  border-left: 3px solid var(--green-light);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}

/* Action-Liste */
.step-actions {
  list-style: disc;
  padding-left: 20px;
  margin: 0;
}

.step-actions li {
  margin-bottom: 6px;
}

.step-actions strong {
  font-weight: 600;
}

/* Start- und Endzeit-Container */
.main-time {
  margin: 18px 0;
  padding: 10px 14px;
  background: var(--green-soft);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Time-Input */
.main-time input[type="time"] {
  font-size: 16px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--green-light);
  background: white;
}

/* Schloss-Indikator */
.lock-indicator {
  margin-left: auto;
  font-size: 16px;
  opacity: 0.7;
}

/* Aktiver Start/Ende-Block */
.main-time.active {
  background: #dff3e4;
  box-shadow: inset 0 0 0 1px var(--green-light);
}

.main-time input:disabled {
  opacity: 0.6;
  background: #f2f2f2;
  cursor: not-allowed;
}

.end-cooking-btn {
  margin-left: 12px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--green-light);
  background: white;
  cursor: pointer;
}

.end-cooking-btn:hover {
  background: var(--green-soft);
}

/* =========================================================
   HINWEIS
   ========================================================= */

.note {
  background: #f6faf7;
  border-left: 4px solid var(--green-soft);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.6;
}

.note h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.note p {
  margin: 8px 0;
}

.note ul {
  margin: 8px 0;
  padding-left: 18px;
}

.note li {
  margin-bottom: 6px;
}

/* =========================================================
   Gallery
   ========================================================= */

.gallery-grid {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.gallery-thumb {
  height: 110px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.gallery-thumb:hover {
  transform: scale(1.05);
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.lightbox {
  position: relative;
  max-width: 92%;
  max-height: 92%;
}

.lightbox-image-wrapper {
  overflow: hidden;
}

.lightbox-image {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 8px;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.lightbox-image.slide-left {
  transform: translateX(-40px);
  opacity: 0;
}

.lightbox-image.slide-right {
  transform: translateX(40px);
  opacity: 0;
}

.lightbox-counter {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 0.9rem;
  opacity: 0.8;
}

.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 42px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  user-select: none;
}

.lightbox-arrow.left  { left: -60px; }
.lightbox-arrow.right { right: -60px; }

.lightbox-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  font-size: 22px;
  cursor: pointer;
}

/* =========================================================
   TRENNLINIEN
   ========================================================= */

hr {
  border: none;
  height: 2px;
  background: var(--green);
  margin: 28px 0;
}

/* =========================================================
   NAVIGATION
   ========================================================= */

.nav-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  font-size: 40px;
  cursor: pointer;
  color: var(--green);
  user-select: none;
  transition: opacity 0.2s ease;
}

.nav-arrow:hover {
  opacity: 0.6;
}

.nav-arrow.left {
  left: 20px;
}

.nav-arrow.right {
  right: 20px;
}

/* Auf kleinen Displays ausblenden */
@media (max-width: 768px) {
  .nav-arrow {
    display: none;
  }
}

/* =========================================================
   Tags und Filter
   ========================================================= */

.pill {
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #ccc;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  margin: 4px;
  color: #000;               
  -webkit-appearance: none;  
}

/* Outline */
.pill.is-present {
  border-color: var(--green);
  border-width: 3px;
}

.pill.is-optional {
  border-color: var(--green); 
  border-style: dashed;
}

.pill.is-absent {
  border-color: #bbb;
}

/* Fill */
.pill.filter-include {
  background: var(--green);
  color: white;
}

.pill.filter-exclude {
  background: #bbb;
  color: white;
}

.active-filters {
  margin: 10px 0 15px 0;
}

.active-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  margin: 4px;
  color: white;
  cursor: pointer;
}

.active-filter-pill.filter-include {
  background: var(--green);
}

.active-filter-pill.filter-exclude {
  background: #bbb;
}

.active-filter-pill .remove {
  font-weight: bold;
  cursor: pointer;
}

#activeFiltersContainer {
  margin: 10px 0 15px 0;
  text-align: center;
}

/* =========================================================
   SEARCH
   ========================================================= */

mark.search-highlight {
  background: #ffeb3b;
  padding: 0 2px;
  border-radius: 2px;
}

.no-results {
  padding: 40px;
  text-align: center;
  font-size: 18px;
  color: var(--gray-text);
}

/* =========================================================
   KARTEN-ANIMATION (Deck-Effekt)
   ========================================================= */

.card.leaving-next {
  transform: translateX(60px) rotate(4deg);
  opacity: 0;
}

.card.leaving-prev {
  transform: translateX(-60px) rotate(-4deg);
  opacity: 0;
}

/* =========================================================
   FOOTER
   ========================================================= */

.recipe-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;

  display: flex;
  align-items: center;
  justify-content: space-between;

  font-size: 0.85rem;
  color: #777;          /* leicht grau */
}

.footer-left,
.footer-center,
.footer-right {
  flex: 1;
}

.footer-left  { text-align: left; }
.footer-center{ text-align: center; }
.footer-right { text-align: right; }

.footer-source-link {
  color: var(--green);
  text-decoration: none;
  font-weight: 500;
}

.footer-source-link:hover {
  text-decoration: underline;
}

.recipe-footer .recipe-download-link {
  color: var(--green); 
  opacity: 0.7;
  text-decoration: none;
}

.recipe-footer .recipe-download-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.app-meta {
  text-align: center;
  margin-top: 1rem;
  margin-bottom: 2rem; /* Abstand zum unteren Rand */
  font-size: 0.9rem;
}


.db-updated {
  margin-bottom: 0.6rem;
  opacity: 0.8;
}

.meta-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.meta-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
  color: #666;
  cursor: pointer;
}

.meta-btn:hover {
  background: #f3f3f3;
}

@media (max-width: 600px) {

  .recipe-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 0.8rem;
  }

  .footer-left,
  .footer-center,
  .footer-right {
    flex: none;
    width: 100%;
  }

  .footer-left {
    text-align: left;
  }

  .footer-center {
    text-align: center;
  }

  .footer-right {
    text-align: right;
    font-size: 0.8rem;
    opacity: 0.85;
  }
}

/* =========================================================
   Push-Status-Overlay
   ========================================================= */

.push-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 14px;
}

.push-table th {
  text-align: left;
  border-bottom: 2px solid #ddd;
  padding: 6px 4px;
}

.push-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #eee;
}

.push-table tr:hover {
  background: #f7f7f7;
}

.push-table button{
  padding:4px 8px;
  margin-right:4px;
  border:1px solid #ccc;
  background:#f5f5f5;
  cursor:pointer;
}

.push-table button:hover{
  background:#e0e0e0;
}

/* =========================================================
   KLEINE UI DETAILS
   ========================================================= */

/* Scrollbar dezent */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* =========================================================
   PRINT LAYOUT
   ========================================================= */

@media print {

  /* --------------------------------
     Grundlayout
  -------------------------------- */

  body {
    background: white;
    color: #000;
    font-size: 11pt;
    line-height: 1.35;
  }

  main {
    padding: 0;
  }

  .card {
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
  }

  /* --------------------------------
     UI entfernen
  -------------------------------- */

  header,
  .nav-arrow,
  .overlay,
  .gallery-grid,
  .lightbox-overlay,
  .app-meta,
  .meta-actions,
  .search-wrapper,
  .result-count,
  .recipe-download-link,
  .main-time,
  .end-cooking-btn,
  .step-footer,
  .step-complete-btn,
  .step-timer-btn,
  .time-jump-btn,
  .ingredient-checkbox,
  .duration-input,
  .pill,
  .active-filters,
  #activeFiltersContainer {
    display: none !important;
  }

  /* alles nach Zubereitung entfernen */

  .steps ~ * {
    display: none !important;
  }

  /* Footer wieder sichtbar */

  .recipe-footer {
    display: flex !important;
  }

/* --------------------------------
   Hero Layout (Bild + Beschreibung)
-------------------------------- */

.hero-layout {
  display: grid !important;
  grid-template-columns: 180px 1fr;  
  gap: 12px;                         
  align-items: start;
}

.hero-image {
  width: 180px;
  height: auto;
  margin: 0;
}

.hero .description {
  width: auto !important;
  margin: 0;
}

  /* --------------------------------
     Titel
  -------------------------------- */

  .hero h1 {
    font-size: 26pt;
    margin-bottom: 4px;
  }

  .hero .subline {
    font-size: 11pt;
    color: #444;
    margin-bottom: 10px;
  }

  /* --------------------------------
     Zutaten
  -------------------------------- */

  .ingredient-item {
    margin: 2px 0;
  }

  /* --------------------------------
     Zubereitung zweispaltig
  -------------------------------- */

  .steps {
    margin-top: 24px;
    column-count: 2;
    column-gap: 40px;
  }

  .steps h2 {
    column-span: all;
    margin-bottom: 10px;
  }

  .step-block {
    break-inside: avoid;
    border: none;
    background: none;
    padding: 0;
    margin-bottom: 10px;
  }

  .step-line {
    margin-bottom: 2px;
  }

  .step-number {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    font-size: 11pt;
    font-weight: bold;
  }

  .step-number::after {
    content: ".";
    margin-right: 4px;
  }

  .step-time,
  .step-type {
    display: none;
  }

  .step-ingredients {
    background: none;
    border: none;
    padding: 0;
    margin: 2px 0;
    font-size: 10pt;
  }

  .step-actions {
    margin: 0;
    padding-left: 16px;
  }

  .step-actions li {
    margin-bottom: 2px;
  }

  /* --------------------------------
     Hinweis
  -------------------------------- */

  .note {
    border: none;
    background: none;
    padding: 0;
    margin-top: 20px;
  }

  /* --------------------------------
     Footer
  -------------------------------- */

  .recipe-footer {
    border-top: 1px solid #ddd;
    margin-top: 20px;
    padding-top: 8px;
    font-size: 9pt;
    color: #666;
  }

  /* --------------------------------
     Seitenumbrüche
  -------------------------------- */

  h1, h2 {
    page-break-after: avoid;
  }

  .step-block,
  .ingredient-item {
    page-break-inside: avoid;
  }

}