/* When top navbar hides, move main navbar to the top */
body.top-navbar-hidden .main_navbar {
  top: 0;
}

/* When no top navbar, move main navbar to the top */
body.no-top-navbar .main_navbar {
  top: 0;
}

/*========== NAV + CONTAINER ==========*/
.main_navbar {
    position: fixed;
    width: 100%;
    top: var(--top-nav-height);
    left: 0;
    background: var(--menu-bg);
    z-index: 998;
}

.main_navbar.no-transition {
  transition: none !important;
}

.main_navbar-container {
    display: flex;
    position: relative;
    height: var(--main-nav-height);
    min-height: var(--main-nav-height);
    padding: 0.5rem clamp(1rem, 2vw + 0.5rem, 3rem);
    align-items: center;
    justify-content: space-between;
}

.main_navbar-logo {
    display: flex;
    z-index: 1000;
}

.main_navbar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--page-text);
    font-family: var(--logo-text-font-family);
    font-size: clamp(1.25rem, 1.5vw, 1.75rem);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}


.main_navbar-logo_img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(40.25px, 3.5vw, 48.3px);
    height: clamp(35px, 3vw, 42px);
}

.main_navbar-buttons {
    display: flex;
    align-items: center;
    gap: clamp(0.75rem, 1vw, 1.25rem);
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    outline: none;
    transition: transform 0.15s, box-shadow 0.2s;
}

.login-btn-link{
    font-size: clamp(0.9rem, 0.9vw, 1.05rem);
    font-weight: 700;
    color: var(--page-text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.login-btn:hover {
    text-shadow: 0 0 15px rgba(0, 213, 246, 0.50);
}

.getstarted-btn {
    display: flex;
    width: clamp(5rem, 15vw, 15.625rem);
    min-width: 8rem;
    align-items: center;
    justify-content: center;
    background: var(--primary-btn-bg);
    border: var(--primary-btn-border-color);
    outline: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
}

.getstarted-btn-link {
    display: block;
    width: 100%;
    height: 100%;
    padding: clamp(0.5rem, 0.8vw, 0.75rem) clamp(0.85rem, 1.5vw, 1.5rem);
    font-size: clamp(0.9rem, 0.9vw, 1.05rem);
    font-weight: 700;
    color: var(--primary-btn-text);
    text-decoration: none;
    white-space: nowrap;
}

.getstarted-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px -8px rgba(0, 213, 246, 0.50);
}

.main_navbar-toggle {
    display: flex;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1000;
}

/*========== Navigation for mobile devices ==========*/

@media screen and (max-width: 1000px){
    body.nav-open {
        overflow: hidden;
    }

    .main_navbar-menu {
        display: flex;
        position: fixed;

        left: -100vw;
        top: 0;

        width: 100vw;
        height: 100dvh;

        box-sizing: border-box;

        background-color: var(--menu-bg);

        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;

        padding-top: calc(clamp(6rem, 12vh, 10rem) + env(safe-area-inset-top));
        padding-right: calc(clamp(1rem, 5vw, 2.5rem) + env(safe-area-inset-right));
        padding-bottom: calc(clamp(1rem, 4vh, 2rem) + env(safe-area-inset-bottom));
        padding-left: calc(clamp(1rem, 5vw, 2.5rem) + env(safe-area-inset-left));

        flex-direction: column;
        justify-content: space-between;

        transition: left 0.4s, opacity 0.4s ease;
        z-index: 997;
    }

    .main_navbar-container .main_navbar-menu.active {
        left: 0;
    }

    /* Toggle transition */
    .main_navbar-toggle {
        display: block;
        opacity: 1;
        z-index: 998;
        transition: opacity 0.35s ease;
    }

    .main_navbar-toggle.hiding {
        opacity: 0;
        pointer-events: none;
    }

    /* Toggle animation */
    .main_navbar-toggle.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .main_navbar-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .main_navbar-toggle.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    /*Menu link animation*/
    .mnavm-item{
        opacity: 0;
        transform: translateX(-150px);
        transition: transform 0.4s ease-out, opacity 0.4s;
    }

    .main_navbar-menu.active .mnavm-item:nth-child(1){
        transition-delay: 0.1s;
    }
    .main_navbar-menu.active .mnavm-item:nth-child(2){
        transition-delay: 0.2s;
    }
    .main_navbar-menu.active .mnavm-item:nth-child(3){
        transition-delay: 0.3s;
    }
    .main_navbar-menu.active .mnavm-item:nth-child(4){
        transition-delay: 0.4s;
    }
    .main_navbar-menu.active .mnavm-item:nth-child(5){
        transition-delay: 0.5s;
    }
}

/*========== NAVBAR MOBILE MENU ==========*/
.mnavm-list {
    display: flex;
    flex-direction: column;
    row-gap: 3rem;
    list-style: none;
}

.mnavm-link {
    position: relative;
    color: var(--page-text);
    font-size: clamp(1rem, 4vw, 2.5rem);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.4s ease;
}

.mnavm-link i{
   position: absolute;
   opacity: 0;
   visibility: hidden;
   transition: opacity 0.4s, visibility 0.4s;
}

.mnavm-link span{
    position: relative;
    transition: margin 0.4s;
}

.mnavm-link span::after{
    position: absolute;
    content: '';
    left: 0;
    bottom: -6px;
    width: 0;
    height: 2px;
    background-color: var(--page-text);
    transition: width 0.4s ease-out;
}

/*========== Animation link on hover ==========*/
.mnavm-link:hover span{
    margin-left: 2.5rem;
}

.mnavm-link:hover i{
    opacity: 1;
    visibility: visible;
}

.mnavm-link:hover span::after{
   width: 100%;
}

/*========== Sibling fade animation ==========*/
.mnavm-list:has(.mnavm-link:hover) .mnavm-link:not(:hover){
    opacity: 0.4;
}

/*========== NAVBAR TOGGLE BTN ==========*/
.main_navbar-toggle .bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background: #fff;
    transition: all 0.3s ease-in-out;
}

/* ========== MOBILE MENU LINK ANIMATION ==========*/
.main_navbar-menu.active .mnavm-item {
    transform: translateX(0);
    opacity: 1;
}


.mnavm-butterfly-icon {
    display: inline-flex;
    width: 1.5rem;
    height: 1.5rem;
    background-size: contain;
    background-repeat: no-repeat;
}
.mnavm-butterfly-right-up-line{
    background-image: url("../../../images/icons/butterfly_icon_white.33f48204d983.svg");
}


/* ========== BREAKPOINTS FOR LARGE SCREENS ==========*/
@media screen and (min-width: 1000px){
    .main_navbar-container{ 
        display: grid;
        align-items: center;
        height: clamp(3.5rem, 5vh, 4.5rem);
        gap: clamp(1rem, 1.5vw, 2rem);
    }

    .main_navbar-logo {
        justify-self: start;
    }

    .main_navbar-menu {
        display: contents;
    }

    .mnavm-list {
        display: flex;
        flex-direction: row;
        column-gap: clamp(1.5rem, 2vw, 3rem);
        row-gap: 0;
        justify-self: center;
        grid-column: 2;
        list-style: none;
    }

    .main_navbar-buttons {
        display: flex;
        justify-self: end;
        grid-column: 3;
        margin: 0;
        gap: clamp(0.75rem, 1vw, 1.25rem);
    }

    .main_navbar-toggle {
        display: none;
        pointer-events: none;
    }

    .mnavm-link {
        font-size: clamp(0.95rem, 1vw, 1.1rem);
    }

    .mnavm-link i{
        font-size: clamp(1rem, 1.2vw, 1.35rem);
    }
}

:root[data-theme="light"] .mnavm-butterfly-right-up-line{
    background-image: url("../../../images/icons/butterfly_icon_black.5cca2a0e01dd.svg");
}


/* ========== PROFILE DROPDOWN (MAIN NAVBAR) ========== */
.profile {
    position: relative;
    z-index: 1001;
}

.profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease;
}

.profile-btn:hover { transform: scale(1.05); }
.profile-btn:active { transform: scale(0.98); }

.profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-btn-bg);
    border: 2px solid var(--accent);
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.profile-btn:hover .profile-avatar,
.profile.profile-open .profile-avatar {
    box-shadow: 0 0 0 4px var(--accent-soft);
    border-color: var(--accent);
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-initials {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-btn-text);
    user-select: none;
}

/* ===== Desktop dropdown ===== */
.profile-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;

    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    min-width: 200px;

    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;

    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    z-index: 1003;
    pointer-events: none;
}

.profile-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 16px;
    width: 12px;
    height: 12px;
    background: var(--surface-bg);
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    transform: rotate(45deg);
}

/* Open state */
.profile.profile-open .profile-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.profile-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;

    color: var(--page-text);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.profile-menu-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.profile-menu-sep {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

/* ===== Mobile: bottom sheet ===== */
@media screen and (max-width: 1000px) {
    .profile {
        position: static;
    }

    .profile-menu {
        position: fixed;
        left: 16px;
        right: 16px;
        bottom: 16px;
        top: auto;

        width: calc(100vw - 32px);
        max-width: 360px;
        min-width: 0;
        max-height: min(320px, 45vh);
        
        overflow: auto;

        transform: translate(12px);

        z-index: 1001;
    }

    .profile.profile-open .profile-menu {
        transform: translateY(0);
    }

    .profile-menu::before {
        display: none;
    }
}

/* Light theme adjustments */
:root[data-theme="light"] .profile-menu {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

:root[data-theme="light"] .profile-avatar {
    border-color: var(--accent);
}