/* The footer, drawn by `shared/chrome.js` on every kind of page.
 *
 * Its colours chain through three names on purpose. `--primary-dark` and the
 * rest are the portal bundle's tokens, and only pages that run the bundle have
 * them; a data space's own documents and the vendor's application load this
 * stylesheet on its own, where an unresolved `var()` is not a fallback to the
 * default but an invalid declaration — which is how the home came to have a
 * transparent footer while every portal screen had a navy one. The second name
 * in each chain is the published palette in `/shared/theme.css`, which every
 * page does serve.
 */
.footer {
  background: var(--primary-dark, var(--theme-footer-bg, var(--theme-primary-dark, #0a2a45)));
  color: var(--theme-footer-text, #b0c4d8);
  padding: 48px 0 32px;
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

/* With an identity and a list of links and nothing else, the three-track grid
   left one track empty on the right and the links landed mid-street. Two tracks,
   with the links against the edge. The grid's third child is a column only in
   the three-column variant; in the others it is the funding block. */
.footer-inner:not(.footer-row):not(:has(> .footer-col:nth-child(3))) {
  grid-template-columns: 1fr auto;
}

.footer .logo-title {
  color: white;
  font-size: 18px;
  margin-bottom: 8px;
}

/* A grid item's `min-width` is `auto`, so its widest word — a long link label, a
   programme name — sets a floor the track cannot go below, and the grid grows
   past the viewport instead. The page then scrolls sideways on a phone, which is
   how this was found. */
.footer-col { min-width: 0; }
.footer-col p { font-size: 13px; line-height: 1.6; overflow-wrap: break-word; }
.footer-col h4 { color: white; font-size: 14px; margin-bottom: 12px; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 8px; }
/* The fallback is the bundle's own derivation of this token, repeated here so
   a page without the bundle reaches the same colour rather than a near one:
   sections/_shared/tokens.css mixes the accent 18% into white. */
.footer-col a {
  color: var(--accent-light, color-mix(in srgb, var(--theme-accent, #2CC5BA) 18%, #FFFFFF));
  font-size: 13px;
  overflow-wrap: anywhere;
}
.footer-col a:hover { color: white; }

.footer-funding {
  grid-column: 1 / -1;
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  line-height: 1.8;
  color: var(--theme-footer-text, #7f9cb8);
}
.footer-program {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 20px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm, 6px);
}
.footer-program img { height: 56px; width: auto; }
.footer-program span { font-size: 12px; color: var(--theme-footer-text, #a0b8cc); font-weight: 500; }

/* The minimal variant is one line: a credit on the left, the links on the right.
   It has to be allowed to become two — without `flex-wrap` the row keeps its
   width and the page scrolls sideways, which is what a phone showed. */
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 0; }
.footer-row .footer-col { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.footer-row .footer-col ul { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.footer-row .footer-col li { margin-bottom: 0; }
.footer-row .footer-col p { margin: 0; }
/* With no credit, no disclaimer and no badge there is nothing to frame: the rule
   only ever applied to the minimal variant, and in the others it left an empty
   band with a rule across it. */
.footer-funding:empty { display: none; }
.footer-copyright { font-size: 13px; }
.footer-badge { margin: 8px 0; }
/* 60% gives the reading measure on a wide screen, but on a phone it would leave
   a column three words across. The floor comes from the typography itself, and
   `min()` keeps that floor from overflowing a narrower container still. */
.footer-funding p {
  white-space: pre-line;
  width: 60%;
  min-width: min(38ch, 100%);
  margin: auto;
}
.footer-disclaimer { font-size: 11px; opacity: .7; }

/* ── Narrow viewports ───────────────────────────────────────────────────────
 *
 * The footer is the one block of the page that was laid out only for a wide
 * screen: three fixed grid tracks and a row of links that could not wrap, so at
 * 375px the page carried 104px of horizontal scroll. Everything here is about
 * letting it stack rather than about how it looks stacked.
 */
@media (max-width: 760px) {
  .footer { padding: 36px 0 24px; }

  .footer-inner,
  .footer-inner:not(.footer-row):not(:has(> .footer-col:nth-child(3))) {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
  }

  /* The credit above its links rather than beside them: side by side, each gets
     half a phone's width and both wrap to three lines. */
  .footer-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .footer-row .footer-col ul { gap: 8px 18px; }

  .footer-funding p { width: 100%; }
  .footer-program { flex-wrap: wrap; padding: 12px 14px; }
  .footer-program img { height: 44px; max-width: 100%; }
}
