/* Shared footer styles.
 *
 * Loaded by every page, after its own base styles, so the footer looks and
 * behaves identically everywhere. Scoped to .site-footer.
 */

/* Dedicated white footer band. It adds only vertical breathing room (20px top
   and bottom); every item inside it provides its own side spacing.
 *
 * Two bands stacked: the columns (form, Contact, links), then the copyright
 * below all of them, centred across the full width of the footer. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  background-color: #fff;
  padding: 20px 0;
  /* Separates the footer from the page above it: the inactive grey, one step
     lighter than the form's resting border. */
  border-top: 1px solid #ccc;
}

/* The columns — the form, the Contact column and the links column — get 15px
   top/bottom and 20px on the sides. */
.site-footer > form,
.site-footer > .footer-contact,
.site-footer > .footer-links {
  margin: 0;
  padding: 15px 20px;
}

/* The copyright: its own band under the columns, centred from edge to edge. */
.site-footer > .footer-note {
  flex: 0 0 100%;
  margin: 0;
  padding: 15px 20px;
  text-align: center;
}

/* The rows inside the right-hand columns — Contact and each social link —
   add no padding of their own: the column already has the 20px side padding,
   and the vertical rhythm comes from the column rules below, which is what
   keeps each column's first line on the same line as the form title. */
.site-footer .footer-contact > *,
.site-footer .footer-links > * {
  margin: 0;
  padding: 0;
}

/* The browser's own validation bubble would sit behind other layers. */
.site-footer form {
  margin: 0;
}

/* Links: no underline at rest, underlined with a gap on hover only. */
.site-footer a {
  color: inherit;
  font-size: inherit;
  text-decoration: none;
  text-decoration-color: currentColor;
  text-underline-offset: 0.38em;
  text-decoration-thickness: 1px;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Copyright line: same 13px type, inherits the footer item padding. */
.site-footer .footer-note {
  margin: 0;
  font-size: 13px;
  white-space: nowrap;
}

/* Opens a mail client at contact@andreacarpini.com. */
.site-footer .contact-button {
  display: inline-block;
  white-space: nowrap;
}

/* The two right-hand columns — Contact and the social links — share one row
   rhythm. Each column gets exactly the same top/bottom padding as any other
   footer item (the rules at the top of this file, including the desktop 28px),
   which is what puts its first row on the same line as the form title; rows
   carry no vertical padding of their own, and the space between two rows is a
   margin on every row but the first. */
.site-footer .footer-contact,
.site-footer .footer-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.site-footer .footer-contact > * + *,
.site-footer .footer-links > * + * {
  margin-top: 30px;
}

/* Desktop: both columns read as one compact group next to the form, so the
   step between rows is a little tighter than on a phone — enough to read as a
   group, without stretching to the form's height. */
.site-footer .footer-links a {
  white-space: nowrap;
}

/* Newsletter: the heading above the sign-up controls. */
.site-footer .signup {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.6rem;
  font-size: 13px;
}

/* Headline above the field. Deliberately not a <label>: clicking it must not
   focus the input.
 *
 * It is one short line, but it sits in a multi-line footer: the 1.55 leading
 * adds half a line above the text (0.275em). Pulling that back keeps the line
 * on exactly the same line as the first row of the columns beside it, which is
 * what the negative margin does. */
.site-footer .signup-title {
  max-width: 22rem;
  /* Multi-line leading adds half a line above the first line (0.275em at
     1.55). Pulling that back keeps the first line on exactly the same line as
     the first row of the columns beside it, which is what line-height 1 was
     doing before the heading grew. */
  margin: -0.275em 0 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
  cursor: default;
}

/* Screen-reader-only label for the email field. */
.site-footer .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Consent row: a checkbox followed by its label. The label is the click target
   for the whole sentence, which is what makes a small control usable. */
/* The consent line: checkbox and label on one row, left aligned with the rest
   of the form. */
.site-footer .privacy-note {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  max-width: 22rem;
  margin: 0;
  /* Clear space above, so the row is not glued to the field. */
  padding: 1rem 0 0.25rem;
  font-size: 11px;
  line-height: 1.35;
}

.site-footer .privacy-note label {
  display: inline;
  flex: 1 1 auto;
  padding: 0.4rem 0 0.4rem 0.5em;
  cursor: pointer;
}

/* The checkbox itself: a plain square that follows the inactive/grey → black
   language of the field and button. */
.site-footer .privacy-note input[type='checkbox'] {
  /* A replaced element inside a flex row: pin both axes explicitly so no flex
     stretch or content sizing can turn the box into a rectangle. */
  flex: 0 0 13px;
  box-sizing: border-box;
  width: 13px;
  min-width: 13px;
  max-width: 13px;
  height: 13px;
  min-height: 13px;
  max-height: 13px;
  /* Centred against the label's line, not pinned to the top of the row. */
  align-self: center;
  padding: 0;
  margin: 0;
  border: 1px solid #999;
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.site-footer .privacy-note input[type='checkbox']:checked {
  border-color: #000;
  background-color: #000;
  /* A white tick drawn with a rotated corner, so no image or icon font. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.5 3.6' fill='none' stroke='%23fff' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.site-footer .privacy-note input[type='checkbox']:focus-visible {
  outline: 1px solid #000;
  outline-offset: 2px;
}

/* The link inside the consent sentence is always underlined: it is inline text. */
.site-footer .privacy-note a {
  text-decoration: underline;
}

/* The email field and button stay on one row, under the heading. */
.site-footer .signup-row {
  display: flex;
  /* The field sets the row height; the button stretches to match it. */
  align-items: stretch;
  gap: 0.5rem;
  /* Extra breathing room above the controls, on top of the form's gap. */
  margin-top: 0.4rem;
}

/* Inactive grey text and border. The text turns black when focused or filled. */
.site-footer .signup input {
  width: 15rem;
  max-width: 45vw;
  padding: 0.45rem 0.6rem;
  border: 1px solid #999;
  border-radius: 0;
  background: transparent;
  color: #999;
  font: inherit;
}


.site-footer .signup input::placeholder {
  color: #999;
  opacity: 1;
}

.site-footer .signup input:focus,
.site-footer .signup input:not(:placeholder-shown) {
  outline: none;
  color: #000;
}

/* Always live: the button never greys out, whether or not the field holds a
   valid address. Clicking it with something missing shows the message; a
   filled form sends. Hover and keyboard focus invert it, as before. */
.site-footer .signup button {
  padding: 0.45rem 0.9rem;
  border: 1px solid #000;
  border-radius: 0;
  background: #000;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.site-footer .signup button:hover,
.site-footer .signup button:focus-visible {
  background: #fff;
  color: #000;
}

/* Confirmation / error line. */
/* Status line sits under the field and button, on its own row. */
.site-footer .signup-status {
  margin: 0;
  font-size: 13px;
  /* Explicit 400, the same weight as the headline and the consent line: the
     message is told apart by its words, not by a heavier face. */
  font-weight: 400;
  /* 1.55, the same leading as the 13px headline it belongs with. */
  line-height: 1.55;
}

/* A failure is the one place colour earns its keep: this is material's error
   red (#b00020), the common choice for form errors and 7.3:1 on white, so it
   passes WCAG AA at this size. The confirmation stays black. */
.site-footer .signup-status[data-state='error'] {
  color: #b00020;
}

/* The line is always in the DOM so the live region exists before there is
   anything to announce; collapsing it only while empty keeps it out of the
   layout without ever removing it from the accessibility tree. */
.site-footer .signup-status:empty {
  display: none;
}

/* Desktop: a touch more breathing room above and below; sides unchanged.
   The link column is a footer item too, so it grows by the same 28px from
   the `> *` rule and its first line stays level with the other items. */
/* The footer has exactly two layouts, and the two queries below are the whole
   of the difference:
     - up to 767px: stacked in one column, full-width rows;
     - from 768px: the columns side by side (form, Contact, links) with the
       copyright band under them.
   Everything outside these queries is identical at every width, so there is no
   third, in-between state to drift. */
@media (min-width: 768px) {
  /* Desktop reads as a wider band than the stacked layout: every column gets
     the breathing room above and below, and three times the side spacing
     (60px instead of 20px) so neighbouring columns are separated by 120px.
     The copyright band keeps its own 20px, since it is centred across the full
     width and has no neighbours. */
  .site-footer > form,
  .site-footer > .footer-contact,
  .site-footer > .footer-links {
    padding-top: 28px;
    padding-bottom: 28px;
    padding-left: 60px;
    padding-right: 60px;
  }

  .site-footer > .footer-note {
    padding-top: 28px;
    padding-bottom: 28px;
  }

  /* Two halves. The sign-up form owns the left half — exactly half the footer,
     left aligned — and the two link columns sit against the right edge of the
     other half. The form is a fixed 50%, and the auto left margin on the
     Contact column takes all the space that is left, which is what pushes both
     link columns to the right. */
  .site-footer > form {
    flex: 0 0 50%;
  }

  .site-footer > .footer-contact {
    margin-left: auto;
  }

  /* Inside the left half the form uses the full width it has: the headline
     runs to the half's edge and wraps there, and the field and button share
     that width in the same 2:1 split they have on a phone. */
  .site-footer .signup {
    align-items: stretch;
  }

  .site-footer .signup-title {
    max-width: 100%;
  }

  .site-footer .signup-row {
    align-self: stretch;
  }

  .site-footer .signup input {
    flex: 0 0 calc(66.666% - 0.25rem);
    width: auto;
    max-width: none;
    min-width: 0;
  }

  .site-footer .signup button {
    flex: 1 1 0;
    min-width: 0;
  }

  /* The step between rows in the two link columns: tighter than on a phone,
     because the columns read as one compact group beside the form. */
  .site-footer .footer-contact > * + *,
  .site-footer .footer-links > * + * {
    margin-top: 20px;
  }
}

/* Stacked layout: one column, every row full width. */
@media (max-width: 767px) {
  .site-footer {
    flex-direction: column;
    /* Stretch, so every stacked row — the form included — fills the width.
       With flex-start each item would shrink to its content and the form row
       would stop short of the footer's edges. */
    align-items: stretch;
    justify-content: flex-start;
  }

  /* The columns — and the copyright band under them — span the screen width
     so their rows line up with the text above. The columns keep the 15px
     top/bottom every footer item has here and drop their side padding: on a
     full-width stack that padding would indent every row, so the rows take
     the 20px instead and nothing is doubled. */
  .site-footer > .footer-contact,
  .site-footer > .footer-links,
  .site-footer > .footer-note {
    align-self: stretch;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }

  /* The form keeps its 20px side padding here: its full-width rule below sits
     on the footer's edges, under the text, not under the padding edge. */
  .site-footer > form {
    border-bottom: 1px solid #ccc;
  }

  /* The rule is the link stack's first step, so the first link takes the same
     30px the rows below it take from each other (the `> * + *` rule above):
     30px top padding instead of the 15px every other footer item keeps. Only
     the first column gets it — the social column follows the contact column's
     15px, so its own gap stays uniform. */
  .site-footer .footer-contact {
    padding-top: 30px;
  }

  .site-footer .footer-contact > *,
  .site-footer .footer-links > * {
    padding-left: 20px;
    padding-right: 20px;
  }

  .site-footer .signup-title {
    max-width: 100%;
  }

  /* Field and button share one row filling the footer: the field takes two
     thirds, the button the rest. The form column aligns its children to the
     start, which would let the row shrink to its content; stretching it lets
     the split use the full width. */
  .site-footer .signup-row {
    flex-wrap: nowrap;
    align-self: stretch;
  }

  .site-footer .signup input,
  .site-footer .signup button {
    height: 36px;
    box-sizing: border-box;
  }

  .site-footer .signup input {
    /* Two thirds of the row, less half the gap, so field + gap + button add
       up to exactly 100% of the row. */
    flex: 0 0 calc(66.666% - 0.25rem);
    width: auto;
    max-width: none;
    min-width: 0;
  }

  .site-footer .signup button {
    /* Takes all the space that is left. */
    flex: 1 1 0;
    min-width: 0;
  }
}
