/* assets/style.css – Ergänzungen zu Tailwind */

/* ----------------------------------------------------------------
 * Lokale Schriftart Inter (DSGVO-konform selbst gehostet, kein Google)
 * ---------------------------------------------------------------- */
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 400;
    font-display: swap; src: url('fonts/inter-latin-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 500;
    font-display: swap; src: url('fonts/inter-latin-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 600;
    font-display: swap; src: url('fonts/inter-latin-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 700;
    font-display: swap; src: url('fonts/inter-latin-700.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 800;
    font-display: swap; src: url('fonts/inter-latin-800.woff2') format('woff2');
}

/* Verhindert horizontales Überlaufen auf echten Mobilgeräten / PWA */
html, body { max-width: 100vw; overflow-x: hidden; }

/* ----------------------------------------------------------------
 * Einkaufsliste: Auto-Sortierung (abgehakt sinkt unter den Trenner)
 * ---------------------------------------------------------------- */
.shopping-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.shopping-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .15rem;
    border-bottom: 1px solid #f5f5f4;
    order: 0;                                  /* offen: oben */
    transition: opacity .2s, background .2s, transform .15s;
}
/* Drei Zonen: zu kaufen (oben) · Anderer Laden · Erledigt (unten) */
.shopping-item.is-remembered:not(.is-checked) { order: 2; }   /* anderer Laden */
.shopping-item.is-checked { order: 4; }                       /* abgehakt/im Wagen */
.shop-check { width: 1.25rem; height: 1.25rem; }

.shopping-item.is-checked .item-text { text-decoration: line-through; color: #a8a29e; }
.shopping-item.is-checked .item-text .font-semibold { color: #a8a29e; }

/* „Anderer Laden"-Markierung (nur solange nicht abgehakt) */
.shopping-item .remember-badge { display: none; font-size: 1rem; flex-shrink: 0; }
.shopping-item.is-remembered:not(.is-checked) .remember-badge { display: inline; }

/* Trenner – nur sichtbar, wenn die jeweilige Zone Einträge hat */
.shopping-divider { display: none; align-items: center; gap: .5rem; padding: .5rem 0; }
.divider-laden    { order: 1; }
.divider-erledigt { order: 3; }
.shopping-list:has(.is-remembered:not(.is-checked)) .divider-laden { display: flex; }
.shopping-list:has(.is-checked) .divider-erledigt { display: flex; }
.shopping-divider span {
    font-size: .7rem; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: #a8a29e; white-space: nowrap;
}
.divider-laden span { color: #b45309; }   /* amber für „Anderer Laden" */
.shopping-divider::before, .shopping-divider::after { content: ""; flex: 1; height: 1px; background: #e7e5e4; }

/* Einkaufsmodus: große Tippflächen, Wisch-Geste */
.shopping-mode .shopping-item { padding: .85rem .25rem; font-size: 1.05rem; touch-action: pan-y; user-select: none; }
.shopping-mode .shop-check { width: 1.6rem; height: 1.6rem; }
.shopping-item.swiping { transition: none; background: #fff7ed; }
.shopping-item.remember-flash { background: #fff7ed; }
.shopping-item { user-select: none; }

/* Griff-Drag (Bearbeiten-Modus) – nutzt .drag-handle wie der Zutaten-Editor */
.shopping-list.drag-active { touch-action: none; }
.shopping-item.dragging {
    opacity: .75; background: #fff7ed; border-radius: .5rem;
    box-shadow: 0 8px 20px rgba(0,0,0,.16); position: relative; z-index: 5;
}

/* ----------------------------------------------------------------
 * Einkaufsläden: Badges, Gruppen-Header, Auswahl-Chips, Reorder
 * ---------------------------------------------------------------- */
.store-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem; border-radius: 9999px;
    font-size: .8rem; font-weight: 800; flex-shrink: 0; line-height: 1;
}
.store-badge.store-logo { background: #fff; border: 1px solid #e7e5e4; overflow: hidden; }
.store-badge.store-logo img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.store-line { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.store-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: #57534e; }

.store-header {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .15rem .35rem; margin-top: .25rem;
    border-bottom: 2px solid #f5f5f4;
}
.store-header-name { font-weight: 700; color: #44403c; font-size: .9rem; flex: 1; }

/* Reorder-Pfeile (Bearbeiten-Modus) */
.reorder { display: inline-flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.reorder button {
    width: 1.4rem; height: 1.1rem; line-height: 1; font-size: .7rem;
    border: 1px solid #e7e5e4; background: #fafaf9; color: #78716c; border-radius: .3rem;
}
.reorder button:hover { background: #fff7ed; color: #ea580c; border-color: #fdba74; }

/* Laden-Auswahl beim Anlegen */
.store-picker { display: flex; flex-wrap: wrap; gap: .4rem; }
.store-pick { cursor: pointer; }
.store-pick input { position: absolute; opacity: 0; pointer-events: none; }
.store-pick .store-chip {
    border: 1px solid #e7e5e4; border-radius: 9999px; padding: .25rem .6rem .25rem .25rem;
    transition: border-color .15s, background .15s;
}
.store-pick input:checked + .store-chip { border-color: #ea580c; background: #fff7ed; }

.rd-store { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }

/* ----------------------------------------------------------------
 * Rezept-Dialog (Portionen + Zutatenauswahl)
 * ---------------------------------------------------------------- */
.recipe-dialog {
    width: min(28rem, calc(100vw - 1.5rem));
    border: none; border-radius: 1rem; padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.recipe-dialog::backdrop { background: rgba(0,0,0,.4); }
.recipe-dialog .rd-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.recipe-dialog .rd-portions { display: flex; align-items: center; gap: .5rem; }
.recipe-dialog .rd-stepper { display: inline-flex; align-items: center; gap: .25rem; }
.recipe-dialog .rd-stepper button {
    width: 2rem; height: 2rem; border-radius: .5rem; border: 1px solid #e7e5e4;
    background: #fafaf9; color: #57534e; font-size: 1.1rem; line-height: 1;
}
.recipe-dialog .rd-stepper button:hover { background: #fff7ed; color: #ea580c; }
.recipe-dialog .rd-stepper input {
    width: 3.25rem; text-align: center; padding: .4rem; border: 1px solid #e7e5e4; border-radius: .5rem;
}
.recipe-dialog .rd-ingredients { list-style: none; margin: 0 0 1rem; padding: 0; max-height: 50vh; overflow-y: auto; }
.recipe-dialog .rd-ingredients li { border-bottom: 1px solid #f5f5f4; }
.recipe-dialog .rd-ingredients label { display: flex; align-items: center; gap: .6rem; padding: .55rem .15rem; cursor: pointer; }
.recipe-dialog .rd-ingredients input[type="checkbox"] { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.recipe-dialog .rd-amount { font-weight: 600; color: #44403c; white-space: nowrap; }
.recipe-dialog .rd-name { color: #57534e; }
.recipe-dialog .rd-foot { display: flex; justify-content: flex-end; gap: .5rem; }

/* ----------------------------------------------------------------
 * Responsive Navigation: Desktop / Mobile Hamburger
 * ---------------------------------------------------------------- */
/* Desktop: normale Flex-Reihe */
#nav-desktop {
    display: none;          /* versteckt auf Mobile */
    align-items: center;
    gap: 0.5rem;
}
/* Hamburger-Button: nur auf Mobile sichtbar */
#nav-toggle { display: flex; }

@media (min-width: 640px) {
    #nav-desktop { display: flex; }   /* sichtbar auf sm+ */
    #nav-toggle  { display: none; }   /* versteckt auf sm+ */
    #nav-menu    { display: none !important; } /* Mobile-Panel immer weg */
}

/* ----------------------------------------------------------------
 * Zeilen-Begrenzung (line-clamp Fallback) */
.line-clamp-1 { display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; overflow:hidden; }
.line-clamp-2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

/* Sanfte Pulse-Animation bei Mengenänderung */
@keyframes amountPulse {
    0%   { color:#ea580c; transform:scale(1.12); }
    100% { color:inherit; transform:scale(1); }
}
.amount-pulse { animation: amountPulse .3s ease; display:inline-block; }

/* Flash-Einblendung */
.flash { animation: flashIn .35s ease; }
@keyframes flashIn {
    from { opacity:0; transform:translateY(-10px); }
    to   { opacity:1; transform:translateY(0); }
}

/* Hübschere Zahleneingaben */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity:1; }

/* Sanftes Scrollverhalten & Fokus-Sichtbarkeit */
:focus-visible { outline: none; }

/* Nur im Druck sichtbare Elemente – im Bildschirm verstecken */
.print-only { display: none; }

/* ----------------------------------------------------------------
 * Sortierbare Zutaten-/Abschnittszeilen (Drag & Drop)
 * ---------------------------------------------------------------- */
/* Mobile: Zutaten-Zeile zweizeilig (Menge+Einheit / Name+Löschen) */
@media (max-width: 639px) {
    .ingredient-row:not(.section-row) {
        flex-wrap: wrap;
        align-items: flex-start;
    }
    /* Drag-Handle vertikal mittig zur ersten Zeile */
    .ingredient-row:not(.section-row) > span.drag-handle {
        padding-top: 7px;
    }
    /* Name-Feld: Flex-Basis größer als verbleibender Platz → bricht um */
    .ingredient-row:not(.section-row) > input:nth-of-type(4) {
        flex: 1 0 calc(100% - 96px);
        min-width: 0;
    }
    /* Löschen-Button folgt dem Name-Feld auf Zeile 2 */
    .ingredient-row:not(.section-row) > button.remove-ing {
        align-self: flex-end;
        margin-bottom: 1px;
    }
}

.drag-handle {
    cursor: grab;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 .15rem;
    touch-action: none;              /* Touch-Ziehen ohne Scrollen */
    transition: color .15s;
}
.drag-handle:active { cursor: grabbing; }
.ingredient-row { transition: background .15s, box-shadow .15s; border-radius: .5rem; }
.ingredient-row.dragging {
    opacity: .6;
    background: #fff7ed;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
}

/* ----------------------------------------------------------------
 * Horizontal scrollbare Kategorie-Reihen
 * ---------------------------------------------------------------- */
.scroll-row {
    scroll-behavior: smooth;
    scrollbar-width: thin;                /* Firefox */
    scrollbar-color: #d6d3d1 transparent;
    cursor: grab;
}
.scroll-row.is-dragging { cursor: grabbing; scroll-behavior: auto; }
.scroll-row::-webkit-scrollbar { height: 8px; }
.scroll-row::-webkit-scrollbar-track { background: transparent; }
.scroll-row::-webkit-scrollbar-thumb {
    background: #e7e5e4; border-radius: 9999px;
}
.scroll-row:hover::-webkit-scrollbar-thumb { background: #d6d3d1; }

.scroll-btn {
    width: 2.25rem; height: 2.25rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9999px;
    border: 1px solid #e7e5e4;
    background: #fff;
    color: #57534e;
    font-size: 1.25rem; line-height: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    transition: background .15s, color .15s, opacity .2s, transform .1s;
}
.scroll-btn:hover { background: #fff7ed; color: #ea580c; border-color: #fdba74; }
.scroll-btn:active { transform: scale(.9); }
.scroll-btn--off { opacity: .3; pointer-events: none; }

/* ----------------------------------------------------------------
 * Druckansicht – gestaltet wie eine Seite aus einem Kochbuch
 * ---------------------------------------------------------------- */
@media print {
    /* Seitenränder wie in einem Buch */
    @page { margin: 18mm 16mm; }

    /* Nicht-druckbare Elemente ausblenden */
    .no-print,
    header,
    footer,
    #flash-container { display: none !important; }

    .print-only { display: block !important; }

    html, body {
        background: #fff !important;
        color: #1a1a1a;
        font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
        font-size: 11.5pt;
        line-height: 1.5;
    }

    main { max-width: none !important; padding: 0 !important; margin: 0 !important; }

    /* Karte/Boxen flach & rahmenlos drucken */
    article,
    .bg-white,
    .bg-stone-50,
    .recipe-ingredients > div {
        box-shadow: none !important;
        border: none !important;
        background: #fff !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .lg\:sticky { position: static !important; }

    /* ---- Buch-Kopf ---- */
    .print-book-head {
        text-align: center;
        font-size: 9.5pt;
        letter-spacing: 0.35em;
        text-transform: uppercase;
        color: #8a6d3b;
        margin-bottom: 10mm !important;
    }

    /* ---- Titelbereich ---- */
    .recipe-hero {
        aspect-ratio: auto !important;
        height: auto !important;
        max-height: 70mm;
        width: 70%;
        margin: 0 auto 8mm !important;
        overflow: hidden;
        border-radius: 4px !important;
    }
    .recipe-hero img {
        width: 100%;
        height: auto;
        max-height: 70mm;
        object-fit: cover;
        filter: grayscale(0);
    }

    /* Titelkopf als zentrierter Block (Flex aufbrechen) */
    .recipe-head { display: block !important; }
    .recipe-head-main { width: 100% !important; }
    .recipe-eyebrow { justify-content: center !important; }
    .recipe-eyebrow span {
        background: transparent !important;
        color: #8a6d3b !important;
        font-size: 9.5pt !important;
        letter-spacing: 0.15em;
        text-transform: uppercase;
        padding: 0 !important;
    }
    /* Meta-Zeile (Zubereitungszeit) zentrieren */
    .recipe-head-main > .flex { justify-content: center !important; color: #555 !important; font-style: italic; }

    /* Titel zentriert, mit feinen Linien wie ein Rezeptkopf */
    h1 {
        text-align: center;
        font-size: 26pt !important;
        font-weight: 700;
        letter-spacing: -0.01em;
        margin: 0 0 4mm !important;
        line-height: 1.15;
    }
    /* Eyebrow-Zeile (Kategorie/Lieblingsrezept) zentrieren */
    .recipe-body { margin-top: 6mm !important; }

    /* Meta-Zeile (Zeit) zentriert & kursiv */
    h1 + p, .recipe-method, .recipe-ingredients { color: #1a1a1a; }

    /* Beschreibung zentriert, kursiv */
    h1 ~ p { text-align: center; font-style: italic; color: #444; }

    /* Trennlinie unter dem Kopf */
    .recipe-body::before {
        content: "";
        display: block;
        width: 40mm;
        height: 1px;
        background: #c9a14a;
        margin: 0 auto 8mm;
    }

    /* ---- Zweispaltiges Buch-Layout: Zutaten als Seitenkasten rechts ---- */
    .recipe-body { display: block !important; }
    .recipe-ingredients {
        float: right;
        width: 38%;
        margin: 0 0 6mm 8mm !important;
        padding: 5mm !important;
        border: 1px solid #ddd !important;
        border-radius: 4px !important;
        background: #faf8f3 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .recipe-ingredients > div,
    .recipe-ingredients .bg-white { background: transparent !important; }
    .recipe-method { width: auto; display: block; }

    /* Überschriften "Zutaten" / "Zubereitung" im Buchstil */
    h2 {
        font-size: 13pt !important;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: #8a6d3b !important;
        border-bottom: 1px solid #e2d8c3;
        padding-bottom: 1.5mm;
        margin-bottom: 4mm !important;
    }

    /* Portionsangabe im Kasten */
    .print-portions {
        font-style: italic;
        color: #666;
        font-size: 10.5pt;
        margin: 0 0 4mm !important;
    }

    /* Zutatenliste */
    #ingredient-list { margin: 0; padding: 0; }
    #ingredient-list ul { margin: 0; padding: 0; }
    #ingredient-list li {
        list-style: none;
        padding: 1mm 0;
        border-bottom: 1px dotted #ddd;
        page-break-inside: avoid;
    }
    #ingredient-list .ingredient-group { margin-bottom: 3mm; page-break-inside: avoid; }
    #ingredient-list .text-brand-400 { display: none; } /* Bullet weg */

    /* Abschnitts-Überschriften (Zutaten & Zubereitung) */
    .ingredient-section-title, .step-section-title {
        color: #8a6d3b !important;
        font-weight: 700;
        font-size: 10.5pt !important;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        margin: 0 0 2mm !important;
    }

    /* Zubereitungsschritte */
    .recipe-method ol { margin: 0; padding: 0; }
    .recipe-method .step-group { margin-bottom: 5mm; }
    .recipe-method ol li {
        display: flex;
        gap: 4mm;
        margin-bottom: 4mm;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .recipe-method ol li > span:first-child {
        background: #8a6d3b !important;
        color: #fff !important;
        width: 7mm; height: 7mm;
        min-width: 7mm;
        border-radius: 50%;
        font-family: Georgia, serif;
        font-size: 10pt;
    }
    .recipe-method ol li p { padding-top: 0.5mm; }

    /* ---- Buch-Fuß ---- */
    .print-book-foot {
        clear: both;
        text-align: center;
        margin-top: 12mm !important;
        padding-top: 4mm;
        border-top: 1px solid #e2d8c3;
        font-style: italic;
        font-size: 9.5pt;
        color: #8a6d3b;
    }

    /* Allgemeine Umbruchregeln */
    h1, h2 { page-break-after: avoid; }
    a[href]::after { content: ""; }
}
