/* AI Project Universe V5.0 — compact mobile navigation for selected projects */
.apu-v5-mobile-project-bar,
.apu-v5-mobile-nav-drawer { display:none; }

@media (max-width: 54rem) {
  html[data-apu-mobile-nav-v5="true"],
  html[data-apu-mobile-nav-v5="true"] body {
    overflow-x:hidden !important;
  }

  .apu-v5-mobile-project-bar {
    position:sticky;
    top:0;
    z-index:900;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    min-height:58px;
    padding:9px max(12px,env(safe-area-inset-right)) 9px max(12px,env(safe-area-inset-left));
    border-bottom:1px solid var(--apu-v5-nav-border,#313131);
    background:var(--apu-v5-nav-bg,#141414);
    color:var(--apu-v5-nav-fg,#f8fafc);
    box-shadow:0 8px 24px rgba(0,0,0,.14);
  }
  .apu-v5-mobile-project-brand {
    min-width:0;
    display:flex;
    align-items:center;
    gap:10px;
  }
  .apu-v5-mobile-project-mark {
    flex:0 0 36px;
    width:36px;
    height:36px;
    display:grid;
    place-items:center;
    border-radius:11px;
    background:var(--apu-v5-nav-accent,#afafaf);
    color:var(--apu-v5-mark-fg,#101010);
    font-weight:900;
    font-size:13px;
    box-shadow:inset 0 0 0 1px rgba(255,255,255,.22);
  }
  .apu-v5-mobile-project-brand-text { min-width:0; }
  .apu-v5-mobile-project-brand strong,
  .apu-v5-mobile-project-brand small {
    display:block;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .apu-v5-mobile-project-brand strong { font-size:13px; line-height:1.2; }
  .apu-v5-mobile-project-brand small { margin-top:2px; color:var(--apu-v5-nav-muted,#aeaeae); font-size:10px; }
  .apu-v5-mobile-project-toggle {
    flex:0 0 auto;
    min-width:44px;
    min-height:42px;
    padding:0 12px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    border:1px solid var(--apu-v5-nav-border,#414141);
    border-radius:11px;
    background:var(--apu-v5-toggle-bg,#212121);
    color:var(--apu-v5-nav-fg,#fff);
    font:800 12px/1 system-ui,sans-serif;
    cursor:pointer;
    touch-action:manipulation;
  }
  .apu-v5-mobile-project-toggle::before { content:"☰"; font-size:17px; }
  .apu-v5-mobile-project-toggle[aria-expanded="true"]::before { content:"×"; font-size:22px; }

  .apu-v5-mobile-nav-drawer {
    position:sticky;
    top:58px;
    z-index:899;
    display:none;
    width:100%;
    max-height:calc(100dvh - 58px);
    overflow-y:auto;
    overscroll-behavior:contain;
    padding:10px max(12px,env(safe-area-inset-right)) 14px max(12px,env(safe-area-inset-left));
    border-bottom:1px solid var(--apu-v5-nav-border,#313131);
    background:var(--apu-v5-drawer-bg,#181818);
    box-shadow:0 16px 28px rgba(0,0,0,.18);
  }
  .apu-v5-mobile-nav-drawer.is-open { display:grid; gap:7px; }
  .apu-v5-mobile-nav-drawer a {
    display:flex;
    align-items:center;
    min-height:44px;
    padding:10px 12px;
    border:1px solid transparent;
    border-radius:10px;
    color:var(--apu-v5-nav-link,#e3e3e3);
    background:var(--apu-v5-link-bg,rgba(255,255,255,.035));
    text-decoration:none;
    font:750 12px/1.25 system-ui,sans-serif;
  }
  .apu-v5-mobile-nav-drawer a[aria-current="page"],
  .apu-v5-mobile-nav-drawer a.is-active {
    border-color:color-mix(in srgb,var(--apu-v5-nav-accent,#afafaf) 55%,transparent);
    background:color-mix(in srgb,var(--apu-v5-nav-accent,#afafaf) 15%,transparent);
    color:#fff;
  }

  [data-apu-mobile-sidebar="true"] { display:none !important; }
  [data-apu-mobile-main="true"] {
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    margin:0 !important;
    inset:auto !important;
  }

  html[data-scroll-theme="academic-evidence"] {
    --apu-v5-nav-bg:#161616; --apu-v5-drawer-bg:#1c1c1c; --apu-v5-nav-border:#313131;
    --apu-v5-nav-accent:#8d8d8d; --apu-v5-mark-fg:#fff; --apu-v5-toggle-bg:#262626;
  }
  html[data-scroll-theme="sentiment-analysis"] {
    --apu-v5-nav-bg:#121212; --apu-v5-drawer-bg:#171717; --apu-v5-nav-border:#2f2f2f;
    --apu-v5-nav-accent:#afafaf; --apu-v5-toggle-bg:#222222;
  }
  html[data-scroll-theme="student-performance"] {
    --apu-v5-nav-bg:#121212; --apu-v5-drawer-bg:#161616; --apu-v5-nav-border:#303030;
    --apu-v5-nav-accent:#6f6f6f; --apu-v5-mark-fg:#fff; --apu-v5-toggle-bg:#212121;
  }

  /* React portfolio and SentiScope roots become normal document flow. */
  html[data-scroll-theme="academic-evidence"] #root > div,
  html[data-scroll-theme="sentiment-analysis"] #root > div {
    display:block !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    min-height:100dvh !important;
  }
  html[data-scroll-theme="academic-evidence"] main,
  html[data-scroll-theme="sentiment-analysis"] main {
    margin-left:0 !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    padding-left:12px !important;
    padding-right:12px !important;
  }

  /* Student Performance uses the shared compact bar instead of a large grid navbar. */
  html[data-scroll-theme="student-performance"] .sp-sidebar { display:none !important; }
  html[data-scroll-theme="student-performance"] .sp-app { display:block !important; }
  html[data-scroll-theme="student-performance"] .sp-main {
    width:100% !important;
    max-width:100% !important;
    padding:18px 12px 56px !important;
  }

  /* Native Network Tools header: compact, solid, closable and non-overlapping. */
  html[data-scroll-theme="network-subnet"] .app-header {
    position:sticky !important;
    top:0 !important;
    z-index:900 !important;
    display:grid !important;
    grid-template-columns:minmax(0,1fr) auto !important;
    gap:8px 10px !important;
    min-height:58px !important;
    padding:8px 12px !important;
    background:#fff !important;
    backdrop-filter:none !important;
  }
  html[data-scroll-theme="network-subnet"] .brand { min-width:0 !important; gap:9px !important; }
  html[data-scroll-theme="network-subnet"] .brand-icon { width:36px !important; height:36px !important; border-radius:10px !important; }
  html[data-scroll-theme="network-subnet"] .brand strong { font-size:13px !important; }
  html[data-scroll-theme="network-subnet"] .brand small { display:block !important; font-size:9px !important; }
  html[data-scroll-theme="network-subnet"] .menu-toggle {
    display:inline-flex !important;
    min-height:40px !important;
    align-items:center !important;
    justify-content:center !important;
    padding:0 12px !important;
    border-radius:10px !important;
  }
  html[data-scroll-theme="network-subnet"] .main-nav {
    grid-column:1 / -1 !important;
    order:3 !important;
    display:none !important;
    width:100% !important;
    max-height:calc(100dvh - 66px) !important;
    overflow-y:auto !important;
    padding:6px 0 4px !important;
    flex-direction:column !important;
    align-items:stretch !important;
  }
  html[data-scroll-theme="network-subnet"] .main-nav.is-open { display:flex !important; }
  html[data-scroll-theme="network-subnet"] .main-nav a { min-height:42px; display:flex; align-items:center; }
  html[data-scroll-theme="network-subnet"] .header-status { display:none !important; }
}

@media (max-width:54rem) {
  /* Hide legacy mobile bars/overlays supplied by the bundled React apps so
     only the compact V5 navigation is present. */
  html[data-scroll-theme="academic-evidence"] [class*="md:hidden"][class*="fixed"],
  html[data-scroll-theme="sentiment-analysis"] main > header[class*="md:hidden"] {
    display:none !important;
  }
  html[data-scroll-theme="academic-evidence"] main {
    padding-top:0 !important;
  }
  html[data-scroll-theme="sentiment-analysis"] main > div[class*="overflow-auto"] {
    overflow:visible !important;
    height:auto !important;
    min-height:0 !important;
    padding:16px 12px 54px !important;
  }
}
