/* =====================================================================
   SPECTRE - phone helpers (partials/phone-float.blade.php + js/spectre/phone-float.js)
   Floating Menu button, Back to top, quick menu sheet, scrolling-table fade.
   Phones and small tablets only (<= 900px). Colours are theme tokens (--sp-*, --pp-rgb), so every look
   draws it in its own dress; the fallbacks only matter on a page with no theme sheet.
   ===================================================================== */

.sp-float { display: none; }

@media (max-width: 900px) {
    .sp-float:not([hidden]) {
        position: fixed;
        z-index: 940;               /* above the page and its header (900), below the scrim (950) and the drawer (1000) */
        right: max(14px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 10px;
        pointer-events: none;       /* only the buttons and the sheet take taps */
    }
    .sp-float > * { pointer-events: auto; }
    /* the floating buttons sit over the right edge of the page for good: keep the footer's text (the fan-notice line is its last) clear of them, or the buttons hide it (and the readability check reads the buttons' pixels behind the words) */
    .sp-footer__inner, .st-foot, .cl-foot { padding-right: 82px !important; }

    .sp-float__btn {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        width: 48px;
        height: 48px;
        padding: 0;
        margin: 0;
        color: var(--sp-text-hi, #f2f4f8);
        background: var(--sp-surface, #181b22);
        border: 1px solid var(--sp-line-strong, rgba(255,255,255,0.28));
        border-radius: 50%;
        box-shadow: 0 6px 18px rgba(0,0,0,0.45), 0 0 0 3px rgba(var(--pp-rgb, 90,160,255), 0.18);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
    }
    .sp-float__btn[hidden] { display: none; }
    .sp-float__fab { width: 54px; height: 54px; }
    .sp-float__btn svg { width: 24px; height: 24px; }
    .sp-float__btn:active { transform: scale(0.94); }
    .sp-float__btn:focus-visible,
    .sp-float__link:focus-visible {
        outline: 3px solid var(--sp-focus, #ffd166);
        outline-offset: 2px;
    }
    .sp-float__ico-close { display: none; }
    .sp-float__fab[aria-expanded="true"] .sp-float__ico-open { display: none; }
    .sp-float__fab[aria-expanded="true"] .sp-float__ico-close { display: block; }

    .sp-float__sheet {
        box-sizing: border-box;
        width: min(300px, calc(100vw - 28px));
        max-height: min(60vh, 420px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 8px;
        background: var(--sp-surface, #181b22);
        border: 1px solid var(--sp-line-strong, rgba(255,255,255,0.28));
        border-radius: var(--sp-radius, 10px);
        box-shadow: 0 18px 40px rgba(0,0,0,0.55);
    }
    .sp-float__sheet[hidden] { display: none; }
    .sp-float__list { margin: 0; padding: 0; list-style: none; }
    .sp-float__link {
        display: flex;
        align-items: center;
        box-sizing: border-box;
        width: 100%;
        min-height: 44px;           /* a comfortable tap target */
        padding: 10px 12px;
        font: inherit;
        font-size: 0.95rem;
        letter-spacing: normal;
        text-transform: none;
        text-align: left;
        text-decoration: none;
        color: var(--sp-text, #dde2ea);
        background: none;
        border: 0;
        border-radius: var(--sp-radius-sm, 6px);
        cursor: pointer;
    }
    .sp-float__link:hover,
    .sp-float__link:active { background: rgba(var(--pp-rgb, 90,160,255), 0.12); color: var(--sp-text-hi, #fff); text-decoration: none; }
    .sp-float__link.active { background: rgba(var(--pp-rgb, 90,160,255), 0.18); color: var(--sp-text-hi, #fff); font-weight: 600; }
    .sp-float__pages { margin-top: 6px; border-top: 1px solid var(--sp-line, rgba(255,255,255,0.14)); border-radius: 0 0 var(--sp-radius-sm, 6px) var(--sp-radius-sm, 6px); padding-top: 12px; }
    .sp-float__pages[hidden] { display: none; }

    /* the drawer and its scrim cover the floating buttons while the side menu is open */
    html.sp-lock .sp-float { visibility: hidden; }

    /* a wide table that scrolls sideways fades at the edge while there is more to see (phone-float.js sets the flag) */
    [data-sp-more="1"] {
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), rgba(0,0,0,0.08));
        mask-image: linear-gradient(to right, #000 calc(100% - 44px), rgba(0,0,0,0.08));
    }

    /* the floating buttons never sit on top of the editor's bottom bars */
    body.sp-em-on .sp-float:not([hidden]) { bottom: max(72px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .sp-float__btn { transition: none; }
    .sp-float__btn:active { transform: none; }
}

@media print { .sp-float { display: none !important; } }
