/* Desktop layout.
   The app is built phone-first: one centred column at most 448 units wide and a
   bottom pill for navigation. Everything below 901px keeps that experience
   untouched. From 901px up (the breakpoint surface.css already uses for its
   desktop branches) the shell grows a top header with the brand and the primary
   destinations, and the reading column widens to --shell-width (1080px) instead
   of hugging the left edge. Header, main and footer share that one measure. */

/* Phone layout is unchanged: the header nav and brand only exist from 901px up. */
.app-brand,
.top-nav { display: none; }

@media (min-width: 901px) {
  :root { --shell-width: calc(270 * var(--unit)); }

  /* Header: brand, primary destinations, then the existing actions. */
  body[data-page]:has(#main) > .top.market-top {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: none;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-4);
    height: calc(18 * var(--unit));
    min-height: calc(18 * var(--unit));
    padding: 0 max(var(--page-gutter), calc((var(--inset-100vw) - var(--shell-width)) / 2));
    border-block-end: var(--space-hairline) solid var(--line);
  }
  /* Home and Explore hide the bar on phones because the feed brings its own heading.
     The :has(#main) copies of the phone rules keep the same weight as the page-level
     hide rules, so this later sheet wins. */
  body[data-page=home]:has(#main) > .top.market-top,
  body[data-page=explore]:has(#main) > .top.market-top { display: flex; }

  .app-brand {
    display: inline-flex;
    align-items: center;
    flex: none;
    min-height: var(--hit);
    color: var(--brand);
    font-size: var(--type-section);
    font-weight: 400;
    letter-spacing: var(--tracking-display);
    line-height: 1;
  }

  .top-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-inline: auto;
    min-width: 0;
  }
  .top-nav a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--hit);
    padding: 0 var(--space-3);
    border-radius: var(--radius-pill);
    color: var(--muted);
    font-size: var(--caption-size);
    font-weight: 560;
    letter-spacing: var(--tracking-body);
    white-space: nowrap;
    transition: background-color var(--motion-tap), color var(--motion-tap);
  }
  .top-nav a:hover { background: var(--hover); color: var(--ink); }
  .top-nav a[aria-current=page] { background: var(--surface2); color: var(--ink); }
  .top-nav a svg { width: calc(4.75 * var(--unit)); height: calc(4.75 * var(--unit)); }
  body[data-page=home] .top-nav a:hover,
  body[data-page=home] .top-nav a[aria-current=page] { background: var(--night-control); color: var(--on-night); }

  /* The pill dock becomes the header nav, so it steps aside at this width. */
  .dock { display: none; }

  /* Container: one max-width, real gutters, no left-hugging content. */
  body[data-page] #main {
    width: 100%;
    max-width: var(--shell-width);
    margin-inline: auto;
    padding-inline: var(--page-gutter);
  }
  body[data-page=home] #main {
    max-width: var(--shell-width);
    padding-inline: var(--page-gutter);
    padding-block: var(--space-6) var(--space-8);
  }
  /* Inventory screens keep their own narrower reading measure. */
  body:is([data-page=profile],[data-page=ranks],[data-page=activity],[data-page=settings],[data-page=notifications],[data-page=search],[data-page=invite],[data-page=finishes],[data-page=agent-unlocked],[data-page=payment]) #main {
    max-width: calc(200 * var(--unit));
  }
  .foot {
    width: 100%;
    max-width: var(--shell-width);
    margin-inline: auto;
    padding-inline: var(--page-gutter);
  }

  /* Home: the card rails become grids so the shelves use the container width. */
  .shop-home { --home-edge: 0; }
  .shop-home :is(.home-heroes,.home-card-rail) { padding-inline: 0; }
  .shop-home .home-heroes {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fit, minmax(calc(100 * var(--unit)), 1fr));
    gap: var(--space-4);
    overflow: visible;
  }
  .shop-home .home-card-rail {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, minmax(calc(100 * var(--unit)), 1fr));
    gap: var(--space-4);
    overflow: visible;
  }
  .shop-home :is(.home-heroes,.home-card-rail) > * { width: auto; flex: none; }
  .home-shelf-wrap .home-arrow { display: none; }
}
