/* Site-wide mobile: toolbar overlap prevention + reliable header ticker */

@media (max-width: 768px) {
  html,
  body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* ---- Mobile nav drawer (bulletproof stacking) ----
     NEVER put the dim mask on body / body::before.
     .wrap { z-index:1 } and .live-sticky-chrome { position:sticky }
     trap descendants, so a body-level mask always eats menu clicks.
     Backdrop lives INSIDE .topbar and shares its stacking context. */
  body::before,
  body.nav-drawer-open::before {
    content: none !important;
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    background: none !important;
    opacity: 0 !important;
  }

  body.nav-drawer-open {
    overflow: hidden;
  }

  /* Lift header stack above page content while open — wrap must stay BELOW chrome */
  body.nav-drawer-open .wrap,
  body.nav-drawer-open .wrap.wide {
    z-index: 1 !important;
    position: relative;
  }

body.nav-drawer-open .live-sticky-chrome,
body.nav-drawer-open .site-sticky-chrome {
  z-index: 10050 !important;
  position: relative !important;
}

  body.nav-drawer-open .bb-util-bar {
    z-index: 10060 !important;
  }

  .topbar {
    z-index: 100;
    position: relative;
    background: var(--bg-main);
  }

  .nav-toggle,
  .topbar .nav-toggle,
  #navToggle {
    position: relative !important;
    z-index: 10070 !important;
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .nav-actions {
    display: none !important;
  }
  .topbar.nav-open .nav-actions {
    display: flex !important;
  }

  .lang-pills,
  .nav-actions .lang-pills {
    height: 44px;
  }
  .lang-pills button,
  .nav-actions .lang-pills button {
    min-width: 48px;
    min-height: 44px;
    padding: 0 12px;
  }

  .bb-util-mark {
    display: none !important;
  }

body.live-page .live-sticky-chrome,
body .site-sticky-chrome {
  z-index: 100;
  overflow: visible;
}

body.has-bb-util.live-page .live-sticky-chrome,
body.has-bb-util .site-sticky-chrome {
  top: 32px;
}

  body.nav-drawer-open .topbar,
  .topbar.nav-open {
    position: relative !important;
    z-index: 10001 !important;
    isolation: isolate;
    background: #000000;
    pointer-events: auto !important;
  }

  /* Backdrop injected as first child of .topbar (see nav.js) */
  .topbar > .nav-drawer-backdrop {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: rgba(0, 0, 0, 0.45) !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    pointer-events: none !important;
    transform: none !important;
    flex: none !important;
  }

  .topbar.nav-open > .nav-drawer-backdrop,
  .topbar > .nav-drawer-backdrop:not([hidden]) {
    display: block !important;
    pointer-events: auto !important;
  }

  /* Keep all topbar chrome above the in-topbar backdrop */
  .topbar.nav-open > *:not(.nav-drawer-backdrop),
  .topbar .nav-end,
  .topbar .nav-toggle,
  .topbar #navToggle {
    position: relative;
    z-index: 2;
    pointer-events: auto !important;
  }

  .topbar.nav-open .nav-actions {
    position: relative;
    z-index: 2;
    background: var(--bg-surface);
    border: 1px solid var(--border-line);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    padding: 8px;
    margin-top: 4px;
    pointer-events: auto !important;
    width: 100%;
    flex-basis: 100%;
    order: 99;
  }

  .topbar .nav-end {
    position: relative;
    z-index: 10071 !important;
    pointer-events: auto !important;
  }

  .topbar.nav-open .nav-actions a,
  .topbar.nav-open .nav-actions button {
    position: relative;
    z-index: 3;
    pointer-events: auto !important;
  }

  /* Orphan body-level backdrop (legacy) must never intercept */
  body > .nav-drawer-backdrop {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  /* ---- Toolbars: flow layout, no absolute overlap ---- */
  .topbar,
  .nav-end,
  .term-tabs,
  .mobile-view-tabs,
  .lab-top,
  .bt-meta,
  .bbg-status-strip,
  .sidebar-header-aligned .main-title-flex,
  .selected-matrix-head,
  .ai-bt-head {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .topbar button:not(.nav-drawer-backdrop),
  .topbar .btn,
  .term-tabs button,
  .mobile-view-tabs button,
  .chart-touch-toggle,
  .chart-frame-rel .chart-touch-toggle,
  .lab-top button,
  .sidebar-header-aligned button {
    position: static !important;
    transform: none !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    flex-shrink: 0;
  }

  .term-tabs,
  .mobile-view-tabs,
  .filter-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100% !important;
    max-width: 100% !important;
    white-space: nowrap;
    padding: 4px 0 8px !important;
  }

  .term-tabs::-webkit-scrollbar,
  .mobile-view-tabs::-webkit-scrollbar,
  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .term-tab,
  .mv-tab,
  .filter-tabs button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
  }

  body.plaza-page .term-tabs.term-tabs-mobile-select {
    display: block !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    white-space: normal !important;
    padding: 0 !important;
  }

  /* ---- Chart controls: document flow (terminal + live) ---- */
  .chart-frame-rel,
  .lab-chart-frame,
  .war-chart-frame {
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: auto !important;
    overflow: visible;
    position: relative;
  }

  .chart-frame-rel .chart-touch-toggle,
  .lab-chart-frame .chart-touch-toggle,
  .war-chart-frame .chart-touch-toggle {
    order: 1;
    align-self: flex-start;
    margin: 0 8px;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
  }

  .war-chart-frame .scan-hud {
    position: static !important;
    order: 2;
    width: calc(100% - 16px) !important;
    max-width: calc(100% - 16px) !important;
    margin: 0 8px;
    pointer-events: none;
  }

  .war-chart-frame .scan-hud-text {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.35;
  }

  .war-chart-frame .war-chart-legend {
    order: 0;
    flex-wrap: wrap;
  }

  .war-chart-frame .war-chart,
  .chart-frame-rel .chart-container,
  .lab-chart-frame .chart-container {
    order: 3;
    width: 100% !important;
    max-width: 100% !important;
  }

  .bt-meta,
  .bt-meta.five {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .thumb-dock,
  .mobile-view-tabs,
  .mobile-live-dock,
  .tg-fab,
  .toast {
    padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="search"],
  select,
  textarea,
  .otp-cell {
    font-size: 16px !important;
  }

  .modal-bg {
    z-index: 9998;
    align-items: flex-start;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal,
  .modal.login-modal,
  .modal.wide {
    width: 90% !important;
    max-width: 380px !important;
    max-height: 85vh;
    margin: auto;
    border-radius: 12px;
    overflow-y: auto;
    box-sizing: border-box;
  }
}

/* ---- Header crypto ticker: always visible, never collapse ---- */
.ticker-bar {
  display: flex !important;
  align-items: center;
  flex: 0 0 auto;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  min-height: 40px !important;
  height: 40px !important;
  max-height: 40px !important;
  line-height: 40px !important;
  padding: 0 !important;
  overflow: hidden;
  visibility: visible !important;
  opacity: 1 !important;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  /* contain:layout was collapsing transformed marquee children to a hairline */
  contain: none;
}

.live-sticky-chrome .ticker-bar,
.wrap > .ticker-bar,
.wrap .ticker-bar {
  display: flex !important;
}

.ticker-bar .ticker-track {
  display: inline-flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  min-width: max-content;
  height: 40px;
  min-height: 40px;
  line-height: 40px;
  will-change: transform;
  animation: qaTickerMarquee 60s linear infinite;
}

.ticker-bar.is-paused .ticker-track {
  animation-play-state: paused;
}

.ticker-pill {
  flex: 0 0 auto;
  height: 28px !important;
  min-height: 28px !important;
  overflow: visible !important;
}

/* Flash marquee owned by css/marquee-ticker.css — no white/44px override */
#bloomberg-marquee-bar,
.bb-marquee,
.news-ticker-container {
  flex-shrink: 0 !important;
  width: 100%;
  max-width: 100%;
  overflow: hidden !important;
  visibility: visible !important;
}

@media (max-width: 768px) {
  .ticker-bar {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    min-width: 0;
  }

  .ticker-bar .ticker-track {
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-bar .ticker-track {
    animation: none;
    transform: none;
    overflow-x: auto;
    max-width: 100%;
  }
}
