/* Libertalia HQ — mobile-fixes.css (v12)
   Purpose: stop Android "scroll bleed" in Ship Index.
   - The drawer (.legend) should NOT be the scroll container.
   - Only the list (.legend__list) scrolls; header stays pinned/masks content.
   - Uses left-based drawer (no transforms) for reliable touch scroll.
*/
@media (max-width: 960px){
  /* Drawer movement: left-based (transform can break scrolling on Android) */
  .legend{
    left: -105% !important;
    transform: none !important;
    transition: left .18s ease !important;
  }
  body[data-legend="open"] .legend{
    left: 0 !important;
  }

  /* Drawer layout: header fixed, list scrolls */
  .legend{
    display: flex !important;
    flex-direction: column !important;

    /* Use top+bottom geometry so height is always known */
    position: fixed !important;
    top: var(--topbar-h, 56px) !important;
    bottom: 0 !important;
    height: auto !important;

    /* IMPORTANT: drawer itself does NOT scroll */
    overflow: hidden !important;

    /* Let Android route vertical pans into the list */
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .legend__head{
    flex: 0 0 auto !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;

    /* Mask list items so they never appear "above" the header */
    background: rgba(8, 12, 18, 0.92) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border-bottom: 1px solid rgba(255,255,255,0.10) !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.35) !important;
  }

  .legend__list{
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    touch-action: pan-y !important;
  }

  /* Ensure list items are always below header in stacking */
  .legendItem, .legendBtn{ position: relative !important; z-index: 1 !important; }
}


/* Mobile playback relief: reduce compositing / GPU work around video */
@media (max-width: 960px){
  .bs-videoWrap{
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08) !important;
  }

  .bs-videoWrap::before,
  .bs-videoWrap::after{
    content: none !important;
    display: none !important;
  }

  .bs-video{
    filter: none !important;
    transform: translateZ(0);
    will-change: auto;
  }

  .inspect,
  .inspect::backdrop{
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .inspectFrame,
  .inspectFrame iframe{
    background: #000 !important;
  }
}


/* 2026-03-15 dedicated mobile shell reset
   Goal: keep mobile simple — visible Modules button, working drawer, portrait scenes.
   Desktop untouched.
*/
@media (max-width: 960px){
  html, body{
    overflow: hidden !important;
  }

  .topbar{
    display: grid !important;
    grid-template-columns: minmax(0,1fr) auto !important;
    align-items: center !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 90 !important;
    min-height: 54px !important;
    padding: 8px 12px !important;
    gap: 10px !important;
    background: rgba(4,10,16,.88) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    overflow: visible !important;
  }

  .topbar .brand{
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    min-width: 0 !important;
    width: min(58vw, 220px) !important;
    max-width: min(58vw, 220px) !important;
    padding: 3px 10px 0 8px !important;
    margin: 0 !important;
    position: relative !important;
    z-index: 1 !important;
    isolation: isolate !important;
  }

  .topbar .brand::before{
    left: -5px !important;
    right: -8px !important;
    top: -5px !important;
    bottom: -7px !important;
    opacity: .78 !important;
  }

  .topbar .brand__title{
    display: block !important;
    font-size: 11px !important;
    line-height: .96 !important;
    letter-spacing: .12em !important;
    white-space: nowrap !important;
    transform: translateY(-2px) !important;
    transform-origin: left top !important;
  }

  .topbar .brand__sub{
    display: block !important;
    font-size: 6.6px !important;
    line-height: 1.02 !important;
    letter-spacing: .05em !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    transform: translateY(-3px) !important;
    transform-origin: left top !important;
  }

  .topbarRight{
    margin-left: 0 !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-self: end !important;
  }

  #modulesBtn{
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 118px !important;
    height: 40px !important;
    padding: 0 14px !important;
    margin-left: 0 !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    letter-spacing: .07em !important;
    line-height: 1 !important;
    text-transform: uppercase !important;
    color: #f3e5b4 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 91 !important;
  }

  .layout{
    position: fixed !important;
    top: var(--topbar-h, 56px) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    grid-template-columns: 1fr !important;
  }

  .legend{
    position: fixed !important;
    top: calc(var(--topbar-h, 56px) + 10px) !important;
    left: -96% !important;
    bottom: 12px !important;
    width: min(340px, 88vw) !important;
    max-width: 88vw !important;
    height: auto !important;
    z-index: 95 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    transform: none !important;
    transition: left .18s ease !important;
    border-radius: 16px !important;
    padding: 12px !important;
    border: 1px solid rgba(255,255,255,.14) !important;
    box-shadow: 0 14px 40px rgba(0,0,0,.42) !important;
  }

  body[data-legend="open"] .legend{
    left: 12px !important;
  }

  .legend__head{
    flex: 0 0 auto !important;
    position: relative !important;
    top: auto !important;
    padding-bottom: 12px !important;
    margin-bottom: 8px !important;
  }

  .legend__list{
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 14px !important;
  }

  .legendItem{
    grid-template-columns: 36px 1fr !important;
    gap: 8px !important;
    align-items: start !important;
  }

  .legendNum{
    min-width: 36px !important;
    padding-top: 16px !important;
    font-size: 11px !important;
  }

  .legendBtn{
    min-height: 68px !important;
    padding: 12px 60px 12px 14px !important;
    border-radius: 14px !important;
  }

  .legendBtn::after{
    display: block !important;
    width: 42px !important;
    height: 42px !important;
    right: 8px !important;
    border-radius: 10px !important;
    opacity: .96 !important;
  }

  .legendBtn__title,
  .legendBtn__purpose{
    padding-left: 24px !important;
  }

  .legendBtn__title{
    font-size: 12px !important;
    line-height: 1.2 !important;
  }

  .legendBtn__purpose{
    font-size: 11px !important;
    line-height: 1.2 !important;
    margin-top: 4px !important;
  }

  .mapPane{
    padding: 10px !important;
    padding-bottom: 96px !important;
  }

  .mapFigure{
    min-height: 0 !important;
    border-radius: 20px !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
  }

  body[data-scene="home"] .mapFigure{ background-position: 56% center !important; }
  body[data-scene="dock"] .mapFigure{ background-position: 59% center !important; }
  body[data-scene="codex"] .mapFigure{ background-position: 34% center !important; }
  body[data-scene="cargo"] .mapFigure{ background-position: 66% center !important; }
  body[data-scene="fuel"] .mapFigure{ background-position: 39% center !important; }

  .sceneHotspot{
    min-width: 176px !important;
    min-height: 50px !important;
    padding: 8px 14px 8px 42px !important;
    z-index: 6 !important;
  }

  .sceneHotspot__label{
    font-size: 10px !important;
    letter-spacing: .07em !important;
  }

  #hud,
  #hud.hud--topbar{
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    top: auto !important;
    bottom: 10px !important;
    width: auto !important;
    height: auto !important;
    z-index: 70 !important;
  }
}


@media (max-width: 820px){
  html[data-skin="ui"] .fuelModal__head{
    gap: 8px !important;
    padding: 8px 10px !important;
  }
  html[data-skin="ui"] .fuelModal__title{
    font-size: 12px !important;
  }
  html[data-skin="ui"] .fuelModal__note{
    font-size: 11px !important;
    line-height: 1.3 !important;
  }
  html[data-skin="ui"] .fuelModal__body{
    padding: 8px !important;
    place-items: start center !important;
    overflow: auto !important;
  }
  html[data-skin="ui"] .fuelModal__frame{
    width: min(100%, 332px) !important;
    max-width: 332px !important;
    margin-inline: auto !important;
    background: transparent !important;
    border-color: rgba(255,255,255,.08) !important;
  }
  html[data-skin="ui"] .fuelModal__frame iframe{
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 980px !important;
    min-height: 980px !important;
    border-radius: 14px !important;
  }
}
