/*
 * Card grids, on every page (29 Sep 2026).
 *
 * What was wrong, measured over every page: a card's mark stood beside all of
 * its text, so in a row of four the words had 190px to run in and a short
 * paragraph became eight lines; a row of seven left one cell empty; and one
 * card with a thirteen-line list made its three neighbours as tall as itself
 * and mostly empty.
 *
 *   1. The mark stands beside the title only. The text under them has the
 *      whole width of the card.
 *   2. Rows are filled. The last row shares the width between the cards it
 *      has, so seven cards are four and three, never four and three and a gap.
 *   3. A card with far more to say than the others leaves the row: two cards
 *      wide, or a row to itself with its list across it in columns. Which, is
 *      decided from the copy in DocPage.tsx (shapesOf).
 *
 * .is-fill marks the grids this applies to.
 */

/* ---- 2. rows that fill ---- */

main .ds-dcards.is-fill,
main .ds-dsteps.is-fill {
  --cols: 3;
  --gap: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--gap);
}
main .is-fill.is-c1 { --cols: 1; }
main .is-fill.is-c2 { --cols: 2; }
main .is-fill.is-c3 { --cols: 3; }
main .is-fill.is-c4 { --cols: 4; }
main .is-fill.is-c5 { --cols: 4; }

main .is-fill > .ds-dcard,
main .is-fill > .ds-dstep {
  --span: 1;
  flex: 1 1 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols) * var(--span) + (var(--span) - 1) * var(--gap));
  min-width: 0;
  /* A card alone on the last row of five is not the width of the page. */
  max-width: 100%;
}
main .is-fill > .is-double {
  --span: 2;
}
main .is-fill > .is-wide,
main .is-fill > .ds-dcard:has(.ds-dcards, .ds-dsteps, .ds-dtable-wrap) {
  flex-basis: 100%;
}

@media (max-width: 1199px) {
  main .is-fill.is-c4,
  main .is-fill.is-c5 {
    --cols: 3;
  }
}
@media (max-width: 991px) {
  main .is-fill[class] {
    --cols: 2;
  }
  main .is-fill.is-c1 {
    --cols: 1;
  }
}
@media (max-width: 640px) {
  main .is-fill[class] {
    --cols: 1;
    --gap: 12px;
  }
  main .is-fill > .is-double {
    --span: 1;
  }
}

/* ---- 1. inside a card ---- */

main .is-fill > .ds-dcard,
main .is-fill > .ds-dstep {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-auto-rows: min-content;
  align-content: start;
  column-gap: 14px;
  row-gap: 0;
  padding: 22px 22px 24px;
  container-type: inline-size;
}
main .is-fill > .ds-dcard > *,
main .is-fill > .ds-dstep > * {
  grid-column: 1 / -1;
  margin: 0 !important;
}
main .is-fill > .ds-dcard > .ds-dcard-ic,
main .is-fill > .ds-dstep > .ds-dstep-n {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  width: 44px;
  height: 44px;
}
main .is-fill > .ds-dcard > h3,
main .is-fill > .ds-dstep > h3 {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  font-size: 17.5px;
  line-height: 1.35;
  text-wrap: balance;
}
/* A card with no mark (the onward links): the title has the row. */
main .is-fill > .ds-dcard > h3:first-child {
  grid-column: 1 / -1;
}
/* The first thing under the title stands clear of it; the rest follow closely. */
main .is-fill > .ds-dcard > h3 + *,
main .is-fill > .ds-dstep > h3 + * {
  margin-top: 14px !important;
}
main .is-fill > .ds-dcard > h3 + * ~ *,
main .is-fill > .ds-dstep > h3 + * ~ * {
  margin-top: 10px !important;
}
main .is-fill .ds-dcard .ds-dp,
main .is-fill .ds-dstep .ds-dp {
  font-size: 15px;
  line-height: 1.6;
}
main .is-fill .ds-dcard .ds-dlist,
main .is-fill .ds-dstep .ds-dlist {
  gap: 8px 22px;
}
main .is-fill .ds-dcard .ds-dlist li,
main .is-fill .ds-dstep .ds-dlist li {
  font-size: 14.5px;
  line-height: 1.45;
}
main .is-fill > .ds-dcard > .ds-card-more {
  align-self: end;
  margin-top: 14px !important;
  padding-top: 0;
}
/* Where the card is wide enough, a list of five or more runs in two columns. */
@container (min-width: 430px) {
  main .is-fill .ds-dcard .ds-dlist:has(> :nth-child(5)),
  main .is-fill .ds-dstep .ds-dlist:has(> :nth-child(5)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container (min-width: 760px) {
  main .is-fill .ds-dcard .ds-dlist:has(> :nth-child(7)),
  main .is-fill .ds-dstep .ds-dlist:has(> :nth-child(7)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- 3. the card with a row to itself ---- */

main .is-fill > .ds-dcard.is-wide {
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.9fr);
  column-gap: 14px;
  padding: 26px 28px 28px;
  border-left: 3px solid var(--ds-teal);
}
main .is-fill > .ds-dcard.is-wide > .ds-dcard-main {
  grid-column: 1 / 3;
  grid-row: 2;
  margin-top: 14px !important;
  padding-right: 18px;
}
main .is-fill > .ds-dcard.is-wide > .ds-dcard-side {
  grid-column: 3;
  grid-row: 1 / span 3;
  margin: 0 !important;
  padding-left: 28px;
  border-left: 1px solid var(--hs-line);
  container-type: inline-size;
}
main .is-fill .ds-dcard-main > * + *,
main .is-fill .ds-dcard-side > * + * {
  margin-top: 10px;
}
main .is-fill .ds-dcard-side > .ds-dp {
  font-weight: 600;
  color: var(--ds-ink);
}
@container (min-width: 420px) {
  main .is-fill .ds-dcard .ds-dcard-side .ds-dlist {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container (min-width: 640px) {
  main .is-fill .ds-dcard .ds-dcard-side .ds-dlist {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 991px) {
  main .is-fill > .ds-dcard.is-wide {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 22px 22px 24px;
  }
  main .is-fill > .ds-dcard.is-wide > .ds-dcard-main {
    grid-column: 1 / -1;
    grid-row: auto;
    padding-right: 0;
  }
  main .is-fill > .ds-dcard.is-wide > .ds-dcard-side {
    grid-column: 1 / -1;
    grid-row: auto;
    margin-top: 16px !important;
    padding: 16px 0 0;
    border-left: 0;
    border-top: 1px solid var(--hs-line);
  }
}

/* A step with a row to itself: its number and title, then what it says across the row. */
main .is-fill > .ds-dstep.is-wide {
  padding: 24px 28px 26px;
  border-left: 3px solid var(--ds-teal);
}

/* A card that holds cards: what it holds is laid out across it. */
main .is-fill > .ds-dcard > .ds-dcards,
main .is-fill > .ds-dcard > .ds-dsteps {
  margin-top: 16px !important;
}

/* ---- the column under a section's heading ---- */

.ds-deditorial > .ds-dside {
  min-width: 0;
}
.ds-deditorial > .ds-dside > .ds-dhead {
  margin-bottom: 0;
}
@media (max-width: 991px) {
  .ds-deditorial > .ds-dside > .ds-dhead {
    margin-bottom: 24px;
  }
}

/* ------------------------------------------------------------------ */
/* the standards pages (sl-): the same two rules                        */
/* ------------------------------------------------------------------ */

main .sl-cards {
  --cols: 3;
  --gap: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--gap);
}
main .sl-cards.is-two,
main .sl-cards.is-four {
  --cols: 2;
}
main .sl-cards > .sl-card {
  flex: 1 1 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  min-width: 0;
  container-type: inline-size;
}
main .sl-cards > .sl-card.is-wide {
  flex-basis: 100%;
  border-left: 3px solid var(--ds-teal);
}
@container (min-width: 520px) {
  main .sl-card .sl-list:has(> :nth-child(4)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
  }
}
@container (min-width: 820px) {
  main .sl-card .sl-list:has(> :nth-child(6)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 1199px) {
  main .sl-cards {
    --cols: 2;
  }
}
@media (max-width: 640px) {
  main .sl-cards[class] {
    --cols: 1;
  }
}

/* ------------------------------------------------------------------ */
/* tables on a phone                                                    */
/* ------------------------------------------------------------------ */
/* The standards tables were 560px wide at the least and were scrolled
   sideways on a phone, so every one of them was cut off at the right edge.
   Under 640px a row is a card: its first cell is its title and each cell after
   it carries its column's name (data-label). */
@media (max-width: 639px) {
  main .sl-table-wrap,
  main .st-tablewrap {
    overflow: visible;
    border: 0;
    background: none;
    box-shadow: none;
  }
  main .sl-table,
  main .st-table {
    display: block;
    min-width: 0;
    width: 100%;
  }
  main .sl-table thead,
  main .st-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  main .sl-table tbody,
  main .st-table tbody {
    display: grid;
    gap: 10px;
  }
  main .sl-table tr,
  main .st-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 16px 16px 18px;
    border: 1px solid var(--hs-line, #cfdfdc);
    border-left: 3px solid var(--ds-teal);
    background: #fff;
  }
  main .sl-table tbody th,
  main .sl-table td,
  main .st-table td {
    display: block;
    padding: 0;
    border: 0;
    background: none !important;
    font-size: 15px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  main .sl-table tbody th,
  main .st-table td:first-child {
    font-size: 16px;
    font-weight: 600;
    color: var(--ds-ink);
  }
  main .sl-table td[data-label]::before,
  main .st-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ds-teal);
  }
  /* Two columns and no names needed: the second cell is the answer to the first. */
  main .st-table-2 td + td {
    color: #454a56;
  }
  /* The catalogue: number and name across, the three short fields abreast. */
  main .st-table-5 tr {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 12px;
  }
  main .st-table-5 td:first-child {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: 600;
    color: var(--ds-teal);
  }
  main .st-table-5 td:first-child::before {
    content: "No. ";
  }
  main .st-table-5 td:nth-child(2) {
    grid-column: 1 / -1;
    font-size: 16px;
    font-weight: 600;
  }
  main .st-table-5 td:nth-child(n + 3) {
    font-size: 14px;
  }
}

/* An action inside a card: a button the width of its words, not of the card. */
main .is-fill .ds-dcard .ds-dbtns,
main .is-fill .ds-dstep .ds-dbtns {
  margin-top: 14px !important;
}
main .is-fill .ds-dcard .ds-dbtns .ds-btn,
main .is-fill .ds-dstep .ds-dbtns .ds-btn {
  padding: 10px 16px;
  font-size: 14px;
}

/* The hashtags in a post's side column. Words, not links: they lead nowhere. */
.bl-tags ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bl-tags li {
  padding: 6px 11px;
  border: 1px solid #cfe5e1;
  background: #f0faf9;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  color: #00695f;
  overflow-wrap: anywhere;
}

/* One line under the enquiry panel's copy and under a standard's buttons. */
.ds-query-note {
  margin: 18px 0 0;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
  color: #8fe8de;
}
.st-hero-note {
  margin: 16px 0 0;
  max-width: 52ch;
  font-size: 14.5px;
  line-height: 1.55;
  opacity: 0.85;
}
