/* ============================================================
   Images & Figures — pillar page
   ============================================================ */

/* Hero figure — no caption, full width inside hero section */
.hero-figure {
  margin: 1.5rem 0 0 0;
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-deep);
  background: var(--bg-muted);
}

.hero-figure img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
}

/* Section figures — with caption */
[data-content] figure {
  margin: 2rem 0;
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-muted);
  border: 1px solid var(--border-muted);
}

[data-content] figure img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
}

[data-content] figcaption {
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 0.85rem 1.1rem;
  background: var(--bg-page);
  border-top: 1px solid var(--border-muted);
  font-style: italic;
}

/* Mobile adjustments */
@media (max-width: 720px) {
  .hero-figure {
    margin-top: 1.2rem;
    border-radius: 6px;
  }
  [data-content] figure {
    margin: 1.5rem 0;
    border-radius: 6px;
  }
  [data-content] figcaption {
    font-size: 0.85rem;
    padding: 0.75rem 0.9rem;
  }
}

/* ============================================================
   Layout fixes — TL;DR, card-grid, comparison tables
   ============================================================ */

/* TL;DR at-a-glance: 5 cells must fit one row on desktop.
   Override the design's auto-fit (minmax 160px) which forces
   a 4+1 break at 750px content-width. */
.at-a-glance {
  grid-template-columns: repeat(5, 1fr);
}
.at-a-glance > div {
  padding: 1rem 0.85rem;
}
.at-a-glance > div p:first-child,
.at-a-glance > div p:first-child strong {
  font-family: var(--font-heading);
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  text-transform: none;
}
.at-a-glance > div p {
  font-size: 0.86rem;
  line-height: 1.45;
}

/* If a particular at-a-glance has 3 cells, fall back to 3 columns
   so they don't get squashed into the 5-column rule above. */
.at-a-glance:has(> div:nth-child(3):last-child) {
  grid-template-columns: repeat(3, 1fr);
}
.at-a-glance:has(> div:nth-child(4):last-child) {
  grid-template-columns: repeat(4, 1fr);
}

/* card-grid with exactly 4 cells -> 2x2 grid (no orphan card) */
.card-grid:has(> div:nth-child(4):last-child) {
  grid-template-columns: repeat(2, 1fr);
}

/* Comparison tables: when a <table> is nested inside .comparison,
   the wrapping grid is irrelevant — let the table flow as a block
   at full width, and break the parent section out of the 750px
   content-width so columns get readable proportions. */
.comparison:has(> table),
.comparison:has(table) {
  display: block;
  max-width: none;
}
[data-content]:has(.comparison > table),
[data-content]:has(.comparison table) {
  max-width: min(960px, 94vw);
}
[data-content] table {
  table-layout: fixed;
  width: 100%;
}
[data-content] table th,
[data-content] table td {
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 0.92rem;
  padding: 0.75rem 0.85rem;
}
/* First column (parameter name) — narrower, distinctive */
[data-content] table th:first-child,
[data-content] table td:first-child {
  width: 16%;
  font-weight: 600;
  color: var(--text-primary);
}

/* Mobile fallback for layout fixes */
@media (max-width: 720px) {
  .at-a-glance,
  .at-a-glance:has(> div:nth-child(3):last-child),
  .at-a-glance:has(> div:nth-child(4):last-child) {
    grid-template-columns: 1fr;
  }
  .at-a-glance > div p:first-child,
  .at-a-glance > div p:first-child strong {
    font-size: 1.05rem;
  }
  .card-grid:has(> div:nth-child(4):last-child) {
    grid-template-columns: 1fr;
  }
  [data-content]:has(.comparison > table),
  [data-content]:has(.comparison table) {
    max-width: var(--content-width);
  }
  [data-content] table {
    table-layout: auto;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.85rem;
  }
  [data-content] table th,
  [data-content] table td {
    white-space: normal;
  }
}
