/*
 * Horizontal navigation / viewport integration.
 * Fixed overlays and sticky panels were authored for a headerless viewport.
 * Constrain only these presentation surfaces under the two-tier top bar.
 * No page content, dialog HTML, data, routing, or planner editor changed.
 *
 * When Original (left-sidebar) layout is selected, none of these rules apply.
 */
html[data-gtt-design-mode="workbench"] {
  --gtt-safe-nav-top:calc(var(--gtt-nav-height,68px) + var(--gtt-context-height,32px));
  --gtt-safe-page-height:calc(100dvh - var(--gtt-safe-nav-top));
  --gtt-safe-dialog-height:calc(100dvh - var(--gtt-safe-nav-top) - 24px);
}

/* All user-facing page dialogs must remain within the visible area BELOW the
   persistent navbar and breadcrumb. Especially important for tall item data. */
html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .gp-overlay {
  inset:var(--gtt-safe-nav-top) 0 0!important;
  box-sizing:border-box!important;
  min-height:0!important;
  padding:12px!important;
  overflow:hidden!important;
  overscroll-behavior:contain;
}
html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content
:is(.gp-detail,.gp-detail-v2) {
  box-sizing:border-box!important;
  max-height:var(--gtt-safe-dialog-height)!important;
  min-height:0!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  overscroll-behavior:contain;
}
html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .gp-close {
  z-index:2;
}

/* Market: the inspector's title, close button and price data must never
   render behind the header. Preserve original inspector widths and buttons. */
html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .gm-drawer-mask {
  inset:var(--gtt-safe-nav-top) 0 0!important;
}
html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .gm-inspector:not(.gm-inline-detail) {
  top:calc(var(--gtt-safe-nav-top) + 12px)!important;
  bottom:12px!important;
  height:auto!important;
  max-height:calc(var(--gtt-safe-page-height) - 24px)!important;
  min-height:0!important;
  overscroll-behavior:contain;
}

/* Market item details are NOT a fixed drawer: market-v118 inserts the
   disclosure as a grid child directly below the selected card row.
   The former blanket .gm-inspector top:112px offset displaced this entire
   inline card by about 110px, creating a huge blank band in the gallery.
   Restore its natural grid position, including narrow screens. */
html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content
.gtmarket.gm-v111 .gm-inspector.gm-detail-page.gm-inline-detail {
  position:relative!important;
  z-index:auto!important;
  inset:auto!important;
  width:100%!important;
  height:auto!important;
  max-height:none!important;
  overflow:hidden!important;
  margin:7px 0 11px!important;
}

/* Native app dialogs/search/results use one shared viewport without losing
   focus, background dismissal, or the existing modal appearance. */
html[data-gtt-design-mode="workbench"] body[data-theme="glass"]
:is(#modal-root .modal-backdrop,.dialog-backdrop) {
  inset:var(--gtt-safe-nav-top) 0 0!important;
  min-height:0!important;
  box-sizing:border-box!important;
  padding:12px!important;
  overflow:hidden!important;
}
html[data-gtt-design-mode="workbench"] body[data-theme="glass"]
:is(#modal-root .modal,.dialog-backdrop .dialog) {
  box-sizing:border-box!important;
  max-height:var(--gtt-safe-dialog-height)!important;
  overflow-y:auto!important;
  overscroll-behavior:contain;
}

/* Other established full-screen content dialogs (Arcade sharing and site
   changelog) follow the same safe viewport. They retain their own z-index. */
html[data-gtt-design-mode="workbench"] body[data-theme="glass"]
:is(.arc-share-overlay,.v84-overlay) {
  inset:var(--gtt-safe-nav-top) 0 0!important;
  min-height:0!important;
  box-sizing:border-box!important;
  padding:12px!important;
  overflow:hidden!important;
}
html[data-gtt-design-mode="workbench"] body[data-theme="glass"]
:is(.arc-share-panel,.v84-updates-dialog) {
  box-sizing:border-box!important;
  max-height:var(--gtt-safe-dialog-height)!important;
  overflow-y:auto!important;
  overscroll-behavior:contain;
}

/* Stickies move with the navbar rather than disappearing behind it while
   scrolling on desktop. On mobile these are regular, nonsticky panels. */
@media(min-width:941px) {
  html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .gp-sidebar-v147 {
    top:calc(var(--gtt-safe-nav-top) + 12px)!important;
    max-height:calc(var(--gtt-safe-page-height) - 24px)!important;
  }
  html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .ep-v2 .ep2-inspector {
    top:calc(var(--gtt-safe-nav-top) + 16px)!important;
  }
}

/* Market's existing mobile rules use !important top:0 and height:100dvh,
   so override those explicitly. This keeps the close control reachable. */
@media(max-width:700px) {
  html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .gm-inspector:not(.gm-inline-detail) {
    top:var(--gtt-safe-nav-top)!important;
    bottom:0!important;
    left:0!important;
    right:0!important;
    height:var(--gtt-safe-page-height)!important;
    max-height:var(--gtt-safe-page-height)!important;
  }
}

/* Conserve vertical space on small screens while retaining tap-sized close
   controls and internal scrolling of long item descriptions. */
@media(max-width:780px) {
  html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content .gp-overlay {
    padding:8px!important;
  }
  html[data-gtt-design-mode="workbench"] body[data-theme="glass"] #content
  :is(.gp-detail,.gp-detail-v2) {
    max-height:calc(var(--gtt-safe-page-height) - 16px)!important;
  }
  html[data-gtt-design-mode="workbench"] body[data-theme="glass"]
  :is(#modal-root .modal,.dialog-backdrop .dialog,.arc-share-panel,.v84-updates-dialog) {
    max-height:calc(var(--gtt-safe-page-height) - 16px)!important;
  }
}
