/*
 * The product footer, shared by dashboard.html and privacy.html.
 *
 * landing.html keeps its own .foot block: its nav is page-anchors that exist nowhere else, and its
 * local --line/--muted/--s-* variables already alias to the same --mf-* tokens used here, so the two
 * render identically. Every value below is lifted from that block rather than re-invented.
 *
 * This cannot live in design-system.css — designSystem.test.ts asserts that file carries tokens and
 * no component selectors — and pulling the 15k-line styles.css into privacy.html for one footer is
 * worse than a 60-line sheet.
 */

/*
 * Sticky footer: hug the viewport bottom when the page is short — an empty Trends list, a category
 * filtered to nothing, a failed load — and sink with the content when there is enough of it.
 *
 * :has() scopes this to the two pages carrying the footer, so no body class is needed, and a browser
 * without :has() drops the whole rule as an invalid selector and simply gets the flowing footer.
 *
 * Everything else in these bodies is out of flow already (the background pseudo-elements, the request
 * modal and the toast are all position:fixed; scripts are display:none), so main and the footer are
 * the only flex items. main keeps centering, because its auto inline margins still resolve in a
 * column flex container.
 *
 * The grow goes on main rather than margin-block-start:auto on the footer: auto resolves to 0 as soon
 * as the page is tall enough, which would collapse the gap separating the footer's rule from the
 * content above it — exactly the case this is meant to leave alone.
 */
body:has(> .mf-foot) {
  min-block-size: 100vh;
  min-block-size: 100svh;
  display: flex;
  flex-direction: column;
}

body:has(> .mf-foot) > main {
  flex: 1 0 auto;
  /* A flex item's automatic minimum size refuses to shrink below its min-content width, which on the
     policy page is 568px — set by the tables' own min-width. main stopped tracking the viewport, so
     the tables' overflow-x:auto containers never engaged and the whole page scrolled sideways at
     375px instead. Without this line, making body a flex column silently breaks narrow screens. */
  min-inline-size: 0;
}

body:has(> .mf-foot) > .mf-foot {
  flex-shrink: 0;
}

.mf-foot {
  border-block-start: 1px solid var(--mf-border-subtle, rgba(17, 19, 22, 0.105));
  margin-block-start: var(--mf-space-10, 48px);
  color: var(--mf-text-secondary, #65707a);
  font-family: var(--mf-font-sans, Inter, "Helvetica Neue", "Segoe UI", Arial, sans-serif);
  font-size: 13.5px;
}

.mf-foot-inner {
  width: min(var(--mf-layout-app-max, 1480px), calc(100% - var(--mf-space-16, 64px)));
  margin-inline: auto;
  padding-block: 24px 40px;
  display: grid;
  gap: 18px;
}

.mf-foot-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 24px;
}

.mf-foot-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.mf-foot-mark {
  display: block;
  width: 22px;
  height: 30px;
}

.mf-foot-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.mf-foot a {
  color: inherit;
  text-decoration: none;
}

.mf-foot-nav a:hover {
  color: var(--mf-text-strong, #111316);
  text-decoration: underline;
}

/* Third-party marks, so filled paths rather than the product icon set's 1.5–1.75 stroke. The 32px hit
   box is the floor for a dense secondary control; the negative margin pulls the glyphs — not their
   padding — flush with the column edge. */
.mf-foot-social {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-inline: -7px;
}

.mf-soc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--mf-text-secondary, #65707a);
  transition:
    color 0.16s ease,
    background 0.16s ease;
}

.mf-soc svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.mf-soc:hover {
  color: var(--mf-text-strong, #111316);
  background: rgba(17, 19, 22, 0.05);
}

.mf-foot a:focus-visible {
  outline: 2px solid var(--mf-signal-accent-ink, #08758a);
  outline-offset: 2px;
  border-radius: var(--mf-radius-xs, 4px);
}

/* The risk statement is prose, so it takes the sans face and normal tracking — mono is for data. */
.mf-foot-risk {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--mf-text-secondary, #65707a);
  text-wrap: pretty;
}

/*
 * Narrow screens. The flex row gives each of the three groups its own line at 375px, which with the
 * padding and gaps made the footer 336px — 41% of a phone viewport, and tall enough to push an
 * otherwise-short page below the fold on its own.
 *
 * A 2-column grid pairs the brand with the social marks on one line and drops the nav underneath,
 * saving a whole row; the rest is tightened padding and gaps. The risk statement keeps its 12.5px —
 * shrinking a risk disclosure to fit is the one thing not on the table here.
 */
@media (max-width: 640px) {
  .mf-foot-inner {
    width: min(var(--mf-layout-app-max, 1480px), calc(100% - var(--mf-space-12, 48px)));
    padding-block: 20px 28px;
    gap: 14px;
  }

  .mf-foot-top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px 16px;
  }

  .mf-foot-brand {
    grid-area: 1 / 1;
  }

  .mf-foot-social {
    grid-area: 1 / 2;
    justify-self: end;
  }

  .mf-foot-nav {
    grid-area: 2 / 1 / auto / -1;
    gap: 8px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mf-soc {
    transition: none;
  }
}

@media (forced-colors: active) {
  .mf-foot {
    border-block-start: 1px solid CanvasText;
  }
}

/* ── Touch: footer link targets ──────────────────────────────────────────────────────────────────────────
   The nav links are 21-22px line boxes — under WCAG 2.2's 24px minimum, on every page of the site. The
   footer was deliberately tightened for phones (see the compact block above: it was 336px, 41% of a phone
   viewport), so the fix must not put that height back: the boxes stay where they are and an invisible
   ::after carries the target. 40px, not 44px: the nav wraps to several rows with a 20px gap, and a 44px box
   would overlap the row above it by 3px — a band where a tap would land on the wrong link. */
@media (hover: none) and (pointer: coarse) {
  .mf-foot-nav a {
    position: relative;
  }

  .mf-foot-nav a::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: max(100%, 40px);
    transform: translateY(-50%);
  }
}
