/*
 * MIIGO_A_MOBILE_REAL_PHONE_FIX_V2
 * A-site real mobile viewport only.
 *
 * Important:
 * - Desktop phone-shell uses >=700px outer viewport and is untouched.
 * - The home control dock is moved out of the sticky header by V2 JS.
 */

@media (max-width: 699px) {

  html,
  body {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden !important;
    overscroll-behavior-x: none !important;
  }

  html.miigo-a-mobile-v2,
  html.miigo-a-mobile-v2 body {
    height: 100% !important;
    background: #000 !important;
  }

  html.miigo-a-mobile-v2 #stage2hApp,
  html.miigo-a-mobile-v2 .s2h-app {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;

    width: 100% !important;
    max-width: 100% !important;

    /* JS replaces this with the exact real phone/PWA viewport. */
    height: var(--miigo-a-mobile-real-height, 100dvh) !important;
    max-height: none !important;

    margin: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }

  html.miigo-a-mobile-v2 .s2h-main,
  html.miigo-a-mobile-v2 .s2h-page,
  html.miigo-a-mobile-v2 .s2h-page.is-active,
  html.miigo-a-mobile-v2 #d27TencentHome,
  html.miigo-a-mobile-v2 .d27-home,
  html.miigo-a-mobile-v2 .d27-home-head,
  html.miigo-a-mobile-v2 .d27-home-main,
  html.miigo-a-mobile-v2 .miigo-a-mobile-flow-dock-v2 {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /*
   * 1) WHOLE PAGE HORIZONTAL LOCK
   * Individual rails below can still scroll horizontally inside themselves.
   */
  html.miigo-a-mobile-v2 .s2h-main,
  html.miigo-a-mobile-v2 .s2h-page,
  html.miigo-a-mobile-v2 #d27TencentHome,
  html.miigo-a-mobile-v2 .d27-home,
  html.miigo-a-mobile-v2 .d27-home-main,
  html.miigo-a-mobile-v2 .miigo-a-mobile-flow-dock-v2 {
    overflow-x: hidden !important;
    overscroll-behavior-x: none !important;
  }

  html.miigo-a-mobile-v2 #d27TencentHome {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html.miigo-a-mobile-v2 img,
  html.miigo-a-mobile-v2 video,
  html.miigo-a-mobile-v2 canvas,
  html.miigo-a-mobile-v2 iframe {
    max-width: 100%;
  }

  /*
   * Keep the intended horizontal chip/category rails working.
   * Their own scrollLeft can move; the page/root cannot.
   */
  html.miigo-a-mobile-v2 .d27-theme-tabs,
  html.miigo-a-mobile-v2 [class*="taxonomy-scroll"],
  html.miigo-a-mobile-v2 [class*="category-scroll"],
  html.miigo-a-mobile-v2 [class*="chip-scroll"],
  html.miigo-a-mobile-v2 [class*="tabs-scroll"] {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /*
   * 2) MOBILE STICKY BOUNDARY
   * Header contains brand/search + theme row only after JS moves dock out.
   */
  html.miigo-a-mobile-v2 .d27-home-head {
    position: sticky !important;
    top: 0 !important;
    z-index: 80 !important;
  }

  html.miigo-a-mobile-v2 #d27HomeThemes {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
  }

  /*
   * Ad + primary/secondary/tertiary categories are now a normal-flow
   * sibling between sticky header and content main.
   */
  html.miigo-a-mobile-v2 .miigo-a-mobile-flow-dock-v2 {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;

    z-index: 2 !important;

    margin: 0 !important;
    padding: 2px 12px 0 !important;

    transform: none !important;
    overflow-x: hidden !important;
  }

  html.miigo-a-mobile-v2 .miigo-a-mobile-flow-dock-v2 #d27HomeAd,
  html.miigo-a-mobile-v2 .miigo-a-mobile-flow-dock-v2 #d27PrimaryTaxonomy,
  html.miigo-a-mobile-v2 .miigo-a-mobile-flow-dock-v2 #d27SecondaryTaxonomy,
  html.miigo-a-mobile-v2 .miigo-a-mobile-flow-dock-v2 #d27TertiaryTaxonomy {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
  }

  /*
   * 3) REAL PHONE / PWA BOTTOM NAV
   * Remove the old seam mask and make the black nav background itself
   * include the iPhone bottom safe area.
   */
  html.miigo-a-mobile-v2 .d2714-bottom-seam-mask {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
  }

  html.miigo-a-mobile-v2 .s2h-bottom-nav {
    position: absolute !important;

    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;

    width: 100% !important;
    max-width: 100% !important;

    height: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
    min-height: calc(58px + env(safe-area-inset-bottom, 0px)) !important;

    margin: 0 !important;
    padding:
      0
      6px
      env(safe-area-inset-bottom, 0px)
      6px !important;

    transform: none !important;
    box-sizing: border-box !important;

    background: #000 !important;
    border-radius: 0 !important;
    z-index: 980 !important;
  }

  html.miigo-a-mobile-v2 .s2h-bottom-nav button {
    min-width: 0 !important;
    height: 58px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  html.miigo-a-mobile-v2 .s2h-bottom-nav img,
  html.miigo-a-mobile-v2 .s2h-bottom-nav [data-d26-nav-icon] {
    display: block !important;
    visibility: visible !important;

    width: 29px !important;
    height: 29px !important;
    max-width: 29px !important;
    max-height: 29px !important;

    object-fit: contain !important;
    opacity: .82 !important;
  }

  html.miigo-a-mobile-v2 .s2h-bottom-nav button.is-active img,
  html.miigo-a-mobile-v2 .s2h-bottom-nav button.is-active [data-d26-nav-icon] {
    opacity: 1 !important;
  }
}

/*
 * MIIGO_A_MOBILE_BOTTOM_NAV_OVERLAY_FIX_V2_2
 *
 * V2.1 used the full safe-area-inset-bottom as padding inside the nav.
 * That lifted all five icons above the iPhone bottom area and left a large
 * empty black strip below them. V2.2 intentionally overlays the navigation
 * surface on the physical bottom area instead.
 *
 * This block is A mobile only. Horizontal-lock and sticky-flow logic are
 * deliberately not changed.
 */
@media (max-width: 699px) {
  html.miigo-a-mobile-v2 #d27TencentHome {
    bottom: 58px !important;
  }

  html.miigo-a-mobile-v2 .s2h-bottom-nav {
    position: fixed !important;

    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;

    width: 100% !important;
    max-width: 100% !important;

    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;

    margin: 0 !important;
    padding: 0 6px !important;
    padding-bottom: 0 !important;

    transform: none !important;
    box-sizing: border-box !important;

    background: #000 !important;
    border-radius: 0 !important;
    z-index: 999 !important;
  }

  html.miigo-a-mobile-v2 .s2h-bottom-nav button {
    height: 58px !important;
    min-height: 58px !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    margin: 0 !important;
    padding: 0 !important;
  }

  html.miigo-a-mobile-v2 .s2h-bottom-nav img,
  html.miigo-a-mobile-v2 .s2h-bottom-nav [data-d26-nav-icon] {
    display: block !important;
    visibility: visible !important;
  }

  html.miigo-a-mobile-v2 .d2714-bottom-seam-mask {
    display: none !important;
    height: 0 !important;
  }
}
