/*
  Layout: the container, sections and the few grids every page is built from.
  One container (.wrap) with the same side gutter for header, sections and footer.
*/

.wrap { width: min(100% - 2 * var(--gut), var(--container)); margin-inline: auto; }
.narrow { max-width: 820px; }

.site-main { flex: 1 0 auto; outline: none; }

.section { padding-block: var(--section-y); }
.section--page { --page-top: calc(var(--s-6) + 8px); padding-block: var(--page-top) var(--section-y); }

/* ---------------------------------------------------------------- headings of sections and pages */
.section-head { display: grid; gap: var(--s-4); max-width: 760px; margin-bottom: var(--s-7); }
.section-head .lead { color: var(--ink); max-width: 60ch; }
.section-head--row { max-width: none; display: flex; align-items: end; justify-content: space-between; gap: var(--s-5); flex-wrap: wrap; }
.section-head--row h2 { max-width: 760px; }

.page-head { display: grid; gap: var(--s-3); margin-bottom: var(--s-6); }
.page-head--row { display: flex; align-items: end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
/* the router moves the focus to the heading for screen readers; a ring around it would only distract */
.page-head h1, .page-head h1:focus-visible, .sheet__title:focus-visible { outline: none; box-shadow: none; }
.section-title { font-size: var(--t-card); font-weight: 600; letter-spacing: 0; margin-bottom: var(--s-3); }

.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-1); margin-bottom: var(--s-5); font-size: var(--t-small); color: var(--muted); }
.breadcrumb a { transition: color var(--dur) var(--ease); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .icon { width: 14px; height: 14px; opacity: .6; }
.breadcrumb [aria-current] { color: var(--ink); font-weight: 500; }

/* ---------------------------------------------------------------- split: text left, picture right */
.split { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); row-gap: var(--s-7); align-items: start; }
.split__text { grid-column: 1 / span 6; }
.split__media { grid-column: 7 / -1; }
.split--form .split__text { grid-column: 1 / span 7; }
.split--form .split__media { grid-column: 9 / -1; position: sticky; top: calc(var(--header-h) + var(--s-5)); }
@media (max-width: 1023px) {
  .split .split__text, .split .split__media { grid-column: 1 / -1; }
  .split--form .split__media { position: static; }
}

/* ---------------------------------------------------------------- tiles (product grids) */
.tiles { display: grid; gap: var(--s-7) var(--gap); }
.tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1279px) { .tiles--4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1023px) { .tiles--3, .tiles--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--s-6); } }
@media (max-width: 479px) { .tiles--3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- side navigation + content (account, admin) */
/* The area navigation (account, team area) stands in the page's left margin, outside the content: the
   content starts on the logo's line and ends on the header's right edge, like every page (.wrap); the
   navigation sits just left of the logo's line, as far from the content as the page title from the
   header (--page-top), set apart by that space alone. Where the margin is too narrow for it (below ~1840 px), the
   content moves right just as far as needed and the navigation keeps 32 px from the window's edge.
   The layout spans the page itself (no .wrap around it) – pages.css "side navigation". */
.side-layout {
  --side-w: 216px; --side-gap: var(--page-top, var(--s-6));
  --wrap-left: max(var(--gut), (100% - var(--container)) / 2);
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); gap: var(--side-gap); align-items: start;
  padding-inline: max(var(--s-6), var(--wrap-left) - var(--side-w) - var(--side-gap)) var(--wrap-left);
}
.side-layout__main { min-width: 0; }
@media (max-width: 1023px) { .side-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); padding-inline: var(--gut); } }

/* ---------------------------------------------------------------- checkout / cart: form + summary */
.checkout-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--s-7); align-items: start; }
.checkout-layout__main { min-width: 0; display: grid; gap: var(--s-5); align-content: start; }
.checkout-layout__aside { position: sticky; top: calc(var(--header-h) + var(--s-5)); display: grid; gap: var(--s-4); }
@media (max-width: 1023px) {
  .checkout-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }
  .checkout-layout__aside { position: static; }
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin-block: var(--gap); }
.grid-2--wide-first { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
@media (max-width: 1023px) { .grid-2, .grid-2--wide-first { grid-template-columns: minmax(0, 1fr); } }

/* Stacks are one-column grids. minmax(0, 1fr) keeps the column at the container's width, so a long
   word or a nowrap button inside can never push the page wider than the screen. */
.stack, .stack-lg, .form-stack, .card, .summary, .product__info, .product__head, .checkout-step, .info, .page-head { grid-template-columns: minmax(0, 1fr); }
.stack { display: grid; gap: var(--s-3); }
.stack-lg { display: grid; gap: var(--s-5); }

/* a form is a container: its two-column rows stack when the form itself is narrow (a card beside a
   picture, a dialog), not only on small screens */
.form-stack { display: grid; gap: var(--s-5); align-content: start; container-type: inline-size; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) var(--s-4); }
.form-grid > .field--wide { grid-column: 1 / -1; }
/* a longer form in parts (the print, who asks, where it goes): each with a small title, parted from the
   one before by a hairline */
.form-section { display: grid; gap: var(--s-5); min-width: 0; margin: 0; padding: 0; border: 0; }
.form-section + .form-section { padding-top: var(--s-5); border-top: 1px solid var(--line); }
/* float takes the legend out of the fieldset's border (where browsers draw it), so it is a plain title */
.form-section__title { float: left; width: 100%; padding: 0; font-size: var(--t-body); font-weight: 600; letter-spacing: 0; }
@media (max-width: 639px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
@container (max-width: 459px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }

/* ---------------------------------------------------------------- long text */
.prose { display: grid; gap: var(--s-5); }
.prose h2 { font-size: var(--t-h3); margin-top: var(--s-4); }
.prose p { max-width: 68ch; }
/* terms and privacy in a dialog (checkout, sign-up): tighter, the headings a step smaller */
.legal-dialog { gap: var(--s-4); }
.legal-dialog h2 { font-size: var(--t-lead); margin-top: var(--s-2); }
