/*
 * Layout 1 "Grat" (ridge)
 * Files: footer.php (footer1 branch), assets/js/hover-to-click-footer1.js
 *
 * The main menu stands on a mountain ridgeline fixed to the bottom of the viewport.
 * Colours come from the site's Customizer tokens; the ridge is the site's own shade,
 * outlined in its border colour. Labels sit under the circles, the current page is
 * the one filled circle, submenus stack upward like a cairn.
 */

:root {
    --ridge-h: 56px;          /* the flat band under the buttons; the circles rise into the peaks */
    --ridge-edge: 48px;       /* near range: peaks above the band */
    --ridge-far: 96px;        /* far range behind it, higher and fainter */
    --ridge-item: 54px;       /* menu circle */
    --ridge-home: 64px;       /* home circle */
    --ridge-gap: 4px;
    --ridge-label: 0.72rem;   /* label size; the home circle is padded by one label so all circles share a baseline */
}

body.layout-ridge {
    padding-bottom: calc(var(--ridge-h) + var(--ridge-far) + env(safe-area-inset-bottom, 0px));
}

/* The ridge is the navigation in this layout. */
body.layout-ridge .sidebar {
    display: none;
}

footer {
    margin: 0;
}

/* ---------- the band and its ridgeline ---------- */

.ridge-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    /* the box spans band + near range so the buttons may sit on the peaks; only the band is painted */
    height: calc(var(--ridge-h) + var(--ridge-edge) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
    background: linear-gradient(to top, var(--another-shade) calc(var(--ridge-h) + env(safe-area-inset-bottom, 0px)), transparent calc(var(--ridge-h) + env(safe-area-inset-bottom, 0px)));
    color: var(--text-color);
}

/* the near range: the band's own colour, with the crest drawn as a thin line */
.ridge-nav::before,
.ridge-nav::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--ridge-h) + env(safe-area-inset-bottom, 0px));
    height: var(--ridge-edge);
    z-index: 0;
    pointer-events: none;
    -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='100' viewBox='0 0 640 100' preserveAspectRatio='none'%3E%3Cpath d='M0 100V62L48 40 88 58 140 22 176 48 214 34 262 60 318 12 356 44 400 30 452 56 500 22 540 50 588 36 640 62V100Z'/%3E%3C/svg%3E") repeat-x left bottom / 640px var(--ridge-edge);
            mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='100' viewBox='0 0 640 100' preserveAspectRatio='none'%3E%3Cpath d='M0 100V62L48 40 88 58 140 22 176 48 214 34 262 60 318 12 356 44 400 30 452 56 500 22 540 50 588 36 640 62V100Z'/%3E%3C/svg%3E") repeat-x left bottom / 640px var(--ridge-edge);
}

.ridge-nav::before {
    background: var(--border-color-subtle);
    background: color-mix(in srgb, var(--another-shade) 45%, var(--h1-color));
}

.ridge-nav::after {
    background: var(--another-shade);
    transform: translateY(2px);
}

/* the far range: higher peaks, a fainter tone, offset so the ranges interleave */
.ridge-far {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--ridge-h) + env(safe-area-inset-bottom, 0px));
    height: var(--ridge-far);
    z-index: 0;
    pointer-events: none;
    /* an opaque tone with a hint of the site colour, so the far peaks read against the page in both modes */
    background: var(--another-shade);
    background: color-mix(in srgb, var(--another-shade) 80%, var(--h1-color));
    -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='100' viewBox='0 0 640 100' preserveAspectRatio='none'%3E%3Cpath d='M0 100V56L60 28 110 46 170 4 230 38 290 20 350 50 410 10 470 40 520 26 580 46 640 56V100Z'/%3E%3C/svg%3E") repeat-x -220px bottom / 640px var(--ridge-far);
            mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='100' viewBox='0 0 640 100' preserveAspectRatio='none'%3E%3Cpath d='M0 100V56L60 28 110 46 170 4 230 38 290 20 350 50 410 10 470 40 520 26 580 46 640 56V100Z'/%3E%3C/svg%3E") repeat-x -220px bottom / 640px var(--ridge-far);
}

/* ---------- the row ---------- */

.ridge-nav-track {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.ridge-nav-track::-webkit-scrollbar {
    display: none;
}

/* edge fades, shown by the script only towards the side that still scrolls */
.ridge-fade {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: 36px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ridge-fade-left {
    left: 0;
    background: linear-gradient(to right, var(--another-shade), transparent);
}

.ridge-fade-right {
    right: 0;
    background: linear-gradient(to left, var(--another-shade), transparent);
}

.ridge-nav.can-scroll-left .ridge-fade-left,
.ridge-nav.can-scroll-right .ridge-fade-right {
    opacity: 1;
}

footer #menu-main {
    display: flex;
    align-items: flex-end;
    gap: var(--ridge-gap);
    width: max-content;
    margin: 0 auto;
    padding: 0 0 7px;
    list-style: none;
}

footer #menu-main > li {
    position: relative;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
}

/* ---------- one item: circle above label ---------- */

footer #menu-main li a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 72px;
    padding: 0;
    color: var(--text-color) !important;
    text-decoration: none;
    font-family: inherit;
    font-size: var(--ridge-label);
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: 0.01em;
}

footer #menu-main li a > i,
footer #menu-main li a > img.custom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ridge-item);
    height: var(--ridge-item);
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--bg-color);
    border: 1px solid var(--border-color-subtle);
    color: var(--text-color);
    font-size: 1.35rem;
    object-fit: cover;
    transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

footer #menu-main li a:hover > i,
footer #menu-main li a:hover > img.custom-nav-icon {
    transform: translateY(-3px);
}

footer #menu-main .menu-item-text {
    display: block;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* current page: the one filled circle */
footer #menu-main > li.current-menu-item > a > i,
footer #menu-main > li.current-menu-ancestor > a > i,
footer #menu-main > li.current-menu-item > a > img.custom-nav-icon {
    background: var(--h1-color);
    border-color: var(--h1-color);
    color: var(--bg-color);
}

footer #menu-main > li.current-menu-item > a,
footer #menu-main > li.current-menu-ancestor > a {
    color: var(--h1-color) !important;
}

/* open parent */
footer #menu-main > li.is-open > a > i {
    background: var(--text-color);
    border-color: var(--text-color);
    color: var(--bg-color);
}

footer #menu-main li a:focus-visible {
    outline: none;
}

footer #menu-main li a:focus-visible > i,
footer #menu-main li a:focus-visible > img.custom-nav-icon,
footer #menu-item-home a:focus-visible svg {
    outline: 2px solid var(--focus-color, var(--h1-color));
    outline-offset: 3px;
}

/* ---------- home: the site mark, a size larger ---------- */

footer #menu-item-home {
    margin-right: 10px;
}

footer #menu-item-home a {
    width: var(--ridge-home);
    /* no label under the mark: pad by a label's height plus the gap so its bottom lines up with the other circles */
    padding-bottom: calc(var(--ridge-label) * 1.15 + 5px);
}

footer #menu-item-home a svg {
    display: block;
    width: var(--ridge-home);
    height: var(--ridge-home);
    padding: 3px;
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--bg-color);
    border: 1px solid var(--border-color-subtle);
    color: var(--text-color);
    transition: transform 0.18s ease;
}

footer #menu-item-home a:hover svg {
    transform: translateY(-3px);
}

footer #menu-item-home.current-menu-item a svg {
    background: var(--h1-color);
    border-color: var(--h1-color);
    color: var(--bg-color);
}

/* the colour chooser forces the mark's fill to the text colour; on the filled circle it must be the ground */
footer #menu-item-home.current-menu-item a svg path {
    fill: var(--bg-color) !important;
}

/* ---------- submenu: a cairn above the item ---------- */

footer #menu-main .sub-menu {
    display: none;
    position: fixed;
    bottom: calc(var(--ridge-h) + var(--ridge-edge) + env(safe-area-inset-bottom, 0px));
    left: 0;
    z-index: 10000;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--another-shade);
    border: 1px solid var(--border-color-subtle);
    border-radius: 16px;
}

footer #menu-main .sub-menu.is-open {
    display: flex;
}

footer #menu-main .sub-menu li {
    margin: 0;
    padding: 0;
}

footer #menu-main .sub-menu li a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    width: auto;
    min-width: 160px;
    padding: 3px 14px 3px 3px;
    border-radius: 999px;
    font-size: 0.82rem;
    transition: background-color 0.18s ease;
}

footer #menu-main .sub-menu li a > i,
footer #menu-main .sub-menu li a > img.custom-nav-icon {
    width: 38px;
    height: 38px;
    font-size: 1.05rem;
}

footer #menu-main .sub-menu li a:hover {
    background: var(--bg-color);
}

footer #menu-main .sub-menu li a:hover > i {
    transform: none;
}

footer #menu-main .sub-menu li.current-menu-item a > i {
    background: var(--h1-color);
    border-color: var(--h1-color);
    color: var(--bg-color);
}

footer #menu-main .sub-menu .menu-item-text {
    max-width: none;
    white-space: normal;
    text-align: left;
}

/* the parent page stays reachable: last entry, nearest to the circle */
footer #menu-main .sub-menu li.open-main-item {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border-color-subtle);
}

/* ---------- the one motion moment: the ridge rises once ---------- */

@media (prefers-reduced-motion: no-preference) {
    .ridge-nav {
        animation: ridge-rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }

    @keyframes ridge-rise {
        from { transform: translateY(calc(100% + var(--ridge-far))); }
        to   { transform: none; }
    }
}

/* ---------- floating cart (woo-merchants) keeps the same circle language ---------- */

.wm-floating-cart {
    position: fixed;
    top: 84px;
    right: 20px;
    bottom: auto;
    width: var(--ridge-item);
    height: var(--ridge-item);
    border-radius: 50%;
    background: var(--bg-color);
    border: 1px solid var(--border-color-subtle);
    color: var(--text-color);
    font-size: 20px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.wm-floating-cart:hover {
    background: var(--another-shade);
    color: var(--text-color);
}

.wm-floating-cart-count {
    background: var(--h1-color) !important;
    color: var(--bg-color) !important;
}

/* ---------- small screens ---------- */

@media (max-width: 768px) {
    :root {
        --ridge-h: 50px;
        --ridge-edge: 30px;
        --ridge-far: 60px;
        --ridge-item: 48px;
        --ridge-home: 56px;
        --ridge-gap: 2px;
        --ridge-label: 0.66rem;
    }

    footer #menu-main li a {
        width: 64px;
    }

    footer #menu-main .menu-item-text {
        max-width: 64px;
    }

    footer #menu-main li a > i,
    footer #menu-main li a > img.custom-nav-icon {
        font-size: 1.2rem;
    }

    footer #menu-item-home {
        margin-right: 4px;
    }

    .wm-floating-cart {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        font-size: 17px;
    }
}
