/* TK Wandsimulation */

/*
 * Farben leiten sich aus --tkws-accent ab (Einstellung "Akzentfarbe"), damit
 * dasselbe Plugin auf tapetenmax (Blau), wallcover (Gruen) und papierpeint
 * (Dunkelbraun) passt. Ohne color-mix bleiben die tapetenmax-Toene.
 */
.tkws,
.tkws-trigger,
.tkws-badge {
    --tkws-soft: #eef3f9;
    --tkws-soft-hover: #e3ecf6;
    --tkws-ink: #2c5382;
    --tkws-glow: var(--tkws-glow);
    --tkws-glow-0: var(--tkws-glow-0);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
    .tkws,
    .tkws-trigger,
    .tkws-badge {
        --tkws-soft: color-mix(in srgb, var(--tkws-accent, #3d6ea6) 9%, #fff);
        --tkws-soft-hover: color-mix(in srgb, var(--tkws-accent, #3d6ea6) 15%, #fff);
        --tkws-ink: color-mix(in srgb, var(--tkws-accent, #3d6ea6) 80%, #000);
        --tkws-glow: color-mix(in srgb, var(--tkws-accent, #3d6ea6) 55%, transparent);
        --tkws-glow-0: color-mix(in srgb, var(--tkws-accent, #3d6ea6) 0%, transparent);
    }
}

.tkws-trigger {
    display: none;
    margin: 12px 0;
}

.tkws-trigger.is-placed {
    display: block;
}

.tkws-trigger.is-replacing {
    margin: 0;
}

/* Breite Kachel im Stil der Trust-Box (hellblau wie der ersetzte Block) */
.tkws-trigger .btn.tkws-open {
    display: flex;
    width: 100%;
    min-height: 56px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1.5px solid var(--tkws-soft);
    border-radius: 10px;
    background: var(--tkws-soft);
    color: var(--tkws-ink);
    font-weight: 700;
    letter-spacing: .45px;
    white-space: normal;
    box-shadow: none;
}

.tkws-trigger .btn.tkws-open:hover,
.tkws-trigger .btn.tkws-open:focus-visible {
    border-color: var(--tkws-accent, #3d6ea6);
    background: var(--tkws-soft-hover);
    color: var(--tkws-ink);
}

.tkws-icon {
    flex: 0 0 auto;
}

.tkws-trigger__hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}

/* Overlay im Artikelbild */

.tkws-badge {
    display: none;
}

.tkws-badge.is-placed {
    --tkws-edge: 16px;
    position: absolute;
    z-index: 5;
    display: block;
    max-width: calc(100% - 2 * var(--tkws-edge));
}

/* Position im Bild (Einstellung "Position des Overlays im Bild") */
.tkws-badge--bottom-left.is-placed { left: var(--tkws-edge); bottom: var(--tkws-edge); }
.tkws-badge--bottom-right.is-placed { right: var(--tkws-edge); bottom: var(--tkws-edge); }
.tkws-badge--top-left.is-placed { left: var(--tkws-edge); top: var(--tkws-edge); }
.tkws-badge--top-right.is-placed { right: var(--tkws-edge); top: var(--tkws-edge); }
.tkws-badge--middle-left.is-placed { left: var(--tkws-edge); top: 50%; transform: translateY(-50%); }
.tkws-badge--middle-right.is-placed { right: var(--tkws-edge); top: 50%; transform: translateY(-50%); }

.tkws-badge--bottom-center.is-placed,
.tkws-badge--top-center.is-placed,
.tkws-badge--center.is-placed {
    left: 50%;
    width: max-content;
    transform: translateX(-50%);
}

.tkws-badge--bottom-center.is-placed { bottom: var(--tkws-edge); }
.tkws-badge--top-center.is-placed { top: var(--tkws-edge); }
.tkws-badge--center.is-placed { top: 50%; transform: translate(-50%, -50%); }

.tkws-badge__open {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    padding: 6px 16px 6px 6px;
    border: 0;
    border-radius: 999px;
    background: var(--tkws-badge-bg, rgba(255, 255, 255, .95));
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 20px rgba(17, 24, 39, .18);
    color: #1f2937;
    font: inherit;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}

.tkws-badge__open:hover,
.tkws-badge__open:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(17, 24, 39, .24);
    outline: none;
}

/* X oben rechts an der Pille */
.tkws-badge__close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #374151;
    box-shadow: 0 2px 6px rgba(17, 24, 39, .25);
    color: #fff;
    font-size: 16px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
}

/* Groessere Trefferflaeche fuer Finger, ohne das X groesser zu zeichnen */
.tkws-badge__close::before {
    content: "";
    position: absolute;
    inset: -10px;
}

.tkws-badge__close:hover {
    background: #111827;
}

.tkws-badge__icon {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--tkws-accent, #3d6ea6);
    color: #fff;
}

/* Dreimal sanft pulsieren, dann Ruhe */
.tkws-badge__icon::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    animation: tkws-pulse 2.4s ease-out 1s 3;
}

@keyframes tkws-pulse {
    0% { box-shadow: 0 0 0 0 var(--tkws-glow); }
    70% { box-shadow: 0 0 0 12px var(--tkws-glow-0); }
    100% { box-shadow: 0 0 0 0 var(--tkws-glow-0); }
}

@media (prefers-reduced-motion: reduce) {
    .tkws-badge__icon::after {
        animation: none;
    }
}

.tkws-badge__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tkws-badge__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--tkws-ink);
}

.tkws-badge__sub {
    margin-top: 2px;
    font-size: 12px;
    color: #6b7280;
}

@media (max-width: 575.98px) {
    .tkws-badge.is-placed {
        --tkws-edge: 10px;
    }

    .tkws-badge__open {
        gap: 8px;
        padding: 5px 12px 5px 5px;
    }

    .tkws-badge__icon {
        width: 34px;
        height: 34px;
    }

    .tkws-badge__title {
        font-size: 13px;
    }

    .tkws-badge__sub {
        font-size: 11px;
    }
}

html.tkws-locked,
html.tkws-locked body {
    overflow: hidden;
}

/* Overlay */

.tkws-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    color: #1f2937;
    background: #fff;
    overflow: auto;
}

.tkws-dialog::backdrop {
    background: rgba(17, 24, 39, .55);
}

.tkws-dialog--fallback {
    position: fixed;
    inset: 16px;
    margin: auto;
    z-index: 100000;
}

.tkws-dialog__inner {
    position: relative;
    padding: 28px 24px 24px;
}

.tkws-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
}

.tkws-close:hover {
    color: #111827;
}

.tkws-title {
    margin: 0 32px 8px 0;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
}

.tkws-title:focus {
    outline: none;
}

.tkws-intro {
    margin: 0 0 18px;
    font-size: 15px;
    line-height: 1.5;
    color: #4b5563;
}

.tkws-field {
    margin-bottom: 14px;
}

.tkws-label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 600;
}

.tkws-help {
    margin: 6px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: #6b7280;
}

.tkws .form-control.is-invalid {
    border-color: #c0392b;
}

/* Fotokacheln */

.tkws-photos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.tkws-photo,
.tkws-add {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
}

.tkws-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tkws-photo__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 24, 39, .7);
    color: #fff;
    font-size: 18px;
    line-height: 28px;
    padding: 0;
    cursor: pointer;
}

.tkws-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0;
    border: 2px dashed var(--tkws-accent, #3d6ea6);
    background: var(--tkws-soft);
    color: var(--tkws-accent, #3d6ea6);
    text-align: center;
    cursor: pointer;
}

/* Nur ein Foto: eine breite Kachel statt drei kleiner */
.tkws-photos--single {
    grid-template-columns: 1fr;
}

.tkws-photos--single .tkws-photo,
.tkws-photos--single .tkws-add {
    aspect-ratio: 16 / 9;
}

.tkws-photos--single .tkws-photo img {
    object-fit: contain;
    background: #f3f4f6;
}

.tkws-add[hidden] {
    display: none;
}

.tkws-add:hover,
.tkws-add:focus-within {
    background: var(--tkws-soft-hover);
}

.tkws-add .tkws-file {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.tkws-add__plus {
    font-size: 30px;
    line-height: 1;
    font-weight: 300;
}

.tkws-add__text {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.tkws-add.is-busy {
    pointer-events: none;
    opacity: .6;
}

.tkws-add.is-busy .tkws-add__plus {
    animation: tkws-spin 1s linear infinite;
}

@keyframes tkws-spin {
    to { transform: rotate(360deg); }
}

/* Einwilligung, Fehler, Absenden */

.tkws-consent {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 4px 0 14px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
    color: #4b5563;
    cursor: pointer;
}

.tkws-consent input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--tkws-accent, #3d6ea6);
}

.tkws-newsletter {
    margin-top: -6px;
}

.tkws-consent.is-invalid {
    color: #c0392b;
}

.tkws-consent a {
    text-decoration: underline;
}

.tkws-limit {
    margin: 0 0 14px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--tkws-soft);
    color: var(--tkws-ink);
    font-size: 13px;
    line-height: 1.45;
}

.tkws-error {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 6px;
    background: #fdecea;
    color: #8a1f12;
    font-size: 14px;
}

.tkws-error[hidden],
.tkws-step[hidden] {
    display: none;
}

.tkws-submit[disabled] {
    opacity: .7;
    cursor: progress;
}

/* Bestaetigung */

.tkws-step--done {
    padding: 12px 0 4px;
    text-align: center;
}

.tkws-step--done .tkws-title {
    margin-right: 0;
}

.tkws-done__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--tkws-soft-hover);
    color: var(--tkws-accent, #3d6ea6);
}

/* Mobil: Overlay als Vollbild-Blatt */

@media (max-width: 575.98px) {
    .tkws-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }

    .tkws-dialog__inner {
        padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    }

    .tkws-title {
        font-size: 20px;
    }

    .tkws-dialog input.form-control,
    .tkws-dialog textarea.form-control {
        font-size: 16px; /* verhindert Zoom in iOS */
    }
}
