/* ==========================================================================
   P4P Product Finder · Globales Popup, schwebender Button, [p4p_finder_btn]
   v3.14.0 – ersetzt das Inline-CSS der Snippets „Floating Finder Widget“
   und „Marken-Finder CTA Button“. Klassen unverändert, damit Theme-CSS
   und die WP-Rocket-Safelist (.p4p-finder-popup(.*)) weiter greifen.
   Zustands-Klassen auf <html>/<body> beginnen ebenfalls mit
   .p4p-finder-popup, damit sie von derselben Safelist erfasst sind.
   ========================================================================== */

/* === Schwebender Button === */
.p4p-finder-widget {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: 349;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    opacity: 0;
    visibility: hidden;
    transform: translateX(140%);
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s linear 0.6s;
    /* Nur der runde Button nimmt Klicks an; die unsichtbare Tooltip-Fläche
       verdeckt sonst Slider-Pfeile u. Ä. (vorher Fix im Theme-CSS der Startseite) */
    pointer-events: none;
}
.p4p-finder-widget .p4p-finder-btn { pointer-events: auto; }
.p4p-finder-widget.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s linear 0s;
}
.p4p-finder-tooltip {
    position: relative;
    background: #0b1117;
    color: #ffffff;
    padding: 9px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.p4p-finder-tooltip::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -5px;
    transform: translateY(-50%);
    border-left: 6px solid #0b1117;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}
.p4p-finder-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #0D83C8 0%, #0AB4FF 100%);
    box-shadow: 0 4px 14px rgba(13, 131, 200, 0.45);
    cursor: pointer;
    border: none;
    flex-shrink: 0;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.p4p-finder-icon {
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}
@media (hover: hover) {
    .p4p-finder-btn:hover {
        transform: scale(1.08);
        box-shadow: 0 6px 22px rgba(10, 180, 255, 0.55);
    }
    .p4p-finder-widget.is-visible:hover .p4p-finder-tooltip {
        opacity: 1;
        transform: translateX(0);
    }
}
.p4p-finder-btn:focus-visible {
    outline: none;
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(10, 180, 255, 0.55);
}
.p4p-finder-widget.is-visible:focus-within .p4p-finder-tooltip {
    opacity: 1;
    transform: translateX(0);
}
.p4p-finder-widget.p4p-finder-hint .p4p-finder-tooltip {
    animation: p4pHintTooltip 2.5s ease forwards;
}
.p4p-finder-widget.p4p-finder-hint .p4p-finder-btn {
    animation: p4pHintPulse 0.55s ease 2;
}
@keyframes p4pHintTooltip {
    0%   { opacity: 0; transform: translateX(8px) scale(0.9); }
    12%  { opacity: 1; transform: translateX(0) scale(1.06); }
    22%  { opacity: 1; transform: translateX(0) scale(1); }
    78%  { opacity: 1; transform: translateX(0) scale(1); }
    100% { opacity: 0; transform: translateX(8px) scale(0.95); }
}
@keyframes p4pHintPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 14px rgba(13, 131, 200, 0.45); }
    50%      { transform: scale(1.13); box-shadow: 0 6px 24px rgba(10, 180, 255, 0.7); }
}

/* === Button [p4p_finder_btn] (Optik wie bisheriges CTA-Snippet) === */
.p4p-cta-wrap { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }
.p4p-cta-wrap--left   { text-align: left; }
.p4p-cta-wrap--center { text-align: center; }
.p4p-cta-wrap--right  { text-align: right; }
.p4p-cta-wrap .p4p-cta-btn,
button.p4p-cta-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, #0D83C8 0%, #0AB4FF 100%) !important;
    background-image: linear-gradient(135deg, #0D83C8 0%, #0AB4FF 100%) !important;
    color: #ffffff !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    padding: 14px 32px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    border: none !important;
    outline: none !important;
    cursor: pointer !important;
    box-shadow: 0 4px 14px rgba(13, 131, 200, 0.45) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    min-height: 0 !important;
    width: auto !important;
    height: auto !important;
}
.p4p-cta-btn::before,
.p4p-cta-btn::after {
    display: none !important;
    content: none !important;
    background: none !important;
}
@media (hover: hover) {
    .p4p-cta-wrap .p4p-cta-btn:hover,
    button.p4p-cta-btn:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 6px 22px rgba(10, 180, 255, 0.55) !important;
        background: linear-gradient(135deg, #0D83C8 0%, #0AB4FF 100%) !important;
        color: #ffffff !important;
    }
}
.p4p-cta-wrap .p4p-cta-btn:focus-visible {
    outline: none !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 0 0 3px rgba(10, 180, 255, 0.35), 0 6px 22px rgba(10, 180, 255, 0.55) !important;
}
.p4p-cta-wrap .p4p-cta-btn:active { transform: translateY(0) !important; }

/* === Popup === */
.p4p-finder-popup {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.p4p-finder-popup[hidden] { display: none; }
.p4p-finder-popup__overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 17, 23, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.p4p-finder-popup.is-open .p4p-finder-popup__overlay { opacity: 1; }
.p4p-finder-popup__dialog {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    max-width: 1024px;
    width: 100%;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.p4p-finder-popup.is-open .p4p-finder-popup__dialog {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.p4p-finder-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    min-height: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #0b1117;
    border: 1px solid #DDE8EF;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.p4p-finder-popup__close:hover,
.p4p-finder-popup__close:focus-visible {
    background: #0D83C8;
    color: #ffffff;
    border-color: #0D83C8;
    outline: none;
    transform: rotate(90deg);
}
.p4p-finder-popup__sr-title {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.p4p-finder-popup__content { padding: 32px; }
.p4p-finder-popup__panel[hidden] { display: none; }
.p4p-finder-popup__loading {
    padding: 48px 0;
    text-align: center;
    color: #3D4558;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Scroll-Sperre (auch iOS): html/body bekommen Klassen mit Popup-Präfix */
html.p4p-finder-popup-locked,
html.p4p-finder-popup-locked body { overflow: hidden !important; }
body.p4p-finder-popup-locked {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
}

/* Mobil (Breakpoint 1024px - WoodMart) */
@media (max-width: 1024px) {
    .p4p-finder-widget {
        right: 12px;
        bottom: 115px;
        gap: 8px;
    }
    .p4p-finder-btn { width: 40px; height: 40px; }
    .p4p-finder-icon { width: 24px; height: 24px; }
    .p4p-finder-tooltip { font-size: 13px; padding: 7px 11px; }

    .p4p-finder-popup { padding: 0; }
    .p4p-finder-popup__dialog {
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
        /* iPhone: 100vh ist bei ausgeklappter Adressleiste zu hoch */
        max-height: 100dvh;
        height: 100dvh;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
    }
    .p4p-finder-popup__close {
        top: calc(env(safe-area-inset-top, 0px) + 12px);
        right: calc(env(safe-area-inset-right, 0px) + 12px);
    }
    .p4p-finder-popup__content {
        padding: 60px 16px 24px;
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .p4p-finder-widget,
    .p4p-finder-btn,
    .p4p-cta-btn,
    .p4p-finder-widget.p4p-finder-hint .p4p-finder-tooltip,
    .p4p-finder-widget.p4p-finder-hint .p4p-finder-btn,
    .p4p-finder-popup__overlay,
    .p4p-finder-popup__dialog {
        animation: none !important;
        transition: opacity 0.2s ease !important;
    }
    .p4p-finder-widget { transform: none !important; }
}

/* ==========================================================================
   v3.14.1 · Theme-Schutz
   WoodMart setzt eigene Button-Stile (Position, Größe, Ecken, Abstände).
   Die folgenden Regeln hängen an den IDs und sind deshalb stärker als jede
   Theme-Regel auf Klassenebene. So bleiben Schließen-Kreuz (oben rechts IM
   Fenster) und runder schwebender Button immer gleich.
   ========================================================================== */
#p4p-finder-widget .p4p-finder-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 50px !important;
    height: 50px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #0D83C8 0%, #0AB4FF 100%) !important;
    line-height: 1 !important;
    overflow: visible !important;
}
#p4p-finder-widget .p4p-finder-icon {
    display: block !important;
    width: 30px !important;
    height: 30px !important;
    max-width: none !important;
    flex: 0 0 auto !important;
}

#p4p-finder-popup .p4p-finder-popup__close {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 5 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid #DDE8EF !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    color: #0b1117 !important;
    box-shadow: 0 2px 8px rgba(11, 17, 23, 0.12) !important;
    line-height: 1 !important;
}
#p4p-finder-popup .p4p-finder-popup__close:hover,
#p4p-finder-popup .p4p-finder-popup__close:focus-visible {
    background: #0b1117 !important;
    color: #ffffff !important;
    border-color: #0b1117 !important;
}
#p4p-finder-popup .p4p-finder-popup__close svg {
    display: block !important;
    width: 18px !important;
    height: 18px !important;
}

@media (max-width: 1024px) {
    #p4p-finder-widget .p4p-finder-btn { width: 40px !important; height: 40px !important; }
    #p4p-finder-widget .p4p-finder-icon { width: 24px !important; height: 24px !important; }
    #p4p-finder-popup .p4p-finder-popup__close {
        top: calc(env(safe-area-inset-top, 0px) + 10px) !important;
        right: calc(env(safe-area-inset-right, 0px) + 10px) !important;
        width: 44px !important;
        height: 44px !important;
    }
}

/* ==========================================================================
   v3.17.1 · Schließen-Kreuz bleibt immer sichtbar
   Vorher absolut im scrollenden Fenster: Es scrollte mit dem Inhalt weg und
   rutschte am Handy unter die Scrollleiste bzw. an den Rand. Jetzt „klebt“
   es oben rechts im Fenster (position: sticky) und liegt über dem Inhalt,
   ohne Platz zu belegen (negativer unterer Rand).
   ========================================================================== */
#p4p-finder-popup .p4p-finder-popup__close {
    position: sticky !important;
    top: 12px !important;
    right: auto !important;
    left: auto !important;
    bottom: auto !important;
    margin: 12px 12px -52px auto !important;
    z-index: 20 !important;
}
#p4p-finder-popup .p4p-finder-popup__close:hover,
#p4p-finder-popup .p4p-finder-popup__close:focus-visible { transform: none !important; }
@media (max-width: 1024px) {
    #p4p-finder-popup .p4p-finder-popup__close {
        top: 10px !important;
        margin: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 10px) -54px auto !important;
    }
}
