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

.ldp-container {
    --ldp-z-overlay: 99998;
    --ldp-z-popup: 99999;
    --ldp-z-button: 99990;
    font-family: inherit;
}

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

.ldp-overlay.ldp-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

/* ============================================================
   Popup Base
   ============================================================ */
.ldp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: var(--ldp-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 ldp-popup-body — popup itself clips */
    overflow: hidden;
    /* flex column: close button stays on top, body scrolls */
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s linear 0.3s;
    box-sizing: border-box;
    line-height: 1.6;
}

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

/* Scrollable body inside popup */
.ldp-popup-body {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    flex: 1;
    min-height: 0;
    padding: var(--ldp-content-padding, 40px);
    /* ensure content never hides behind the close button */
    padding-top: max(var(--ldp-content-padding, 40px), calc(14px + var(--ldp-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 */
.ldp-popup-body [style*="position: fixed"],
.ldp-popup-body [style*="position:fixed"],
.ldp-popup-body [style*="position: sticky"],
.ldp-popup-body [style*="position:sticky"],
.ldp-popup-body .elementor-sticky,
.ldp-popup-body [data-sticky],
.ldp-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 */
.ldp-popup-body img,
.ldp-popup-body video,
.ldp-popup-body iframe {
    max-width: 100% !important;
}

/* Full-Width / Stretched-Sections von Page-Buildern eindämmen */
.ldp-popup-body .elementor-section-stretched,
.ldp-popup-body .alignfull,
.ldp-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 */
.ldp-popup-body [style*="100vh"],
.ldp-popup-body [style*="height: 100v"],
.ldp-popup-body [style*="height:100v"],
.ldp-popup-body [style*="min-height: 100v"],
.ldp-popup-body [style*="min-height:100v"] {
    height: auto !important;
    min-height: 0 !important;
}

/* Scroll indicator: Pfeil am unteren Rand */
.ldp-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;
}

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

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

.ldp-popup.ldp-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

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

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

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

/* ============================================================
   Close Button
   ============================================================ */
.ldp-close {
    /* Sits above the scrollable body — always visible */
    position: absolute;
    top: 14px;
    right: 14px;
    width: var(--ldp-close-size, 38px);
    height: var(--ldp-close-size, 38px);
    flex-shrink: 0;
    border: none;
    background: var(--ldp-close-bg, #eeeeee);
    color: var(--ldp-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;
}

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

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

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

.ldp-close-icon::before,
.ldp-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);
}

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

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

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

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

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

.ldp-content a {
    color: inherit;
    text-decoration: underline;
}

.ldp-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
   ============================================================ */
.ldp-floating-button {
    position: fixed;
    z-index: var(--ldp-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: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
    text-decoration: none;
    opacity: 1;
    visibility: visible;
}

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

.ldp-floating-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.25), 0 4px 10px rgba(0,0,0,0.15);
    filter: brightness(1.08);
}

.ldp-floating-button:active {
    transform: translateY(-1px);
}

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

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

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

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

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

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

@keyframes ldp-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.ldp-popup-open {
    overflow: hidden;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .ldp-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;
        --ldp-content-padding: 24px;
    }

    .ldp-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);
    }
    .ldp-size-fullscreen.ldp-active {
        transform: none !important;
    }

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

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

    .ldp-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. */
    .ldp-popup:not(.ldp-size-fullscreen) .ldp-close {
        top: 10px;
        right: 10px;
    }
}

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