/* ============================================================
   Life Design Popup - Frontend Styles
   ============================================================ */

.ldpm-container {
    /* Startet sofort, laeuft weich aus. Die eingebauten Browser-Kurven sind
       dafuer zu weich, das Popup wirkt damit traege. */
    --ldpm-ease: cubic-bezier(0.23, 1, 0.32, 1);
    --ldpm-in: 260ms;
    --ldpm-out: 180ms;
    --ldpm-z-overlay: 99998;
    --ldpm-z-popup: 99999;
    --ldpm-z-button: 99990;
    font-family: inherit;
}

/* ============================================================
   Overlay
   ============================================================ */
.ldpm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--ldpm-z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ldpm-out) var(--ldpm-ease), visibility 0s linear var(--ldpm-out);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.ldpm-overlay.ldpm-active {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--ldpm-in) var(--ldpm-ease);
}

/* ============================================================
   Popup Base
   ============================================================ */
.ldpm-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: var(--ldpm-z-popup);
    /* vh als Fallback, dvh berücksichtigt dynamische Browser-UI (iOS Safari etc.) */
    max-height: 90vh;
    max-height: 90dvh;
    width: 90%;
    box-shadow: 0 25px 60px rgba(0,0,0,0.25), 0 10px 30px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    /* overflow handled by ldpm-popup-body — popup itself clips */
    overflow: hidden;
    /* flex column: close button stays on top, body scrolls */
    display: flex;
    flex-direction: column;
    transition: opacity var(--ldpm-out) var(--ldpm-ease), transform var(--ldpm-out) var(--ldpm-ease), visibility 0s linear var(--ldpm-out);
    box-sizing: border-box;
    line-height: 1.6;
}

.ldpm-popup * {
    box-sizing: border-box;
}

/* Scrollable body inside popup */
.ldpm-popup-body {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    flex: 1;
    min-height: 0;
    padding: var(--ldpm-content-padding, 40px);
    /* ensure content never hides behind the close button */
    padding-top: max(var(--ldpm-content-padding, 40px), calc(14px + var(--ldpm-close-size, 38px) + 10px));
    position: relative;
    /* iOS Momentum-Scroll */
    -webkit-overflow-scrolling: touch;
    /* Touch-Events fürs Scrollen explizit erlauben — Page-Builder JS schluckt sonst manchmal Touch-Events */
    touch-action: pan-y;
}

/* ============================================================
   Page-Builder-Schutz im Popup-Inhalt
   Verhindert dass injected Page-Builder-Markup (Elementor, Divi, Bricks…)
   das Popup-Layout sprengt oder Scrolling blockiert.
   Wir greifen NUR sticky/fixed-Elemente und Full-Width-Container an —
   alles andere bleibt unverändert.
   ============================================================ */

/* Sticky/Fixed-Elemente (Sticky-Header, Sticky-Sidebars, Back-to-Top-Buttons aus Builder-Templates)
   innerhalb des Popups in den normalen Fluss zwingen, sonst blockieren sie Scroll/X-Button */
.ldpm-popup-body [style*="position: fixed"],
.ldpm-popup-body [style*="position:fixed"],
.ldpm-popup-body [style*="position: sticky"],
.ldpm-popup-body [style*="position:sticky"],
.ldpm-popup-body .elementor-sticky,
.ldpm-popup-body [data-sticky],
.ldpm-popup-body [data-elementor-sticky] {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    transform: none !important;
}

/* Inhalts-Elemente sollen sich in die Popup-Breite einfügen */
.ldpm-popup-body img,
.ldpm-popup-body video,
.ldpm-popup-body iframe {
    max-width: 100% !important;
}

/* Full-Width / Stretched-Sections von Page-Buildern eindämmen */
.ldpm-popup-body .elementor-section-stretched,
.ldpm-popup-body .alignfull,
.ldpm-popup-body .alignwide {
    width: auto !important;
    left: auto !important;
    right: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: none !important;
}

/* Page-Builder-Wrapper, die 100vh erzwingen (Hero-Sections), neutralisieren —
   sonst füllt eine einzige Section das ganze Popup und der Rest ist unscrollbar */
.ldpm-popup-body [style*="100vh"],
.ldpm-popup-body [style*="height: 100v"],
.ldpm-popup-body [style*="height:100v"],
.ldpm-popup-body [style*="min-height: 100v"],
.ldpm-popup-body [style*="min-height:100v"] {
    height: auto !important;
    min-height: 0 !important;
}

/* Scroll indicator: Pfeil am unteren Rand */
.ldpm-popup::before {
    content: '';
    position: absolute;
    bottom: 14px;
    left: 50%;
    width: 16px;
    height: 16px;
    border-right: 3px solid rgba(0, 0, 0, 0.4);
    border-bottom: 3px solid rgba(0, 0, 0, 0.4);
    transform: translateX(-50%) rotate(45deg);
    pointer-events: none;
    z-index: 7;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 1px;
}

.ldpm-popup.ldpm-scrollable::before {
    opacity: 1;
}

.ldpm-popup.ldpm-at-bottom::before {
    opacity: 0;
}

.ldpm-popup.ldpm-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    transition: opacity var(--ldpm-in) var(--ldpm-ease), transform var(--ldpm-in) var(--ldpm-ease);
}

/* Sizes */
.ldpm-size-small      { max-width: 400px; }
.ldpm-size-medium     { max-width: 600px; }
.ldpm-size-large      { max-width: 800px; }
.ldpm-size-xlarge     { max-width: 1000px; }
.ldpm-size-fullscreen {
    max-width: 95vw;
    width: 95vw;
    max-height: 95vh;
    max-height: 95dvh;
}

/* ============================================================
   Animations
   ============================================================ */
.ldpm-anim-none.ldpm-popup {
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
    transform: translate(-50%, -50%);
}
.ldpm-anim-none.ldpm-popup.ldpm-active {
    transform: translate(-50%, -50%);
}

.ldpm-anim-slide-up.ldpm-popup {
    transform: translate(-50%, calc(-50% + 40px));
}
.ldpm-anim-slide-up.ldpm-popup.ldpm-active {
    transform: translate(-50%, -50%);
}

.ldpm-anim-slide-down.ldpm-popup {
    transform: translate(-50%, calc(-50% - 40px));
}
.ldpm-anim-slide-down.ldpm-popup.ldpm-active {
    transform: translate(-50%, -50%);
}

.ldpm-anim-zoom.ldpm-popup {
    transform: translate(-50%, -50%) scale(0.92);
}
.ldpm-anim-zoom.ldpm-popup.ldpm-active {
    transform: translate(-50%, -50%) scale(1);
}

/* ============================================================
   Close Button
   ============================================================ */
.ldpm-close {
    /* Sits above the scrollable body — always visible */
    position: absolute;
    top: 14px;
    right: 14px;
    width: var(--ldpm-close-size, 38px);
    height: var(--ldpm-close-size, 38px);
    flex-shrink: 0;
    border: none;
    background: var(--ldpm-close-bg, #eeeeee);
    color: var(--ldpm-close-color, #444444);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, opacity 0.18s ease;
    padding: 0;
    z-index: 10;
    opacity: 0.8;
}

.ldpm-close:hover {
    opacity: 1;
    filter: brightness(0.9);
}

.ldpm-close:focus {
    outline: 2px solid var(--ldpm-close-color, #444444);
    outline-offset: 2px;
}

/* CSS-gezeichnetes X-Symbol */
.ldpm-close-icon {
    position: relative;
    display: block;
    width: 45%;
    height: 45%;
}

.ldpm-close-icon::before,
.ldpm-close-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    background: currentColor;
    border-radius: var(--x-radius, 1.5px);
    height: var(--x-thickness, 2px);
    margin-top: calc(var(--x-thickness, 2px) / -2);
}

.ldpm-close-icon::before { transform: rotate(45deg); }
.ldpm-close-icon::after  { transform: rotate(-45deg); }

/* Varianten */
.ldpm-close-icon-thin      .ldpm-close-icon { --x-thickness: 1.5px; --x-radius: 1px; }
.ldpm-close-icon-normal    .ldpm-close-icon { --x-thickness: 2px;   --x-radius: 1.5px; }
.ldpm-close-icon-bold      .ldpm-close-icon { --x-thickness: 3.5px; --x-radius: 2px; }
.ldpm-close-icon-sharp     .ldpm-close-icon { --x-thickness: 2px;   --x-radius: 0; }
.ldpm-close-icon-bold-sharp .ldpm-close-icon { --x-thickness: 4px;  --x-radius: 0; }

/* ============================================================
   Content
   ============================================================ */
.ldpm-content {
    max-width: 100%;
}

.ldpm-content img {
    max-width: 100%;
    height: auto;
}

.ldpm-content h1,
.ldpm-content h2,
.ldpm-content h3 {
    margin-top: 0;
}

/* Links im Popup erben die Textfarbe. Bausteine bringen ihre eigene Farbe mit
   (z.B. der Button), die darf diese Regel nicht überschreiben. */
.ldpm-content a:not(.ldpm-b-button) {
    color: inherit;
    text-decoration: underline;
}

.ldpm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Floating Button
   ============================================================ */
.ldpm-floating-button {
    position: fixed;
    z-index: var(--ldpm-z-button);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s var(--ldpm-ease, cubic-bezier(0.23, 1, 0.32, 1)), box-shadow 0.2s ease, opacity 0.2s ease, visibility 0s;
    line-height: 1;
    text-decoration: none;
    opacity: 1;
    visibility: visible;
}

.ldpm-floating-button.ldpm-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.ldpm-floating-button:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .ldpm-floating-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 28px rgba(0,0,0,0.25), 0 4px 10px rgba(0,0,0,0.15);
        filter: brightness(1.08);
    }
    /* Der Druck gewinnt gegen den Hover, sonst federt der Knopf beim Klicken nach oben. */
    .ldpm-floating-button:hover:active {
        transform: scale(0.97);
    }
}

.ldpm-floating-button:focus {
    outline: 3px solid rgba(255,255,255,0.5);
    outline-offset: 2px;
}

/* Positions
   --ldpm-offset-h / --ldpm-offset-v werden über inline-Style vom Plugin gesetzt
   (Defaults 24px, im Admin pro Popup einstellbar). */
.ldpm-pos-bottom-right { bottom: var(--ldpm-offset-v, 24px); right: var(--ldpm-offset-h, 24px); }
.ldpm-pos-bottom-left  { bottom: var(--ldpm-offset-v, 24px); left:  var(--ldpm-offset-h, 24px); }
.ldpm-pos-top-right    { top:    var(--ldpm-offset-v, 24px); right: var(--ldpm-offset-h, 24px); }
.ldpm-pos-top-left     { top:    var(--ldpm-offset-v, 24px); left:  var(--ldpm-offset-h, 24px); }
.ldpm-pos-middle-right { top: 50%; right: var(--ldpm-offset-h, 24px); transform: translateY(-50%); }
.ldpm-pos-middle-left  { top: 50%; left:  var(--ldpm-offset-h, 24px); transform: translateY(-50%); }

.ldpm-pos-middle-right:hover,
.ldpm-pos-middle-left:hover {
    transform: translateY(-50%) translateX(var(--ldpm-pull, -4px));
}
.ldpm-pos-middle-right { --ldpm-pull: -4px; }
.ldpm-pos-middle-left  { --ldpm-pull: 4px; }

/* Sizes */
.ldpm-btnsize-small  { padding: 10px 18px; font-size: 13px; }
.ldpm-btnsize-medium { padding: 14px 22px; font-size: 15px; }
.ldpm-btnsize-large  { padding: 18px 28px; font-size: 17px; }

/* Shapes */
.ldpm-shape-pill    { border-radius: 999px; }
.ldpm-shape-rounded { border-radius: 10px; }
.ldpm-shape-circle  {
    border-radius: 50%;
    padding: 0;
    width: 60px;
    height: 60px;
    aspect-ratio: 1;
}
.ldpm-shape-circle.ldpm-btnsize-small  { width: 48px; height: 48px; font-size: 18px; }
.ldpm-shape-circle.ldpm-btnsize-medium { width: 60px; height: 60px; font-size: 22px; }
.ldpm-shape-circle.ldpm-btnsize-large  { width: 72px; height: 72px; font-size: 26px; }

/* Pulse animation */
.ldpm-pulse::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    z-index: -1;
    animation: ldpm-pulse-anim 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes ldpm-pulse-anim {
    0%   { transform: scale(1); opacity: 0.7; }
    70%  { transform: scale(1.3); opacity: 0; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* Prevent body scroll when popup is open */
body.ldpm-popup-open {
    overflow: hidden;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .ldpm-popup {
        width: 95%;
        /* Fallback für ältere Browser */
        max-height: 88vh;
        /* dvh berücksichtigt iOS-Browser-UI; Safe-Area + Puffer für X-Button */
        max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
        border-radius: 16px !important;
        --ldpm-content-padding: 24px;
    }

    .ldpm-size-fullscreen {
        width: 100vw;
        max-width: 100vw;
        /* Fallback */
        max-height: 100vh;
        height: 100vh;
        /* dvh: keine Lücke, kein Überlauf bei dynamischer Browser-UI */
        max-height: 100dvh;
        height: 100dvh;
        top: 0;
        left: 0;
        transform: none !important;
        border-radius: 0 !important;
        /* Safe-Area-Insets: X-Button & Inhalt kommen nicht hinter Notch/Home-Indicator */
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .ldpm-size-fullscreen.ldpm-active {
        transform: none !important;
    }

    /* Auf Mobile: User-Offsets respektieren, aber Mobile-Default ist 16 statt 24 */
    .ldpm-pos-bottom-right,
    .ldpm-pos-bottom-left { bottom: var(--ldpm-offset-v, 16px); }
    .ldpm-pos-bottom-right { right: var(--ldpm-offset-h, 16px); }
    .ldpm-pos-bottom-left  { left:  var(--ldpm-offset-h, 16px); }
    .ldpm-pos-top-right,
    .ldpm-pos-top-left { top: var(--ldpm-offset-v, 16px); }
    .ldpm-pos-top-right { right: var(--ldpm-offset-h, 16px); }
    .ldpm-pos-top-left  { left:  var(--ldpm-offset-h, 16px); }

    /* Auf Mobile etwas kleiner */
    .ldpm-btnsize-large {
        padding: 14px 22px;
        font-size: 15px;
    }
    .ldpm-shape-circle.ldpm-btnsize-large {
        width: 60px;
        height: 60px;
    }

    .ldpm-close {
        /* +Safe-Area, damit der X-Button im Fullscreen-Modus nicht hinter dem iPhone-Notch sitzt */
        top: calc(10px + env(safe-area-inset-top, 0px));
        right: calc(10px + env(safe-area-inset-right, 0px));
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    /* Im Nicht-Fullscreen-Popup wird der Body schon durch den Container begrenzt –
       hier reicht der normale Abstand, sonst gibt's eine Doppel-Lücke. */
    .ldpm-popup:not(.ldpm-size-fullscreen) .ldpm-close {
        top: 10px;
        right: 10px;
    }
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
    .ldpm-popup,
    .ldpm-overlay,
    .ldpm-floating-button {
        transition: opacity 0.15s ease !important;
    }
    .ldpm-pulse::before,
    .ldpm-popup.ldpm-scrollable:not(.ldpm-at-bottom)::before {
        animation: none !important;
    }
}

/* ============================================================
   Baukasten-Inhalte
   Die Bausteine erben Schrift und Farbe vom Popup. Alles hier setzt
   nur Rhythmus und Proportion, keine eigenen Farbwelten.
   ============================================================ */
.ldpm-blocks {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
}

.ldpm-blocks > .ldpm-b { margin: 0; }
.ldpm-blocks > .ldpm-b + .ldpm-b { margin-top: 16px; }

/* Überschrift und der Text darunter gehören optisch zusammen */
.ldpm-blocks > .ldpm-b-heading + .ldpm-b-text { margin-top: 8px; }
.ldpm-blocks > .ldpm-b + .ldpm-b-heading { margin-top: 26px; }

.ldpm-b-align-left   { text-align: left; }
.ldpm-b-align-center { text-align: center; }
.ldpm-b-align-right  { text-align: right; }

/* --- Überschrift --- */
.ldpm-b-heading {
    margin: 0;
    color: inherit;
    font-weight: 700;
    line-height: 1.22;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

h2.ldpm-b-heading { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); }
h3.ldpm-b-heading { font-size: clamp(1.15rem, 1rem + 0.6vw, 1.35rem); }
h4.ldpm-b-heading { font-size: 1.05rem; letter-spacing: 0; }

/* --- Text --- */
.ldpm-b-text {
    font-size: 1rem;
    line-height: 1.65;
    color: inherit;
}

.ldpm-b-text > :first-child { margin-top: 0; }
.ldpm-b-text > :last-child { margin-bottom: 0; }
.ldpm-b-text p { margin: 0 0 0.85em; }
.ldpm-b-text ul,
.ldpm-b-text ol { margin: 0 0 0.85em; padding-left: 1.35em; }
.ldpm-b-text li { margin-bottom: 0.35em; }

.ldpm-b-text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
    text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
    transition: text-decoration-color 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .ldpm-b-text a:hover { text-decoration-color: currentColor; }
}

/* --- Bild --- */
.ldpm-b-image {
    margin: 0;
    line-height: 0;
}

.ldpm-b-image-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

.ldpm-b-w-full  .ldpm-b-image-img { width: 100%; }
.ldpm-b-w-half  .ldpm-b-image-img { width: 60%; }
.ldpm-b-w-small .ldpm-b-image-img { width: 38%; }

.ldpm-b-image.ldpm-b-align-center .ldpm-b-image-img { margin-inline: auto; }
.ldpm-b-image.ldpm-b-align-right  .ldpm-b-image-img { margin-inline-start: auto; }

.ldpm-b-shape-rounded .ldpm-b-image-img { border-radius: 12px; }
.ldpm-b-shape-square  .ldpm-b-image-img { border-radius: 0; }
.ldpm-b-shape-circle  .ldpm-b-image-img {
    border-radius: 50%;
    aspect-ratio: 1;
    object-fit: cover;
}

/* --- Button --- */
.ldpm-b-buttonwrap { line-height: 0; }

.ldpm-b-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: 10px;
    font-size: 0.975rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    /* Farben kommen vom Popup, damit Button und schwebender Knopf zusammenpassen */
    background: var(--ldpm-accent, #1f2937);
    color: var(--ldpm-accent-contrast, #ffffff);
    border: 1.5px solid transparent;
    transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.16s cubic-bezier(0.23, 1, 0.32, 1), background-color 0.16s ease, color 0.16s ease;
}

.ldpm-b-button-outline {
    background: transparent;
    color: inherit;
    border-color: color-mix(in srgb, currentColor 35%, transparent);
}

.ldpm-b-button-link {
    background: transparent;
    color: inherit;
    border-color: transparent;
    padding: 4px 0;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

@media (hover: hover) and (pointer: fine) {
    .ldpm-b-button:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16); }
    .ldpm-b-button-outline:hover { border-color: currentColor; box-shadow: none; }
    .ldpm-b-button-link:hover { box-shadow: none; }
}

.ldpm-b-button:active { transform: scale(0.97); }

/* --- Trennlinie und Abstand --- */
.ldpm-b-divider {
    border: 0;
    border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent);
    margin-block: 4px;
}

.ldpm-b-spacer-s { height: 8px; }
.ldpm-b-spacer-m { height: 20px; }
.ldpm-b-spacer-l { height: 40px; }

@media (max-width: 520px) {
    .ldpm-b-w-half  .ldpm-b-image-img,
    .ldpm-b-w-small .ldpm-b-image-img { width: 100%; }
    .ldpm-b-button { width: 100%; }
    .ldpm-b-buttonwrap.ldpm-b-align-center .ldpm-b-button,
    .ldpm-b-buttonwrap.ldpm-b-align-right  .ldpm-b-button { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .ldpm-b-button:active { transform: none; }
}
