/* Looping full-page background video + dim overlay. */

.app-bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin-top: -150px;
  object-fit: contain;
  pointer-events: none;
  z-index: 2;
}

.app-bg-video.is-disabled {
  display: none;
}

/* Dim overlay only on lobby / watch list; other pages keep the video bright. */
.app-bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: contrast(1.55) brightness(0.38) saturate(0.6);
  -webkit-backdrop-filter: contrast(1.55) brightness(0.38) saturate(0.6);
  opacity: 0;
  transition: opacity 0.2s ease;
}

body:has(main.app-main--lobby-list) .app-bg-overlay {
  opacity: 1;
}

/* Pass-through wrapper; pages-bg pages overlay bg + content. */
.app-page-stack {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Decorative page frame (quests, shop, clan, legal, profile modal, etc.) */
.app-pages-bg {
  display: none;
  flex-direction: column;
  min-height: 100%;
  align-self: stretch;
  pointer-events: none;
  z-index: 0;
}

.app-pages-bg-top,
.app-pages-bg-bottom {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  flex: 0 0 auto;
}

.app-main.app-main--page{
  margin-top:-1px;
}

.app-pages-bg-middle {
  flex: 1 1 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  background: url("/icons/pages-bg-middle.webp") repeat-y center top;
  background-size: 100% auto;
}

main.app-main--pages-bg {
  overflow-x: clip;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  --pages-frame-pad-top: 0px;
  --pages-frame-pad-x: clamp(10px, 2.5vw, 44px);
  --pages-frame-pad-bottom: clamp(14px, 2vw, 28px);
  --pages-frame-pad-top-shop: 0px;
  --pages-frame-pad-bottom-shop: clamp(14px, 3vw, 50px);
  --pages-frame-pad-top-clan: 0px;
  --pages-frame-pad-x-clan: clamp(18px, 4.5vw, 56px);
}

/*
 * Stack must grow with scrollable content (flex-shrink: 0), while still
 * filling the main viewport when content is short (min-height: 100% + grow).
 * Bg shares one grid cell with content so it matches that full height.
 */
main.app-main--pages-bg .app-page-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto;
  align-items: stretch;
  align-content: stretch;
  /* Grow to fill main when short; never shrink below content when scrolling. */
  flex: 1 0 auto;
  align-self: stretch;
  min-height: 100%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  overflow-y: visible;
}

main.app-main--pages-bg .app-page-stack > .app-pages-bg,
main.app-main--pages-bg .app-page-stack > .app-page-content {
  grid-area: 1 / 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

main.app-main--pages-bg .app-pages-bg {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  justify-self: stretch;
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-width: 0;
  max-width: 100%;
  pointer-events: none;
  z-index: 0;
}

main.app-main--pages-bg.is-page-loading .app-pages-bg {
  display: none !important;
}

main.app-main--pages-bg .app-page-content {
  position: relative;
  z-index: 1;
  flex: initial;
  align-self: stretch;
  width: 100%;
  min-height: 100%;
  min-width: 0;
  max-width: 100%;
  display: block;
  overflow-x: clip;
  overflow-y: visible;
  box-sizing: border-box;
}

main.app-main--pages-bg .app-page-content > * {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Shop + achievements: scroll on main (nested panels break with pages-bg grid). */
main.app-main--pages-bg.app-main--shop,
main.app-main--pages-bg.app-main--achievements {
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

main.app-main--pages-bg .shop-page {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  flex: none;
  min-height: auto;
  overflow-x: clip;
  overflow-y: visible;
}

main.app-main--pages-bg .shop-content {
  background: transparent;
  flex: none;
  min-height: auto;
  overflow-x: clip;
  overflow-y: visible;
  padding-bottom: var(--bottom-nav-clearance, calc(110px + env(safe-area-inset-bottom, 0px)));
}

main.app-main--pages-bg.app-main--clans .clans-toolbar,
main.app-main--pages-bg.app-main--clans .clans-list-section {
  padding-inline: var(--pages-frame-pad-x-clan, clamp(18px, 4.5vw, 56px));
  box-sizing: border-box;
}

main.app-main--pages-bg.app-main--clans .clans-list-section {
  margin-inline: 4px;
}

main.app-main--pages-bg .achievements-page {
  flex: none;
  min-height: auto;
}

main.app-main--pages-bg .achievements-scroll {
  flex: none;
  min-height: auto;
  overflow: visible;
  padding-bottom: var(--bottom-nav-clearance, calc(110px + env(safe-area-inset-bottom, 0px)));
  padding-left: 4px;
  padding-right: 4px;
}

