/* ============================================
   Phone tab bar (Layout/_TabBar), below 768px only.
   The active tab gets a soft green pill behind its icon. On the guest bar the Search tab in the
   middle is a raised green circle instead (it opens the search sheet; phones have no header
   search).
   Scrolling down it turns slim (html.bl-bars-down, header.js): see "Slim" below.
   ============================================ */

body.has-tabbar {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

.bl-tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-tabbar);
    padding: 0 max(var(--space-2), env(safe-area-inset-right, 0px)) var(--safe-bottom) max(var(--space-2), env(safe-area-inset-left, 0px));
    border-top: 1px solid var(--color-border-light);
    background: var(--color-surface);
    background: color-mix(in srgb, var(--color-surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.8) blur(18px);
    backdrop-filter: saturate(1.8) blur(18px);
}

.bl-tabbar__list {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    height: var(--tabbar-h);
    margin: 0;
    padding: 0;
    list-style: none;
}

.bl-tabbar__tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    min-height: 44px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
}

.bl-tabbar__icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 30px;
    border-radius: var(--radius-pill);
    font-size: 18px;
    isolation: isolate;
    transition: scale var(--press-duration) var(--press-ease);
}

.bl-tabbar__icon::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--green-50);
    opacity: 0;
    scale: 0.6 0.9;
    transition: opacity var(--duration-base) var(--ease-out), scale var(--duration-base) var(--ease-out);
}

.bl-tabbar__label {
    /* 12px, easing to 11px below about 353px wide so "Dashboard" (the longest label, 600 weight
       when current) fits a fifth of a 320px phone instead of ending in an ellipsis. */
    font-size: clamp(11px, 3.4vw, 12px);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bl-tabbar__tab[aria-current="page"] {
    color: var(--green-700);
    font-weight: 600;
}

.bl-tabbar__tab[aria-current="page"] .bl-tabbar__icon::before {
    opacity: 1;
    scale: 1;
}

.bl-tabbar__tab:active .bl-tabbar__icon {
    scale: 0.92;
}

/* --- Search: the raised green circle in the middle (guest bar) ---
   The tab itself grows upwards by --space-3, so the circle stays inside its box: the whole
   circle is tappable and the focus ring (components.css) wraps the circle and its label. Content
   sits at the bottom, so the label lines up with its neighbours'. */
.bl-tabbar__tab--search {
    justify-content: flex-end;
    height: calc(100% + var(--space-3));
    margin-top: calc(-1 * var(--space-3));
    /* Puts the label on its neighbours' line (they centre a 30px icon + label). */
    padding-bottom: calc(var(--space-2) + 2px);
}

.bl-tabbar__fab {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    /* Fills the grown tab exactly: 52 + 2 gap + the label + the padding. */
    width: 52px;
    height: 52px;
    /* The surface-coloured ring lifts the circle off the bar's top border. */
    border: 3px solid var(--color-surface);
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: var(--shadow-2);
    color: var(--color-surface);
    font-size: 20px;
    transition: scale var(--press-duration) var(--press-ease), background-color var(--duration-fast) var(--ease-out);
}

.bl-tabbar__tab--search[aria-current="page"] .bl-tabbar__fab {
    background: var(--color-primary-hover);
}

.bl-tabbar__tab:active .bl-tabbar__fab {
    scale: 0.94;
}

@media (hover: hover) and (pointer: fine) {
    .bl-tabbar__tab--search:hover .bl-tabbar__fab {
        background: var(--color-primary-hover);
    }
}

@media (prefers-reduced-motion: reduce) {
    .bl-tabbar__icon::before {
        scale: 1;
    }

    .bl-tabbar__tab:active .bl-tabbar__icon,
    .bl-tabbar__tab:active .bl-tabbar__fab {
        scale: 1;
    }
}

/* --- Slim while the guest scrolls down (html.bl-bars-down, set by header.js) ---
   The bar sinks by --tabbar-sink, so 44px of it shows above the safe area: the labels fade out,
   the icons stay, the Search circle shrinks and sits lower. Every bar docked on it
   ([data-dock-bottom]: the listing page's price bar, the Favorites compare bar) sinks with it on
   the same curve, so the two stay one dock; floating things above it (toasts, the calendar's
   Today) keep their place. Translate, opacity and transform only (never the height); the circle
   takes transform so its press (scale) still composes. Under reduced motion it keeps its size. */
@media (max-width: 767.98px) and (prefers-reduced-motion: no-preference) {
    body.has-tabbar [data-dock-bottom] {
        transition: translate var(--duration-base) var(--ease-out);
    }

    html.bl-bars-down body.has-tabbar [data-dock-bottom] {
        translate: 0 var(--tabbar-sink);
    }

    .bl-tabbar__label {
        transition: opacity var(--duration-fast) var(--ease-out);
    }

    html.bl-bars-down .bl-tabbar__label {
        opacity: 0;
    }

    .bl-tabbar__icon {
        transition: scale var(--press-duration) var(--press-ease), translate var(--duration-base) var(--ease-out);
    }

    /* Centred in what shows. */
    html.bl-bars-down .bl-tabbar__icon {
        translate: 0 calc(-1 * var(--space-1));
    }

    .bl-tabbar__fab {
        transition: scale var(--press-duration) var(--press-ease), background-color var(--duration-fast) var(--ease-out), transform var(--duration-base) var(--ease-out);
    }

    /* About 40px, level with the slim bar's top edge instead of standing 14px above it. */
    html.bl-bars-down .bl-tabbar__fab {
        transform: translateY(var(--space-1)) scale(0.77);
    }
}

@media (min-width: 768px) {
    body.has-tabbar {
        padding-bottom: 0;
    }

    .bl-tabbar {
        display: none;
    }
}

/* The outline heart is thinner than the solid icons beside it: a stroke in its own colour
   thickens its line to match. */
.bl-tabbar__icon .fa-regular.fa-heart {
    -webkit-text-stroke: 1px currentColor;
}
