/* ============================================================
 * polish.css  –  zentrale Polish-Schicht
 *
 * Wird NACH allen anderen Stylesheets geladen.
 * Überschreibt keine bestehenden Regeln, sondern ergänzt:
 *   • erweiterte Design-Tokens
 *   • globaler Fokus-Ring (Tastatur)
 *   • sanftere Scroll-Physik
 *   • Reveal-on-Scroll (per .reveal-Klasse)
 *   • Haptik-Micro-Squash für klickbare Elemente
 *   • Toast-System (live-region, a11y)
 *   • Empty-State-Beautifier
 * ============================================================ */

/* ---------- Erweiterte Tokens (greifen nur, wenn nicht gesetzt) ---------- */
:root {
    /* Modernisierter Coral-Akzent: wärmer, mit Tiefenstaffelung */
    --accent-coral-50:  #FFF7E0;
    --accent-coral-100: #FFE9A8;
    --accent-coral-200: #FFD973;
    --accent-coral-300: #FDB813;
    --accent-coral-400: #F5A623;
    --accent-coral-500: #E08F0E;

    /* Modernisiertes Grün */
    --green-50:  #E8F5EC;
    --green-100: #C7E4CF;
    --green-200: #9CCFA9;
    --green-300: #6BB57E;
    --green-400: #1B6B33;
    --green-500: #145226;

    /* Neutrals (moderner, leicht bläulich) */
    --neutral-0:   #ffffff;
    --neutral-50:  #f8f9fb;
    --neutral-100: #f1f3f7;
    --neutral-200: #e7eaf0;
    --neutral-300: #d1d6e0;
    --neutral-400: #9ca3af;
    --neutral-500: #6b7280;
    --neutral-600: #4b5563;
    --neutral-700: #2c3340;
    --neutral-800: #1a1f2b;
    --neutral-900: #0f1320;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --dur-fast:   150ms;
    --dur-base:   250ms;
    --dur-slow:   450ms;

    /* Layered shadows (für Top-Bar, Cards, Modals) */
    --shadow-xs: 0 1px 2px rgba(15, 19, 32, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 19, 32, 0.05), 0 1px 2px rgba(15, 19, 32, 0.04);
    --shadow-md: 0 6px 20px rgba(15, 19, 32, 0.08), 0 2px 6px rgba(15, 19, 32, 0.04);
    --shadow-lg: 0 16px 40px rgba(15, 19, 32, 0.10), 0 4px 12px rgba(15, 19, 32, 0.05);
    --shadow-xl: 0 24px 60px rgba(15, 19, 32, 0.14), 0 8px 24px rgba(15, 19, 32, 0.06);
    --shadow-glow-coral: 0 0 0 4px rgba(253, 184, 19, 0.18);
    --shadow-glow-green: 0 0 0 4px rgba(27, 107, 51, 0.18);

    /* Fokus-Ring (Tastatur) */
    --focus-ring: 0 0 0 3px rgba(253, 184, 19, 0.45);
    --focus-ring-green: 0 0 0 3px rgba(27, 107, 51, 0.35);
}

/* ---------- Globale Scroll-Physik ---------- */
html {
    scroll-behavior: smooth;
    /* Schmalere, dezentere Scrollbar in Webkit */
}
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.32); background-clip: padding-box; border: 2px solid transparent; }

/* ---------- Fokus-Indikatoren (Tastatur) ---------- */
:focus { outline: none; }
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: 8px;
    transition: box-shadow var(--dur-fast) var(--ease-out);
}
/* Inputs/Texareas bekommen einen grünen Ring */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    box-shadow: var(--focus-ring-green);
    border-color: var(--green-400);
}
/* Buttons in Admin bekommen ihren Coral-Ring */
.admin-main .btn:focus-visible {
    box-shadow: var(--focus-ring);
}

/* ---------- Sanftere Standard-Übergänge für klickbare Elemente ---------- */
a, button, .btn, [role="button"] {
    transition:
        transform var(--dur-fast) var(--ease-out),
        background-color var(--dur-base) var(--ease-out),
        color var(--dur-base) var(--ease-out),
        box-shadow var(--dur-base) var(--ease-out),
        border-color var(--dur-base) var(--ease-out);
}

/* ---------- Micro-Squash beim Klicken (global, überschreibbar) ---------- */
.btn:not(:disabled):active,
button:not(:disabled):active,
a.btn:not([aria-disabled="true"]):active {
    transform: scale(0.97);
    transition-duration: 80ms;
}

/* ---------- Top-Bar Schatten beim Scrollen (kunde) ---------- */
.top-bar.scrolled {
    box-shadow: 0 1px 0 rgba(15, 19, 32, 0.04), 0 4px 16px rgba(15, 19, 32, 0.04);
}

/* ---------- Bottom-Nav Bounce beim Klick ---------- */
.bottom-nav a:active .nav-icon {
    transform: scale(0.9);
    transition-duration: 80ms;
}
.bottom-nav a.active .nav-icon { animation: none; }

/* ---------- Reveal-on-Scroll ---------- */
.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition:
        opacity var(--dur-slow) var(--ease-out),
        transform var(--dur-slow) var(--ease-out);
    will-change: opacity, transform;
}
.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}
/* Stagger: einfach .reveal-stagger am Container, Kinder > .reveal bekommen automatisch Delay */
.reveal-stagger > .reveal:nth-child(1)  { transition-delay: 0ms; }
.reveal-stagger > .reveal:nth-child(2)  { transition-delay: 60ms; }
.reveal-stagger > .reveal:nth-child(3)  { transition-delay: 120ms; }
.reveal-stagger > .reveal:nth-child(4)  { transition-delay: 180ms; }
.reveal-stagger > .reveal:nth-child(5)  { transition-delay: 240ms; }
.reveal-stagger > .reveal:nth-child(6)  { transition-delay: 300ms; }
.reveal-stagger > .reveal:nth-child(7)  { transition-delay: 360ms; }
.reveal-stagger > .reveal:nth-child(8)  { transition-delay: 420ms; }
.reveal-stagger > .reveal:nth-child(n+9){ transition-delay: 480ms; }

/* ---------- Empty-State (verschönert) ---------- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}
.empty-state .es-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neutral-100), var(--neutral-50));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: var(--neutral-400);
    box-shadow: inset 0 0 0 1px var(--neutral-200);
    animation: emptyPulse 3s ease-in-out infinite;
}
@keyframes emptyPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}
.empty-state p {
    color: var(--neutral-500);
    font-size: .92rem;
    margin: 0;
}
.empty-state .es-title {
    color: var(--neutral-700);
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0 0 4px;
}

/* ---------- Toast-System (live region) ---------- */
.toast-stack {
    position: fixed;
    z-index: 9999;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 90px); /* über der Bottom-Nav */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: min(420px, calc(100% - 24px));
    max-width: calc(100% - 24px);
}
@media (min-width: 768px) {
    .toast-stack { bottom: 24px; }
}
.toast {
    pointer-events: auto;
    background: var(--neutral-800);
    color: #fff;
    padding: 12px 16px;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .9rem;
    font-weight: 500;
    line-height: 1.3;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    transition:
        opacity var(--dur-base) var(--ease-out),
        transform var(--dur-base) var(--ease-out);
    position: relative;
    overflow: hidden;
}
.toast::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--neutral-500);
}
.toast.is-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.toast .toast-icon {
    width: 28px; height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
}
.toast .toast-msg { flex: 1; min-width: 0; }
.toast .toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 4px;
    border-radius: 6px;
    line-height: 1;
    cursor: pointer;
    font-size: 1rem;
}
.toast .toast-close:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.toast.toast-success::before { background: #22c55e; }
.toast.toast-success .toast-icon { background: rgba(34, 197, 94, 0.2); color: #86efac; }

.toast.toast-error::before   { background: #ef4444; }
.toast.toast-error .toast-icon { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

.toast.toast-info::before    { background: #3b82f6; }
.toast.toast-info .toast-icon { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }

.toast.toast-warning::before { background: var(--accent-coral-300); }
.toast.toast-warning .toast-icon { background: rgba(253, 184, 19, 0.2); color: #fde68a; }

/* Fortschrittsbalken (Timeout-Indikator) */
.toast .toast-progress {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.18);
    transform-origin: left;
    animation: toastProgress var(--toast-duration, 4s) linear forwards;
}
@keyframes toastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ---------- Modal/Overlay Polish (für später wiederverwendbar) ---------- */
.overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 19, 32, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9000;
    opacity: 0;
    animation: fadeIn var(--dur-base) var(--ease-out) forwards;
}
@keyframes fadeIn { to { opacity: 1; } }

/* ---------- Sanfte Listen-Items (Konto/Kassenbons) ---------- */
.list-row {
    transition: background-color var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.list-row:active { transform: scale(0.995); }

/* ---------- Tabellen (Admin) ---------- */
.admin-main table.table tbody tr {
    transition: background-color var(--dur-base) var(--ease-out);
}
.admin-main table.table tbody tr:hover {
    background-color: var(--neutral-50);
}

/* ---------- Aktive Filter-Pille (Angebote-Seite) ---------- */
.active-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 14px;
    background: linear-gradient(135deg, var(--neutral-800), var(--neutral-700));
    color: #fff;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(15, 19, 32, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
    position: relative;
}
.active-filter-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(15, 19, 32, 0.25);
    color: #fff;
}
.active-filter-pill strong { color: var(--accent-coral-300); }
.active-filter-pill .afp-close {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    margin-left: 2px;
    transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.active-filter-pill:hover .afp-close { background: rgba(255, 255, 255, 0.22); }
.active-filter-pill:active .afp-close { transform: scale(0.85); }

@keyframes filterPillIn {
    0%   { opacity: 0; transform: translateY(-6px) scale(0.85); }
    60%  { opacity: 1; transform: translateY(0) scale(1.06); }
    100% { transform: translateY(0) scale(1); }
}

/* ---------- Wow-Layer: deutlichere Animationen für Startseite & Angebote ----------
 *
 * Bewusst zurückhaltend: KEINE kontinuierlichen Loops, KEINE Hover-only-Effekte.
 * Alles, was hier steht, muss auf Mobile ohne Hover sichtbar wirken.
 * -------------------------------------------------------------------------- */

/* Sanfter Skeleton-Shimmer (override der harten Variante) */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(241, 243, 247, 0.6) 0%,
        rgba(231, 234, 240, 0.9) 50%,
        rgba(241, 243, 247, 0.6) 100%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.6s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

/* ---------- Inputs: bisschen mehr Höhe, klarere Border ---------- */
.form-control,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    transition:
        border-color var(--dur-base) var(--ease-out),
        box-shadow var(--dur-base) var(--ease-out),
        background-color var(--dur-base) var(--ease-out);
}

/* ---------- Skeleton-Loader (universell) ---------- */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--neutral-100) 0%,
        var(--neutral-200) 50%,
        var(--neutral-100) 100%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
}
@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Bild-Ladezustand fuer Angebotskarten ---------- */
.offer-card .card-img-wrap {
    background: var(--neutral-100);
    isolation: isolate;
}
.offer-card .card-image-skeleton {
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: 0;
    transition: opacity 420ms var(--ease-out), visibility 420ms var(--ease-out);
}
.offer-card .smooth-image {
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: scale(1.035);
    filter: saturate(.88);
    transition:
        opacity 520ms var(--ease-out),
        transform 750ms var(--ease-out),
        filter 650ms var(--ease-out);
}
.offer-card .is-image-ready .smooth-image {
    opacity: 1;
    transform: scale(1);
    filter: saturate(1);
}
.offer-card .is-image-ready .card-image-skeleton,
.offer-card .is-image-error .card-image-skeleton {
    opacity: 0;
    visibility: hidden;
}
.offer-card .image-fallback {
    position: absolute;
    inset: 0;
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    transform: scale(.96);
    transition: opacity 350ms var(--ease-out), transform 500ms var(--ease-bounce), visibility 350ms;
}
.offer-card .image-fallback span {
    font-size: 2.8rem;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,.08));
}
.offer-card .is-image-error .smooth-image { display: none; }
.offer-card .is-image-error .image-fallback {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}
.offer-card:hover .is-image-ready .smooth-image { transform: scale(1.055); }

/* Skeleton-Karten spiegeln das echte Layout, damit beim Laden nichts springt. */
.offer-card-skeleton {
    border: 1.5px solid var(--border, var(--neutral-200));
    min-width: 0;
}
.offer-card-skeleton .skeleton-body { min-height: 166px; }
.offer-card-skeleton .skeleton-tag { width: 36%; height: 18px; border-radius: 999px; }
.offer-card-skeleton .skeleton-title { width: 86%; height: 14px; margin-top: 12px; }
.offer-card-skeleton .skeleton-copy { width: 68%; height: 12px; }
.offer-card-skeleton .skeleton-price { width: 48%; height: 22px; margin-top: 18px; margin-bottom: 0; }

/* ---------- Premium Intro-System (orchestriert, einmalig beim Page-Load) ----------
 *
 * Startzustand: alle Elemente warten „hinter der Bühne".
 * polish.js fügt .is-intro-ready zu <body> hinzu, sobald alles bereit ist,
 * dann beginnt die orchestrierte Show.
 * -------------------------------------------------------------------------- */

/* Initialzustand: nichts ist sichtbar */
body:not(.is-intro-ready) .intro-fade,
body:not(.is-intro-ready) .intro-rise,
body:not(.is-intro-ready) .intro-burst,
body:not(.is-intro-ready) .intro-slide-down,
body:not(.is-intro-ready) .intro-slide-up,
body:not(.is-intro-ready) .intro-stagger > * {
    opacity: 0;
}

/* Fade – einfach sanft rein */
.intro-fade {
    transition: opacity 700ms var(--ease-out);
}
body.is-intro-ready .intro-fade { opacity: 1; }

/* Rise – von unten rein, mit leichter Skalierung */
.intro-rise {
    transform: translateY(20px);
    transition: opacity 700ms var(--ease-out), transform 800ms var(--ease-out);
}
body.is-intro-ready .intro-rise {
    opacity: 1;
    transform: translateY(0);
}

/* Burst – das ist der Hero-Moment, mit Bounce */
.intro-burst {
    transform: scale(0.92) translateY(24px);
    transform-origin: center;
    transition: opacity 800ms var(--ease-out), transform 1000ms var(--ease-bounce);
}
body.is-intro-ready .intro-burst {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Slide-Down – Top-Bar */
.intro-slide-down {
    transform: translateY(-100%);
    transition: transform 700ms var(--ease-out);
}
body.is-intro-ready .intro-slide-down {
    transform: translateY(0);
}

/* Slide-Up – Bottom-Nav */
.intro-slide-up {
    transform: translateY(100%);
    transition: transform 800ms var(--ease-bounce);
}
body.is-intro-ready .intro-slide-up {
    transform: translateY(0);
}

/* Stagger – Kinder erscheinen nacheinander.
 * Standard-Delays sind eng gestaffelt für eine schöne Welle.
 * Wer längere/schnellere Stagger möchte: .intro-stagger-fast / .intro-stagger-slow
 */
.intro-stagger > * {
    transform: translateY(16px);
    transition: opacity 600ms var(--ease-out), transform 700ms var(--ease-out);
}
body.is-intro-ready .intro-stagger > * {
    opacity: 1;
    transform: translateY(0);
}
.intro-stagger > *:nth-child(1)  { transition-delay: 0ms; }
.intro-stagger > *:nth-child(2)  { transition-delay: 60ms; }
.intro-stagger > *:nth-child(3)  { transition-delay: 120ms; }
.intro-stagger > *:nth-child(4)  { transition-delay: 180ms; }
.intro-stagger > *:nth-child(5)  { transition-delay: 240ms; }
.intro-stagger > *:nth-child(6)  { transition-delay: 300ms; }
.intro-stagger > *:nth-child(7)  { transition-delay: 360ms; }
.intro-stagger > *:nth-child(8)  { transition-delay: 420ms; }
.intro-stagger > *:nth-child(9)  { transition-delay: 480ms; }
.intro-stagger > *:nth-child(10) { transition-delay: 540ms; }
.intro-stagger > *:nth-child(n+11) { transition-delay: 600ms; }

/* Stagger-Varianten */
.intro-stagger-fast > * { transition-duration: 350ms; }
.intro-stagger-fast > *:nth-child(1)  { transition-delay: 0ms; }
.intro-stagger-fast > *:nth-child(2)  { transition-delay: 40ms; }
.intro-stagger-fast > *:nth-child(3)  { transition-delay: 80ms; }
.intro-stagger-fast > *:nth-child(4)  { transition-delay: 120ms; }
.intro-stagger-fast > *:nth-child(5)  { transition-delay: 160ms; }
.intro-stagger-fast > *:nth-child(6)  { transition-delay: 200ms; }
.intro-stagger-fast > *:nth-child(n+7) { transition-delay: 240ms; }

.intro-stagger-slow > * { transition-duration: 900ms; }
.intro-stagger-slow > *:nth-child(1)  { transition-delay: 0ms; }
.intro-stagger-slow > *:nth-child(2)  { transition-delay: 100ms; }
.intro-stagger-slow > *:nth-child(3)  { transition-delay: 200ms; }
.intro-stagger-slow > *:nth-child(4)  { transition-delay: 300ms; }
.intro-stagger-slow > *:nth-child(5)  { transition-delay: 400ms; }
.intro-stagger-slow > *:nth-child(6)  { transition-delay: 500ms; }
.intro-stagger-slow > *:nth-child(n+7) { transition-delay: 600ms; }

/* Skeleton bekommt eine besonders ruhige, breite Welle */
.offer-card .skeleton,
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(241, 243, 247, 0.5) 0%,
        rgba(231, 234, 240, 0.95) 50%,
        rgba(241, 243, 247, 0.5) 100%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.6s ease-in-out infinite;
}

/* ---------- Reduced Motion respektieren ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal { opacity: 1; transform: none; }
}
