/* ==========================================================================
   Footer

   The markup is built from ACF content blocks stacked inside a column —
   a heading, an icon list, a row of social links, a paragraph, a button,
   in whatever order the site has arranged them. So nothing here can
   assume an order; the rhythm has to come from the column itself.
   ========================================================================== */

.site-footer {

    /*
     * One line of footer text, as a length.
     *
     * Written in rem on purpose. rem resolves against the root font size,
     * not the element's, so this computes to the same number of pixels on
     * a child element whatever font-size that child carries. An icon
     * given this as its height therefore sits exactly on the first line
     * of the text beside it, which `em` could not do from inside an icon
     * that sets its own font-size.
     */
    --footer-font-size: 1rem;
    --footer-line-height: var(--line-height-body, 1.7);
    --footer-line: calc(var(--footer-font-size) * var(--footer-line-height));

    /* The gap between stacked blocks inside one column. */
    --footer-block-gap: var(--space-md, 1.5rem);

    /*
     * Both are set here rather than inherited, because --footer-line
     * above is only a true line height if the text is actually laid out
     * at these values. Left to inherit, a site that never sets a body
     * line-height gets the browser's `normal` — about 1.2 — while the
     * token still calculates 1.7, and every icon sits low by half the
     * difference. That was 5px with no child theme active.
     */
    font-size: var(--footer-font-size);
    line-height: var(--footer-line-height);
}


/* Grid
   ========================================================================== */

.site-footer__grid {
    display: grid;
    gap: 2rem;
}

.site-footer__grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.site-footer__grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.site-footer__grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.site-footer__grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.site-footer__grid--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }


/* Column
   --------------------------------------------------------------------------
   A flex column rather than a block, for two reasons: `gap` gives one
   rhythm between the blocks without every block needing to know what sits
   above it, and it lets a trailing button be pushed to the bottom.

   A grid item stretches to its row's height by default, so every column
   in a row is as tall as the tallest. That is the slack the button rule
   below takes up.
   ========================================================================== */

/* A grid item defaults to min-width: auto, so it can outgrow its track
   even when the track itself is capped. */
.site-footer__column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--footer-block-gap);
}

/*
 * Margins are cleared so the gap above is the only thing deciding the
 * spacing. Left in place they stack on top of it, and a paragraph's
 * margin differs from a list's, so two columns built from different
 * blocks would not line up.
 */
.site-footer__column > * {
    margin-block: 0;
}

/* A new heading part-way down a column gets more air than a plain gap,
   because it starts a new group rather than continuing one. */
.site-footer__column > h3:not(:first-child) {
    margin-top: var(--space-sm);
}

/*
 * A button that ends a column drops to the bottom of it, so the buttons
 * in neighboring columns line up with each other instead of each one
 * sitting wherever its own column's content happened to leave it.
 *
 * `auto` takes up free space on top of the gap rather than replacing it,
 * so the tallest column — the one with no slack — still keeps a full gap
 * above its button.
 *
 * The cost is that the buttons sit at the bottom of the tallest column in
 * the row, which can leave a stretch of space above them. A site that
 * would rather have each button follow its own content sets
 * --footer-button-align to var(--footer-block-gap).
 */
.site-footer__column > .btn:last-child {
    margin-top: var(--footer-button-align, auto);
}


/* Pieces
   ========================================================================== */

.site-footer__social {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/*
 * One social link. It wraps a mark and no text at all, which makes two
 * things matter here that do not for a link in a sentence.
 *
 * 2.5.8 Target Size (Minimum) is the first. 24px square is the floor and
 * a 20px glyph on its own is under it, so the box is padded out to 24
 * rather than the mark being grown — the row still reads as a row of
 * marks instead of a row of buttons.
 *
 * The focus ring is the second. There is no text to underline and no
 * background to invert, so the outline is all a keyboard has to go on,
 * and it is drawn in currentColor so it is visible in a pale column and
 * a dark one both without a second rule.
 */
.site-footer__social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    color: inherit;
}

/*
 * Hover and keyboard focus both take the brand color. The marks are
 * drawn in currentColor, so one declaration moves the whole mark — and
 * a link whose only content is a logo has nothing else to change: no
 * text to underline, no label to move.
 *
 * It had no hover state at all until now, which on an icon-only link
 * is the one place a pointer gets no feedback that it is over a
 * control.
 */
.site-footer__social-link:hover,
.site-footer__social-link:focus-visible {
    color: var(--color-primary);
}

.site-footer__social-link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/*
 * The mark is sized by its height, with the width left to follow the
 * viewBox. They are not all the same proportion — a lone Facebook f is
 * half the width of YouTube's rounded rectangle — so a fixed square box
 * would stretch most of them. Matching heights are what reads as an even
 * row.
 *
 * A child theme that wants them larger sets --footer-social-size and
 * nothing else has to move. Past 24px it should raise the min-height
 * above too, or the mark will overflow its target box.
 */
.ssc-social-icon {
    display: block;
    flex: 0 0 auto;
    width: auto;
    height: var(--footer-social-size, 1.25rem);
}

/*
 * The icon picker's two other kinds, at the same height. A row can hold
 * both at once — a site that sets Platform on three rows and leaves the
 * picker on a fourth — and the odd one out should not be the one that is
 * a different size.
 */
.site-footer__social-link .dashicons {
    width: var(--footer-social-size, 1.25rem);
    height: var(--footer-social-size, 1.25rem);
    font-size: var(--footer-social-size, 1.25rem);
    line-height: 1;
}

.site-footer__social-link img {
    display: block;
    width: auto;
    height: var(--footer-social-size, 1.25rem);
}

.site-footer__icon-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--footer-icon-list-gap, .4rem);
}

/*
 * An icon beside a line of text. The icon's box is one line tall with the
 * glyph centered in it, so it sits on the first line and stays there when
 * the text wraps to a second — which an address does at almost every
 * width.
 *
 * A child theme that wants a different icon size sets --footer-icon-size
 * and nothing else needs to move.
 */
.site-footer__icon-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-xs, .5rem);
}

.site-footer__icon-list .dashicons,
.site-footer__icon-list .site-footer__icon-list-icon {
    flex: 0 0 auto;
    width: var(--footer-icon-size, 1rem);
    height: var(--footer-line);
    font-size: var(--footer-icon-size, 1rem);
    line-height: var(--footer-line);
}

.site-footer__image {
    display: block;
    width: 100%;
    height: auto;
}


/* Rows
   ========================================================================== */

.site-footer__row--small  { padding: 2rem 0; }
.site-footer__row--medium { padding: 4rem 0; }
.site-footer__row--large  { padding: 6rem 0; }


/* Responsive
   ========================================================================== */

@media (max-width: 991px) {

    .site-footer__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

}

/*
 * One column.
 *
 * Whether that column is centered is the site's call, not the framework's,
 * so it is two tokens rather than a decision taken here. Set both to
 * `center` in a child theme for a centered footer on phones; left unset,
 * nothing about a site's current footer moves.
 *
 * Both are needed: `align-items` centers the blocks themselves, which is
 * what brings a logo and a row of social links into the middle, while
 * `text-align` only moves the text inside them.
 *
 * The trailing button's auto margin goes back to a plain gap here. With
 * one column per row there is no taller neighbor to line up with, and
 * the slack would open a gap the height of the whole column.
 */
@media (max-width: 767px) {

    .site-footer__grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .site-footer__column {
        align-items: var(--footer-mobile-items, stretch);
        text-align: var(--footer-mobile-text, start);
    }

    .site-footer__column > .btn:last-child {
        margin-top: 0;
    }

    .site-footer__social,
    .site-footer__icon-list li {
        justify-content: var(--footer-mobile-text, start);
    }

}


/* ==========================================================================
   Back to top
   --------------------------------------------------------------------------
   Printed only when Site Settings asks for it, and hidden by the script
   until there is something to come back from.

   Neutral here, like the rest of the framework: a circle in the corner at
   the site's primary color. A child theme repaints it.
   ========================================================================== */

.ssc-to-top {
    --ssc-to-top-size: 56px;
    --ssc-to-top-inset: var(--space-lg, 2rem);

    position: fixed;
    right: var(--ssc-to-top-inset);
    bottom: var(--ssc-to-top-inset);
    z-index: 90;

    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ssc-to-top-size);
    height: var(--ssc-to-top-size);

    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-on-primary, #fff);
    text-decoration: none;

    transition: opacity var(--transition-fast, .2s);
}

.ssc-to-top[hidden] {
    display: none;
}

.ssc-to-top:hover,
.ssc-to-top:focus-visible {
    opacity: .9;
    color: var(--color-on-primary, #fff);
}

.ssc-to-top:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/*
 * The arrow is drawn rather than loaded: it follows currentColor, there is
 * no request for one glyph, and it survives forced-colors mode, which a
 * background image does not.
 */
.ssc-to-top__icon {
    width: 12px;
    height: 12px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: translateY(2px) rotate(-45deg);
}

@media (max-width: 768px) {

    .ssc-to-top {
        --ssc-to-top-size: 48px;
        --ssc-to-top-inset: var(--space-sm, 1rem);
    }

}

@media (prefers-reduced-motion: reduce) {

    .ssc-to-top {
        transition: none;
    }

}
