/* The rail's size (main_nav.pug) - shared with layouts that offset their content
   for it (_app/_app_layout.css). */
:root {
    --rail-width: 85px;
    --rail-bar-height: 60px;
    --avatar-size: 38px; /* the profile button (menu/menu.css .profile-btn) */
}

/* -----------------------------
   BASE LAYOUT
----------------------------- */

.page-container {
    display: flex;
    position: relative;
    min-height: 100dvh;
    width: 100%;
    height: 100%;
}

.menu-holder {
    position: fixed;
    top: 0;
    z-index: 2;
    height: 100dvh;
}

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

/* -----------------------------
   SIDEBAR MAIN MENU
----------------------------- */

#mainMenu {
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    width: var(--rail-width);
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* scrollable middle */
.menu-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* top + bottom anchors */
#hamburgerAnchorMainMenu {
    flex-shrink: 0;
}



/* The avatar (profile menu, main_nav.pug #ui). Not inside the rail: fixed at
   the spot it has in it - bottom-centre of the desktop rail, right end of the
   mobile bar - so the rail can collapse or slide around it without moving it. */
#ui {
    position: fixed;
    z-index: 1001;
    left: calc((var(--rail-width) - var(--avatar-size)) / 2);
    bottom: 10px;
}

/* Its place in the rail (main_nav.pug): an empty item that holds the space, so
   the rail's flex layout keeps the items clear of the avatar at any size.
   Desktop: the rail's foot. */
.rail-avatar-slot {
    flex: 0 0 auto;
    width: 100%;
    height: calc(var(--avatar-size) + 20px);
}

/* -----------------------------
   NAV ITEMS (BASE - BOTH MODES)
----------------------------- */

#mainMenu .nav {
    width: 100%;
}

#mainMenu .nav-item {
    flex: 0 0 auto;
}

#mainMenu .nav-link {
    user-select: none;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 10px;
    transition: background 0.15s ease;
}

/* hover + active */
#mainMenu .nav-link:hover {
    background: none;
}

#mainMenu .nav-link.active {
    background: none;
}

/* icon */
#mainMenu .nav-link i {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: background 0.15s ease, color 0.15s ease;
}

#mainMenu .nav-link:hover i {
    background: rgba(111, 66, 193, 0.12); /* soft purple */
    color: #6f42c1;
}

/* label */
#mainMenu .nav-link span {
    transition: color 0.15s ease;
}

#mainMenu .nav-link:hover span {
    color: #6f42c1;
}

#mainMenu .nav-link.active i {
    background: rgba(111, 66, 193, 0.18);
    color: #6f42c1;
}

#mainMenu .nav-link.active span {
    color: #6f42c1;
    font-weight: 500;
}

/* Selected main-menu item: the filled glyph. Bootstrap Icons has no
   "-fill" twin for graph-up, so Sales is bar-chart-line (filled when selected). */
#mainMenu .nav-link.active i.bi-house-door::before { content: "\f422"; }
#mainMenu .nav-link.active i.bi-palette::before { content: "\f4b0"; }
#mainMenu .nav-link.active i.bi-bar-chart-line::before { content: "\f17b"; }
#mainMenu .nav-link.active i.bi-gear::before { content: "\f3e2"; }
#mainMenu .nav-link.active i.bi-shield-lock::before { content: "\f537"; }

/* Section menu links (home_menu/design_menu/sales_menu/settings_menu/
   audience_menu/member_menu - whichever is currently mounted in #sideMenu).
   Generic on purpose: modules/activeLinks.js toggles `.active` on any
   `.nav-link` under #sideMenu purely from its resolved href, with no
   knowledge of which menu or which items it holds, so this rule needs no
   per-menu counterpart either. */
#sideMenu .nav-link {
    border-radius: 8px;
}

/* A menu in sections (admin/_admin_menu.pug): an h6 label at the menu's edge,
   its list of links indented beneath it */
#sideMenu .menu-sections {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    padding: 0 1rem;
}

#sideMenu .menu-section > .navbar-nav {
    padding-left: .75rem;
}

#sideMenu .menu-section-label {
    margin: 0 0 .5rem;
    padding: 0;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

#sideMenu .menu-section-empty {
    margin: 0;
    padding: 0 0 0 .75rem;
    font-size: .8rem;
    color: var(--text-tertiary);
}

#sideMenu .nav-link.active {
    background: rgba(111, 66, 193, 0.1);
    border-radius: 8px;
    color: #6f42c1;
    font-weight: 500;
}

#sideMenu .nav-link.active i {
    color: #6f42c1;
}

/* Dark mode: hover and selected are white (text + icon), not purple. The
   section menus' icons are Font Awesome solid already, so they are filled. */
html[data-bs-theme='dark'] #mainMenu .nav-link:hover i,
html[data-bs-theme='dark'] #mainMenu .nav-link:hover span,
html[data-bs-theme='dark'] #mainMenu .nav-link.active i,
html[data-bs-theme='dark'] #mainMenu .nav-link.active span,
html[data-bs-theme='dark'] #sideMenu .nav-link:hover,
html[data-bs-theme='dark'] #sideMenu .nav-link:hover i,
html[data-bs-theme='dark'] #sideMenu .nav-link.active,
html[data-bs-theme='dark'] #sideMenu .nav-link.active i {
    color: #fff !important;
}





/* -----------------------------
   CONTENT (BASE)
----------------------------- */

#content-container {
    position: sticky;
    z-index: 1;
    margin-left: var(--rail-width);
    width: 100%;
    display: flex;
    height: 100%;
}

.main-content {
    margin-left: 0;
}

.content-pane {
    padding: 0 0.5rem;
}

/* overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    display: none;
}

.menu-overlay.show {
    display: block;
}

/* -----------------------------
   MOBILE (BOTTOM NAV)
----------------------------- */

@media (max-width: 767px) {

    .page-container {
        flex-direction: column;
    }

    .menu-holder {
        height: unset;
    }

    .menu-container {
        flex-direction: column;
        height: auto;
    }

    #mainMenu {
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: var(--rail-bar-height);
        display: flex;
        flex-direction: row;
        align-items: center;
        z-index: 1000;
    }

    #hamburgerAnchorMainMenu {
        display: none;
    }

    .menu-scroll {
        flex: 1 1 auto;
        min-width: 0;
        overflow: visible;
    }

    #mainMenu .nav {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        padding: 0 6px;
        gap: 6px;
    }

    #mainMenu .nav-item {
        flex-grow: 1;
        min-width: 0; /* shrink on a narrow screen rather than overflow into the avatar's slot */
        text-align: center;
    }

    #mainMenu .nav-link {
        width: 56px;
        max-width: 100%; /* with .nav-item min-width:0 - narrows instead of overflowing */
        gap: 2px;
        padding: 4px 0;
    }

    #mainMenu .nav-link i {
        font-size: 16px;
        width: 34px;
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
    }

    #mainMenu .nav-link span {
        font-size: 9px;
    }

    #ui {
        left: auto;
        right: 14px;
        bottom: calc((var(--rail-bar-height) - var(--avatar-size)) / 2);
    }

    /* mobile: the bar's right end */
    .rail-avatar-slot {
        width: calc(var(--avatar-size) + 16px);
        height: 100%;
    }

    #sideMenu {
        position: fixed;
        height: 100dvh;
        width: 204px;
        z-index: 2000;
        top: 0;
        left: -204px;
        transition: left 0.2s ease-out;
        /* frosted: blur of what's behind + the theme's gradient at 92%.
           backdrop-filter never blurs the menu's own children. Needs no
           bg-* class on #sideMenu - Bootstrap's are !important */
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }

    /* The gradient .bg-secondary-subtle actually paints (custom_purple.css),
       on its own layer so opacity fades it and not the menu options. */
    #sideMenu::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        border-radius: inherit;
        background: var(--brand-body-bg-grad);
        opacity: 0.94;
    }

    #sideMenu.show {
        left: 0;
    }

    #content-container {
        margin-left: 0 !important;
        width: 100%;
        padding-bottom: var(--rail-bar-height);
    }

    #mainContent,
    .main-content {
        margin-left: 0 !important;
    }

    .mobile-side-controls {
        display: flex !important;
    }
    #mainMenu,
    #content-container {
        transition: transform 0.3s ease, padding-bottom 0.3s ease;
    }

    /* Signed out: no bar. It slides off the bottom and the page runs to the
       bottom edge; the avatar (#ui) isn't in it, so it stays exactly where it
       was. Signing in slides the bar back up around it. */
    .page-container[data-signed-in="false"] #mainMenu {
        transform: translateY(100%);
    }

    .page-container[data-signed-in="false"] #content-container {
        padding-bottom: 0;
    }

    /* what a page's screen-fixed UI (attached here - [data-overlay-root], e.g.
       the public page's checkout bar) must clear: the rail's bar, while it's up */
    .page-container[data-signed-in="true"] {
        --shell-bottom-inset: var(--rail-bar-height);
    }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    #mainMenu,
    #content-container {
        transition: none;
    }
}

/* -----------------------------
   DESKTOP (SIDEBAR NAV)
----------------------------- */

@media (min-width: 768px) {

    .menu-container {
        flex-direction: row;
        width: fit-content;
    }

    #mainMenu {
        width: var(--rail-width);
        height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 6px 0;
    }

    #mainMenu .nav {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
        gap: 10px;
        flex: 1;
    }

    #mainMenu .nav-link {
        width: 70px;
        gap: 4px;
        padding: 6px 0;
    }

    #mainMenu .nav-link i {
        font-size: 20px;
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
    }

    #mainMenu .nav-link span {
        font-size: 11px;
    }

    #sideMenu {
        width: 204px;
        transform: none;
        background: var(--brand-body-bg-grad);
    }

    #sideMenu.hidden {
        display: none;
    }

    #content-container {
        margin-left: var(--rail-width);
    }

    #mainContent,
    .main-content {
        margin-left: 204px;
    }

    #mainContent.menu-offset,
    .main-content.menu-offset,
    .menu-offset {
        margin-left: 0px;
    }

    .mobile-side-controls {
        display: none !important;
    }
}

/* Logo (giveap.svg inlined by _main.pug). Page CSS styles the gradient's stops:
   - g/i/e/p fade to gray (--logo-gray, 1.5s) while the socket is not open
     (data-socket on <html>, set by body-scripts refreshStatus). A fill can't
     fade between a flat color and a gradient, so the stops themselves are
     mixed toward gray.
   - while open, the stops flip end to end (--logo-stop-N, 8s), unless the
     user prefers reduced motion.
   Registered so they interpolate; the stop initial values are the file's. */
@property --logo-gray { syntax: '<percentage>'; inherits: true; initial-value: 0%; }
@property --logo-stop-0 { syntax: '<color>'; inherits: true; initial-value: #b249e9; }
@property --logo-stop-1 { syntax: '<color>'; inherits: true; initial-value: #6359e4; }
@property --logo-stop-2 { syntax: '<color>'; inherits: true; initial-value: #5c75e1; }
@property --logo-stop-3 { syntax: '<color>'; inherits: true; initial-value: #588bdf; }
@property --logo-stop-4 { syntax: '<color>'; inherits: true; initial-value: #529add; }
@property --logo-stop-5 { syntax: '<color>'; inherits: true; initial-value: #4fb7de; }

.giveap-logo svg { display: block; width: 150px; height: auto; }
.giveap-logo { transition: --logo-gray 1.5s ease; }
html:not([data-socket="open"]) .giveap-logo { --logo-gray: 100%; }

.giveap-logo stop:nth-of-type(1) { stop-color: color-mix(in srgb, var(--logo-stop-0), #9aa0a6 var(--logo-gray)); }
.giveap-logo stop:nth-of-type(2) { stop-color: color-mix(in srgb, var(--logo-stop-1), #9aa0a6 var(--logo-gray)); }
.giveap-logo stop:nth-of-type(3) { stop-color: color-mix(in srgb, var(--logo-stop-2), #9aa0a6 var(--logo-gray)); }
.giveap-logo stop:nth-of-type(4) { stop-color: color-mix(in srgb, var(--logo-stop-3), #9aa0a6 var(--logo-gray)); }
.giveap-logo stop:nth-of-type(5) { stop-color: color-mix(in srgb, var(--logo-stop-4), #9aa0a6 var(--logo-gray)); }
.giveap-logo stop:nth-of-type(6) { stop-color: color-mix(in srgb, var(--logo-stop-5), #9aa0a6 var(--logo-gray)); }

@keyframes giveap-logo-drift {
  50% {
    --logo-stop-0: #4fb7de;
    --logo-stop-1: #529add;
    --logo-stop-2: #588bdf;
    --logo-stop-3: #5c75e1;
    --logo-stop-4: #6359e4;
    --logo-stop-5: #b249e9;
  }
}
@media (prefers-reduced-motion: no-preference) {
  html[data-socket="open"] .giveap-logo { animation: giveap-logo-drift 8s ease-in-out infinite; }
}
