/* ==========================================================================
   GITLEAF DESIGN SYSTEM — 03. LAYOUT
   Containers, sections, grids and the shared section-header pattern.
   ========================================================================== */

/* --- Container ------------------------------------------------------------ */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.container--prose {
  max-width: var(--container-prose);
}

/* --- Page shell ----------------------------------------------------------- */
.site-main {
  /* The header is fixed, so the first section provides its own top offset. */
  display: block;
  min-height: 60vh;
}

/* --- Sections ------------------------------------------------------------- */
.section {
  position: relative;
  padding-block: var(--space-section);
}

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

.section--flush-top {
  padding-top: 0;
}

.section--flush-bottom {
  padding-bottom: 0;
}

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

/* A hairline that fades at both ends, separating stacked dark sections. */
.section--ruled {
  border-top: 1px solid var(--color-border);
}

.section--hairline::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 1px;
  background-image: var(--gradient-hairline);
}

/* Very low-contrast grid texture for sections that need engineering character. */
.section--grid-texture::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--pattern-grid);
  background-size: var(--pattern-grid-size) var(--pattern-grid-size);
  /* Fade the grid out towards the edges so it never reads as a hard box. */
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 0%, transparent 100%);
  pointer-events: none;
}

/* --- Section header pattern ----------------------------------------------- */
.section-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 62ch;
  margin-bottom: var(--space-gap-lg);
}

.section-head--center {
  max-width: 68ch;
  margin-inline: auto;
  text-align: center;
  align-items: center;
}

.section-head--split {
  max-width: none;
  flex-direction: column;
}

.section-head__title {
  font-size: var(--fs-h2);
}

.section-head__lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-relaxed);
  color: var(--color-text-muted);
  max-width: 60ch;
}

@media (min-width: 900px) {
  .section-head--split {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-gap-lg);
  }

  .section-head--split .section-head__group {
    max-width: 58ch;
  }

  .section-head--split .section-head__aside {
    flex: none;
    padding-bottom: var(--space-1);
  }
}

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

/* --- Eyebrow / technical label -------------------------------------------- */
/* Mono, uppercase, tracked, preceded by a short accent rule. The signature
   small-type detail of the system. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--color-accent);
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background-color: currentcolor;
  opacity: 0.6;
}

.eyebrow--plain::before {
  display: none;
}

.section-head--center .eyebrow::after {
  content: "";
  width: 24px;
  height: 1px;
  background-color: currentcolor;
  opacity: 0.6;
}

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

/* Auto-fit grids keep every breakpoint between 360px and 1920px sensible
   without a media query per column count. */
.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
}

.grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

/* Fixed 2-up that collapses once, used where auto-fit would create 3 columns. */
.grid--pair {
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .grid--pair {
    grid-template-columns: 1fr 1fr;
  }
}

.grid--gap-lg {
  gap: var(--space-gap-lg);
}

/* --- Split layout (text + visual) ----------------------------------------- */
.split {
  display: grid;
  gap: var(--space-gap-lg);
  align-items: center;
}

@media (min-width: 960px) {
  .split {
    grid-template-columns: 1fr 1fr;
    gap: clamp(3rem, 6vw, 6rem);
  }

  .split--wide-start {
    grid-template-columns: 1.15fr 1fr;
  }

  .split--wide-end {
    grid-template-columns: 1fr 1.15fr;
  }

  /* Puts the visual first on desktop while keeping text first in the DOM. */
  .split--flip > :first-child {
    order: 2;
  }
}

/* --- Sidebar layout (sticky rail + content) ------------------------------- */
.rail-layout {
  display: grid;
  gap: var(--space-gap-lg);
}

@media (min-width: 1024px) {
  .rail-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: clamp(3rem, 5vw, 5rem);
    align-items: start;
  }

  .rail-layout__rail {
    position: sticky;
    top: calc(var(--header-height) + var(--space-7));
  }
}

/* --- Stacks and flow ------------------------------------------------------ */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.stack--tight {
  gap: var(--space-3);
}

.stack--loose {
  gap: var(--space-7);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.cluster--tight {
  gap: var(--space-2);
}

/* --- Prose ---------------------------------------------------------------- */
/* Long-form copy for legal pages and insight articles. */
.prose {
  max-width: var(--container-prose);
  font-size: var(--fs-body);
  line-height: var(--lh-relaxed);
  color: var(--color-body);
}

.prose > * + * {
  margin-top: var(--space-5);
}

.prose h2 {
  margin-top: var(--space-10);
  font-size: var(--fs-h3);
}

.prose h3 {
  margin-top: var(--space-8);
  font-size: var(--fs-card);
}

.prose h2 + *,
.prose h3 + * {
  margin-top: var(--space-4);
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li::marker {
  color: var(--color-accent-45);
}

.prose strong {
  color: var(--color-text);
  font-weight: var(--fw-semibold);
}

.prose a {
  font-weight: var(--fw-medium);
}

.prose code {
  padding: 0.15em 0.4em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background-color: var(--color-card);
  color: var(--color-accent);
}

.prose blockquote {
  padding-left: var(--space-6);
  border-left: 2px solid var(--color-accent-45);
  color: var(--color-text);
  font-size: var(--fs-lead);
  font-style: normal;
}

/* --- Utilities ------------------------------------------------------------ */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-bright {
  color: var(--color-text);
}

.text-accent {
  color: var(--color-accent);
}

.text-lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-relaxed);
}

.text-mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-lg);
  letter-spacing: var(--ls-wide);
}

.full-bleed {
  margin-inline: calc(var(--container-pad) * -1);
}

/* --- Scroll reveal -------------------------------------------------------- */
/* Elements opt in with data-reveal. The hidden start state is scoped to
   html.js, which assets/js/boot.js sets before the first paint, so content
   stays visible if scripting is unavailable or blocked. */
html.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--duration-reveal) var(--ease-out),
    transform var(--duration-reveal) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

html.js [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
  will-change: auto;
}
