/* ==========================================================================
   Schoolopedia — layout primitives
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Section shell: vertical rhythm of the whole page. */
.section {
  padding-block: var(--space-20);
}

.section--tight {
  padding-block: var(--space-15);
}

.section--alt {
  background-color: var(--color-surface-alt);
}

.section--sunk {
  background-color: var(--color-surface-sunk);
}

.section--dark {
  background-color: var(--color-surface-dark);
  background-image: var(--gradient-dark);
}

.section__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-15);
}

/* Two-column section header: heading left, standfirst right.
   Same column ratio and gutter as .split and .module, so every right-hand
   column on the page starts at the same x and the standfirst lines up with
   the image beneath it. */
.section-header {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-12);
  align-items: end;
}

.section-header__lead {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* The aside is a standfirst, not stray body copy.
   A vertical hairline gives the right column real structure — the same device
   the footer already uses between its columns — and the text sits a step above
   body size in a darker ink so it reads as an introduction rather than a
   caption. It bottom-aligns with the heading, which keeps the two columns on a
   shared baseline whether the aside runs to one line or four. */
.section-header__aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  align-items: flex-start;
  text-align: left;
  align-self: stretch;
  justify-content: flex-end;
  margin-left: calc((var(--space-6) + 1px) * -1);
  padding-left: var(--space-6);
  border-left: 1px solid var(--color-line);
}

.section-header__aside > p {
  width: 100%;
  font-size: 17px;
  line-height: 27px;
  color: var(--color-ink-soft);
}

/* On the dark panels the hairline and the deck invert. This has to be stated
   here because `.section-header__aside > p` out-ranks the `.text-invert-muted`
   utility the markup carries. */
.section--dark .section-header__aside {
  border-left-color: var(--overlay-hairline-invert);
}

.section--dark .section-header__aside > p {
  color: var(--color-ink-invert-muted);
}

.section-header--center {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  text-align: center;
  max-width: 720px;
  margin-inline: auto;
}

.section-header--center .section-header__lead {
  align-items: center;
}

/* Grids */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Media + copy split */
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-12);
  align-items: center;
}

/* Top-align when the two columns are deliberately unequal — a long list
   beside a short paragraph should not float the paragraph to the middle. */
.split--top {
  align-items: start;
}

.split__copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  align-items: flex-start;
}

.divider {
  height: 1px;
  width: 100%;
  background-color: var(--color-line);
  border: 0;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .section-header {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
  }

  /* One column — there is no right edge to align against any more. */
  /* One column — the vertical divider becomes a horizontal one. */
  .section-header__aside {
    align-self: auto;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    padding-top: var(--space-5);
    border-top: 1px solid var(--color-line);
  }

  .section--dark .section-header__aside {
    border-top-color: var(--overlay-hairline-invert);
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-8);
  }

}

@media (max-width: 640px) {
  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: minmax(0, 1fr);
  }
}
