/**
 * Floating Change-Size Button — split out of frontend.css so it can be
 * conditionally NOT enqueued on pages where the Brandoz Filter & Sort Bar
 * widget/shortcode is present (see Brandoz_Frontend::enqueue_assets() and
 * Brandoz_Filter_Sort_Bar_Presence). frontend.css (popup, shortcode picker,
 * inline picker, product-page size pills) still always loads on its own —
 * only this self-contained floating-button block moved here.
 *
 * Position is controlled by the data-position attribute set from PHP/admin.
 * Default fallback = bottom-right.
 */

#brandoz-floating-btn {
    position: fixed;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px 10px 14px;
    background: #ffffff;
    color: #003d82;
    border: 2px solid #ffdd00;
    border-radius: 50px;
    cursor: pointer;
    z-index: 99998;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    /* Default = bottom-right */
    bottom: 24px;
    right: 24px;
    left: auto;
    top: auto;
    transition: transform 0.15s, box-shadow 0.15s;
}

/* Expanding ring that pops out from the button border to draw the eye —
   only while no size has been selected yet; see .brandoz-needs-selection
   toggled from assets/js/frontend.js:updateSizeDisplays(). */
#brandoz-floating-btn.brandoz-needs-selection::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid #ffdd00;
    animation: brandozFloatingRing 2.2s ease-out infinite;
    pointer-events: none;
}

@keyframes brandozFloatingRing {
    0%   { transform: scale(1);    opacity: 0.9; }
    70%  { opacity: 0.2; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ── Bottom Right (default) ──────────────────────────────────────────────── */
#brandoz-floating-btn[data-position="bottom-right"] {
    bottom: 24px;
    right: 24px;
    left: auto;
    top: auto;
}

#brandoz-floating-btn[data-position="bottom-right"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ── Bottom Left ─────────────────────────────────────────────────────────── */
#brandoz-floating-btn[data-position="bottom-left"] {
    bottom: 24px;
    left: 24px;
    right: auto;
    top: auto;
}

#brandoz-floating-btn[data-position="bottom-left"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ── Bottom Center ───────────────────────────────────────────────────────── */
#brandoz-floating-btn[data-position="bottom-center"] {
    bottom: 24px;
    left: 50%;
    right: auto;
    top: auto;
    transform: translateX(-50%);
}

#brandoz-floating-btn[data-position="bottom-center"]:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ── Top Right ───────────────────────────────────────────────────────────── */
#brandoz-floating-btn[data-position="top-right"] {
    top: 24px;
    right: 24px;
    bottom: auto;
    left: auto;
}

#brandoz-floating-btn[data-position="top-right"]:hover {
    transform: translateY(2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ── Top Left ────────────────────────────────────────────────────────────── */
#brandoz-floating-btn[data-position="top-left"] {
    top: 24px;
    left: 24px;
    bottom: auto;
    right: auto;
}

#brandoz-floating-btn[data-position="top-left"]:hover {
    transform: translateY(2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Focus ring (all positions) */
#brandoz-floating-btn:focus {
    outline: 3px solid color-mix(in srgb, var(--brandoz-color) 50%, transparent);
    outline-offset: 3px;
}

.brandoz-floating-icon {
    font-size: 1rem;
    line-height: 1;
}

.brandoz-floating-label {
    opacity: 0.85;
    font-weight: 400;
}

.brandoz-floating-size,
.brandoz-floating-chip {
    font-weight: 700;
}

.brandoz-floating-divider {
    opacity: 0.6;
    font-weight: 400;
}

/* Fallback shown on the floating button when no size has been chosen yet
   (e.g. a visitor skipped the popup) — a prompt, not a value, so lighter
   weight than the bold size chips above. */
.brandoz-floating-chip-empty {
    font-weight: 600;
}

/* RTL mirrors left↔right for left/right positions */
[dir="rtl"] #brandoz-floating-btn[data-position="bottom-right"],
[dir="rtl"] #brandoz-floating-btn:not([data-position]) {
    right: auto;
    left: 24px;
}

[dir="rtl"] #brandoz-floating-btn[data-position="bottom-left"] {
    left: auto;
    right: 24px;
}

[dir="rtl"] #brandoz-floating-btn[data-position="top-right"] {
    right: auto;
    left: 24px;
}

[dir="rtl"] #brandoz-floating-btn[data-position="top-left"] {
    left: auto;
    right: 24px;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    #brandoz-floating-btn,
    #brandoz-floating-btn[data-position="bottom-right"] {
        bottom: 16px;
        right: 16px;
        left: auto;
        top: auto;
        padding: 10px 14px 10px 12px;
        font-size: 0.82rem;
    }

    #brandoz-floating-btn[data-position="bottom-left"] {
        bottom: 16px;
        left: 16px;
        right: auto;
        top: auto;
        padding: 10px 14px 10px 12px;
        font-size: 0.82rem;
    }

    #brandoz-floating-btn[data-position="bottom-center"] {
        bottom: 16px;
        left: 50%;
        right: auto;
        top: auto;
        padding: 10px 14px 10px 12px;
        font-size: 0.82rem;
        transform: translateX(-50%);
    }

    #brandoz-floating-btn[data-position="bottom-center"]:hover {
        transform: translateX(-50%); /* no lift on mobile */
    }

    #brandoz-floating-btn[data-position="top-right"] {
        top: 16px;
        right: 16px;
        bottom: auto;
        left: auto;
        padding: 10px 14px 10px 12px;
        font-size: 0.82rem;
    }

    #brandoz-floating-btn[data-position="top-left"] {
        top: 16px;
        left: 16px;
        bottom: auto;
        right: auto;
        padding: 10px 14px 10px 12px;
        font-size: 0.82rem;
    }

    [dir="rtl"] #brandoz-floating-btn[data-position="bottom-right"],
    [dir="rtl"] #brandoz-floating-btn:not([data-position]) {
        right: auto;
        left: 16px;
    }

    [dir="rtl"] #brandoz-floating-btn[data-position="bottom-left"] {
        left: auto;
        right: 16px;
    }

    [dir="rtl"] #brandoz-floating-btn[data-position="top-right"] {
        right: auto;
        left: 16px;
    }

    [dir="rtl"] #brandoz-floating-btn[data-position="top-left"] {
        left: auto;
        right: 16px;
    }
}

/* ── Accessibility: skip animation for prefer-reduced-motion ─────────────── */
@media (prefers-reduced-motion: reduce) {
    #brandoz-floating-btn {
        transition: none;
    }

    #brandoz-floating-btn.brandoz-needs-selection::before {
        animation: none;
        display: none;
    }
}
