/* Messenger-Kontaktlayer (me_messenger) – m-edia.com */

.mem {
    --mem-size: var(--mem-m-size, 52px);
    --mem-x: var(--mem-m-x, 16px);
    --mem-y: var(--mem-m-y, 16px);
    --mem-gap: var(--mem-m-gap, 10px);
    --mem-ink: #1c1c1c;
    --mem-muted: #5c5c5c;
    --mem-line: #d4d4d4;

    position: fixed;
    bottom: calc(var(--mem-y) + env(safe-area-inset-bottom, 0px));
    z-index: 1040;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: inherit;
    line-height: 1.4;
    pointer-events: none;
}

.mem > * {
    pointer-events: auto;
}

/* Position mobil */
.mem--m-right { right: var(--mem-x); left: auto; align-items: flex-end; }
.mem--m-left  { left: var(--mem-x); right: auto; align-items: flex-start; }
.mem--m-hide  { display: none; }

/* Buttons: WhatsApp steht immer der Ecke am nächsten */
.mem__stack {
    display: flex;
    flex-direction: column;
    gap: var(--mem-gap);
}
.mem--m-row .mem__stack { flex-direction: row; }
.mem--m-row.mem--m-left .mem__stack { flex-direction: row-reverse; }

.mem__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--mem-size);
    height: var(--mem-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18), 0 6px 16px rgba(0, 0, 0, .12);
    transition: transform .15s ease;
    text-decoration: none;
}
.mem__btn--wa { background: var(--mem-wa, #25D366); }
.mem__btn--fb { background: var(--mem-fb, #0866FF); }
.mem__btn:hover { transform: scale(1.06); color: #fff; }
.mem__btn:focus-visible,
.mem__close:focus-visible,
.mem__send:focus-visible {
    outline: 3px solid var(--mem-ink);
    outline-offset: 3px;
}

.mem__icon {
    width: 56%;
    height: 56%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.mem__icon .mem__icon-fill { fill: currentColor; stroke: none; }
.mem__icon--img { stroke: none; object-fit: contain; }

/* Nachrichtenbox */
.mem__box {
    box-sizing: border-box;
    width: min(320px, calc(100vw - 2 * var(--mem-x)));
    padding: 16px;
    background: #fff;
    color: var(--mem-ink);
    border-radius: 12px;
    border-top: 4px solid var(--mem-wa, #25D366);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12), 0 16px 40px rgba(0, 0, 0, .16);
    animation: mem-in .16s ease-out;
}
.mem__box[hidden] { display: none; }

.mem__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.mem__title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.3;
}
.mem__close {
    flex: 0 0 auto;
    display: inline-flex;
    width: 32px;
    height: 32px;
    margin: -6px -6px 0 0;
    padding: 6px;
    background: transparent;
    border: 0;
    border-radius: 50%;
    color: var(--mem-muted);
    cursor: pointer;
}
.mem__close:hover { background: #f0f0f0; color: var(--mem-ink); }
.mem__close svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.mem__text {
    margin: 0 0 12px;
    font-size: .9375rem;
    color: var(--mem-muted);
}
.mem__label {
    display: block;
    margin-bottom: 4px;
    font-size: .8125rem;
    font-weight: 600;
}
.mem__msg {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-height: 88px;
    padding: 8px 10px;
    font: inherit;
    font-size: 1rem; /* verhindert Auto-Zoom auf iOS */
    color: var(--mem-ink);
    background: #fff;
    border: 1px solid var(--mem-line);
    border-radius: 8px;
    resize: vertical;
}
.mem__msg:focus {
    outline: none;
    border-color: var(--mem-ink);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .12);
}
/* Senden-Button ist ein Link (target=_blank) */
.mem__send {
    box-sizing: border-box;
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px 14px;
    font: inherit;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    color: #06371a;
    background: var(--mem-wa, #25D366);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
.mem__send:hover,
.mem__send:focus {
    color: #06371a;
    text-decoration: none;
    filter: brightness(.95);
}
.mem__hint {
    margin: 8px 0 0;
    font-size: .75rem;
    color: var(--mem-muted);
}

@keyframes mem-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* Desktop */
@media (min-width: 768px) {
    .mem {
        --mem-size: var(--mem-d-size, 56px);
        --mem-x: var(--mem-d-x, 24px);
        --mem-y: var(--mem-d-y, 24px);
        --mem-gap: var(--mem-d-gap, 12px);
    }
    .mem--m-hide { display: flex; }
    .mem--d-hide { display: none; }

    .mem--d-right { right: var(--mem-x); left: auto; align-items: flex-end; }
    .mem--d-left  { left: var(--mem-x); right: auto; align-items: flex-start; }

    .mem.mem--d-col .mem__stack { flex-direction: column; }
    .mem.mem--d-row .mem__stack { flex-direction: row; }
    .mem.mem--d-row.mem--d-left .mem__stack { flex-direction: row-reverse; }
}

@media (prefers-reduced-motion: reduce) {
    .mem__btn { transition: none; }
    .mem__btn:hover { transform: none; }
    .mem__box { animation: none; }
}

@media print {
    .mem { display: none !important; }
}
