/*
 * Mobile site header (templates/site-header-mobile.php). Shown below 1024px; the desktop header
 * (css/site-header.css) takes over from there. Same colours, fonts and motion as desktop.
 */
.ofm {
    --ofh-font: Lato, Arial, Helvetica, sans-serif;
    --ofh-ink: #1c1c1a;
    --ofh-ink-soft: #55534e;
    --ofh-line: #e9e5de;
    --ofh-paper: #fff;
    --ofh-paper-warm: #f6f3ee;
    --ofh-accent: #0063A8;
    --ofh-announce-bg: #1c1c1a;
    --ofh-announce-ink: #f3efe8;
    --ofh-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ofm-bar-height: 64px;
    --ofm-gutter: 20px;

    display: none;
    font-family: var(--ofh-font);
    -webkit-font-smoothing: antialiased;
}

@media only screen and (max-width: 1023px) {

    .ofm {
        display: contents; /* lets .ofm-sticky stick against the whole page */
    }

    html.ofm-locked,
    html.ofm-locked body {
        overflow: hidden;
    }

    .ofm *,
    .ofm *::before,
    .ofm *::after {
        box-sizing: border-box;
    }

    .ofm ul,
    .ofm li {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .ofm button {
        all: unset;
        box-sizing: border-box;
        margin: 0 !important; /* parent theme: button { margin: 10px 0 40px !important } */
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .ofm a {
        -webkit-tap-highlight-color: transparent;
    }

    .ofm a:not([href="#"]) {
        cursor: pointer;
    }

    .ofm :focus-visible {
        outline: 2px solid var(--ofh-ink);
        outline-offset: 2px;
    }

    .ofm svg {
        fill: none;
        stroke: currentColor;
        stroke-width: 1.5;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* ---- announcement bar ---- */

    .ofm .ofm-announce {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 34px;
        padding: 8px var(--ofm-gutter);
        background: var(--ofh-announce-bg);
        color: var(--ofh-announce-ink) !important;
        font-size: 10px;
        letter-spacing: 0.18em;
        line-height: 1.4;
        text-align: center;
        text-transform: uppercase;
        text-decoration: none !important;
    }

    .ofm .ofm-announce svg {
        flex: none;
        width: 14px;
        height: 14px;
    }

    /* ---- sticky bar ---- */

    .ofm .ofm-sticky {
        position: sticky;
        top: 0;
        z-index: 9990;
        transition: transform 0.45s var(--ofh-ease);
    }

    body.admin-bar .ofm .ofm-sticky {
        top: 46px;
    }

    .ofm .ofm-sticky.is-hidden {
        transform: translateY(-100%);
    }

    .ofm .ofm-bar {
        position: relative;
        z-index: 2;
        display: grid;
        grid-template-columns: 1fr auto 1fr; /* logo stays centred whatever the icons do */
        align-items: center;
        height: var(--ofm-bar-height);
        padding: 0 calc(var(--ofm-gutter) - 10px);
        background: var(--ofh-paper);
        border-bottom: 1px solid var(--ofh-line);
        transition: box-shadow 0.3s ease;
    }

    .ofm .ofm-sticky.is-stuck .ofm-bar {
        box-shadow: 0 6px 20px rgba(28, 28, 26, 0.08);
    }

    .ofm .ofm-logo {
        display: block;
        color: var(--ofh-ink) !important;
        text-decoration: none !important;
    }

    .ofm .ofm-logo img {
        display: block;
        width: auto;
        height: 48px;
        max-width: none;
    }

    .ofm .ofm-icons {
        display: flex;
        justify-content: flex-end;
    }

    .ofm .ofm-icon {
        position: relative;
        display: grid;
        place-items: center;
        width: 44px;
        height: 44px;
        color: var(--ofh-ink) !important;
    }

    .ofm .ofm-icon svg {
        width: 24px;
        height: 24px;
    }

    .ofm .ofh-cart__count {
        position: absolute;
        top: 5px;
        right: 2px;
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        border-radius: 9px;
        background: var(--ofh-accent);
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        line-height: 17px;
        text-align: center;
    }

    .ofm .ofh-cart__count.is-empty {
        display: none;
    }

    /* ---- search ---- */

    .ofm .ofm-search {
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        z-index: 1;
        background: var(--ofh-paper);
        border-bottom: 1px solid var(--ofh-line);
        box-shadow: 0 16px 30px rgba(28, 28, 26, 0.08);
        opacity: 0;
        translate: 0 -8px;
        transition: opacity 0.25s ease, translate 0.25s ease;
    }

    .ofm .ofm-search.is-open {
        opacity: 1;
        translate: 0 0;
    }

    .ofm .ofm-search__form {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0;
        padding: 12px var(--ofm-gutter);
    }

    .ofm .ofm-search__form > svg {
        flex: none;
        width: 20px;
        height: 20px;
        color: var(--ofh-ink-soft);
    }

    .ofm .ofm-search input[type="search"] {
        flex: 1;
        min-width: 0;
        height: 44px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        color: var(--ofh-ink);
        font-family: var(--ofh-font);
        font-size: 16px; /* 16px stops iOS zooming in */
        outline: none;
    }

    .ofm .ofm-search__submit {
        padding: 10px 16px;
        background: var(--ofh-ink);
        color: #fff !important;
        font-size: 11px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
    }

    /* ---- drawer ---- */

    .ofm .ofm-drawer {
        position: fixed;
        inset: 0;
        z-index: 100000; /* above the WP admin bar */
    }

    .ofm .ofm-drawer__scrim {
        position: absolute;
        inset: 0;
        background: rgba(28, 28, 26, 0.3); /* lighter tint: the blur does most of the work */
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
        opacity: 0;
        transition: opacity 0.4s ease;
    }

    .ofm .ofm-drawer__sheet {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        display: flex;
        flex-direction: column;
        width: min(420px, 100%);
        background: var(--ofh-paper);
        box-shadow: 12px 0 40px rgba(28, 28, 26, 0.12);
        transform: translateX(-100%);
        transition: transform 0.4s var(--ofh-ease);
    }

    .ofm .ofm-drawer.is-open .ofm-drawer__scrim {
        opacity: 1;
    }

    .ofm .ofm-drawer.is-open .ofm-drawer__sheet {
        transform: none;
    }

    .ofm .ofm-drawer__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex: none;
        height: var(--ofm-bar-height);
        padding: 0 var(--ofm-gutter) 0 calc(var(--ofm-gutter) - 10px);
        border-bottom: 1px solid var(--ofh-line);
    }

    .ofm .ofm-drawer__account {
        display: flex;
        align-items: center;
        gap: 8px;
        color: var(--ofh-ink-soft) !important;
        font-size: 11px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
        text-decoration: none !important;
    }

    .ofm .ofm-drawer__account svg {
        width: 20px;
        height: 20px;
    }

    /* main list and the sliding panels share this box */
    .ofm .ofm-panels {
        position: relative;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .ofm .ofm-main,
    .ofm .ofm-panel {
        position: absolute;
        inset: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        background: var(--ofh-paper);
    }

    .ofm .ofm-main {
        transition: transform 0.4s var(--ofh-ease), opacity 0.4s ease;
    }

    .ofm .ofm-main.is-behind {
        transform: translateX(-30%);
        opacity: 0;
    }

    .ofm .ofm-panel {
        visibility: hidden;
        transform: translateX(100%);
        transition: transform 0.4s var(--ofh-ease), visibility 0s linear 0.4s;
    }

    .ofm .ofm-panel.is-open {
        visibility: visible;
        transform: none;
        transition: transform 0.4s var(--ofh-ease), visibility 0s;
    }

    /* ---- top items ---- */

    .ofm .ofm-menu {
        padding: 8px var(--ofm-gutter) 0;
    }

    .ofm .ofm-menu > li + li {
        border-top: 1px solid var(--ofh-line);
    }

    .ofm .ofm-menu > li > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 58px;
        color: var(--ofh-ink) !important;
        font-size: 14px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
        text-decoration: none !important;
    }

    .ofm .ofm-menu > li.menu-item-has-children > a::after,
    .ofm .ofm-panel__back svg {
        flex: none;
    }

    .ofm .ofm-menu > li.menu-item-has-children > a::after {
        content: "";
        width: 7px;
        height: 7px;
        margin-right: 4px;
        border-top: 1px solid currentColor;
        border-right: 1px solid currentColor;
        transform: rotate(45deg);
    }

    /* rows cascade in when the drawer or a panel opens; --i is set in js/site-header-mobile.js */
    .ofm .ofm-menu > li,
    .ofm .ofm-panel > .sub-menu > li {
        opacity: 0;
        translate: 0 8px;
    }

    .ofm .ofm-drawer.is-open .ofm-menu > li,
    .ofm .ofm-panel.is-open > .sub-menu > li {
        opacity: 1;
        translate: none;
        transition: opacity 0.35s ease, translate 0.35s ease;
        transition-delay: calc(0.12s + var(--i, 0) * 0.05s);
    }

    /* ---- drawer footer ---- */

    .ofm .ofm-foot {
        margin-top: 16px;
        padding: 24px var(--ofm-gutter) 40px;
        background: var(--ofh-paper-warm);
    }

    .ofm .ofm-foot__links {
        display: flex;
        flex-wrap: wrap;
        gap: 10px 22px;
        padding-bottom: 22px !important;
        border-bottom: 1px solid #e3ddd3;
    }

    .ofm .ofm-foot a {
        color: var(--ofh-ink) !important;
        text-decoration: none !important;
    }

    .ofm .ofm-foot__links a,
    .ofm .ofm-foot__label {
        font-size: 11px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
    }

    .ofm .ofm-foot__links a {
        text-decoration: underline !important;
        text-decoration-color: rgba(28, 28, 26, 0.3) !important;
        text-underline-offset: 5px;
    }

    .ofm .ofm-foot__label {
        margin: 22px 0 12px;
        color: var(--ofh-ink-soft);
    }

    .ofm .ofm-showrooms {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 18px 16px;
    }

    .ofm .ofm-showrooms li {
        display: flex;
        flex-direction: column;
        gap: 3px;
        font-size: 14px;
        line-height: 1.4;
    }

    .ofm .ofm-showrooms__name {
        margin-bottom: 2px;
        color: var(--ofh-ink);
        font-size: 15px;
    }

    .ofm .ofm-showrooms a {
        color: var(--ofh-ink-soft) !important;
        text-decoration: underline !important;
        text-decoration-color: rgba(28, 28, 26, 0.25) !important;
        text-underline-offset: 4px;
    }

    /* ---- panels ---- */

    .ofm .ofm-panel__head {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        height: 56px;
        padding: 0 var(--ofm-gutter) 0 calc(var(--ofm-gutter) - 6px);
        background: var(--ofh-paper);
        border-bottom: 1px solid var(--ofh-line);
    }

    .ofm .ofm-panel__back {
        display: flex;
        align-items: center;
        gap: 6px;
        min-height: 44px;
        color: var(--ofh-ink) !important; /* parent theme makes buttons white */
        font-size: 13px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
    }

    .ofm .ofm-panel__back svg {
        width: 20px;
        height: 20px;
    }

    .ofm .ofm-panel__all {
        color: var(--ofh-ink-soft) !important;
        font-size: 11px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
        text-decoration: underline !important;
        text-decoration-color: rgba(28, 28, 26, 0.3) !important;
        text-underline-offset: 5px;
    }

    .ofm .ofm-panel > .sub-menu {
        padding: 4px var(--ofm-gutter) 40px;
    }

    .ofm .ofm-panel > .sub-menu > li {
        position: relative;
        border-bottom: 1px solid var(--ofh-line);
    }

    /* second level: groups ("SHOP BY BRAND") and plain links ("Contrast Therapy", Info pages) */
    .ofm .ofm-panel > .sub-menu > li > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        min-height: 56px;
        padding: 8px 0;
        color: var(--ofh-ink) !important;
        font-size: 16px;
        line-height: 1.35;
        text-decoration: none !important;
    }

    .ofm .ofm-panel > .sub-menu > li.ofm-acc > a {
        font-size: 12px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
    }

    .ofm .ofm-panel > .sub-menu > li.ofm-acc > a[role="button"] {
        cursor: pointer;
    }

    /* +/- on groups: on the label itself, or on the extra button next to a real link */
    .ofm .ofm-panel li.ofm-acc > a[role="button"]::after,
    .ofm .ofm-acc-toggle::after {
        content: "";
        flex: none;
        width: 12px;
        height: 12px;
        background:
            linear-gradient(currentColor, currentColor) center / 12px 1px no-repeat,
            linear-gradient(currentColor, currentColor) center / 1px 12px no-repeat;
        transition: transform 0.3s var(--ofh-ease), background-size 0.3s var(--ofh-ease);
    }

    .ofm .ofm-panel li.ofm-acc.is-expanded > a[role="button"]::after,
    .ofm .ofm-panel li.ofm-acc.is-expanded > .ofm-acc-toggle::after {
        transform: rotate(180deg);
        background-size: 12px 1px, 1px 0;
    }

    .ofm .ofm-panel li.ofm-acc:has(> .ofm-acc-toggle) > a {
        padding-right: 52px;
    }

    .ofm .ofm-acc-toggle {
        position: absolute;
        top: 0;
        right: -22px; /* lines its + up with the ones drawn on the labels */
        display: grid;
        place-items: center;
        width: 56px;
        height: 56px;
        color: var(--ofh-ink) !important;
    }

    /* group contents */
    .ofm .ofm-panel li.ofm-acc > .sub-menu {
        display: none;
        margin: 0 0 20px 2px !important;
        padding: 2px 0 2px 18px !important;
        border-left: 1px solid var(--ofh-line);
    }

    .ofm .ofm-panel li.ofm-acc.is-expanded > .sub-menu {
        display: block;
        animation: ofm-reveal 0.35s var(--ofh-ease);
    }

    @keyframes ofm-reveal {
        from {
            opacity: 0;
            translate: 0 -6px;
        }
    }

    .ofm .ofm-panel li.ofm-acc > .sub-menu a {
        display: block;
        padding: 9px 0;
        color: var(--ofh-ink) !important;
        font-size: 15px;
        line-height: 1.4;
        text-decoration: none !important;
    }

    /* in-list labels ("SUPPLIES") */
    .ofm .ofm-panel li.ofm-acc > .sub-menu li.disabled > a,
    .ofm .ofm-panel li.ofm-acc > .sub-menu li.black-link > a {
        margin-top: 10px;
        color: var(--ofh-ink-soft) !important;
        font-size: 11px;
        letter-spacing: 0.16em;
        text-transform: uppercase;
    }

    .ofm .ofm-panel li.ofm-acc > .sub-menu li.disabled > a {
        pointer-events: none;
    }

    /* ---- brand cards (logo from the Menu Image plugin, name, product count from functions.php) ---- */

    .ofm .ofm-panel li.ofm-acc > .sub-menu:has(img.menu-image) {
        margin-left: 0 !important;
        padding-left: 0 !important;
        border-left: 0;
    }

    .ofm .ofm-panel .sub-menu li:has(> a > img.menu-image) + li:has(> a > img.menu-image) {
        margin-top: 26px;
    }

    .ofm .ofm-panel .sub-menu li:has(> a > img.menu-image) + li:not(:has(> a > img.menu-image)) {
        margin-top: 16px;
    }

    .ofm .ofm-panel .sub-menu a:has(> img.menu-image) {
        display: flex !important;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0 16px;
        padding: 0 16px 14px !important;
        background: var(--ofh-paper-warm); /* whole card, so the logos' white boxes multiply into it */
        border-radius: 6px;
        box-shadow: 0 1px 2px rgba(28, 28, 26, 0.06), 0 4px 12px rgba(28, 28, 26, 0.06);
        text-align: left;
    }

    .ofm .ofm-panel .sub-menu img.menu-image {
        order: -1; /* the plugin prints the title first */
        display: block !important;
        flex: 0 0 100%;
        width: 100% !important;
        max-width: none;
        height: 76px !important;
        margin-bottom: 6px;
        padding: 14px 24px 6px;
        object-fit: contain;
        mix-blend-mode: multiply; /* the JPG logos' white box takes on the panel colour */
    }

    .ofm .ofm-panel .sub-menu a > .menu-image-title-hide.menu-image-title {
        display: block !important; /* style.css hides it: the card shows the name under the logo */
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        font-size: 15px;
        line-height: 1.3;
        text-align: left;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .ofm .ofh-brand__count {
        flex: none;
        color: var(--ofh-ink-soft);
        font-size: 11px;
        letter-spacing: 0.14em;
        line-height: 1.4;
        text-transform: uppercase;
        white-space: nowrap;
    }
}

@media only screen and (max-width: 1023px) and (prefers-reduced-motion: reduce) {
    .ofm *,
    .ofm *::before,
    .ofm *::after {
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
        animation: none !important;
    }
}
