/* Alpha-Gal Living 0.9.2: mobile layout, navigation, and readability fixes. */

html,
body {
  min-height: 100%;
  overscroll-behavior-y: none;
}

.main-content {
  padding-bottom: calc(108px + env(safe-area-inset-bottom));
}

.screen {
  padding-bottom: 36px;
}

.bottom-nav {
  min-height: 76px;
}

.filter-row {
  scroll-snap-type: x proximity;
  scroll-padding-inline: 12px;
  padding-inline: 2px;
}

.filter-row button {
  flex: 0 0 auto;
  min-height: 42px;
  scroll-snap-align: center;
}

.filter-row button.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 3px 10px rgba(35, 79, 69, 0.2);
}

/* Keep Safety tools in the page chrome instead of over the page content. */
#agl-safety-launch {
  position: static !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 21;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 10px 13px;
  box-shadow: none;
  white-space: nowrap;
}

.mobile-header #agl-safety-launch {
  margin-left: auto;
  margin-right: 7px;
  font-size: 12px;
}

.mobile-header #agl-safety-launch span {
  font-size: 16px;
}

.detail-body > #agl-safety-launch {
  width: 100%;
  justify-content: center;
  margin: 0 0 18px;
  padding: 14px 18px;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(50, 103, 90, 0.18);
}

body > #agl-safety-launch {
  position: fixed !important;
  top: calc(max(12px, env(safe-area-inset-top)) + 8px);
  right: 68px !important;
}

/* Every Safety Toolkit label is fully visible; the rows scroll with the sheet. */
.agl-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
  padding: 10px 12px 12px;
}

.agl-tab {
  min-width: 0;
  min-height: 44px;
  padding: 8px 5px;
  white-space: normal;
  line-height: 1.15;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.agl-tab .agl-mini-count {
  flex: 0 0 auto;
  min-width: 20px;
  height: 20px;
  padding-inline: 5px;
}

.agl-tab.active .agl-mini-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

#agl-toolkit,
#mp-app {
  box-sizing: border-box;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: env(safe-area-inset-bottom);
}

.agl-sheet,
.mp-shell {
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
}

#agl-toolkit,
#mp-app {
  display: flex;
  flex-direction: column;
}

.agl-body,
.mp-content {
  padding-bottom: calc(34px + env(safe-area-inset-bottom));
}

.mp-main-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex: 0 0 auto;
  overflow: visible;
  padding: 11px 12px 12px;
}

.mp-main-tabs button {
  min-width: 0;
  min-height: 46px;
  padding: 8px 6px;
  white-space: normal;
  line-height: 1.15;
}

.mp-head {
  flex: 0 0 auto;
}

.mp-head h2,
.mp-head p,
.agl-head h2,
.agl-head p {
  overflow-wrap: anywhere;
}

.recipe-detail .detail-back,
.recipe-detail .detail-save {
  top: max(36px, calc(env(safe-area-inset-top) + 12px));
}

.recipe-detail .detail-body {
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

.profile-banner-content {
  min-width: 0;
}

@media (max-width: 600px) {
  #mp-app {
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .mp-shell,
  .agl-sheet {
    border-radius: 0;
  }

  .mobile-header {
    height: auto;
    min-height: 76px;
    gap: 6px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .mobile-header .brand {
    min-width: 0;
  }

  .mobile-header .brand strong {
    font-size: 17px;
  }

  .mobile-header .brand > div span {
    font-size: 10px;
  }

  .mobile-header .icon-button {
    flex: 0 0 41px;
  }
}

@media (max-width: 390px) {
  .mobile-header #agl-safety-launch {
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .mobile-header #agl-safety-launch span {
    font-size: 20px;
  }

  .agl-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
