/* Page width, section spacing and grids */

@layer layout {
  /* The page column: content up to --wrap-max wide, with a gutter on each side */
  .wrap { width: 100%; max-width: calc(var(--wrap-max) + 2 * var(--wrap-gutter)); margin-inline: auto; padding-inline: var(--wrap-gutter); }

  /* Sections: vertical spacing and the background chosen in the editor */
  .section { padding-block: var(--space-section); color: var(--color-text); }
  .section--white { background: var(--color-white); }
  .section--light { background: var(--color-paper); }
  .section--dark { --color-text: var(--color-white); --color-ink: var(--color-white); background: var(--color-grey); }

  /* Two sections in a row on the same background read as one, so the gap between them isn't doubled.
     A photo hero or call to action isn't on its background colour, so the section after it keeps its gap. */
  .section--white:not(.hero--image, .hero--slider, .cta--image) + .section--white,
  .section--light:not(.hero--image, .hero--slider, .cta--image) + .section--light { padding-top: 0; }

  /* A dark section at the end of the page is the footer's grey: a soft line keeps them apart */
  main:has(> .section--dark:last-child) + .site-footer { border-top: 1px solid var(--color-line-on-grey); }

  /* A section's heading and intro: centred, with the short dark rule under an intro (components.css) */
  .section__head { max-width: var(--measure); margin: 0 auto var(--space-head); text-align: center; }
  .section__intro { margin-top: var(--space-2xs); & + .section__intro { margin-top: var(--space-s); } }

  /* Grids: one column on phones, two from small screens, then the chosen number from large screens */
  /* minmax(0, 1fr): one column on phones that never grows wider than the page for a long line in it */
  .grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-m); }
  @media (min-width: 40rem) {
    .grid--2, .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (min-width: 64rem) {
    .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
}
