/**
 * layout.css — Page structure, grid, spacing utilities.
 *
 * Covers: .wrap, site-level sections (nav, hero, main content), responsive
 * breakpoints. No component-specific styling — that belongs in components.css.
 *
 * Import order: tokens.css → reset.css → layout.css
 */

/* ── Breakpoints (for reference in comments) ─────────────── */
/* --bp-md: 640px  — small tablets                           */
/* --bp-lg: 860px  — two-column hero threshold               */
/* --bp-xl: 1024px — full-width enhancement                  */

/* ── Wrapper ─────────────────────────────────────────────── */
.wrap {
  max-width: var(--wrap-max);
  margin-inline: auto;
  padding-inline: var(--wrap-pad);
}

/* Narrow variant — article text, guides */
.wrap-narrow {
  max-width: 740px;
  margin-inline: auto;
  padding-inline: var(--wrap-pad);
}

/* ── Site nav ────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.site-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  gap: var(--space-8);
}

/* ── Hero layout ─────────────────────────────────────────── */
/*
 * Asymmetric two-column split:
 *   Left (1fr): headline + copy
 *   Right (420px fixed): calculator widget
 *
 * The calculator IS the product demo — not a screenshot below the fold.
 * align-items: start keeps the widget top-aligned (not stretched to copy height).
 */
.hero {
  display: grid;
  grid-template-columns: 1fr var(--widget-width);
  gap: var(--hero-gap);
  align-items: start;
  padding-block: var(--space-18) var(--space-20);
}

.hero__copy {
  padding-top: var(--space-2);
}

.hero__widget {
  /* Sticky within the scroll so widget stays in view as copy scrolls */
  position: sticky;
  top: calc(var(--nav-height) + var(--space-6));
}

/* ── Below-hero strip ────────────────────────────────────── */
.below-hero {
  border-top: 1px solid var(--rule);
  padding-block: var(--space-12) var(--space-14);
}

/* ── Diff grid (the "Why different" stat strip) ──────────── */
.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.diff-grid__item {
  padding-inline-end: var(--space-8);
  border-inline-end: 1px solid var(--rule);
}
.diff-grid__item:first-child { padding-inline-start: 0; }
.diff-grid__item:last-child  {
  border-inline-end: none;
  padding-inline-end: 0;
}
.diff-grid__item + .diff-grid__item {
  padding-inline-start: var(--space-8);
}

/* ── Content section ─────────────────────────────────────── */
/* Used for guide/FAQ/article sections */
.content-section {
  padding-block: var(--space-12);
  border-top: 1px solid var(--rule);
}
/* Paragraph spacing inside content sections */
.content-section p + p { margin-top: var(--space-4); }
/* Heading after paragraphs needs breathing room */
.content-section h2,
.content-section h3 { margin-bottom: var(--space-3); }
/* When content-sections live inside .below-hero, the first child
   already has the outer section's border-top and padding — suppress the duplicate */
.below-hero .content-section:first-child {
  border-top: none;
  padding-block-start: 0;
}

/* ── Two-column content layout ───────────────────────────── */
/* e.g. sidebar + main article */
.content-with-sidebar {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-16);
  align-items: start;
}

/* ── Utility: visually hidden (screen reader only) ───────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Utility: overflow-safe horizontal scroll ────────────── */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── ─────────────────────────────────────────────────────── */
/* RESPONSIVE                                                 */
/* ── ─────────────────────────────────────────────────────── */

/* Large (≤1024px): tighten hero gap */
@media (max-width: 1024px) {
  .hero {
    gap: var(--space-10);
  }
  .content-with-sidebar {
    grid-template-columns: 200px 1fr;
    gap: var(--space-10);
  }
}

/* Medium (≤860px): stack hero to single column */
@media (max-width: 860px) {
  :root {
    --wrap-pad: 20px;
    --hero-gap: 40px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: var(--hero-gap);
    padding-block: var(--space-12) var(--space-14);
  }

  /* Unstick widget on mobile — it's below the fold copy */
  .hero__widget {
    position: static;
  }

  .diff-grid {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .diff-grid__item {
    border-inline-end: none;
    padding-inline-end: 0;
    padding-inline-start: 0;
  }
  .diff-grid__item + .diff-grid__item {
    padding-inline-start: 0;
  }

  .content-with-sidebar {
    grid-template-columns: 1fr;
  }
}

/* Small (≤480px): reduce padding further */
@media (max-width: 480px) {
  :root {
    --wrap-pad: 16px;
  }
}

/* ── Section rhythm variants ─────────────────────────────────── */
/*
 * Not every section needs identical breathing room.
 * .content-section is the base (48/56px padding-block).
 * These variants adjust for content density.
 */
.section-tight {
  padding-block: var(--space-8) var(--space-10);
  border-top: 1px solid var(--rule);
}
.section-open {
  padding-block: var(--space-16) var(--space-20);
  border-top: 1px solid var(--rule);
}
/* Paragraph + heading spacing inside section-open content areas */
.section-open p + p       { margin-top: var(--space-4); }
.section-open h2          { margin-top: var(--space-10); margin-bottom: var(--space-3); }
.section-open h2:first-child { margin-top: 0; }
.section-open h3          { margin-top: var(--space-8); margin-bottom: var(--space-2); }
.section-open ul, .section-open ol { margin-bottom: var(--space-4); }
.section-open li + li     { margin-top: var(--space-2); }

/* ── Asymmetric offset grid ──────────────────────────────────── */
/*
 * Two-column with 2:3 ratio — text/stat on left, content on right.
 * Use for stat callouts, asymmetric feature sections, pull-out data.
 * NOT for hero (that's .hero in layout.css above).
 */
.offset-grid {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: var(--space-16);
  align-items: center;
}
.offset-grid--flipped {
  grid-template-columns: 3fr 2fr;
}
@media (max-width: 860px) {
  .offset-grid,
  .offset-grid--flipped {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
}

/* ── 50/50 split ─────────────────────────────────────────────── */
/* Equal columns — for paired content blocks */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-12);
}
@media (max-width: 860px) {
  .split {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
}

/* ── Aside pull-out (bleeds right) ───────────────────────────── */
/*
 * Used inside .wrap-narrow — an element that steps out of
 * the narrow column to the full content width.
 * Subtle asymmetry without breaking the grid.
 */
@media (min-width: 860px) {
  .pull-wide {
    margin-right: calc(-1 * (var(--wrap-max) - 740px) / 2);
    max-width: none;
  }
}
