/* ============================================================
   Rezepte App – Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green:       #16a34a;
    --green-dark:  #15803d;
    --green-light: #dcfce7;
    --bg:          #f3f4f6;
    --card:        #ffffff;
    --text:        #111827;
    --muted:       #6b7280;
    --border:      #e5e7eb;
    --header-h:    54px;
    --radius:      14px;
    --shadow:      0 2px 10px rgba(0,0,0,0.08);
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: white;
    color: var(--text);
    min-height: 100vh;
    padding-top: var(--header-h);
    overscroll-behavior: none;
}

#viewGrid, #viewDetail { background: var(--bg); }

/* ============================================================
   HEADER
============================================================ */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    z-index: 200;
    background: var(--green);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 8px 0 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-btn {
    width: 40px; height: 40px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.header-btn:active { background: rgba(255,255,255,0.2); }

.header-title {
    flex: 1;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* Kein Spacer mehr nötig – symmetrische Buttons links/rechts */

/* ============================================================
   MENU / DRAWER
============================================================ */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.menu-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.menu-drawer {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 85vw);
    background: white;
    display: flex; flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.menu-overlay.open .menu-drawer { transform: translateX(0); }

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    background: var(--green);
    color: white;
    flex-shrink: 0;
}

.menu-logo { font-size: 1.05rem; font-weight: 700; }

.menu-close {
    background: none; border: none; color: white; cursor: pointer;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; -webkit-tap-highlight-color: transparent;
}
.menu-close:active { background: rgba(255,255,255,0.2); }

.menu-section-title {
    padding: 18px 18px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.category-list { list-style: none; padding: 0 0 24px; }

.category-list li a {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 18px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.97rem;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s;
}
.category-list li a:active,
.category-list li a.active { background: var(--green-light); color: var(--green); }

.cat-icon { font-size: 1.3rem; width: 28px; text-align: center; }

.cat-count {
    margin-left: auto;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}

/* ============================================================
   VIEWS
============================================================ */
.view { padding-bottom: 32px; }

/* ============================================================
   HOME – Suchbereich
============================================================ */
.home-search-section {
    background: white;
    padding: 0 14px 18px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.search-wrap {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 0 10px;
    gap: 8px;
    transition: border-color 0.15s;
}
.search-wrap:focus-within { border-color: var(--green); background: white; }

.search-icon { color: var(--muted); flex-shrink: 0; }

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    -webkit-appearance: none;
    min-width: 0;
}
.search-input::placeholder { color: var(--muted); }

.search-clear {
    background: none; border: none; cursor: pointer;
    color: var(--muted); flex-shrink: 0; display: flex;
    -webkit-tap-highlight-color: transparent;
}

/* Mode-Toggle (Titel / Zutaten) – oberhalb Suchfeld */
.mode-toggle {
    display: flex;
    background: var(--bg);
    border-radius: 10px;
    padding: 3px;
    margin: 20px 0 12px;
    width: fit-content;
    border: 1.5px solid var(--border);
}

.toggle-btn {
    padding: 7px 22px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.18s;
}
.toggle-btn.active {
    background: white;
    color: var(--green);
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Vorschläge */
.suggestions-box {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: white;
    border-top: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 100;
    overflow: hidden;
}

.suggestions-list { list-style: none; }

.suggestions-list li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
}
.suggestions-list li:last-child a { border-bottom: none; }
.suggestions-list li a:active { background: var(--green-light); }

.suggestion-thumb {
    width: 40px; height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--green-light);
    flex-shrink: 0;
}
.suggestion-thumb-placeholder {
    width: 40px; height: 40px;
    border-radius: 8px;
    background: var(--green-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.suggestions-all {
    display: block;
    width: 100%;
    padding: 13px 16px;
    background: var(--green-light);
    border: none;
    border-top: 1px solid var(--border);
    color: var(--green);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.suggestions-all:active { background: #bbf7d0; }

/* ============================================================
   HOME – Top-Rezepte
============================================================ */
.home-section { padding: 18px 14px 0; }

.section-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    margin-bottom: 12px;
}

/* ============================================================
   REZEPT-GRID (tiles)
============================================================ */
#viewGrid { padding: 14px 12px 32px; }

.recipe-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (min-width: 540px) {
    .recipe-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 820px) {
    .recipe-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
    #viewGrid { padding: 20px; }
}

/* Kachel */
.recipe-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    display: block;
    transition: transform 0.12s, box-shadow 0.12s;
}
.recipe-card:active { transform: scale(0.96); box-shadow: 0 1px 4px rgba(0,0,0,0.07); }

.card-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--green-light);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}

.card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.card-img-placeholder {
    font-size: 2rem;
}

.card-rating {
    position: absolute;
    bottom: 7px; left: 7px;
    background: rgba(0,0,0,0.52);
    color: #fbbf24;
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    padding: 3px 7px;
    border-radius: 8px;
    line-height: 1;
    pointer-events: none;
}

.card-body { padding: 10px 11px 12px; }

.card-title {
    font-size: 0.87rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 5px;
}

.card-meta {
    font-size: 0.73rem;
    color: var(--muted);
}

/* ============================================================
   SKELETON
============================================================ */
.skeleton-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}
.skeleton-img  { width: 100%; aspect-ratio: 4/3; }
.skeleton-line { height: 12px; margin: 10px 11px 6px; border-radius: 6px; }
.skeleton-line.short { width: 55%; margin-bottom: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   EMPTY STATE
============================================================ */
.empty-state { grid-column: 1/-1; text-align: center; padding: 60px 24px; }
.empty-icon  { font-size: 3rem; margin-bottom: 14px; }
.empty-state p { color: var(--muted); font-size: 0.95rem; line-height: 1.6; }

/* ============================================================
   DETAIL-ANSICHT
============================================================ */
.detail-hero {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
}
.detail-hero-placeholder {
    width: 100%; height: 200px;
    background: var(--green-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 4rem;
}

.detail-body { padding: 0 0 40px; }

/* Kategorie-Badges (mehrere möglich) */
.detail-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 14px 18px 6px;
}
.detail-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--green-light);
    color: var(--green);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.25;
    padding: 4px 18px 0;
    letter-spacing: -0.3px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 18px 14px;
    border-bottom: 1px solid var(--border);
}
.detail-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.detail-meta-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}
.detail-meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.detail-intro {
    padding: 16px 18px;
    font-size: 0.97rem;
    color: var(--muted);
    line-height: 1.7;
    border-bottom: 1px solid var(--border);
    font-style: italic;
}

.detail-section { padding: 18px; border-bottom: 1px solid var(--border); }

.detail-section-title-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 14px;
    gap: 10px;
}
.detail-section-title-row .detail-section-title { margin-bottom: 0; }

.detail-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--green);
    margin-bottom: 14px;
}

/* Zutaten */
.ingredient-list { list-style: none; }
.ingredient-list li {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.4;
    align-items: flex-start;
}
.ingredient-list li:last-child { border-bottom: none; }
.ingredient-amount {
    min-width: 56px;
    color: var(--green);
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.ingredient-name { color: var(--text); }

/* Zubereitung */
.instruction-list { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.instruction-item { display: flex; gap: 14px; align-items: flex-start; }
.instruction-step {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--green);
    color: white;
    font-size: 0.82rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.instruction-text { font-size: 0.95rem; line-height: 1.75; color: var(--text); padding-top: 3px; }

/* Portionen-Anpasser */
.servings-adjuster {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}
.adj-btn {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 2px solid var(--green);
    background: white;
    color: var(--green);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.adj-btn:active { background: var(--green); color: white; }
.adj-value {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
    color: var(--text);
}
.adj-suffix {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Hinweis / Variante */
.detail-notes {
    background: #fefce8;
    border-left: 4px solid #eab308;
    border-bottom: 1px solid var(--border);
}
.detail-notes .detail-section-title { color: #a16207; }
.notes-text {
    font-size: 0.95rem;
    line-height: 1.65;
    color: #713f12;
}

/* Zusätzliche Bilder */
.detail-extra-img {
    width: 100%;
    display: block;
    max-height: 340px;
    object-fit: cover;
}

/* Quelle */
.detail-source {
    padding: 14px 18px 0;
    font-size: 0.83rem;
}
.detail-source a { color: var(--green); text-decoration: none; }

/* Bewertung */
.detail-rating-section { border-bottom: none; }

.star-rating {
    display: flex;
    gap: 4px;
}
.star-btn {
    background: none;
    border: none;
    font-size: 2.2rem;
    color: #d1d5db;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.1s, transform 0.12s;
}
.star-btn.active { color: #f59e0b; }
.star-btn:active { transform: scale(1.25); }

/* ============================================================
   SCROLL-TO-TOP (kleine Verbesserung)
============================================================ */
.view { scroll-behavior: smooth; }
