/**
 * PathwayAI Pro — site-wide alignment & responsive polish (loads last).
 * Fixes rail mismatch, context strip mobile, and shell consistency.
 */

/* Topbar + context strip share the same horizontal rail as main content */
.topbar-pro .container,
.topbar .container.topbar-inner,
.page-context-wrap.container {
    width: min(1180px, calc(100% - 2 * var(--rail-x)));
    margin-inline: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Wider topbar nav only — keep brand/links breathing room without widening content cards */
.topbar-pro .container.topbar-inner,
.topbar .container.topbar-inner {
    width: min(1440px, calc(100% - 2 * var(--rail-x)));
}

/* Container width already accounts for rail — avoid triple inset on main */
main#mainContent.container,
main.container#mainContent {
    padding-inline: 0;
}

.page-context-wrap {
    padding-inline: 0;
}

.page-context-copy {
    min-width: 0;
    flex: 1 1 12rem;
}

.page-context-title,
.page-context-hint {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.page-context-hint {
    max-width: 72ch;
}

.page-context-action .nav-cta {
    white-space: normal;
    text-align: center;
    max-width: 100%;
}

/* Dashboard + portal context: stack on narrow phones */
@media (max-width: 640px) {
    body.page-dashboard .page-context-inner,
    body.page-portal.page-portal-dashboard .page-context-inner {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3, 12px);
    }

    body.page-dashboard .page-context-action,
    body.page-portal.page-portal-dashboard .page-context-action {
        width: 100%;
        align-self: stretch;
    }

    body.page-dashboard .page-context-action .nav-cta,
    body.page-portal.page-portal-dashboard .page-context-action .nav-cta {
        width: auto;
        max-width: 100%;
    }
}

/* Hero quicklinks stay horizontal when space allows */
@media (max-width: 820px) {
    .cta-row.pathway-hero-quicklinks {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .cta-row.pathway-hero-quicklinks .btn {
        width: auto;
        flex: 0 1 auto;
    }
}

/* Nav drawer links — full readable width on mobile */
@media (max-width: 980px) {
    .nav-toggle:checked ~ .topbar-nav-shell .nav-link,
    .nav-toggle:checked ~ .topbar-nav-shell .nav-link--drawer {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 10px 14px;
        font-size: 0.92rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .topbar-inner {
        flex-wrap: wrap;
        gap: 8px 12px;
    }

    .brand--horizontal {
        flex: 1 1 auto;
        min-width: 0;
        max-width: min(220px, 58vw);
    }
}

/* Cards / grids never bleed past viewport */
.card,
.dashboard-cmd-tile,
.dashboard-snapshot-cell,
.portal-tab-nav,
.os-mission-hub {
    max-width: 100%;
    box-sizing: border-box;
}

.page-portal-main,
.admin-shell,
.comp-shell {
    width: min(1440px, calc(100% - 2 * var(--rail-x)));
    margin-inline: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Admin topbar matches site rail */
.admin-topbar-inner {
    width: min(1440px, calc(100% - 2 * var(--rail-x)));
    margin-inline: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Legacy student pages without page-os-shell still get readable nav */
body.has-mobile-tabbar:not(.page-os-shell) .topbar {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Prevent horizontal scroll from wide tables/pre */
main.container,
main#mainContent {
    overflow-x: clip;
}

table {
    max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME-IDENTICAL NAVBAR SIZE — student panel pages (match index.php)
   Does not touch Learning World HUD, auth, or admin-panel-body chrome.
   Mobile breakpoints below keep compact sizing (no desktop force).
   ═══════════════════════════════════════════════════════════════════════════ */

body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.pathway-login-page):not(.admin-panel-body),
body.page-public-home.home-cinematic {
    --topbar-height: 68px;
    --brand-logo-height: 54px;
}

@media (min-width: 981px) {
    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.pathway-login-page):not(.admin-panel-body) .topbar-inner,
    body.page-public-home.home-cinematic .topbar-inner {
        min-height: 68px !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
        align-items: center !important;
        gap: 14px !important;
        flex-wrap: nowrap !important;
    }

    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .brand,
    body.page-public-home.home-cinematic .topbar .brand {
        min-height: 54px !important;
    }

    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav-student .nav-link:not(.nav-link--drawer),
    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav .nav-link:not(.nav-link--drawer),
    body.page-public-home.home-cinematic .topbar .nav .nav-link:not(.nav-link--drawer) {
        font-size: 0.84rem !important;
        font-weight: 500 !important;
        letter-spacing: 0.01em !important;
        padding: 8px 12px !important;
        min-height: 38px !important;
        line-height: 1.2 !important;
        display: inline-flex !important;
        align-items: center !important;
        box-sizing: border-box !important;
        border-radius: 999px !important;
        border: 1px solid transparent !important;
    }

    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav-dropdown__summary:not(.nav-link--drawer),
    body.page-public-home.home-cinematic .topbar .nav-dropdown__summary:not(.nav-link--drawer) {
        font-size: 0.84rem !important;
        padding: 8px 12px !important;
        min-height: 38px !important;
        display: inline-flex !important;
        align-items: center !important;
        box-sizing: border-box !important;
        border-radius: 999px !important;
    }

    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav-cta,
    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav-actions .btn,
    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav-actions a.btn,
    body.page-public-home.home-cinematic .topbar .nav-cta,
    body.page-public-home.home-cinematic .topbar .nav-actions .btn {
        min-height: 38px !important;
        padding: 8px 16px !important;
        font-size: 0.84rem !important;
        line-height: 1.2 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        border-radius: 999px !important;
    }

    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav-lang-select,
    body.page-public-home.home-cinematic .topbar .nav-lang-select {
        min-height: 36px !important;
        font-size: 0.84rem !important;
        padding: 6px 10px !important;
        box-sizing: border-box !important;
    }

    body.page-os-shell:not(.learning-world-page):not(.page-learning-world):not(.pathway-auth-page):not(.admin-panel-body) .topbar .nav-lang-wrap label,
    body.page-public-home.home-cinematic .topbar .nav-lang-wrap label {
        font-size: 0.68rem !important;
        line-height: 1.2 !important;
    }
}

/* Phone: keep existing compact topbar — do not force desktop home metrics */
@media (max-width: 980px) {
    body.page-os-shell:not(.learning-world-page):not(.admin-panel-body) .topbar-inner,
    body.page-public-home.home-cinematic .topbar-inner {
        min-height: var(--topbar-height);
        padding-top: 6px;
        padding-bottom: 6px;
    }
}

