/*
 * SPO Realtime Bubble v1.4.9
 * The native wpDiscuz Bubble stays alive in the DOM for compatibility, but
 * becomes visually hidden once the realtime bridge successfully mounts the
 * SPO-owned notifier.
 */

body.spo-wpdrt-custom-bubble-active #wpd-bubble-wrapper,
body.spo-wpdrt-custom-bubble-active #wpd-bubble,
body.spo-wpdrt-custom-bubble-active #wpd-bubble-count,
body.spo-wpdrt-custom-bubble-active #wpd-bubble-notification,
body.spo-wpdrt-custom-bubble-active #wpd-bubble-all-comments-count {
    visibility: hidden !important;
    pointer-events: none !important;
}

#spo-wpdrt-new-comments-bubble {
    /*
     * v1.4.9: position is owned by the SPO Bubble itself.
     * !important prevents old native-Bubble rules or stale inline coordinates
     * from moving this control between the top and bottom of the viewport.
     */
    position: fixed !important;
    left: auto !important;
    right: max(18px, env(safe-area-inset-right)) !important;
    bottom: auto !important;
    /*
     * v1.4.9: use a stable UPPER-right rail instead of a bottom offset.
     * SPO can have a sticky footer ad, floating video ad, and other lower-page
     * overlays at the same time. Anchoring from the top keeps the Bubble well
     * above that advertising stack without measuring or chasing any ad element.
     * It therefore stays in one predictable place as ads load and collapse.
     */
    top: max(110px, calc(92px + env(safe-area-inset-top))) !important;
    z-index: 2147483000;
    width: 76px;
    height: 76px;
    margin: 0;
    padding: 0;
    border: 4px solid #272a2d;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    color: #272a2d;
    cursor: pointer;
    font: inherit;
    line-height: 1;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition: opacity 150ms ease, transform 150ms ease, visibility 150ms linear;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#spo-wpdrt-new-comments-bubble.spo-wpdrt-bubble-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#spo-wpdrt-new-comments-bubble:hover,
#spo-wpdrt-new-comments-bubble:focus-visible {
    background: #fff;
    box-shadow: 0 9px 28px rgba(0, 0, 0, 0.23);
}

#spo-wpdrt-new-comments-bubble:active {
    transform: scale(0.96);
}

#spo-wpdrt-new-comments-bubble:focus-visible {
    outline: 3px solid #83d54d;
    outline-offset: 3px;
}

#spo-wpdrt-new-comments-bubble .spo-wpdrt-bubble-chevron {
    position: absolute;
    top: 10px;
    left: 50%;
    width: 43px;
    height: 28px;
    transform: translateX(-50%);
    pointer-events: none;
}

#spo-wpdrt-new-comments-bubble .spo-wpdrt-bubble-chevron svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

#spo-wpdrt-new-comments-bubble .spo-wpdrt-bubble-count {
    position: absolute;
    left: 50%;
    bottom: 7px;
    min-width: 1.1em;
    transform: translateX(-50%);
    color: #ff6900;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1.2px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

#spo-wpdrt-new-comments-bubble[data-spo-digits="2"] .spo-wpdrt-bubble-count {
    font-size: 25px;
    letter-spacing: -1px;
}

#spo-wpdrt-new-comments-bubble[data-spo-digits="3"] .spo-wpdrt-bubble-count,
#spo-wpdrt-new-comments-bubble[data-spo-digits="4"] .spo-wpdrt-bubble-count {
    bottom: 9px;
    font-size: 20px;
    letter-spacing: -0.7px;
}

@media (max-width: 768px) {
    #spo-wpdrt-new-comments-bubble {
        /*
         * Keep the Bubble just below SPO's top navigation on phones/tablets.
         * This matches the requested high placement and leaves the entire
         * lower viewport available to sticky ads and floating video.
         */
        top: max(78px, calc(66px + env(safe-area-inset-top))) !important;
    }
}

@media (max-width: 600px) {
    #spo-wpdrt-new-comments-bubble {
        top: max(70px, calc(60px + env(safe-area-inset-top))) !important;
        width: 68px;
        height: 68px;
        border-width: 4px;
    }

    #spo-wpdrt-new-comments-bubble .spo-wpdrt-bubble-chevron {
        top: 9px;
        width: 38px;
        height: 24px;
    }

    #spo-wpdrt-new-comments-bubble .spo-wpdrt-bubble-count {
        bottom: 6px;
        font-size: 27px;
    }

    #spo-wpdrt-new-comments-bubble[data-spo-digits="2"] .spo-wpdrt-bubble-count {
        font-size: 23px;
    }

    #spo-wpdrt-new-comments-bubble[data-spo-digits="3"] .spo-wpdrt-bubble-count,
    #spo-wpdrt-new-comments-bubble[data-spo-digits="4"] .spo-wpdrt-bubble-count {
        bottom: 8px;
        font-size: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #spo-wpdrt-new-comments-bubble {
        transition: none;
    }
}
