/* Footer legal / status-badge alignment
 *
 * Reusable pattern for KitPak-Building (and the kit-builder, which should
 * copy this file rather than invent a second layout).
 *
 * Markup: each list item that has a page link and a status badge
 * (.draft-flag or .planned-flag) gets class="legal-row". The badge is a
 * sibling of the link, not inside it:
 *
 *   <li class="legal-row">
 *     <a href="privacy.html">Privacy</a>
 *     <span class="draft-flag">Draft pending</span>
 *   </li>
 *
 * Wide view: two-column grid. The link is on the left; every badge sits in
 * a shared right-hand column, so they all start at the same x and line up
 * with the first line of the link.
 *
 * Spacing: every footer list item, in every column, has the same gap
 * below it whether the link wraps or not. Spacing comes from a consistent
 * gap on the list and equal padding on the links — not from a fixed
 * height on the row. Padding is sized so a single-line link still meets
 * a 44px target.
 *
 * At 390px and below: the badge moves under the link and stays left-aligned.
 */

.site-footer .footer-nav {
  --footer-nav-gap: 0.25rem;
  --footer-link-pad: calc((44px - 1lh) / 2);
  display: flex;
  flex-direction: column;
  gap: var(--footer-nav-gap);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer .footer-nav > li {
  display: block;
  margin: 0;
  min-height: 0;
  gap: 0;
}

.site-footer .footer-nav > li > a,
.site-footer .footer-nav > li > button {
  display: flex;
  align-items: flex-start;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding-block: var(--footer-link-pad);
  min-height: 0;
}

/* Lists that include a status badge use a two-column grid so every badge
   starts at the same x. The same gap is used between rows. */
.site-footer .footer-nav:has(> .legal-row) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  column-gap: 0.75rem;
  row-gap: var(--footer-nav-gap);
  align-items: start;
}

.site-footer .footer-nav > li.legal-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10.5rem;
  grid-column: 1 / -1;
  column-gap: 0.75rem;
  align-items: start;
  margin: 0;
  min-height: 0;
}

/* Shared badge column so every badge starts at the same x, even when
   the badge labels have different widths (e.g. "Draft pending" vs
   "Approved draft"). */
@supports (grid-template-columns: subgrid) {
  .site-footer .footer-nav > li.legal-row {
    grid-template-columns: subgrid;
  }
}

.site-footer .footer-nav > li:not(.legal-row) {
  grid-column: 1 / -1;
}

.site-footer .legal-row > a {
  grid-column: 1;
  justify-self: stretch;
}

.site-footer .legal-row > .draft-flag,
.site-footer .legal-row > .planned-flag {
  grid-column: 2;
  justify-self: start;
  align-self: start;
  /* Same top padding as the link, so the badge lines up with the first line. */
  margin: var(--footer-link-pad) 0 0;
  white-space: nowrap;
}

@media (max-width: 390px) {
  .site-footer .footer-nav:has(> .legal-row) {
    grid-template-columns: minmax(0, 1fr);
  }

  .site-footer .footer-nav > li.legal-row {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.15rem;
  }

  .site-footer .legal-row > .draft-flag,
  .site-footer .legal-row > .planned-flag {
    grid-column: 1;
    justify-self: start;
    align-self: start;
    margin: 0;
  }
}
