/* ==============================================================
   WASTELAND ASCENT - GLOBAL SHELL LOCK v2

   Purpose:
   - Top HUD is always the same height on every page.
   - Left sidebar is always the same width on every page.
   - Page content cannot resize or shift the shared shell.
   - Header/sidebar stay aligned while content changes.

   IMPORTANT:
   Load this stylesheet AFTER all page-specific stylesheets.
============================================================== */

:root {
    --wa-header-height: 56px;
    --wa-sidebar-width: 220px;
    --wa-shell-divider: rgba(175, 120, 43, .62);
    --wa-shell-divider-soft: rgba(175, 120, 43, .20);
}

html,
body {
    margin: 0;
    min-width: 0;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}


/* --------------------------------------------------------------
   GLOBAL HUD DIVIDER
   One controlled bronze divider at the TRUE bottom of the HUD.
   This keeps the line aligned with the Inventory/Gym/Dashboard
   panel borders instead of floating above the page content.
-------------------------------------------------------------- */

.top-hud,
.game-header {
    border-bottom: 1px solid var(--wa-shell-divider) !important;

    /* Keep depth subtle without creating a second gold line. */
    box-shadow:
        0 1px 0 rgba(0, 0, 0, .70),
        0 5px 12px rgba(0, 0, 0, .28) !important;

    outline: 0 !important;
    background-clip: padding-box !important;
}

/* Force the shared header container to finish exactly on the divider. */
#sharedHeader.top-hud {
    padding-bottom: 0 !important;
}

/* Do not allow an additional parent pseudo-line to sit above/below it. */
.top-hud::after,
.game-header::after {
    content: none !important;
    display: none !important;
}

/* Main page begins immediately after the HUD divider. */
.game-ui > .game-body,
.game-body,
.game-shell > .game-layout,
.game-layout {
    border-top: 0 !important;
}

/* --------------------------------------------------------------
   CURRENT SHARED SHELL
   Used by pages with .game-ui / .top-hud / .game-body / .sidebar
-------------------------------------------------------------- */

.game-ui {
    width: 100% !important;
    min-width: 0 !important;
}

.game-ui > .top-hud,
#sharedHeader.top-hud,
.top-hud {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;

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

    height: var(--wa-header-height) !important;
    min-height: var(--wa-header-height) !important;
    max-height: var(--wa-header-height) !important;

    margin: 0 !important;
    flex: 0 0 var(--wa-header-height) !important;
    flex-shrink: 0 !important;

    transform: none !important;
    translate: none !important;

    z-index: 5000 !important;
}

.game-ui > .game-body,
.game-body {
    display: grid !important;
    grid-template-columns: var(--wa-sidebar-width) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;

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

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

    align-items: start !important;
}

.game-body > .sidebar,
#sharedSidebar.sidebar,
.game-ui .sidebar {
    position: sticky !important;
    top: var(--wa-header-height) !important;
    left: 0 !important;

    grid-column: 1 !important;

    width: var(--wa-sidebar-width) !important;
    min-width: var(--wa-sidebar-width) !important;
    max-width: var(--wa-sidebar-width) !important;

    height: calc(100vh - var(--wa-header-height)) !important;
    min-height: calc(100vh - var(--wa-header-height)) !important;
    max-height: calc(100vh - var(--wa-header-height)) !important;

    margin: 0 !important;
    flex: 0 0 var(--wa-sidebar-width) !important;
    flex-basis: var(--wa-sidebar-width) !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;

    align-self: start !important;

    transform: none !important;
    translate: none !important;

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

    z-index: 4000 !important;
}

.game-body > main {
    grid-column: 2 !important;

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

    margin-left: 0 !important;
    margin-right: 0 !important;

    align-self: start !important;
}

/* Keep sidebar contents tied to the sidebar width. */
.game-ui .sidebar > *,
.game-ui .sidebar nav,
.game-ui .sidebar .sidebar-profile {
    max-width: 100% !important;
}

/* --------------------------------------------------------------
   LEGACY / EARLIER PAGE SHELL
   Supports pages that still use .game-shell / .game-header /
   .game-layout so they retain identical shell dimensions too.
-------------------------------------------------------------- */

.game-shell {
    width: 100% !important;
    min-width: 0 !important;
}

.game-shell > .game-header,
.game-header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;

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

    height: var(--wa-header-height) !important;
    min-height: var(--wa-header-height) !important;
    max-height: var(--wa-header-height) !important;

    margin: 0 !important;
    flex: 0 0 var(--wa-header-height) !important;
    flex-shrink: 0 !important;

    transform: none !important;
    translate: none !important;

    z-index: 5000 !important;
}

.game-shell > .game-layout,
.game-layout {
    display: grid !important;
    grid-template-columns: var(--wa-sidebar-width) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;

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

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

    align-items: start !important;
}

.game-layout > .sidebar,
.game-shell .sidebar {
    position: sticky !important;
    top: var(--wa-header-height) !important;
    left: 0 !important;

    grid-column: 1 !important;

    width: var(--wa-sidebar-width) !important;
    min-width: var(--wa-sidebar-width) !important;
    max-width: var(--wa-sidebar-width) !important;

    height: calc(100vh - var(--wa-header-height)) !important;
    min-height: calc(100vh - var(--wa-header-height)) !important;
    max-height: calc(100vh - var(--wa-header-height)) !important;

    margin: 0 !important;
    flex: 0 0 var(--wa-sidebar-width) !important;
    flex-basis: var(--wa-sidebar-width) !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;

    align-self: start !important;

    transform: none !important;
    translate: none !important;

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

    z-index: 4000 !important;
}

.game-layout > main,
.game-layout > .main-content,
.game-layout > .content,
.game-layout > .page-content {
    grid-column: 2 !important;

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

    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* --------------------------------------------------------------
   PREVENT PAGE-SPECIFIC RESPONSIVE RULES FROM SHRINKING THE SHELL
   Content is allowed to reflow. Header/sidebar dimensions are not.
-------------------------------------------------------------- */

@media (max-width: 1600px),
       (max-width: 1400px),
       (max-width: 1200px),
       (max-width: 1000px),
       (max-width: 800px),
       (max-width: 600px) {

    :root {
        --wa-header-height: 56px;
        --wa-sidebar-width: 220px;
    }

    .top-hud,
    .game-header {
        height: var(--wa-header-height) !important;
        min-height: var(--wa-header-height) !important;
        max-height: var(--wa-header-height) !important;
    }

    .game-body,
    .game-layout {
        grid-template-columns: var(--wa-sidebar-width) minmax(0, 1fr) !important;
    }

    .game-body > .sidebar,
    .game-layout > .sidebar,
    #sharedSidebar.sidebar,
    .game-ui .sidebar,
    .game-shell .sidebar {
        width: var(--wa-sidebar-width) !important;
        min-width: var(--wa-sidebar-width) !important;
        max-width: var(--wa-sidebar-width) !important;
    }
}
