/* ---------- Shared left navigation rail ----------
   The platform's persistent left-hand nav, extracted from hub.css so every
   page (hub, situation, knowledge, regions, scenario, ...) hosts the same
   rail without pulling in hub.css's page-specific globals (e.g. its global
   `a { color: inherit }` reset). Load this AFTER the page's own stylesheet
   so the `body.hb-page` shell layout wins. */

:root {
    --hb-void: #05070d;
    --hb-bg: #080b12;
    --hb-rail: #0a0e16;
    --hb-card: #0d111a;
    --hb-card-2: #111725;
    --hb-line: #1a2231;
    --hb-line-soft: #151c28;

    --hb-ink: #e9eef7;
    --hb-ink-2: #93a0b5;
    --hb-ink-3: #5f6b80;

    --hb-blue: #3d8bfd;
    --hb-blue-soft: #64a5ff;
    --hb-blue-tint: rgba(61, 139, 253, 0.12);

    --hb-red: #f0564a;
    --hb-amber: #f0a33a;
    --hb-green: #3ecf8e;
    --hb-slate: #64748b;

    --hb-r: 12px;
    --hb-r-lg: 16px;
    --hb-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Rail links are their own thing — never inherit the host page's link
   color or underline. */
.hb-rail a { color: inherit; text-decoration: none; }

/* ---------- Page shell (non-hub pages) ----------
   A `body.hb-page` lays the rail out left of a scrollable content column,
   matching the hub's own flex shell. */

body.hb-page {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    background: var(--hb-bg);
}
.hb-page > .hb-page-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--paper);
}

/* A tool page that pairs a sidebar with a full-bleed map sits its own
   flex row directly inside the hb-page-content column (scenario.html,
   index.html). style.css's `main.layout` rule targets only the element
   named exactly `main.layout`, so a `<div class="layout">` inside the
   shell gets no height and the map stays 0px. Scope the glue to the
   shell so any page in it gets the same flex row. */
.hb-page-content > .layout {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ---------- Left rail ---------- */

.hb-rail {
    position: sticky;
    top: 0;
    align-self: flex-start;
    flex: none;
    width: 216px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.6rem 0 1.1rem;
    background: var(--hb-rail);
    border-right: 1px solid var(--hb-line-soft);
}

.hb-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    padding: 0 1rem 1.9rem;
}
.hb-brand img { display: block; height: auto; }
.hb-brand-name {
    font-size: .95rem; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--hb-ink);
}
.hb-brand-sub {
    font-size: .58rem; font-weight: 600; letter-spacing: .42em;
    text-transform: uppercase; color: var(--hb-ink-3); padding-left: .42em;
}

.hb-nav { display: flex; flex-direction: column; }
.hb-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .82rem 1.15rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--hb-ink-2);
    transition: color .18s var(--hb-ease), background .18s var(--hb-ease);
}
.hb-nav-item svg { width: 19px; height: 19px; flex: none; }
.hb-nav-item:hover { color: var(--hb-ink); background: rgba(255,255,255,.03); }
.hb-nav-item.is-active {
    color: var(--hb-blue-soft);
    background: linear-gradient(90deg, var(--hb-blue-tint), transparent 85%);
}
.hb-nav-item.is-active::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 2.5px; background: var(--hb-blue);
}

.hb-rail-spacer { flex: 1; min-height: 1.5rem; }

.hb-status {
    margin: 0 .85rem .7rem;
    padding: .8rem .9rem;
    border: 1px solid var(--hb-line);
    border-radius: var(--hb-r);
    background: var(--hb-card);
}
.hb-status-title { margin: 0 0 .4rem; font-size: .75rem; color: var(--hb-ink-2); }
.hb-status-line {
    margin: 0; display: flex; align-items: center; gap: .45rem;
    font-size: .78rem; font-weight: 500; color: var(--hb-green);
}
.hb-status-dot {
    width: 7px; height: 7px; border-radius: 50%; flex: none;
    background: var(--hb-green);
    box-shadow: 0 0 0 0 rgba(62,207,142,.55);
    animation: hb-pulse 2.4s ease-out infinite;
}
@keyframes hb-pulse {
    0% { box-shadow: 0 0 0 0 rgba(62,207,142,.5); }
    70% { box-shadow: 0 0 0 7px rgba(62,207,142,0); }
    100% { box-shadow: 0 0 0 0 rgba(62,207,142,0); }
}

.hb-user {
    margin: 0 .85rem;
    padding: .7rem .8rem;
    display: flex; align-items: center; gap: .65rem;
    border: 1px solid var(--hb-line);
    border-radius: var(--hb-r);
    background: var(--hb-card);
}
.hb-user-avatar {
    width: 32px; height: 32px; flex: none;
    display: grid; place-items: center;
    border-radius: 9px;
    background: linear-gradient(150deg, #2f6dbb, #1b3f70);
    color: #eaf3ff; font-size: .74rem; font-weight: 700; letter-spacing: .04em;
}
.hb-user-text { display: flex; flex-direction: column; min-width: 0; }
.hb-user-name {
    font-size: .8rem; font-weight: 600; color: var(--hb-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hb-user-role { font-size: .68rem; color: var(--hb-ink-3); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    body.hb-page { flex-direction: column; overflow-y: auto; }
    .hb-page > .hb-page-content { overflow: visible; }

    .hb-rail {
        position: static;
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: .4rem;
        padding: .5rem .7rem;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--hb-line-soft);
    }
    .hb-brand { flex-direction: row; align-items: center; gap: .5rem; padding: 0 .6rem 0 0; }
    .hb-brand img { width: 68px; }
    .hb-brand-sub { display: none; }
    .hb-nav { flex-direction: row; }
    .hb-nav-item { padding: .55rem .7rem; white-space: nowrap; font-size: .8rem; }
    .hb-nav-item.is-active { background: var(--hb-blue-tint); border-radius: 8px; }
    .hb-nav-item.is-active::before { top: auto; bottom: 0; left: .7rem; right: .7rem; width: auto; height: 2px; }
    .hb-rail-spacer, .hb-status, .hb-user { display: none; }
}
