/* Widget: Radial Navbar */
.w-navbar {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-navbar);
    display: flex;
    justify-content: center;
    align-items: center;

    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.w-navbar.is-hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.4s;
}

/* Trigger Button (Burger) */
.w-navbar-trigger {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    /* bg-glass defined in HTML/Utilities, adding specific overrides */

    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: var(--z-dropdown);
    /* Above items and overlay */
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.w-navbar-trigger:hover {
    border-color: var(--c-primary);
    box-shadow: 0 0 15px color-mix(in srgb, var(--c-primary), transparent 70%);
}

.w-navbar.is-open .w-navbar-trigger {
    border-color: var(--c-primary);
    box-shadow: 0 0 15px color-mix(in srgb, var(--c-primary), transparent 70%);
}

/* Icons in Trigger */
.w-navbar-trigger .icon-wrapper {
    position: relative;
    width: 24px;
    height: 24px;
}

.w-navbar-trigger .icon-wrapper svg {
    position: absolute;
    top: 0;
    left: 0;
    transition: all 0.4s ease;
}

.w-navbar-trigger .icon-close {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
}

.w-navbar.is-open .w-navbar-trigger .icon-menu {
    opacity: 0;
    transform: rotate(180deg) scale(0.5);
}

.w-navbar.is-open .w-navbar-trigger .icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Radial Menu Items Container */
.w-navbar-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: calc(var(--z-navbar) + 1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.4s;
}

.w-navbar.is-open .w-navbar-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0s;
}

/* Individual Radial Item */
.w-radial-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;

    /* background/border handled by .bg-glass-strong */

    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    color: var(--c-text);
    /* Force color for <a> tags */

    /* Center physically using margins */
    margin-top: -1.5rem;
    margin-left: -1.5rem;

    /* Start closed */
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s 0.5s;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.w-radial-item:hover {
    border-color: var(--c-secondary);
    box-shadow: 0 0 15px color-mix(in srgb, var(--c-secondary), transparent 70%);
    color: var(--c-secondary);
    /* Override transform from position */
    z-index: var(--z-above);
}

/* Fan-out Logic */
.w-navbar.is-open .w-radial-item {
    opacity: 1;
    visibility: visible;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s 0s;
    /* 
       Calculate position on a semi-circle below the trigger.
       Radius: 80px (approx 5 rem)
       Angles: distributed from 180deg (Left) to 360deg (Right)? 
       Let's map --i (0..3) to angles: -60, -20, +20, +60 degrees from vertical down?
    */

    /* 
       Using trig in CSS (if supported) or simplified calc. 
       Since we have fixed 4 items, let's use exact transforms based on --i 
    */

    /* 
      i=0 -> -55 deg
      i=1 -> -20 deg
      i=2 -> +20 deg
      i=3 -> +55 deg
      Radius = 90px
    */
}

/* Fan-out Logic (Desktop Defaults: DOWN) */
.w-navbar.is-open .w-radial-item[style*="--i:0"] {
    transform: rotate(-55deg) translateY(90px) rotate(55deg);
}

.w-navbar.is-open .w-radial-item[style*="--i:1"] {
    transform: rotate(-20deg) translateY(90px) rotate(20deg);
}

.w-navbar.is-open .w-radial-item[style*="--i:2"] {
    transform: rotate(20deg) translateY(90px) rotate(-20deg);
}

.w-navbar.is-open .w-radial-item[style*="--i:3"] {
    transform: rotate(55deg) translateY(90px) rotate(-55deg);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .w-navbar {
        top: auto;
        bottom: calc(30px + env(safe-area-inset-bottom, 0px));
        margin-bottom: 0;
        -webkit-tap-highlight-color: transparent;
    }

    /* Invert Fan-out to go UP instead of down */
    .w-navbar.is-open .w-radial-item[style*="--i:0"] {
        transform: rotate(-55deg) translateY(-90px) rotate(55deg);
    }

    .w-navbar.is-open .w-radial-item[style*="--i:1"] {
        transform: rotate(-20deg) translateY(-90px) rotate(20deg);
    }

    .w-navbar.is-open .w-radial-item[style*="--i:2"] {
        transform: rotate(20deg) translateY(-90px) rotate(-20deg);
    }

    .w-navbar.is-open .w-radial-item[style*="--i:3"] {
        transform: rotate(55deg) translateY(-90px) rotate(-55deg);
    }
}