/* =============================================================
   pages.css — shared layout for the inner pages (<main class="page">).
   Every rule is scoped to .page or .policy, so a page that does not
   opt in (glossary.html copies about.html's <head>) is unaffected.
   Mobile-first: base rules are the phone layout; min-width queries
   add columns. Tokens come from styles.css.
   ============================================================= */

.page {
  --gutter: clamp(1.1rem, 0.5rem + 3vw, 2.5rem);
  --gap: clamp(1rem, 0.6rem + 1.8vw, 2rem);
  --gap-wide: clamp(2rem, 5vw, 5rem);
}

/* The section is its own container: no inner wrapper divs. */
.page > section {
  padding-block: var(--space-section);
  padding-inline: max(var(--gutter), (100% - var(--maxw)) / 2 + var(--gutter));
  display: grid;
  gap: var(--gap);
  align-content: start;
}
/* Anchor jumps land below the sticky header, not under it. */
.page > section[id] { scroll-margin-top: 4.5rem; }
/* Two plain sections in a row get a hairline instead of a colour change. */
.page > section.ruled { border-top: 1px solid var(--line); }

.page h2 { font-size: var(--step-3); max-width: 22ch; scroll-margin-top: 6rem; }
.page section > h3 { font-size: var(--step-1); }
.page > section > header > h2 + .lede { margin-top: .8rem; }
.page .lede { max-width: 52ch; }
.page .lede-ish { font-size: var(--step-1); color: var(--ink-2); max-width: 52ch; line-height: 1.6; }
.page .note { font-size: var(--step--1); color: var(--ink-3); max-width: 60ch; line-height: 1.6; }
.page .band-ink .note, .page .band-ink.note, .page .band-ink .lede-ish { color: rgba(251,246,236,.75); }
.page .btn-row { margin-top: 1.2rem; }

/* -------- Page header: title left, the rest right (60/40) -------- */
.page .page-hero {
  padding-block: clamp(2.4rem, 1rem + 6vw, 6rem) clamp(2rem, 1rem + 3vw, 3.5rem);
  row-gap: 1.1rem;
}
.page-hero h1 { font-size: var(--step-5); line-height: 1.02; max-width: 14ch; }
.page-hero .lede { margin-top: 0; }
.page-hero .version {
  font-size: var(--step--1); color: var(--ink-3); margin-top: 1rem;
  padding-top: .8rem; border-top: 1px solid var(--line); max-width: 52ch;
}
/* A plain section straight after the header does not need a second full gap. */
.page .page-hero + section:not(.band):not(.band-ink) { padding-top: clamp(1rem, .5rem + 2vw, 2rem); }

/* -------- Ruled rows: a name beside its explanation -------- */
.page .rows { display: grid; border-top: 1px solid var(--line); list-style: none; padding: 0; margin: 0; }
.page .rows > * {
  display: grid; gap: .35rem; align-content: start;
  padding-block: 1.15rem; border-bottom: 1px solid var(--line);
}
.page .rows dt, .page .rows > * > h3 {
  font-family: var(--font-display); font-weight: 600; font-size: var(--step-2);
  color: var(--ink); line-height: 1.15; text-wrap: balance;
}
.page .rows dd { margin: 0; }
.page .rows dd, .page .rows p { max-width: 60ch; }
.page .rows .key {
  display: block; margin-top: .35rem;
  font-family: var(--font-sans); font-size: var(--step--1); font-weight: 600; line-height: 1.4; color: var(--ink-3);
}
/* In a narrow column, the names step down a size so they do not wrap three times. */
.page .side .rows dt, .page .side .rows > * > h3, .page .rows.compact dt { font-size: var(--step-1); }
.page .rows.compact > * { padding-block: .9rem; }
.page .band-ink .rows, .page .band-ink .rows > * { border-color: rgba(251,246,236,.18); }
.page .band-ink .rows p { color: rgba(251,246,236,.78); }
/* The row names above are set to ink; on the dark band they must turn light. */
.page .band-ink .rows dt, .page .band-ink .rows > * > h3, .page .band-ink .rows > * > h4 { color: var(--paper); }

/* -------- Pairs and full-width rows -------- */
.page .pair { display: grid; gap: var(--gap); }
.page .full { grid-column: 1 / -1; }

/* -------- Bento: alternating wide / narrow cells -------- */
.page .bento { display: grid; gap: var(--gap); }
.page .bento > .card { height: 100%; }

/* -------- Cards -------- */
.page .card { gap: .5rem; }
.page .card h3 { text-wrap: balance; }
.page .card .meta { margin-top: -.25rem; }
.page .card > .btn-row:last-child, .page .card > .link-arrow:last-child { margin-top: auto; padding-top: .8rem; }
.page .card h4 { font-size: var(--step-1); }
/* Program offers: one accent rule on the left, the "for you if" line set apart. */
.page .offer { border-left: 4px solid var(--accent, var(--ink-3)); }
.page .offer .for { font-size: var(--step--1); font-style: italic; color: var(--ink-2); }

/* -------- Impact Unit cards (same treatment as the homepage) -------- */
.page .unit { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; align-content: start; }
.page .unit .glyph { grid-row: span 3; margin: 0; }
.page .unit h3 { font-size: var(--step-1); }
.page .unit .tag, .page .unit p { grid-column: 2; }

/* -------- Programs -------- */
.page .program-aside { display: grid; gap: .55rem; align-content: start; justify-items: start; }
.page .program-aside .deva-name { font-family: var(--font-deva); font-size: var(--step-3); color: var(--ink); line-height: 1.2; }
.page .program-aside .note { margin: 0; }
.page .program-row h2, .page .program-ai h2 { font-size: var(--step-4); }

/* -------- Get involved -------- */
.page .pathways h2 { font-size: var(--step-2); max-width: none; }
.page .pathway .num { margin-bottom: .2rem; }
.page .tracks { display: grid; gap: 1rem; }

/* -------- Showcase: each shelf heading gets air above it -------- */
.page .shelf > h2:not(:first-child) { margin-top: calc(var(--gap) * 1.5); }
.page .shelf > h2 + .lede { margin-top: -.4rem; }

/* -------- Platform: numbered promises and steps, the five ways in, the states -------- */
.platform .promises, .platform .gates { counter-reset: n; }
.platform .promises > li, .platform .gates > li { counter-increment: n; }
.platform .promises > li > h3::before, .platform .gates > li > h4::before {
  content: counter(n); display: inline-block; min-width: 1.7em;
  font-family: var(--font-display); color: var(--ink-3);
}
.page .rows > * > h4 {
  font-family: var(--font-display); font-weight: 600; font-size: var(--step-1);
  color: var(--ink); line-height: 1.15; text-wrap: balance;
}
.platform .way { scroll-margin-top: 5rem; }
.platform .way .status { justify-self: start; align-self: flex-start; }
.platform .way .first { font-size: var(--step--1); color: var(--ink-2); }
.platform .way .first strong { color: var(--ink); }
.platform .way:target { outline: 2.5px solid var(--teal); outline-offset: 3px; }
.platform .gates-wrap { margin-top: calc(var(--gap) * 1.2); }
/* In the narrow column, each step's name sits above its text, not beside it. */
.platform .rows.stack > * { grid-template-columns: 1fr; }
.platform .rows.stack > * > :not(:first-child) { grid-column: 1; }
.platform .gates > li > p { padding-left: 1.7em; }
.platform .gates-wrap h3 { font-size: var(--step-2); }
.platform .gates-wrap .note { margin-top: .6rem; }
.platform .now { display: grid; gap: 1rem; align-content: start; }
.platform .now > h3 { font-size: var(--step-2); }
.platform .now > h3:not(:first-child) { margin-top: 1.2rem; }
.platform .now > p { max-width: 60ch; }
.platform .ticks.waiting li::before { background: var(--ink-3); }
.platform .states .chip { vertical-align: middle; margin-left: .4rem; font-family: var(--font-sans); }
.platform .states .here h4 { color: var(--teal); }
/* Teal text on its own 16% tint measures 4.4:1; one step darker passes AA. */
.platform .chip.live { color: #195C4C; }

/* =================== 48rem: tablet and up =================== */
@media (min-width: 48rem) {
  /* Title and intro share their first baseline, so neither floats. */
  .page .page-hero { grid-template-columns: 3fr 2fr; column-gap: var(--gap-wide); align-items: baseline; }

  .page .rows > * { grid-template-columns: minmax(10rem, 1fr) 2fr; column-gap: var(--gap); align-items: baseline; }
  .page .rows > * > :not(:first-child) { grid-column: 2; }

  .page .bento { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .page .bento > :nth-child(4n+1), .page .bento > :nth-child(4n) { grid-column: span 7; }
  .page .bento > :nth-child(4n+2), .page .bento > :nth-child(4n+3) { grid-column: span 5; }
  .page .bento > :last-child:nth-child(odd) { grid-column: 1 / -1; }

  .page .pair { grid-template-columns: 5fr 7fr; column-gap: var(--gap-wide); align-items: start; }
  .page .pair.rev { grid-template-columns: 7fr 5fr; }
  /* Heading beside its text: they line up on the first baseline. */
  .page .pair.end { align-items: baseline; }

  /* Programs: status column beside the intro, the offers across the full width. */
  .page .program-ai { grid-template-columns: 5fr 7fr; column-gap: var(--gap-wide); align-items: start; }
  .page .program-ai > .lede-ish { padding-top: .6rem; }

  /* Get involved: the first way in runs across the top in two columns; the other two sit below at 7:5. */
  .page .pathways { grid-template-columns: 7fr 5fr; }
  .page .pathways > :first-child { grid-column: 1 / -1; }
}

/* =================== 64rem: desktop =================== */
@media (min-width: 64rem) {
  /* Heading column on the left stays in view; the content scrolls beside it.
     Used with exactly two children: the heading block, then the content. */
  .page .side { grid-template-columns: minmax(14rem, 2fr) 3fr; column-gap: var(--gap-wide); align-items: start; }
  .page .side > :first-child { position: sticky; top: 6rem; }

  .page .pathways > :first-child {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--gap-wide); align-content: start;
  }
  .page .pathways > :first-child > * { grid-column: 1; }
  .page .pathways > :first-child > ul { grid-column: 2; grid-row: 1 / span 4; align-self: center; margin-top: 0; }
}

/* -------- Policy pages -------- */
.policy .num {
  display: block; font-family: var(--font-display); font-size: var(--step-4);
  line-height: 1; color: var(--ink-3); margin-bottom: .3rem;
}
.policy .glance { display: grid; gap: var(--gap); }
.policy .glance h2 { font-size: var(--step-1); max-width: none; }
@media (min-width: 48rem) {
  .policy .glance { grid-template-columns: 7fr 5fr; column-gap: var(--gap-wide); align-items: start; }
  /* The contents become a numbered list whose numbers match the section numbers. */
  .policy .glance .toc { display: grid; gap: 0; counter-reset: toc; border-top: 1px solid var(--line); font-size: var(--step-0); }
  .policy .glance .toc li { display: block; counter-increment: toc; border-bottom: 1px solid var(--line); }
  .policy .glance .toc a {
    display: flex; gap: .9rem; align-items: baseline; padding: .55rem 0;
    border: 0; border-radius: 0; color: var(--ink-2);
  }
  .policy .glance .toc a::before {
    content: counter(toc); min-width: 1.6rem;
    font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); color: var(--ink-3);
  }
  .policy .glance .toc a:hover { color: var(--ink); }
}

@media print {
  .page > section { padding-inline: 0; display: block; }
  .page .side > :first-child { position: static; }
}
