/*
 * Stable viewport shell shared by Treino, Avaliação, Evolução, Hevy and Conta.
 *
 * Only the DOCUMENT scrolls vertically. It must never pan sideways or bounce
 * past the top/bottom viewport edges and displace fixed navigation controls.
 * Deliberate component scrollers (week cards, charts, tables, dialogs) retain
 * their native independent scrolling; do not use global touch gesture restrictions
 * or cancel touch gestures from JavaScript.
 */
html {
  inline-size: 100%;
  max-inline-size: 100%;
  overflow-x: clip;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
}

body {
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  overflow-x: clip;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
}

/*
 * The root document and nested cards are not horizontal scroll containers.
 * Allow flex/grid content to shrink without widening the layout viewport.
 */
.page,
.page > main,
.page .section,
.page .site-header {
  min-inline-size: 0;
}

.page img,
.page video,
.page iframe,
.page canvas {
  max-inline-size: 100%;
}

/* The sticky workout navigator is anchored to the scrolling viewport,
   rather than clipping against the oversized legacy decorative overlay. */
.training-page .section.navigator {
  position: sticky;
  inset-block-start: env(safe-area-inset-top, 0px);
  inset-inline: auto;
  max-inline-size: 100%;
  overflow: visible;
  isolation: isolate;
}

.training-page .section.navigator::before {
  display: none;
}

/*
 * Suppress root-axis gesture chaining, but retain real horizontal scrolling
 * INSIDE a weekly carousel. This must not cancel vertical touch scrolls.
 */
.training-page .week-grid {
  max-inline-size: 100%;
  min-inline-size: 0;
  overscroll-behavior-inline: contain;
}

@media (max-width: 768px) {
  /*
   * Chrome Android/PWA dynamically changes its visual viewport when browser
   * chrome is shown or hidden. Fixed bars must use viewport-relative edges,
   * not be positioned inside a transformed scrollable ancestor.
   */
  .mobile-nav {
    position: fixed;
    inset-block-start: auto;
    inset-block-end: calc(0.55rem + env(safe-area-inset-bottom, 0px));
    inset-inline-start: max(0.65rem, env(safe-area-inset-left, 0px));
    inset-inline-end: max(0.65rem, env(safe-area-inset-right, 0px));
    inline-size: auto;
    max-inline-size: none;
    margin: 0;
    transform: none;
    z-index: 300;
    box-sizing: border-box;
  }

  .mobile-nav__item,
  .mobile-nav__trigger {
    min-inline-size: 0;
  }

  /* Keep the final interactive row clear of the fixed bottom actions. */
  body {
    min-block-size: 100dvh;
    padding-block-end: calc(100px + env(safe-area-inset-bottom, 0px));
  }

  /* Only the specific training page receives its additional FAB clearance. */
  body.training-page {
    padding-block-end: calc(134px + env(safe-area-inset-bottom, 0px));
  }

  .training-page .section.navigator {
    inset-block-start: env(safe-area-inset-top, 0px);
    scroll-margin-block-start: env(safe-area-inset-top, 0px);
  }
}

/* Browser fallback: retain the horizontal clamp if overflow:clip is absent. */
@supports not (overflow: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}
