/*
 * The phone bar (Content Manager › Menus › Phone bar; core/cms/core/phone-bar.php).
 *
 * On phones (under 768px) a bar along the bottom of the screen holds the bar's buttons: the main one filled in the
 * website's colour and given the most room, the others soft. A space as tall as the bar ends the page, so the bar never
 * covers the page's last lines; the iPhone's home bar gets its own room (safe area). Items set to "In the header" are
 * round buttons beside the menu button, wherever the menu button shows.
 *
 * Colours come from the theme: Serepok's --primary / --on-primary (the header button's own) and --mtd-* surfaces,
 * Draisap's --dr-* tokens; dark mode follows body.dark-mode (Serepok) and html[data-theme="dark"] (Draisap). Words in
 * the accent are lifted or deepened so they read on the tint (4.5:1 and more).
 */

.wbams-phonebar,
.wbams-phonetop {
    --wpb-accent: var(--primary, var(--mtd-scheme-primary, #4f56d9));
    --wpb-on-accent: var(--on-primary, #ffffff);
    --wpb-surface: var(--mtd-surface, #ffffff);
    --wpb-ink: var(--mtd-ink, #17191c);
    --wpb-line: var(--mtd-line, rgba(15, 23, 42, .1));
    --wpb-accent-ink: color-mix(in srgb, var(--wpb-accent) 72%, #000000);
    --wpb-tint: color-mix(in srgb, var(--wpb-accent) 10%, var(--wpb-surface));
    --wpb-tint-strong: color-mix(in srgb, var(--wpb-accent) 17%, var(--wpb-surface));
    --wpb-tint-line: color-mix(in srgb, var(--wpb-accent) 24%, transparent);
    --wpb-shadow: rgba(15, 23, 42, .5);
    --wpb-ease: cubic-bezier(.16, 1, .3, 1);
}

.dr-body .wbams-phonebar,
.dr-body .wbams-phonetop {
    --wpb-accent: var(--dr-accent, var(--primary, #4f56d9));
    --wpb-on-accent: var(--dr-on-accent, #ffffff);
    --wpb-surface: var(--dr-surface, #ffffff);
    --wpb-ink: var(--dr-ink, #17191c);
    --wpb-line: var(--dr-line, rgba(15, 23, 42, .1));
}

body.dark-mode .wbams-phonebar,
body.dark-mode .wbams-phonetop,
html[data-theme="dark"] .wbams-phonebar,
html[data-theme="dark"] .wbams-phonetop {
    --wpb-accent-ink: color-mix(in srgb, var(--wpb-accent) 45%, #ffffff);
    --wpb-tint: color-mix(in srgb, var(--wpb-accent) 16%, var(--wpb-surface));
    --wpb-tint-strong: color-mix(in srgb, var(--wpb-accent) 26%, var(--wpb-surface));
    --wpb-tint-line: color-mix(in srgb, var(--wpb-accent) 36%, transparent);
    --wpb-shadow: rgba(0, 0, 0, .85);
}

@supports (color: oklch(from red l c h)) {
    .wbams-phonebar,
    .wbams-phonetop {
        --wpb-accent-ink: oklch(from var(--wpb-accent) min(l, .47) c h);
    }

    body.dark-mode .wbams-phonebar,
    body.dark-mode .wbams-phonetop,
    html[data-theme="dark"] .wbams-phonebar,
    html[data-theme="dark"] .wbams-phonetop {
        --wpb-accent-ink: oklch(from var(--wpb-accent) max(l, .8) min(c, .14) h);
    }
}

/* ---- the bar ------------------------------------------------------------------------------------ */

.wbams-phonebar,
.wbams-phonebar-space {
    display: none;
}

@media (max-width: 767.98px) {
    .wbams-phonebar-space {
        display: block;
        height: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    .wbams-phonebar {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1035;
        display: flex;
        align-items: stretch;
        gap: 8px;
        padding: 10px max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
        border-top: 1px solid var(--wpb-line);
        border-radius: 22px 22px 0 0;
        background: color-mix(in srgb, var(--wpb-surface) 94%, transparent);
        -webkit-backdrop-filter: saturate(1.6) blur(18px);
        backdrop-filter: saturate(1.6) blur(18px);
        box-shadow: 0 -16px 36px -24px var(--wpb-shadow);
    }

    /* (doubled class and !important: Serepok gives every phone link its text's colour, a[href^="tel"]:not(.btn), and
       in dark mode every span the dark text colour) */
    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item {
        position: relative;
        display: inline-flex;
        flex: 1 1 0;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-width: 0;
        min-height: 54px;
        margin: 0;
        padding: 0 14px;
        border: 1px solid var(--wpb-tint-line);
        border-radius: 16px;
        color: var(--wpb-accent-ink) !important;
        background: var(--wpb-tint);
        font-size: 15px;
        font-weight: 800;
        line-height: 1.2;
        letter-spacing: .005em;
        text-decoration: none !important;
        -webkit-tap-highlight-color: transparent;
        transition: transform .18s var(--wpb-ease), background-color .18s ease, box-shadow .18s ease;
    }

    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item:hover,
    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item:focus-visible {
        background: var(--wpb-tint-strong);
    }

    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item:active {
        transform: scale(.97);
    }

    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item:focus-visible {
        outline: 2px solid var(--wpb-accent-ink);
        outline-offset: 2px;
    }

    .wbams-phonebar.wbams-phonebar .wbams-phonebar__item span,
    .wbams-phonebar.wbams-phonebar .wbams-phonebar__item i {
        color: inherit !important;
    }

    .wbams-phonebar .wbams-phonebar__icon {
        display: inline-grid;
        flex: 0 0 auto;
        place-items: center;
        font-size: 17px;
        line-height: 1;
    }

    .wbams-phonebar .wbams-phonebar__label {
        overflow: hidden;
        min-width: 0;
        text-overflow: ellipsis;
        white-space: nowrap;
        /* room for accents and a "g" tail (the line is clipped for the ellipsis) */
        padding-block: .12em;
    }

    /* The main button: filled, the most room, its icon on a tile, a slow sheen. */
    .wbams-phonebar.has-main a.wbams-phonebar__item:not(.is-main) {
        flex: 0 1 auto;
        min-width: 104px;
    }

    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item.is-main {
        flex: 1 1 auto;
        overflow: hidden;
        isolation: isolate;
        border-color: transparent;
        color: var(--wpb-on-accent) !important;
        background: linear-gradient(135deg, color-mix(in srgb, var(--wpb-accent) 84%, #ffffff) 0%, var(--wpb-accent) 46%, color-mix(in srgb, var(--wpb-accent) 82%, #000000) 100%);
        box-shadow: 0 14px 26px -14px color-mix(in srgb, var(--wpb-accent) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, .24);
        font-size: 16px;
    }

    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item.is-main:hover,
    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item.is-main:focus-visible {
        background: linear-gradient(135deg, color-mix(in srgb, var(--wpb-accent) 76%, #ffffff) 0%, var(--wpb-accent) 50%, color-mix(in srgb, var(--wpb-accent) 86%, #000000) 100%);
    }

    .wbams-phonebar .is-main .wbams-phonebar__icon {
        width: 32px;
        height: 32px;
        border-radius: 10px;
        background: rgba(255, 255, 255, .2);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
        font-size: 16px;
    }

    .wbams-phonebar .is-main::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        background: linear-gradient(105deg, transparent 32%, rgba(255, 255, 255, .3) 50%, transparent 68%);
        transform: translateX(-130%);
        animation: wbams-phonebar-sheen 7s ease-in-out 1.6s infinite;
        pointer-events: none;
    }

    /* Three or four buttons: the ones beside the main button stand as small tiles, the icon over the name. */
    .wbams-phonebar.wbams-phonebar--3 a.wbams-phonebar__item:not(.is-main),
    .wbams-phonebar.wbams-phonebar--4 a.wbams-phonebar__item:not(.is-main) {
        flex-direction: column;
        gap: 3px;
        min-width: 66px;
        padding: 6px 8px;
        font-size: 12px;
        letter-spacing: 0;
    }

    .wbams-phonebar.has-main.wbams-phonebar--3 a.wbams-phonebar__item:not(.is-main),
    .wbams-phonebar.has-main.wbams-phonebar--4 a.wbams-phonebar__item:not(.is-main) {
        flex: 0 0 auto;
    }

    .wbams-phonebar--3 .wbams-phonebar__item:not(.is-main) .wbams-phonebar__icon,
    .wbams-phonebar--4 .wbams-phonebar__item:not(.is-main) .wbams-phonebar__icon {
        font-size: 18px;
    }

    .wbams-phonebar--4 {
        gap: 6px;
    }

    .wbams-phonebar.wbams-phonebar--4 a.wbams-phonebar__item:not(.is-main) {
        min-width: 58px;
    }

    /* Draisap's back-to-top button floats in the lower corner: it stands above the bar. (Serepok's sits in the
       footer's last row, which the space under the page keeps clear of the bar.) */
    body:has(> .wbams-phonebar) .dr-to-top {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (max-width: 359.98px) {
    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item {
        padding: 0 10px;
        font-size: 14px;
    }

    .wbams-phonebar.has-main a.wbams-phonebar__item:not(.is-main) {
        min-width: 86px;
    }
}

@keyframes wbams-phonebar-sheen {
    0%, 72% {
        transform: translateX(-130%);
    }
    100% {
        transform: translateX(130%);
    }
}

/* ---- round buttons beside the header's menu button ---------------------------------------------------- */

.wbams-phonetop {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.wbams-phonetop a.wbams-phonetop__item {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--wpb-tint-line);
    border-radius: 999px;
    color: var(--wpb-accent-ink) !important;
    background: var(--wpb-tint);
    font-size: 17px;
    line-height: 1;
    text-decoration: none !important;
    -webkit-tap-highlight-color: transparent;
    transition: transform .18s var(--wpb-ease), background-color .18s ease;
}

.wbams-phonetop a.wbams-phonetop__item:hover,
.wbams-phonetop a.wbams-phonetop__item:focus-visible {
    background: var(--wpb-tint-strong);
}

.wbams-phonetop a.wbams-phonetop__item:active {
    transform: scale(.94);
}

.wbams-phonetop a.wbams-phonetop__item:focus-visible {
    outline: 2px solid var(--wpb-accent-ink);
    outline-offset: 2px;
}

.wbams-phonetop a.wbams-phonetop__item i {
    color: inherit !important;
}

/* Serepok: in the header's row, after the logo, before the button and the menu button. A site's own rule that lays the
   menu button over the row's end (Siam's, from before the header had a button) gives way, so the two never cover each
   other. On phones with a bar the header's button copy goes: the bar has it. */
.section-header #header .serepok-brand-wrap > .wbams-phonetop {
    margin: 0 8px 0 auto;
}

.section-header #header .serepok-brand-wrap > .wbams-phonetop ~ .serepok-phone-cta.btn {
    margin-left: 0;
}

.section-header #header .serepok-brand-wrap > .wbams-phonetop ~ .serepok-menu-toggle {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    flex: 0 0 auto;
    transform: none !important;
}

@media (min-width: 1200px) {
    .section-header .wbams-phonetop {
        display: none !important;
    }
}

@media (max-width: 767.98px) {
    .section-header.serepok-has-phonebar #header .serepok-phone-cta {
        display: none !important;
    }

    .dr-header.dr-header--phonebar .dr-header__cta {
        display: none !important;
    }
}

/* Draisap: in the header's end group, before the button and the menu button, while the menu button shows. */
.dr-header .dr-header__end > .wbams-phonetop {
    gap: 6px;
}

.dr-header .wbams-phonetop a.wbams-phonetop__item {
    width: 40px;
    height: 40px;
    font-size: 15px;
}

@media (min-width: 992px) {
    .dr-header .wbams-phonetop {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wbams-phonebar .is-main::after {
        animation: none;
    }

    .wbams-phonebar.wbams-phonebar a.wbams-phonebar__item,
    .wbams-phonetop a.wbams-phonetop__item {
        transition: none;
    }
}

@media print {
    .wbams-phonebar,
    .wbams-phonebar-space,
    .wbams-phonetop {
        display: none !important;
    }
}
