/*
 * Layout 2 "Kreis" (circle)
 * Files: sidebar.php, footer.php (footer2 branch), assets/js/toggle-sidebar.js
 *
 * The navigation follows a drawn arc, the way the site mark is a drawn ring.
 * On wide screens (min-width 1420px) the items sit on the arc along the left edge.
 * Below that a round button in the bottom-right corner opens the same items as a
 * quarter-circle fan over a scrim. Colours come from the site's Customizer tokens.
 */

:root {
    --circle-item: 56px;
    --circle-logo: 64px;
    --circle-fan-item: 48px;
    --circle-toggle: 60px;
}

/* ---------- the quiet footer ---------- */

footer {
    margin-top: 96px;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-color-muted, var(--border-color));
}

.circle-footer {
    display: inline-block;
    padding-top: 14px;
    border-top: 1px solid var(--border-color-subtle);
}

/* ---------- shared item anatomy ---------- */

.circle-nav {
    color: var(--text-color);
}

.circle-nav .circle-menu-item {
    margin: 0;
}

.circle-nav .circle-menu-item > a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 72px;
    color: var(--text-color) !important;
    text-decoration: none;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: 0.01em;
}

.circle-nav .circle-menu-item > a > i,
.circle-nav .circle-menu-item > a > img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--circle-item);
    height: var(--circle-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;
}

.circle-nav .circle-menu-item > a:hover > i,
.circle-nav .circle-menu-item > a:hover > img {
    transform: translateY(-3px);
}

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

.circle-nav .circle-menu-item.current-menu-item > a > i,
.circle-nav .circle-menu-item.current-menu-ancestor > a > i,
.circle-nav .circle-menu-item.current-menu-item > a > img {
    background: var(--h1-color);
    border-color: var(--h1-color);
    color: var(--bg-color);
}

.circle-nav .circle-menu-item.current-menu-item > a,
.circle-nav .circle-menu-item.current-menu-ancestor > a {
    color: var(--h1-color) !important;
}

.circle-nav .circle-menu-item.is-open > a > i {
    background: var(--text-color);
    border-color: var(--text-color);
    color: var(--bg-color);
}

.circle-nav .circle-menu-item > a:focus-visible {
    outline: none;
}

.circle-nav .circle-menu-item > a:focus-visible > i,
.circle-nav .circle-menu-item > a:focus-visible > img {
    outline: 2px solid var(--focus-color, var(--h1-color));
    outline-offset: 3px;
}

/* the site mark */
.circle-nav .circle-menu-item.logo {
    padding: 0;
}

.circle-nav .circle-menu-item.logo > img {
    width: var(--circle-logo);
    height: var(--circle-logo);
    padding: 0;
    border-color: transparent;
}

.circle-nav-empty {
    margin: 0;
    padding: 8px;
    font-size: 0.75rem;
}

/* ---------- submenu: pills beside the item ---------- */

.circle-nav .sub-menu {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 6px;
    background: var(--another-shade);
    border: 1px solid var(--border-color-subtle);
    border-radius: 16px;
}

.circle-nav .circle-menu-item.is-open > .sub-menu {
    display: flex;
}

.circle-nav .sub-menu .circle-menu-item {
    position: static;
    transform: none;
}

.circle-nav .sub-menu .circle-menu-item > 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;
}

.circle-nav .sub-menu .circle-menu-item > a > i,
.circle-nav .sub-menu .circle-menu-item > a > img {
    width: 38px;
    height: 38px;
    font-size: 1.05rem;
}

.circle-nav .sub-menu .circle-menu-item > a:hover {
    background: var(--bg-color);
}

.circle-nav .sub-menu .circle-menu-item > a:hover > i {
    transform: none;
}

.circle-nav .sub-menu .menu-item-text {
    max-width: none;
    white-space: normal;
    text-align: left;
}

/* the parent page stays reachable: first entry */
.circle-nav .sub-menu .open-main-item {
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color-subtle);
}

/* ---------- the toggle and the scrim (fan state only) ---------- */

.circle-nav-toggle {
    display: none;
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 10002;
    align-items: center;
    justify-content: center;
    width: var(--circle-toggle);
    height: var(--circle-toggle);
    padding: 3px !important;
    box-sizing: border-box;
    border-radius: 50% !important;
    border: 1px solid var(--border-color-subtle) !important;
    background: var(--bg-color) !important;
    color: var(--bg-color) !important;
    box-shadow: 0 6px 18px var(--shadow-color);
    cursor: pointer;
    font: inherit;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.circle-nav-toggle:hover,
.circle-nav-toggle:active {
    transform: none;
}

.circle-nav-toggle img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.circle-nav-toggle i {
    display: none;
    font-size: 26px;
    line-height: 1;
}

.circle-nav-toggle[aria-expanded="true"] {
    background: var(--h1-color) !important;
    border-color: var(--h1-color) !important;
}

.circle-nav-toggle[aria-expanded="true"] img {
    display: none;
}

.circle-nav-toggle[aria-expanded="true"] i {
    display: block;
}

.circle-nav-toggle:focus-visible {
    outline: 2px solid var(--focus-color, var(--h1-color));
    outline-offset: 3px;
}

.circle-nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--bg-color);
    opacity: 0.88;
}

.circle-nav-scrim[hidden] {
    display: none;
}

/* the other floating buttons step aside while the fan is open */
body.circle-nav-open .wm-floating-cart,
body.circle-nav-open .rtcs-create-fab {
    opacity: 0;
    pointer-events: none;
}

/* ---------- floating cart (woo-merchants) ---------- */

.wm-floating-cart {
    position: fixed;
    right: 20px;
    bottom: calc(20px + var(--circle-toggle) + 14px + env(safe-area-inset-bottom, 0px));
    top: auto;
    z-index: 1001;
    width: var(--circle-item);
    height: var(--circle-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);
    transition: opacity 0.18s ease;
}

.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;
}

/* =========================================================
 * Wide screens: the rail on the arc
 * ========================================================= */

@media (min-width: 1420px) {
    .circle-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 999;
        width: 120px;
    }

    .circle-nav-arc {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        overflow: visible;
        pointer-events: none;
    }

    .circle-nav-arc path {
        fill: none;
        stroke: var(--h1-color);
        stroke-width: 1.5;
        stroke-linecap: round;
        opacity: 0.55;
    }

    .circle-menu-container {
        position: relative;
        height: 100%;
    }

    /* the script sets --x (bulge) and --y (top) per item */
    .circle-menu-container > .circle-menu-item {
        position: absolute;
        top: 0;
        left: 16px;
        transform: translate(var(--x, 0px), var(--y, 0px));
    }

    .circle-menu-container > .circle-menu-item.logo {
        margin-left: 4px;
    }

    .circle-menu-container > .circle-menu-item > a > .menu-item-text {
        max-width: 84px;
        padding: 1px 5px;
        border-radius: 6px;
        background: var(--bg-color);
    }

    .circle-nav .circle-menu-item.is-open > .sub-menu {
        position: absolute;
        top: 0;
        left: calc(100% + 8px);
        z-index: 2;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }

    .circle-nav .circle-menu-item.opens-up.is-open > .sub-menu {
        top: auto;
        bottom: 0;
    }

    .wm-floating-cart {
        bottom: 20px;
    }

    /* the one motion moment: the arc draws itself once */
    @media (prefers-reduced-motion: no-preference) {
        .circle-nav-arc path {
            stroke-dasharray: 2400;
            stroke-dashoffset: 2400;
            animation: circle-arc-draw 1s ease-out 0.1s forwards;
        }

        @keyframes circle-arc-draw {
            to { stroke-dashoffset: 0; }
        }
    }
}

/* =========================================================
 * Everything narrower: the button and the fan
 * ========================================================= */

@media (max-width: 1419px) {
    .circle-nav-toggle {
        display: flex;
    }

    .circle-nav-arc {
        display: none;
    }

    .circle-nav {
        position: fixed;
        inset: 0;
        z-index: 10001;
        pointer-events: none;
        visibility: hidden;
        transition: visibility 0s linear 0.35s;
    }

    .circle-nav.is-open {
        visibility: visible;
        transition-delay: 0s;
    }

    /* origin = the centre of the toggle */
    .circle-menu-container {
        position: absolute;
        right: calc(20px + var(--circle-toggle) / 2);
        bottom: calc(20px + var(--circle-toggle) / 2 + env(safe-area-inset-bottom, 0px));
        width: 0;
        height: 0;
    }

    .circle-menu-container > .circle-menu-item {
        position: absolute;
        right: 0;
        bottom: 0;
        pointer-events: auto;
        opacity: 0;
        transform: translate(24px, 24px) scale(0.3);
        transform-origin: right bottom;
        transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease;
        transition-delay: 0s;
    }

    .circle-nav.is-open .circle-menu-container > .circle-menu-item {
        opacity: 1;
        transform: translate(var(--x, 0px), var(--y, 0px));
        transition-delay: calc(var(--i, 0) * 28ms);
    }

    /* the link is the circle; the label sits radially outward (the script sets --lx/--ly) */
    .circle-menu-container > .circle-menu-item > a {
        position: relative;
        display: block;
        width: var(--circle-fan-item);
        height: var(--circle-fan-item);
        font-size: 0.74rem;
    }

    .circle-menu-container > .circle-menu-item > a > i,
    .circle-menu-container > .circle-menu-item > a > img {
        width: var(--circle-fan-item);
        height: var(--circle-fan-item);
        font-size: 1.2rem;
        box-shadow: 0 4px 14px var(--shadow-color);
    }

    .circle-menu-container > .circle-menu-item > a > .menu-item-text {
        position: absolute;
        left: 50%;
        top: 50%;
        max-width: 96px;
        transform: translate(calc(-50% + var(--lx, 0px)), calc(-50% + var(--ly, 0px)));
    }

    /* more items than an arc can hold: a round-cornered sheet above the button */
    .circle-nav.is-sheet .circle-menu-container {
        display: grid;
        grid-template-columns: repeat(4, 72px);
        gap: 10px 4px;
        width: auto;
        height: auto;
        right: 16px;
        bottom: calc(20px + var(--circle-toggle) + 14px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100vw - 32px);
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        padding: 14px 10px;
        box-sizing: border-box;
        background: var(--another-shade);
        border: 1px solid var(--border-color-subtle);
        border-radius: 22px;
        pointer-events: auto;
        opacity: 0;
        transform: translateY(12px) scale(0.96);
        transform-origin: right bottom;
        transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease;
    }

    .circle-nav.is-sheet.is-open .circle-menu-container {
        opacity: 1;
        transform: none;
    }

    .circle-nav.is-sheet .circle-menu-container > .circle-menu-item,
    .circle-nav.is-sheet.is-open .circle-menu-container > .circle-menu-item {
        position: static;
        opacity: 1;
        transform: none;
        transition: none;
    }

    .circle-nav.is-sheet .circle-menu-container > .circle-menu-item > a {
        display: flex;
        flex-direction: column;
        width: 72px;
        height: auto;
    }

    .circle-nav.is-sheet .circle-menu-container > .circle-menu-item > a > i,
    .circle-nav.is-sheet .circle-menu-container > .circle-menu-item > a > img {
        box-shadow: none;
    }

    .circle-nav.is-sheet .circle-menu-container > .circle-menu-item > a > .menu-item-text {
        position: static;
        max-width: 72px;
        transform: none;
    }

    @media (max-width: 400px) {
        .circle-nav.is-sheet .circle-menu-container {
            grid-template-columns: repeat(3, 72px);
        }
    }

    /* an open submenu takes the top of the screen, well away from the fan */
    .circle-nav .circle-menu-item.is-open > .sub-menu {
        position: fixed;
        top: calc(16px + env(safe-area-inset-top, 0px));
        left: 16px;
        right: 16px;
        z-index: 3;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        pointer-events: auto;
    }

    .circle-nav .sub-menu .circle-menu-item > a {
        min-width: 0;
    }

    .circle-nav .sub-menu .open-main-item {
        margin: 0;
        padding: 0;
        border: 0;
    }

    .circle-nav .sub-menu .open-main-item > a {
        background: var(--bg-color);
    }
}

@media (max-width: 1419px) and (prefers-reduced-motion: reduce) {
    .circle-nav,
    .circle-menu-container > .circle-menu-item,
    .circle-nav.is-open .circle-menu-container > .circle-menu-item {
        transition: none;
    }
}
