/*
 * Phone-only quick-find bar + picker sheet.
 * Companion component: components/QuickFind.tsx
 *
 * Fixed to the bottom of the viewport because that is where a thumb rests;
 * the header nav is a scroll away once the visitor is down the page, and the
 * service+city pages are what they are usually after.
 *
 * Everything here is inside `max-width: 767px` — above that the header nav is
 * visible and the bar would be redundant.
 */

.quickfind-bar {
    display: none;
}

@media screen and (max-width: 767px) {
    .quickfind-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        /*
         * The template sets `.float-left` / width rules widely and does not
         * use a global border-box; pinning the width to the viewport keeps
         * the bar from widening the document.
         */
        width: 100%;
        max-width: 100vw;
        z-index: 900;
        display: flex;
        align-items: center;
        gap: 10px;
        /*
         * The template does not set a global border-box, so padding on a
         * left:0/right:0 fixed element would add to the 100% width and make
         * the page scroll sideways.
         */
        box-sizing: border-box;
        padding: 10px 14px;
        /* Clear of the iPhone home indicator. */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background-color: var(--secondary--color);
        border-top: 1px solid var(--border--color);
        box-shadow: 0 -6px 24px rgb(7 41 92 / 12%);
    }

    .quickfind-trigger {
        flex: 1 1 auto;
        min-height: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 0 16px;
        border: none;
        border-radius: 26px;
        background-color: var(--primary--color);
        color: var(--accent--color);
        font-size: 15px;
        font-weight: 600;
        line-height: 1.2;
        cursor: pointer;
    }

    .quickfind-trigger i {
        font-size: 14px;
    }

    .quickfind-call {
        flex: 0 0 auto;
        width: 48px;
        height: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background-color: var(--accent--color);
        color: var(--secondary--color);
        font-size: 16px;
        text-decoration: none;
    }

    .quickfind-call:hover,
    .quickfind-call:focus {
        color: var(--primary--color);
        text-decoration: none;
    }

    .quickfind-trigger:focus-visible,
    .quickfind-call:focus-visible,
    .quickfind-option:focus-visible,
    .quickfind-close:focus-visible,
    .quickfind-back:focus-visible {
        outline: 2px solid var(--accent--color);
        outline-offset: 2px;
    }

    /* ---------- Sheet ---------- */

    .quickfind-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: flex;
        align-items: flex-end;
        background-color: rgb(7 41 92 / 45%);
        animation: quickfind-fade 0.18s ease;
    }

    .quickfind-sheet {
        width: 100%;
        box-sizing: border-box;
        max-height: 82vh;
        display: flex;
        flex-direction: column;
        padding: 8px 14px 18px;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
        background-color: var(--secondary--color);
        border-radius: 20px 20px 0 0;
        animation: quickfind-rise 0.22s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .quickfind-sheet:focus {
        outline: none;
    }

    /* Grab handle, purely a visual affordance. */
    .quickfind-sheet::before {
        content: "";
        flex: 0 0 auto;
        width: 42px;
        height: 4px;
        margin: 0 auto 10px;
        border-radius: 2px;
        background-color: var(--border--color);
    }

    .quickfind-sheet__head {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 44px;
    }

    .quickfind-sheet__title {
        font-size: 16px;
        font-weight: 600;
        color: var(--accent--color);
    }

    .quickfind-back,
    .quickfind-close {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        padding: 0 6px;
        border: none;
        background: none;
        color: var(--accent--color);
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
    }

    .quickfind-close {
        width: 44px;
        justify-content: center;
        font-size: 18px;
    }

    /* The chosen service, shown above the city list in step 2. */
    .quickfind-chosen {
        flex: 0 0 auto;
        margin-top: 2px;
        padding: 6px 2px 10px;
        font-size: 14px !important;
        font-weight: 600;
        line-height: 1.4 !important;
        color: var(--accent--color);
        opacity: 0.72;
    }

    .quickfind-list {
        flex: 1 1 auto;
        margin: 0;
    }

    .quickfind-list li + li {
        border-top: 1px solid var(--border--color);
    }

    .quickfind-option {
        width: 100%;
        min-height: 52px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 4px;
        border: none;
        background: none;
        color: var(--accent--color);
        font-size: 15px;
        font-weight: 500;
        line-height: 1.4;
        text-align: left;
        text-decoration: none;
        cursor: pointer;
    }

    .quickfind-option:hover,
    .quickfind-option:focus {
        color: var(--accent--color);
        text-decoration: none;
    }

    .quickfind-option i {
        flex: 0 0 auto;
        font-size: 13px;
        opacity: 0.5;
    }

    .quickfind-option--all {
        font-weight: 600;
        color: var(--accent--color);
    }

    .quickfind-note {
        flex: 0 0 auto;
        padding-top: 12px;
        font-size: 13px !important;
        line-height: 1.5 !important;
        color: var(--text--color);
    }

    /*
     * The bar covers the bottom of the page, so the last of the content needs
     * room to clear it — otherwise the footer's final row sits underneath.
     */
    body {
        padding-bottom: 76px;
    }

    /*
     * The template's back-to-top button (#button in style.css) is pinned
     * bottom-right and would land on the bar; lift it above.
     */
    #button {
        bottom: 88px !important;
    }
}

@keyframes quickfind-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes quickfind-rise {
    from {
        transform: translateY(14px);
    }
    to {
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .quickfind-backdrop,
    .quickfind-sheet {
        animation: none;
    }
}
