/* =========================================================
   PUBLIC PAGE SAFEGUARD
   The logged-in sidebar shell must never capture index.php.
   Public index.php uses body.aw-public-home.
   ========================================================= */

body.aw-public-home {
    display: block !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    gap: 0 !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

/* =========================================================
   AWITIFY LOGGED-IN APP SHELL
   Locks desktop pages to the left-sidebar layout.
   ========================================================= */

:root {
    --aw-shell-gap: 10px;
    --aw-sidebar-width: 310px;
    --aw-shell-radius: 12px;
    --aw-shell-black: #000;
    --aw-sidebar-bg: #121214;
    --aw-main-bg: #111114;
}

/* The logged-in shell owns the whole viewport. */
html {
    width: 100%;
    height: 100%;
    min-height: 100%;
    background: var(--aw-shell-black) !important;
}

body:not(.aw-public-home):has(.site-header):has(main) {
    width: 100% !important;
    height: 100dvh !important;
    min-height: 100dvh !important;

    margin: 0 !important;
    padding: 0 !important;

    display: grid !important;
    grid-template-columns:
        var(--aw-sidebar-width)
        minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;

    gap: var(--aw-shell-gap) !important;

    overflow: hidden !important;

    background: var(--aw-shell-black) !important;
}

/* LEFT SIDEBAR */
body:not(.aw-public-home):has(.site-header):has(main) > .site-header {
    position: relative !important;
    inset: auto !important;

    width: 100% !important;
    max-width: none !important;

    height: 100% !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 28px 24px !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;

    border: 0 !important;
    border-radius: var(--aw-shell-radius) !important;

    background: var(--aw-sidebar-bg) !important;
    backdrop-filter: none !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;
}

body:not(.aw-public-home):has(.site-header):has(main) > .site-header .brand {
    display: block !important;

    margin: 0 !important;
    padding: 8px 14px 28px !important;

    color: #fff !important;

    font-size: 1.45rem !important;
    font-weight: 900 !important;
    line-height: 1 !important;

    text-decoration: none !important;
}

body:not(.aw-public-home):has(.site-header):has(main) > .site-header nav {
    width: 100% !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;

    gap: 6px !important;
}

body:not(.aw-public-home):has(.site-header):has(main) > .site-header nav a {
    width: 100% !important;

    display: block !important;

    padding: 13px 14px !important;

    border-radius: 9px !important;

    color: #aaa7b1 !important;

    font-size: 1rem !important;
    font-weight: 750 !important;
    line-height: 1.25 !important;

    text-decoration: none !important;

    transition:
        color .15s ease,
        background .15s ease !important;
}

body:not(.aw-public-home):has(.site-header):has(main) > .site-header nav a:hover,
body:not(.aw-public-home):has(.site-header):has(main) > .site-header nav a.is-active {
    color: #fff !important;
    background: rgba(255,255,255,.065) !important;
}

/* MAIN PANEL */
body:not(.aw-public-home):has(.site-header):has(main) > main {
    width: 100% !important;
    max-width: none !important;

    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;

    margin: 0 !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    border-radius: var(--aw-shell-radius) !important;

    background:
        linear-gradient(
            180deg,
            rgba(89, 61, 132, .10),
            transparent 360px
        ),
        var(--aw-main-bg) !important;

    scrollbar-width: thin;
    scrollbar-color: #484b54 transparent;
}

/*
 * Do not allow old page CSS to re-center or constrain the app canvas.
 */
body:not(.aw-public-home):has(.site-header):has(main) > main.shell,
body:not(.aw-public-home):has(.site-header):has(main) > main.dashboard-shell,
body:not(.aw-public-home):has(.site-header):has(main) > main.profile-page,
body:not(.aw-public-home):has(.site-header):has(main) > main.artist-studio,
body:not(.aw-public-home):has(.site-header):has(main) > main.upload-page,
body:not(.aw-public-home):has(.site-header):has(main) > main.account-shell,
body:not(.aw-public-home):has(.site-header):has(main) > main.settings-shell,
body:not(.aw-public-home):has(.site-header):has(main) > main.page-shell {
    width: 100% !important;
    max-width: none !important;

    margin: 0 !important;
}

/* Public profile should resemble the user's first screenshot. */
body:not(.aw-public-home):has(.site-header):has(main)
.profile-page > .public-profile.card {
    width: 100% !important;
    max-width: none !important;

    min-height: 100% !important;

    margin: 0 !important;
    padding: 30px 56px 80px !important;

    border: 0 !important;
    border-radius: 0 !important;

    background: transparent !important;

    text-align: left !important;
}

body:not(.aw-public-home):has(.site-header):has(main)
.profile-page .public-profile .avatar.large {
    width: 220px !important;
    height: 220px !important;

    margin: 0 0 28px !important;

    border-radius: 50% !important;
}

body:not(.aw-public-home):has(.site-header):has(main)
.profile-page .public-profile h1 {
    margin: 8px 0 12px !important;

    font-size: clamp(4rem, 7vw, 7rem) !important;
    line-height: .9 !important;
    letter-spacing: -.055em !important;
}

body:not(.aw-public-home):has(.site-header):has(main)
.profile-page .profile-stats,
body:not(.aw-public-home):has(.site-header):has(main)
.profile-page .profile-actions {
    justify-content: flex-start !important;
}

/* Artist Studio keeps its content but uses the same shell. */
body:not(.aw-public-home):has(.site-header):has(main) > main.artist-studio,
body:not(.aw-public-home):has(.site-header):has(main) > main.upload-page,
body:not(.aw-public-home):has(.site-header):has(main) > main.account-shell {
    padding: 28px !important;
}

/*
 * Persistent bottom player belongs above the shell.
 */
body.aw-player-visible:not(.aw-public-home):has(.site-header):has(main) {
    padding-bottom: 0 !important;
}

body.aw-player-visible:not(.aw-public-home):has(.site-header):has(main) > main {
    scroll-padding-bottom:
        var(--aw-player-safe-height, 0px) !important;
}


/* =========================================================
   PUBLIC ARTIST PROFILE SCROLL FIX
   The old .profile-page grid/min-height combination allowed the
   Covers section to overflow visually without increasing scroll height.
   ========================================================= */

body:not(.aw-public-home):has(.site-header):has(main) > main.profile-page {
    display: block !important;

    height: 100% !important;
    min-height: 0 !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;
}

body:not(.aw-public-home):has(.site-header):has(main)
.profile-page > .public-profile.card {
    display: block !important;

    height: auto !important;
    min-height: 0 !important;

    overflow: visible !important;
}

/*
 * On the public profile, reserve the player's measured height inside
 * the profile content itself. This guarantees the final uploaded track
 * can scroll completely above the fixed player.
 *
 * The generic JS spacer is hidden on profile pages to avoid double space.
 */
body.aw-player-visible:not(.aw-public-home):has(.site-header):has(main)
.profile-page > .public-profile.card {
    padding-bottom:
        calc(
            80px
            + var(--aw-player-safe-height, 150px)
        ) !important;
}

body:not(.aw-public-home):has(.site-header):has(main)
.profile-page > .aw-player-page-spacer {
    display: none !important;
    height: 0 !important;
}

/* MOBILE: sidebar becomes a compact top navigation. */
@media (max-width: 820px) {
    :root {
        --aw-shell-gap: 0px;
    }

    body:not(.aw-public-home):has(.site-header):has(main) {
        height: 100dvh !important;

        display: flex !important;
        flex-direction: column !important;

        gap: 0 !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main) > .site-header {
        width: 100% !important;
        height: auto !important;
        min-height: 64px !important;

        flex: 0 0 auto !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;

        padding: 10px 14px !important;

        border-radius: 0 !important;
        border-bottom: 1px solid #25272d !important;

        overflow: visible !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main) > .site-header .brand {
        padding: 0 !important;
        margin-right: 12px !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main) > .site-header nav {
        width: auto !important;

        flex-direction: row !important;
        align-items: center !important;

        gap: 2px !important;

        overflow-x: auto !important;
        scrollbar-width: none;
    }

    body:not(.aw-public-home):has(.site-header):has(main) > .site-header nav::-webkit-scrollbar {
        display: none;
    }

    body:not(.aw-public-home):has(.site-header):has(main) > .site-header nav a {
        width: auto !important;
        flex: 0 0 auto !important;

        padding: 9px 10px !important;

        font-size: .88rem !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main) > main {
        flex: 1 1 auto !important;

        height: auto !important;
        min-height: 0 !important;

        border-radius: 0 !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main)
    .profile-page > .public-profile.card {
        padding:
            28px
            20px
            calc(
                60px
                + var(--aw-player-safe-height, 220px)
            ) !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main)
    .profile-page .public-profile .avatar.large {
        width: 140px !important;
        height: 140px !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main)
    .profile-page .public-profile h1 {
        font-size: clamp(3rem, 15vw, 5rem) !important;
    }

    body:not(.aw-public-home):has(.site-header):has(main) > main.artist-studio,
    body:not(.aw-public-home):has(.site-header):has(main) > main.upload-page,
    body:not(.aw-public-home):has(.site-header):has(main) > main.account-shell {
        padding: 18px 14px !important;
    }
}
