/* Redesign, explore lane: the photograph grid fits its container.
   Tokens and the layout system live in redesign.css; this file is the only
   stylesheet this page owns. See docs/redesign-workstreams.md.

   Screen 05 draws the six photographs filling the whole space between the banner
   and the tab bar edge to edge: in the reference, `.c { top: 96px; bottom: 84px }`
   holds the grid and `.x-grid` is inset 0 inside it. Nothing is left empty.

   The page used to size itself from the viewport with assumed chrome heights
   (`height: calc(100dvh - 3rem - 8rem)` in redesign.css). Two things are wrong with
   that: the banner and bar heights are guesses that the real chrome does not honour,
   and 100dvh is not the frame the tab bar is anchored to — the bar is `absolute
   bottom-0` of the body, a 100vh box — so on a browser whose dynamic chrome shrinks
   the visible viewport (iOS Safari with its URL bar showing) the grid and the bar
   disagreed by exactly that chrome, and the gap between them was the bone-coloured
   band the launcher floated in.

   So there is no arithmetic here. The chain is:
     body          a 100vh column, the banner in flow at the top
     #app-wrapper  given what the banner leaves (flex: 1), instead of 100vh again
     main          fills it, and its own `pb-32` already reserves the tab bar, whose
                   footer is `h-32` — the same 8rem, stated once by the layout
     .rd-explore   the rest, so its bottom edge is the tab bar's top edge
   Banner, tab bar and grid then share one frame by construction, at every size, and
   no height is written down anywhere. In the iOS wrapper neither bar is rendered
   (the native app draws them), so the bottom reservation is dropped and the grid
   fills the webview. */

@supports selector(:has(*)) {
  /* The app's scroll container takes the space under the banner rather than a second
     full viewport height. `min-height: 0` lets it shrink on a short viewport instead
     of pushing the page taller than the body. */
  #app-wrapper:has(> main > .rd-explore) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  /* `width: 100%` because main carries `mx-auto`: auto margins on the cross axis opt a
     flex item out of stretching, and the grid has no intrinsic width of its own. The
     desktop column keeps its `max-w-screen-sm` and stays centred. */
  main:has(> .rd-explore) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
  }

  /* Overrides `height: calc(100dvh - var(--rd-top-bar) - 8rem)` in redesign.css:
     the grid's height is its container's, so it cannot drift from the chrome. */
  main > .rd-explore {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  /* Turbo Native: no web banner and no web tab bar, so nothing is reserved at the
     bottom — the grid reaches the foot of the webview, as the design's `.pg.in .c
     { bottom: 0 }` does for inner pages. */
  main:has(> .rd-explore--native) {
    padding-bottom: 0;
  }
}
