/* ==========================================================================
   Modern fixed side rail (right, bottom)
   Replaces the legacy .surfytech-chat bubble (a 60px circle painted with a
   raster mail-img.png) with a single rounded rail holding two real buttons:
     1. mail  -> opens the #mailModal quote form
     2. top   -> scrolls back to the top of the page
   Fixed position, no pointer-events tricks, so it never blocks the content
   underneath and stays keyboard reachable.

   Legacy pages still emit <div class="surfytech-chat"></div> (empty, no inner
   markup), so the rail is ALSO available as a pseudo-element on that same
   class - every existing page upgrades with no HTML churn.
   ========================================================================== */

.surfychat-rail {
    position: fixed;
    right: 18px;
    bottom: 18px;
    /* Above the header (1000) but below the quote modal (1060), and the
       body.modal-open rule further down parks it while that modal is open, so
       the rail can never cover the form it opened. */
    z-index: 1000001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-family: "Open Sans", sans-serif;
}

/* --- shared button chrome ------------------------------------------------ */
.surfychat-rail > a,
.surfychat-rail > button {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    min-width: 52px;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(145deg, #0057D9 0%, #1697bf 55%, #0aa39a 100%);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(2, 32, 71, .28);
    transition: transform .25s cubic-bezier(.2, .8, .3, 1),
                box-shadow .25s ease, filter .25s ease;
}

/* soft halo that lifts the rail off the page */
.surfychat-rail::before {
    content: "";
    position: absolute;
    inset: -14px;
    z-index: -1;
    border-radius: 26px;
    background: radial-gradient(60% 60% at 50% 50%, rgba(22, 151, 191, .20), transparent 70%);
    pointer-events: none;
}

.surfychat-rail > a:hover,
.surfychat-rail > button:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(2, 32, 71, .34);
    filter: saturate(1.08);
}

.surfychat-rail > a:active,
.surfychat-rail > button:active {
    transform: translateY(-1px) scale(.97);
}

.surfychat-rail > a:focus-visible,
.surfychat-rail > button:focus-visible {
    outline: 3px solid #ffd166;
    outline-offset: 3px;
}


/* top button: hidden until the page has scrolled. Driven by .surfychat-show,
   which js/scripts.js already toggles alongside surfytech-chat-visible. */
.surfychat-rail .surfychat-top {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(.9);
    transition: opacity .3s ease, transform .3s ease, visibility .3s 0s;
    background: linear-gradient(145deg, #1a365d 0%, #0b2a4a 100%);
}

.surfychat-rail.surfychat-show .surfychat-top {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition: opacity .3s ease, transform .3s ease, visibility 0s;
}

/* mail button: revealed on scroll too, so the pair arrives together exactly
   like the classic back-to-top instead of the mail bubble sitting there
   permanently under the old .cd-top button.
   Deliberately scoped away from .surfychat-legacy: those pages are promoted
   from an empty <div class="surfytech-chat"> that has no scroll trigger, so
   their single mail bubble has to stay permanently visible. */
.surfychat-rail:not(.surfychat-legacy) .surfychat-mail {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(.9);
    transition: opacity .3s ease, transform .3s ease, visibility .3s 0s;
}

.surfychat-rail:not(.surfychat-legacy).surfychat-show .surfychat-mail {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition: opacity .3s ease, transform .3s ease, visibility 0s;
}

/* --- accessible label that appears on hover ------------------------------ */
.surfychat-rail .surfychat-label {
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    padding: 6px 11px;
    border-radius: 8px;
    background: #0b2a4a;
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 6px 18px rgba(2, 32, 71, .28);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
}

.surfychat-rail > a:hover .surfychat-label,
.surfychat-rail > button:hover .surfychat-label,
.surfychat-rail > a:focus-visible .surfychat-label,
.surfychat-rail > button:focus-visible .surfychat-label {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* --- get out of the way while the quote modal is open -------------------- */
body.modal-open .surfychat-rail {
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
}

/* --- legacy empty <div class="surfytech-chat"></div> --------------------- */
/* Older pages have no inner markup, so the mail button is drawn with a
   pseudo-element instead. Same rail, same behaviour, zero HTML churn. */
.surfychat-rail.surfychat-legacy {
    width: 52px;
    height: 52px;
    gap: 0;
    border-radius: 16px;
    background: linear-gradient(145deg, #0057D9 0%, #1697bf 55%, #0aa39a 100%);
    box-shadow: 0 10px 26px rgba(2, 32, 71, .28);
    cursor: pointer;
    transition: transform .25s cubic-bezier(.2, .8, .3, 1), box-shadow .25s ease;
}

.surfychat-rail.surfychat-legacy::after {
    content: "";
    position: absolute;
    inset: 0;
    background: #fff;
    -webkit-mask: no-repeat center / 22px 22px url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='4.5' width='19' height='15' rx='2.5'/%3E%3Cpath d='m3 7 8.2 5.6a1.6 1.6 0 0 0 1.6 0L21 7'/%3E%3C/svg%3E");
    mask: no-repeat center / 22px 22px url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='4.5' width='19' height='15' rx='2.5'/%3E%3Cpath d='m3 7 8.2 5.6a1.6 1.6 0 0 0 1.6 0L21 7'/%3E%3C/svg%3E");
}

.surfychat-rail.surfychat-legacy:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(2, 32, 71, .34);
}

/* --- icons (inline SVG, sized via currentColor) ------------------------- */
.surfychat-rail svg {
    width: 22px;
    height: 22px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .3s ease;
}

.surfychat-rail > a:hover svg,
.surfychat-rail > button:hover svg {
    transform: scale(1.08);
}

/* mail button: gentle attention pulse, paused with the rest of the site */
.surfychat-rail .surfychat-mail::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    border: 2px solid rgba(255, 209, 102, .75);
    opacity: 0;
    animation: surfychat-pulse 2.8s ease-out infinite;
    pointer-events: none;
}

@keyframes surfychat-pulse {
    0%   { transform: scale(.86); opacity: .85; }
    70%  { transform: scale(1.22); opacity: 0; }
    100% { transform: scale(1.22); opacity: 0; }
}
