/* components/site-footer.css — layout for partials/footer.hbs: identity,
   link groups and an account column. All tokens, so it follows the palette
   in both schemes. */

/* No ground of its own: the footer sits on the page colour, set apart by
   the rule alone. The rule is on __inner, inside .container's gutters. */
.site-footer {
  margin-block-start: var(--space-20);
}

.site-footer__inner {
  padding-block: var(--space-12);
  border-block-start: var(--border-width) solid var(--color-border-soft);
}

/* Columns: stacked below --bp-lg, then a row. Identity and account get a
   flex basis; link columns size to content. */
.site-footer__columns {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

@media (width >= 64rem) {
  .site-footer__columns {
    flex-direction: row;
    gap: var(--space-8);
  }
}

/* Rules on the link groups only (the identity column has none), side by
   side only. */
@media (width >= 64rem) {
  .site-footer__group {
    flex: 0 1 auto;
    padding-inline-start: var(--space-8);
    border-inline-start: var(--border-width) solid var(--color-border-soft);
  }
}

/* Identity. Stacked, its box drops out (display: contents) so the fine
   print can be ordered last, under the account column. Side by side it's a
   column again, with the fine print pushed to its foot. */
.site-footer__identity {
  display: contents;
}

.site-footer__masthead {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (width >= 64rem) {
  .site-footer__identity {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
  }
}

/* --font-brand, not --font-heading (which turns serif in editorial scopes). */
.site-footer__brand {
  font-family: var(--font-brand);
  font-size: var(--text-5xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  text-decoration: none;
  color: inherit;
}

.site-footer__tagline {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
}

/* Copyright and legal links: last in the stack, at the column's foot side
   by side. */
.site-footer__fine-print {
  order: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

@media (width >= 64rem) {
  .site-footer__fine-print {
    order: 0;
    margin-block-start: auto;
    padding-block-start: var(--space-8);
  }
}

/* -tone, not -muted: quieter than links but still legible. */
.site-footer__copyright {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-fg-tone);
}

/* One wrapping line in the copyright's size and tone. */
.site-footer__legal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__legal-link {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  text-decoration: none;
  color: var(--color-fg-tone);
}

/* Link groups. Item spacing tracks the menu panel's lists (site-header.css): --space-3
   in the mobile panel, --space-1 in the desktop one — change them together. */
.site-footer__list {
  --site-footer-item-gap: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--site-footer-item-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (width >= 48rem) {
  .site-footer__list {
    --site-footer-item-gap: var(--space-1);
  }
}

/* Sections in two CSS columns, which rebalance as items change. Flex and
   `columns` don't combine, so this switches to block and spaces items with
   margins. */
.site-footer__list--split {
  display: block;
  columns: 2;
  column-gap: var(--space-8);
}

.site-footer__list--split .site-footer__item {
  /* Keep a wrapped label in one column. */
  break-inside: avoid;
}

.site-footer__list--split .site-footer__item + .site-footer__item {
  margin-block-start: var(--site-footer-item-gap);
}

.site-footer__link {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  text-decoration: none;
  color: inherit;
}

.site-footer__link:hover,
.site-footer__link:focus-visible,
.site-footer__legal-link:hover,
.site-footer__legal-link:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: var(--link-underline-width);
}

/* Account column: signup and preferences. */
@media (width >= 64rem) {
  .site-footer__group--account {
    flex: 1 1 0;
    min-width: 0;
  }
}

.site-footer__signup {
  margin-block-start: var(--space-8);
}

.site-footer__signup-text {
  margin-block-end: var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--text-base);
}

/* Field and button, then the messages. */
.site-footer__signup-form {
  display: grid;
  gap: var(--space-4);
}

.site-footer__signup-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* The field takes the remaining width and can shrink below its intrinsic size. */
.site-footer__signup-input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid var(--color-border);
  background-color: var(--color-bg);
  font: inherit;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: inherit;
}

/* Ink and paper swapped via --color-fg/--color-bg — not the invert pair,
   which in dark mode is only a tone off the page. */
.site-footer__signup-button {
  padding: var(--space-3) var(--space-5);
  border: var(--border-width) solid var(--color-border);
  background-color: var(--color-fg);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--color-bg);
  cursor: pointer;
}

.site-footer__signup-form.loading .site-footer__signup-button {
  opacity: var(--card-hover-opacity);
  pointer-events: none;
}

.site-footer__signup-message {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

/* The error <p> is empty until Ghost writes in. */
.site-footer__signup-message--success,
.site-footer__signup-message:empty {
  display: none;
}

.site-footer__signup-message--error {
  color: var(--color-danger);
}

.site-footer__signup-form.success .site-footer__signup-row {
  display: none;
}

.site-footer__signup-form.success .site-footer__signup-message--success {
  display: block;
}

/* To /newsletters/. The arrow: a mask over currentColor, as on
   .section-header__link. */
.site-footer__signup-more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-start: var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  text-decoration: none;
}

.site-footer__signup-more::after {
  content: "";
  inline-size: var(--icon-arrow-size);
  aspect-ratio: 13 / 12;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: var(--icon-arrow) no-repeat center / contain;
  mask: var(--icon-arrow) no-repeat center / contain;
}

/* Site preferences: Site Mode above the type size toggle, each sized to
   its content so only the control itself is clickable, not the row's empty
   width. */
.site-footer__prefs {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  margin-block-start: var(--space-8);
  padding-block-start: var(--space-6);
  border-block-start: var(--border-width) solid var(--color-border-soft);
}

/* Both preference controls: a bare button, glyph then label. */
.theme-toggle,
.type-size-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

/* Theme toggle: the knob follows the resolved palette, not aria-checked,
   so it's right for an OS-dark visitor with no stored choice or no JS.
   The selectors mirror DARK MODE in 01-tokens.css — change them together. */
.theme-toggle__track {
  position: relative;
  display: block;
  flex-shrink: 0;
  inline-size: 2.5rem;
  block-size: 1.375rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: 999px;
  transition: background-color var(--transition);
}

/* Knob sized off the track so they stay concentric. */
.theme-toggle__track::after {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 0.1875rem;
  inline-size: 0.875rem;
  block-size: 0.875rem;
  border-radius: 50%;
  background-color: currentColor;
  translate: 0 -50%;
  transition: translate var(--transition), background-color var(--transition);
}

/* On = dark: knob right, and the switch reads as filled — the track takes
   the ink (near-white in dark mode) and the knob the page colour. */
:root[data-theme="dark"] .theme-toggle__track {
  background-color: var(--color-fg);
}

:root[data-theme="dark"] .theme-toggle__track::after {
  background-color: var(--color-bg);
  translate: 1.125rem -50%;
}

/* The label names the current mode, switched off the same selectors. */
.theme-toggle__label--dark {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__label--light {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__label--dark {
  display: inline;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__track {
    background-color: var(--color-fg);
  }

  :root:not([data-theme="light"]) .theme-toggle__track::after {
    background-color: var(--color-bg);
    translate: 1.125rem -50%;
  }

  :root:not([data-theme="light"]) .theme-toggle__label--light {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle__label--dark {
    display: inline;
  }
}

.theme-toggle__label,
.type-size-toggle__label {
  font-family: var(--font-ui);
  font-size: var(--text-base);
}

/* Type size toggle: a boxed "AA" — a capital A beside a smaller one — in
   the theme track's hairline. Larger type fills the box, as the switch
   fills when on. The glyphs are on the type scale, so they grow a step with
   the choice.
   The two As share a baseline; wrap + align-content centres that one line
   in the box at either type size (align-content needs a wrapping container
   to act). The top padding drops caps that line-height: 1 leaves riding
   high — its box includes descender room the capitals don't use. */
.type-size-toggle__icon {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-content: center;
  align-items: baseline;
  justify-content: center;
  inline-size: 2rem;
  block-size: 1.5rem;
  padding-block-start: var(--space-half);
  border: var(--border-width) solid var(--color-border);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  transition: background-color var(--transition), color var(--transition);
}

.type-size-toggle__icon-small {
  font-size: 0.7em;
}

:root[data-type-size="large"] .type-size-toggle__icon {
  background-color: var(--color-fg);
  color: var(--color-bg);
}

/* Label: the action a click takes — "Increase" at the design's sizes,
   "Decrease" once they're larger. Off the same attribute as the fill, so
   it's right before JS runs. */
.type-size-toggle__label--decrease {
  display: none;
}

:root[data-type-size="large"] .type-size-toggle__label--increase {
  display: none;
}

:root[data-type-size="large"] .type-size-toggle__label--decrease {
  display: inline;
}
