/*
  GritHQ Shell Lock v2 — Alpha4.53
  --------------------------------
  Layout only. No component colors live here.

  Contract:
    AppHeader     = grid row 1
    PageViewport  = grid row 2 and ONLY scroll owner
    PrimaryDock   = grid row 3 and always anchored to viewport bottom

  This supersedes the earlier content-driven Home shell behavior without
  rewriting page modules.
*/

@media (max-width:959px) {
  html,
  body {
    width:100%!important;
    height:100%!important;
    min-height:100%!important;
    max-height:100%!important;
    margin:0!important;
    overflow:hidden!important;
  }

  body:not(.workout-mode) .app-shell {
    position:fixed!important;
    inset:0!important;
    width:100%!important;
    height:100%!important;
    height:100dvh!important;
    min-height:0!important;
    max-height:100dvh!important;
    overflow:hidden!important;
  }

  body:not(.workout-mode) .app-stage {
    position:absolute!important;
    inset:0!important;
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto minmax(0,1fr) auto!important;
    width:auto!important;
    height:auto!important;
    min-width:0!important;
    min-height:0!important;
    max-width:none!important;
    max-height:none!important;
    overflow:hidden!important;
  }

  body:not(.workout-mode) .mobile-appbar {
    grid-row:1!important;
    position:relative!important;
    inset:auto!important;
    width:100%!important;
    min-width:0!important;
    flex:none!important;
    z-index:50!important;
  }

  body:not(.workout-mode) .main-content,
  html.ios-standalone body:not(.workout-mode) .main-content {
    grid-row:2!important;
    width:100%!important;
    height:100%!important;
    min-width:0!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:contain!important;
    touch-action:pan-y!important;
    position:relative!important;
    z-index:1!important;
    padding-bottom:20px!important;
    scroll-padding-bottom:20px!important;
  }

  body:not(.workout-mode) .bottom-nav,
  html.ios-standalone body:not(.workout-mode) .bottom-nav {
    grid-row:3!important;
    position:relative!important;
    inset:auto!important;
    width:auto!important;
    height:58px!important;
    min-height:58px!important;
    max-height:58px!important;
    flex:none!important;
    align-self:end!important;
    margin:
      6px
      max(10px,env(safe-area-inset-right))
      calc(7px + env(safe-area-inset-bottom))
      max(10px,env(safe-area-inset-left))!important;
    transform:none!important;
    z-index:50!important;
  }

  /* Home is a normal page module now. It may scroll, but it may not own
     the shell height or move the header/dock. */
  body.home-mode .main-content {
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    overflow-y:auto!important;
  }

  body.home-mode #view-home.active,
  #view-routines.active,
  #view-history.active,
  #view-profile.active,
  #view-health.active,
  #view-nutrition.active,
  #view-settings.active {
    min-height:0!important;
    contain:none!important;
    transform:none!important;
    will-change:auto!important;
  }

  body.home-mode .gh-home-head {
    display:none!important;
  }
}
