/*
 * EventMatch Bar — schwebende Pille (Look der exhibitly-bar).
 * Akzentfarbe kommt per Inline-Style als CSS-Variable --em-accent.
 */

.em-bar {
    --em-bg: #0b0b0c;
    --em-ink: #f4f4f5;
    --em-muted: rgba(244, 244, 245, 0.55);
    --em-field-bg: rgba(255, 255, 255, 0.06);
    --em-field-border: rgba(255, 255, 255, 0.12);
    --em-accent: #ff2d63;

    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(16px);
    z-index: 2147483000;
    /* width:max-content, sonst begrenzt left:50% die verfügbare Breite auf die halbe
       Viewport-Breite und die Pille bricht um. */
    width: max-content;
    max-width: 95vw;

    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;

    background: var(--em-bg);
    color: var(--em-ink);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.02) inset,
        0 0 32px -8px var(--em-accent);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.2;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s linear 0.35s;
}

.em-bar.em-bar--visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.em-bar.em-bar--hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateX(-50%) translateY(16px) !important;
    pointer-events: none;
}

.em-bar__form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    margin: 0;
}

.em-bar__intro,
.em-bar__connector {
    color: var(--em-ink);
    font-weight: 600;
    white-space: nowrap;
}

.em-bar__connector {
    color: var(--em-muted);
    font-weight: 500;
}

.em-bar__field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--em-field-bg);
    border: 1px solid var(--em-field-border);
    border-radius: 9999px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.em-bar__field:focus-within {
    border-color: var(--em-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--em-accent) 28%, transparent);
}

.em-bar__icon {
    color: var(--em-muted);
    flex: 0 0 auto;
}

.em-bar__field input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--em-ink);
    font: inherit;
    width: 150px;
    max-width: 36vw;
    padding: 0;
    margin: 0;
}

.em-bar__field input::placeholder {
    color: var(--em-muted);
}

.em-bar__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 9999px;
    background: var(--em-accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.em-bar__cta:hover {
    filter: brightness(1.08);
}

.em-bar__cta:active {
    transform: translateY(1px);
}

.em-bar__close {
    position: absolute;
    /* top so weit anheben, dass der Badge oberhalb des CTA-Buttons sitzt und ihn
       nicht überlappt (Pillen-Innenpadding ist 12px → -16px hält den Badge frei). */
    top: -16px;
    right: -8px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9999px;
    background: #1a1a1c;
    color: var(--em-muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.em-bar__close:hover {
    color: var(--em-ink);
    background: #242427;
}

.em-bar__brand {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.4);
    white-space: nowrap;
}

/* Headline + Feld-Labels: nur im aufgeklappten Mobile-Zustand sichtbar (siehe Media-Query). */
.em-bar__headline {
    display: none;
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--em-ink);
}

/* Launcher (mobiler „Journey erstellen"-Button im collapsed-Zustand).
   Auf Desktop ausgeblendet; nur im Mobile-Breakpoint sichtbar. */
.em-bar__launcher {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 13px 22px;
    border: none;
    border-radius: 9999px;
    background: var(--em-accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

/*
 * Mobile: Leiste ist standardmäßig auf den Launcher-Button eingeklappt.
 * Klick auf den Launcher (.em-bar--open) klappt die volle Leiste (Felder + CTA) auf.
 */
@media (max-width: 640px) {
    /* Collapsed: nur der Launcher als kompakte, zentrierte Pille. */
    .em-bar {
        left: 50%;
        right: auto;
        bottom: 16px;
        transform: translateX(-50%) translateY(16px);
        width: max-content;
        max-width: 92vw;
        flex-direction: row;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .em-bar.em-bar--visible {
        transform: translateX(-50%) translateY(0);
    }

    .em-bar.em-bar--hidden {
        transform: translateX(-50%) translateY(16px) !important;
    }

    .em-bar__form,
    .em-bar__brand {
        display: none;
    }

    .em-bar__launcher {
        display: inline-flex;
    }

    /* Expanded: volle Leiste als gestapelte Karte. */
    .em-bar.em-bar--open {
        left: 12px;
        right: 12px;
        bottom: 16px;
        width: auto;
        max-width: none;
        transform: translateY(0);
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 16px;
        background: var(--em-bg);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 20px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 32px -8px var(--em-accent);
    }

    .em-bar--open .em-bar__launcher {
        display: none;
    }

    .em-bar--open .em-bar__form {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .em-bar--open .em-bar__headline {
        display: block;
    }

    .em-bar--open .em-bar__intro,
    .em-bar--open .em-bar__connector {
        display: block;
        font-size: 13px;
        font-weight: 600;
        color: var(--em-muted);
        margin-bottom: -2px;
    }

    .em-bar--open .em-bar__field {
        width: 100%;
    }

    .em-bar--open .em-bar__field input {
        width: 100%;
        max-width: none;
    }

    .em-bar--open .em-bar__cta {
        justify-content: center;
    }

    .em-bar--open .em-bar__brand {
        display: block;
        position: static;
        transform: none;
        text-align: center;
        margin-top: 2px;
    }

    .em-bar__close {
        top: -12px;
        right: -4px;
    }
}

/*
 * Theme-Bleed-Schutz.
 * WordPress-Themes stylen button/input generisch (oft mit !important und hoher
 * Spezifität). Damit die Leiste in jedem Theme korrekt aussieht, überschreiben
 * wir die kritischen Eigenschaften gezielt mit ID-Spezifität (#em-bar) + !important.
 */
#em-bar,
#em-bar *,
#em-bar *::before,
#em-bar *::after {
    box-sizing: border-box;
}

/* Eingabefelder: transparent + helle Schrift + sichtbare Platzhalter erzwingen. */
#em-bar .em-bar__field input {
    background: transparent !important;
    color: var(--em-ink) !important;
    -webkit-text-fill-color: var(--em-ink) !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 15px !important;
    line-height: 1.25 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

#em-bar .em-bar__field input::placeholder {
    color: var(--em-muted) !important;
    -webkit-text-fill-color: var(--em-muted) !important;
    opacity: 1 !important;
}

/* Schließen-Badge: feste Größe + dunkler Grund, damit das Theme-Button-Styling
   (Padding/Farbe) ihn nicht aufbläht und der × zentriert bleibt. */
#em-bar .em-bar__close {
    width: 28px !important;
    height: 28px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #1a1a1c !important;
    color: var(--em-muted) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 9999px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-transform: none !important;
    box-shadow: none !important;
}

#em-bar .em-bar__close:hover {
    background: #242427 !important;
    color: var(--em-ink) !important;
}

/* CTA-Button: eigenes Aussehen gegen Theme-Button durchsetzen.
   display:inline-flex + align-items:center ERZWINGEN, sonst macht das Theme den
   Button zu display:block und Icon/Text richten sich per Baseline aus (Versatz). */
#em-bar .em-bar__cta {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background: var(--em-accent) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 9999px !important;
    margin: 0 !important;
    padding: 11px 20px !important;
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    line-height: 1.2 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-shadow: none !important;
}

/* SVG-Icon im CTA/Launcher als zentriertes Flex-Item (kein Baseline-Versatz). */
#em-bar .em-bar__cta svg,
#em-bar .em-bar__launcher svg {
    flex: 0 0 auto !important;
    vertical-align: middle !important;
}

/* Launcher-Button (Mobile) ebenfalls gegen Theme-Button härten (Optik).
   align-items/gap erzwingen, damit Icon + Text zentriert ausgerichtet bleiben. */
#em-bar .em-bar__launcher {
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background: var(--em-accent) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 9999px !important;
    margin: 0 !important;
    padding: 13px 22px !important;
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    line-height: 1.2 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-shadow: 0 8px 24px -6px var(--em-accent) !important;
}

/*
 * Display-Steuerung je Zustand — MUSS nach dem Härtungsblock stehen, damit sie
 * theme-`button`-Regeln UND das `display:inline-flex !important` der Close-Härtung
 * schlägt. Wichtig: Auf Desktop MUSS der Launcher aus sein (sonst erscheint durch
 * Theme-Bleed ein zweiter „Journey erstellen"-Button neben dem CTA).
 */
#em-bar .em-bar__launcher {
    display: none !important;
}

@media (max-width: 640px) {
    #em-bar:not(.em-bar--open) .em-bar__launcher {
        display: inline-flex !important;
    }

    #em-bar.em-bar--open .em-bar__launcher {
        display: none !important;
    }

    #em-bar:not(.em-bar--open) .em-bar__close {
        display: none !important;
    }
}
