/* The public page's regions (./home.pug). What's in them is the layout's
   (modules/layout.js); the blocks' stylesheets are linked by ../components/_styles.pug. */

/* The page behind the cards - the theme's, or the skin's (_app_layout.pug's
   .app-skin declares the tokens). On the page's scroller (.flow-fill), inside
   the page's own layer: a transition animates the layer, and the background
   goes with it, so the page underneath never shows through. The scroller is the
   layer's full size - its scrollbar gutter included, however wide the screen -
   and a scroll container's background stays put as its content scrolls. Shared
   by the org page (../org/org.pug). */
.app-backdrop {
  background: var(--page-bg-image), var(--page-bg);
}

/* The page's breakpoints are its own width's, not the screen's: the shell's side
   menu takes some of the screen, and a page beside it is narrower than the
   viewport says. Every rule below - and the blocks' own (../components) - asks
   `@container app-page`. */
/* `size`, not just inline-size: the aside below is sized to this box's HEIGHT
   (100cqh) - the page's own scroll area, under the shell's top bar (and the staff
   banner) - not the screen's. Safe: .flow-fill is a flex child of flow-template,
   sized by it, never by its content. */
.app-backdrop {
  container: app-page / size;
}

.app-page {
  /* flow-template is a flex column, and an auto margin on a flex item switches
     off its cross-axis stretch - the page would then be as wide as its content,
     and change width as the carousel shows different campaigns. An explicit
     width makes it the viewport's (max-width and the auto margins still centre it). */
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem 20px 0rem;
}

/* Narrower pages: the card's own padding (--card-spacer-*) already sets the
   content in, so the page's gutter shrinks to what keeps the card's edge and
   shadow off the screen's */
@container app-page (width < 992px) {
  .app-page { padding: 1rem 16px 0rem; }
}

@container app-page (width < 576px) {
  .app-page { padding: 0.5rem 6px 2.5rem; }
}

.app-page__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@container app-page (width >= 780px) {
  .app-page__grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
}

@container app-page (width >= 1200px) {
  .app-page__grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}

/* its look is the theme's `.card.shadow-sm.border-0` (./home.pug), like the dashboard's
   panels; only the clipping is the page's own (the hero runs to the edges) */
.app-page__main {
  overflow: hidden;
}

/* the aside's blocks, stacked */
.app-page__aside {
  display: flex;
  flex-direction: column;
  /*gap: 1rem;*/
}

/* legacy .sticky-app: the aside stays in view beside a long campaign.
   --cart-beside: the checkout bar (../components/cartBar) reads it - it lives
   outside the page, where this query can't reach it. */
.app-page {
  --cart-beside: 0;
}
@container app-page (width >= 780px) {
  .app-page {
    --cart-beside: 1;
  }
  .app-page__aside {
    position: sticky;
    top: 0rem;
  }

  .app-page__main{
    margin-bottom: 3rem;
  }
}

/* The cart and checkout scroll on their own, within the screen: the wheel or a
   touch over them scrolls them, and at their top or bottom the scroll carries on
   to the page (the browser's own chaining). The browser's scrollbar stays the
   campaign's. For the keyboard the aside is a focusable region (./home.pug): Tab
   onto it and the scroll keys move it, and Tab through the checkout scrolls each
   field - and "Give" - into view. All native: no script touches scrolling.
   The padding, with a matching negative margin, keeps the cards' shadows from
   being clipped by the scroll box.
   Its height is the page's scroll area (100cqh, .app-backdrop), not the screen:
   the shell's top bar takes some of the screen, and sized to 100dvh the aside's
   foot - "Give" - ran under the page's bottom edge, out of reach: the aside's
   content still fit its own height, so it had nothing to scroll either. */
@container app-page (width >= 780px) {
  .app-page__aside {
    max-height: calc(100dvh - 0rem); /* without container units */
    max-height: calc(100cqh - 0rem);
    overflow-y: auto;
    scrollbar-width: none;
    padding: 0.5rem 1rem 1.5rem;
    margin: -0.5rem -1rem 0;
  }
}

/* scrollbar-width: none, for Safari before 18.2 (it has only the -webkit- pseudo-element) */
.app-page__aside::-webkit-scrollbar {
  display: none;
}

.app-page__aside:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
  border-radius: var(--card-radius);
}

/* an empty region takes no space */
[data-region]:empty {
  display: none;
}
