#footer {
  --ft-small: max(0.875rem, var(--step--1));
  --ft-top: clamp(8rem, 34vh, 20rem);
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  column-gap: var(--space-2);
  /* A long breath after the knotted button, then the signature */
  padding: var(--ft-top) var(--gutter) 0;
  background: var(--bg);
  color: var(--ink);
}
#footer > * { grid-column: 2; }
#footer .ft-close { grid-row: 1; }
#footer .ft-sign  { grid-row: 2; }
#footer .ft-ps    { grid-row: 3; }
#footer .ft-base  { grid-row: 4; }

/* The thread's loose end: starts flush with the top edge so it never breaks between sections */
#footer .ft-thread {
  grid-column: 1;
  grid-row: 1 / 3;
  margin-top: calc(var(--ft-top) * -1);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
#footer .ft-thread-line {
  display: block;
  /* Grows into the rows it hangs beside, never sizes them: its viewBox would otherwise make it ~35× taller than wide */
  flex: 1 1 0;
  width: 100%;
  height: 0;
  min-height: 0;
  overflow: visible;
}
#footer .ft-thread path {
  fill: none;
  stroke: var(--accent);
  stroke-width: var(--thread-w);
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* The last knot: drawn tight by default; it only starts loose when JS is there to tighten it */
#footer .ft-knot {
  display: block;
  width: 1.5rem;
  height: 1.75rem;
  margin-top: -1px;
  overflow: visible;
  transform-origin: 50% 0;
  transform: scale(.6) rotate(-8deg);
}
#footer .ft-knot[data-knot="waiting"] {
  opacity: 0;
  transform: scale(1) rotate(0deg);
}
#footer .ft-knot path { fill: none; stroke: var(--accent); stroke-width: var(--thread-w); stroke-linecap: round; }

/* The closing sentence, in the same letter column as the rest of the page */
#footer .ft-close p {
  max-width: 34ch;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--t-item);
  line-height: var(--lh-quote);
  letter-spacing: -0.005em;
  text-wrap: pretty;
}
/* On the shop page the closing comes a little sooner: the pieces above already leave room */
#footer.ft-shop { --ft-top: clamp(6rem, 22vh, 14rem); }

/* Signature: pushed right, smaller than any heading above, so the page steps down */
#footer .ft-sign {
  margin-top: var(--space-5);
  padding-left: clamp(2.5rem, 22vw, 9rem);
}
#footer .ft-regards {
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 300;
  font-size: var(--t-body);
  color: var(--muted);
}
#footer .ft-name {
  margin-top: var(--space-1);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--t-title);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--accent);
}
/* The pen stroke under the name: starts under the "N", tucked close, as long as the name */
#footer .ft-stroke {
  display: block;
  width: min(14rem, 100%);
  height: .875rem;
  margin: -.25rem 0 var(--space-3) 0;
  overflow: visible;
}
#footer .ft-stroke path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  stroke-linecap: round;
  opacity: .6;
}
#footer .ft-role,
#footer .ft-place {
  max-width: 36ch;
  font-size: var(--ft-small);
  line-height: 1.6;
  color: var(--muted);
}

/* P.-S.: the contact, repeated without raising its voice (no red on links: red is only the thread) */
#footer .ft-ps {
  margin-top: var(--space-5);
  max-width: 44ch;
}
#footer .ft-ps p {
  font-weight: 300;
  font-size: var(--t-body);
  line-height: var(--lh-body);
  text-wrap: pretty;
}
#footer .ft-ps-mark {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2em;
  margin-right: .25em;
}
#footer .ft-links {
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}
#footer a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .4em;
  text-decoration-color: var(--line);
  transition: color var(--dur-1) var(--ease-out), text-decoration-color var(--dur-1) var(--ease-out);
}
#footer a:hover,
#footer a:focus-visible { text-decoration-color: currentColor; }
#footer .ft-links a { font-weight: 400; overflow-wrap: anywhere; }

/* Base band: full bleed, surface colour, dense and small, hemmed on with a running stitch */
#footer .ft-base {
  position: relative;
  grid-column: 1 / -1;
  margin: clamp(6rem, 20vh, 12rem) calc(var(--gutter) * -1) 0;
  padding: var(--space-4) var(--gutter) var(--space-3);
  background: var(--surface);
  font-size: var(--ft-small);
  color: var(--muted);
}
#footer .ft-base::before {
  content: "";
  position: absolute;
  inset: .625rem 0 auto;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line) 0 .5rem, transparent .5rem .875rem);
}
#footer .ft-base-inner {
  display: grid;
  gap: var(--space-1);
  padding-left: calc(1.75rem + var(--space-2));
}
#footer .ft-mark {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--t-minor);
  letter-spacing: -0.01em;
  color: var(--accent);
}
#footer .ft-legal summary {
  display: inline-flex;
  align-items: center;
  gap: .625rem;
  min-height: 2.75rem;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .4em;
  text-decoration-color: var(--line);
  transition: color var(--dur-1) var(--ease-out);
}
#footer .ft-legal summary::-webkit-details-marker { display: none; }
/* A small cross-stitch: "+" closed, turned to "×" when open */
#footer .ft-legal summary::after {
  content: "+";
  font-family: var(--font-display);
  font-size: 1.25em;
  line-height: 1;
}
#footer .ft-legal[open] summary::after { transform: rotate(45deg); }
#footer .ft-legal summary:hover,
#footer .ft-legal summary:focus-visible { color: var(--ink); }
#footer .ft-legal-body {
  display: grid;
  gap: var(--space-1);
  max-width: 60ch;
  padding: var(--space-1) 0 var(--space-2);
  line-height: 1.6;
}

/* The way back and the ©: set apart from the legal items above */
#footer .ft-meta,
#footer .ft-copy { margin-top: var(--space-3); }
#footer .ft-meta a { color: var(--muted); }
#footer .ft-meta a:hover,
#footer .ft-meta a:focus-visible { color: var(--ink); }
#footer .ft-copy {
  font-size: max(0.875rem, .8em); /* smaller than the band, never under 14px */
  color: var(--muted);
}

/* Wide screens: the 12-column letter. Thread in col 2, body cols 3–7, signature cols 7–11. */
@media (min-width: 64rem) {
  #footer {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--cols-gap);
  }
  #footer .ft-thread { grid-column: 2; }
  #footer .ft-close { grid-column: 3 / 8; }
  #footer .ft-sign  { grid-column: 7 / 12; padding-left: 0; }
  #footer .ft-ps    { grid-column: 3 / 8; }
  #footer .ft-base  { grid-column: 1 / -1; }
  #footer .ft-base-inner {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-3);
    padding-left: 0;
  }
  #footer .ft-base-inner > * { grid-column: 3 / 11; }
  /* One closing row: the way back on the left, the © on the right */
  #footer .ft-base-inner > .ft-meta { grid-column: 3 / 7; align-self: center; }
  #footer .ft-base-inner > .ft-copy { grid-column: 7 / 11; justify-self: end; align-self: center; }
}

@media (prefers-reduced-motion: no-preference) {
  #footer .ft-knot {
    transition: transform 600ms cubic-bezier(.16, 1, .3, 1), opacity var(--dur-1) linear;
  }
  #footer .ft-legal summary::after { transition: transform var(--dur-1) var(--ease-out); }
}
