/* ============================================================
   Sticky Free SEO Audit CTA
   Replaces the old lower-right scroll-to-top circle.
   Uses the site design tokens from style.css.
   ============================================================ */

.sticky-audit {
    position: fixed;
    right: clamp(16px, 2.2vw, 28px);
    bottom: calc(clamp(16px, 2.2vw, 28px) + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    /* Entrance state; .is-ready is added by the script after first paint. */
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.sticky-audit.is-ready {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ----- Primary trigger ----- */

.sticky-audit__trigger {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    max-width: min(320px, calc(100vw - 40px));
    padding: 10px 22px 10px 16px;
    border: 1px solid rgba(17, 17, 17, 0.14);
    border-radius: var(--radius-full, 9999px);
    background: var(--accent-gradient, linear-gradient(135deg, #6EE268 0%, #A8D507 50%, #5BC955 100%));
    color: #101a10;
    font-family: var(--font-primary, 'DM Sans', sans-serif);
    text-align: left;
    cursor: pointer;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.42),
        0 0 26px rgba(110, 226, 104, 0.34);
    transition:
        transform var(--transition-fast, 0.2s cubic-bezier(0.4, 0, 0.2, 1)),
        box-shadow var(--transition-fast, 0.2s cubic-bezier(0.4, 0, 0.2, 1)),
        filter var(--transition-fast, 0.2s cubic-bezier(0.4, 0, 0.2, 1));
}

.sticky-audit__icon {
    display: grid;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 50%;
    background: rgba(16, 26, 16, 0.14);
    color: #0d160d;
}

.sticky-audit__copy {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.sticky-audit__title {
    font-family: var(--font-display, 'Syne', sans-serif);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    white-space: nowrap;
}

.sticky-audit__sub {
    overflow: hidden;
    color: rgba(16, 26, 16, 0.78);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sticky-audit__trigger:hover {
    transform: translateY(-3px);
    filter: saturate(1.06);
    box-shadow:
        0 16px 38px rgba(0, 0, 0, 0.48),
        0 0 40px rgba(110, 226, 104, 0.52);
}

.sticky-audit__trigger:active {
    transform: translateY(-1px) scale(0.985);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.42),
        0 0 22px rgba(110, 226, 104, 0.36);
}

.sticky-audit__trigger:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

.sticky-audit__trigger.is-loading {
    cursor: progress;
    filter: saturate(0.85);
}

/* ----- Minimise / restore control ----- */

.sticky-audit__toggle {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    margin-bottom: 6px;
    border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.12));
    border-radius: 50%;
    background: rgba(17, 17, 17, 0.92);
    color: var(--text-secondary, #b0b0b0);
    cursor: pointer;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.3));
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.sticky-audit__toggle:hover {
    border-color: var(--accent-primary, #6EE268);
    color: var(--accent-primary, #6EE268);
}

.sticky-audit__toggle:focus-visible {
    outline: 3px solid var(--accent-primary, #6EE268);
    outline-offset: 2px;
}

.sticky-audit__toggle-icon {
    display: grid;
    place-items: center;
    transition: transform 0.25s ease;
}

/* Keep the label in the accessibility tree without showing it. */
.sticky-audit__toggle-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ----- Minimised state -----
   The label stays in the DOM (clipped, not display:none) so the button keeps
   its accessible name, and hover/focus expands it again without a click. */

.sticky-audit.is-minimised .sticky-audit__trigger {
    max-width: 56px;
    padding: 10px;
    gap: 0;
}

.sticky-audit.is-minimised .sticky-audit__copy {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.sticky-audit.is-minimised .sticky-audit__toggle-icon {
    transform: rotate(180deg);
}

.sticky-audit.is-minimised .sticky-audit__trigger:hover,
.sticky-audit.is-minimised .sticky-audit__trigger:focus-visible {
    max-width: min(320px, calc(100vw - 40px));
    padding: 10px 22px 10px 16px;
    gap: 12px;
}

.sticky-audit.is-minimised .sticky-audit__trigger:hover .sticky-audit__copy,
.sticky-audit.is-minimised .sticky-audit__trigger:focus-visible .sticky-audit__copy {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
}

/* ----- Mobile ----- */

@media (max-width: 640px) {
    .sticky-audit {
        right: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        gap: 4px;
    }

    .sticky-audit__trigger {
        min-height: 52px;
        max-width: calc(100vw - 72px);
        padding: 8px 18px 8px 12px;
        gap: 10px;
    }

    .sticky-audit__icon {
        width: 32px;
        height: 32px;
    }

    .sticky-audit__title {
        font-size: 14px;
    }

    /* Microcopy is dropped on small screens so the pill never crowds content. */
    .sticky-audit__sub {
        display: none;
    }

    .sticky-audit.is-minimised .sticky-audit__trigger,
    .sticky-audit.is-minimised .sticky-audit__trigger:hover {
        max-width: 52px;
        padding: 8px;
        gap: 0;
    }

    .sticky-audit.is-minimised .sticky-audit__trigger:focus-visible {
        max-width: calc(100vw - 72px);
        padding: 8px 18px 8px 12px;
        gap: 10px;
    }
}

/* The audit modal owns the screen while it is open. */
body.seo-audit-modal-open .sticky-audit {
    opacity: 0;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .sticky-audit,
    .sticky-audit__trigger,
    .sticky-audit__toggle,
    .sticky-audit__toggle-icon {
        transition: none;
    }

    .sticky-audit__trigger:hover,
    .sticky-audit__trigger:active {
        transform: none;
    }
}

/* ============================================================
   Footer back-to-top (secondary utility)
   ============================================================ */

.footer-v2-bottom .footer-back-to-top {
    margin-top: 14px;
}

.footer-back-to-top {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-full, 9999px);
    background: transparent;
    color: var(--text-secondary, #b0b0b0);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.footer-back-to-top:hover,
.footer-back-to-top:focus-visible {
    border-color: var(--accent-primary, #6EE268);
    background: rgba(110, 226, 104, 0.08);
    color: var(--accent-primary, #6EE268);
}

.footer-back-to-top svg {
    flex: 0 0 auto;
}
