/*
 * The footer additions (includes/footer.php) — contact information, newsletter
 * signup, badges, campaign media, CTA buttons, custom HTML and the menu
 * accordion on phones — and the theme's inline-submit form style wherever
 * it's used.
 * Loaded on every page.
 */

/* The logo column is as wide as the logo on its own; give it room. */
@media (min-width: 960px) {
    .site-footer__logo:has(.freida-footer-extras) {
        flex: 0 0 min(20rem, 32%);
    }
}

.freida-footer-extras {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 2rem;
}

/* On tablets the column is the full footer width; keep the text blocks readable. */
.freida-footer-contact,
.freida-footer-newsletter,
.freida-footer-badges {
    max-width: 32rem;
}

.freida-footer-extras .freida-footer-extras__heading {
    font-size: 1rem;
    line-height: 1.3;
    margin: 0 0 0.75rem;
}

/* Contact information ---------------------------------------------------- */

.freida-footer-contact__rows {
    list-style: none;
    margin: 0;
    padding: 0;
}

.freida-footer-contact .freida-footer-contact__subheading {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-sm, 1rem);
    font-weight: var(--font-weight-bold, 700);
    line-height: 1.5;
    margin: 1rem 0 0.25rem;
}

.freida-footer-contact .freida-footer-contact__subheading:first-child,
.freida-footer-extras__heading + .freida-footer-contact__subheading {
    margin-top: 0;
}

.freida-footer-contact__rows + .freida-footer-contact__rows {
    margin-top: 0.375rem;
}

.freida-footer-contact__row {
    align-items: flex-start;
    display: flex;
    font-size: var(--font-size-sm, 1rem);
    gap: 0.625rem;
    line-height: 1.5;
    margin: 0 0 0.375rem;
}

.freida-footer-contact__row:last-child {
    margin-bottom: 0;
}

.freida-footer-contact__icon {
    background: currentColor;
    flex: 0 0 auto;
    height: 1.25rem;
    /* Centred on the first line of text. */
    margin-top: 0.125rem;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
    width: 1.25rem;
}

.freida-footer-contact__row a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.freida-footer-contact__row a:hover {
    text-decoration-thickness: 2px;
}

/* Newsletter: a little more compact than the theme's form fields (58px), still
   a comfortable touch target (46px). The arrow button takes the same height. */
.freida-footer-newsletter {
    --form-field-padding-y: 0.625rem;
}

/* Badges ------------------------------------------------------------------ */

/* Logos of any size and number wrap onto as many rows as they need. */
.freida-footer-badges {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.freida-footer-badges__item {
    margin: 0;
}

.freida-footer-extras .freida-footer-badges__item a {
    color: inherit;
    text-decoration: none;
}

.freida-footer-badges__item a,
.freida-footer-badges__item > .freida-footer-badges__image {
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
}

.freida-footer-badges__image {
    height: auto;
    max-height: 3.5rem;
    max-width: 7rem;
    object-fit: contain;
    width: auto;
}

.freida-footer-badges__name {
    font-size: var(--font-size-xs, 0.875rem);
    line-height: 1.3;
    max-width: 7rem;
}

/* Campaign media ----------------------------------------------------------- */

/* As wide as the column on desktop, the content width on phones (capped on
   tablets), always in its own aspect ratio. */
.freida-footer-campaign {
    margin: 0;
    max-width: 40rem;
}

.freida-footer-campaign a {
    display: block;
}

.freida-footer-campaign__media {
    display: block;
    height: auto;
    width: 100%;
}

/* Custom HTML ------------------------------------------------------------- */

/* As wide as the column (or the max width set for it), as tall as what's in
   it. An embed's own width is kept as long as it fits; nothing in it may push
   the page wider, so no sideways scrolling on phones. */
.freida-footer-html {
    max-width: var(--freida-html-max, 100%);
    min-width: 0;
    overflow-wrap: anywhere;
    overflow-x: clip;
    width: 100%;
}

.freida-footer-html :is(iframe, img, video, embed, object, table, div) {
    max-width: 100%;
}

.freida-footer-html :is(img, video) {
    height: auto;
}

/* CTA buttons ------------------------------------------------------------- */

/* The theme's own buttons (.button, .button--outline), a size smaller so the
   two fit side by side in the desktop column; they wrap if they don't. */
.freida-footer-ctas {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.site-footer .freida-footer-ctas .freida-footer-cta {
    --button-padding: 0.75rem 1.25rem;
    font-size: 1rem;
    justify-content: center;
    min-height: 3rem;
    text-align: center;
    text-decoration: none;
}

/* An outlined button in the theme's brown, whatever colour set the footer
   uses; filled brown on hover, as the theme's outlined buttons are. */
.site-footer .freida-footer-ctas .freida-footer-cta--outline {
    --button-border: var(--color-primary);
    --button-text: var(--color-primary);
}

.site-footer .freida-footer-ctas .freida-footer-cta--outline:hover {
    --button-text: var(--color-white, #fff);
    background-color: var(--color-primary);
}

/* Phones: stacked and centred, each its normal size. */
@media (max-width: 781px) {
    .freida-footer-ctas {
        align-items: center;
        flex-direction: column;
        gap: 1rem;
    }
}

/* Touch targets on phones ------------------------------------------------- */

@media (max-width: 781px) {
    /* Phone numbers and email addresses: a taller tap area, same spacing. */
    .freida-footer-contact__row {
        margin: 0;
    }

    .freida-footer-contact__icon {
        margin-top: 0.75rem;
    }

    .freida-footer-contact__row > span {
        padding: 0.625rem 0;
    }

    .freida-footer-contact__row a {
        display: inline-block;
        margin: -0.625rem 0;
        padding: 0.625rem 0;
    }
}

/* Menu accordion on phones ------------------------------------------------ */

.freida-footer-menu__toggle {
    display: none;
}

/* Below the theme's two-column breakpoint the groups stack in one column. */
@media (max-width: 781px) {
    .site-footer .footer-menu:has(.freida-footer-menu__group) {
        gap: 0;
    }

    /* Every group, collapsible or kept open, as a row with a separator. */
    .site-footer .footer-menu:has(.freida-footer-menu__group) > li {
        border-bottom: 1px solid color-mix(in srgb, currentColor 20%, transparent);
        padding: 0.25rem 0;
    }

    .site-footer .footer-menu > .freida-footer-menu__group > a {
        display: none;
    }

    .site-footer .footer-menu > .freida-footer-menu__group > .freida-footer-menu__toggle {
        align-items: center;
        background: none;
        border: 0;
        color: inherit;
        cursor: pointer;
        display: flex;
        font-family: var(--font-family-sans);
        font-size: 1.125rem;
        font-weight: var(--font-weight-bold);
        justify-content: space-between;
        line-height: var(--line-height-md);
        min-height: 3rem;
        padding: 0.25rem 0;
        text-align: left;
        width: 100%;
    }

    /* A chevron, pointing down when closed and up when open. */
    .freida-footer-menu__toggle::after {
        border-bottom: 2px solid currentColor;
        border-right: 2px solid currentColor;
        content: "";
        flex: 0 0 auto;
        height: 0.5rem;
        margin: 0 0.25rem 0.25rem 1rem;
        transform: rotate(45deg);
        transition: transform 0.2s ease;
        width: 0.5rem;
    }

    .freida-footer-menu__group.is-open > .freida-footer-menu__toggle::after {
        margin-bottom: -0.25rem;
        transform: rotate(-135deg);
    }

    .site-footer .footer-menu > .freida-footer-menu__group:not(.is-open) > .sub-menu {
        display: none;
    }

    .site-footer .footer-menu > .freida-footer-menu__group > .sub-menu {
        padding-top: 0.25rem;
    }
}

/*
 * The theme's "inline submit" form style (form CSS class `inline-submit`)
 * hides the submit button and draws a decorative arrow inside the email field,
 * so the only way to send is the Enter key. Turn the arrow into the button,
 * on every form with that class: hide the drawn one, bring the button back to
 * the right of the field, and show it as just the arrow, with a tap target of
 * the field's height. The button's own text stays as its accessible name.
 *
 * The repeated classes outweigh the theme's own selectors for the same
 * elements, whichever stylesheet loads last.
 */
.gform_wrapper.gform_wrapper.inline-submit_wrapper form {
    align-items: start;
    column-gap: 0.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
}

/* Anything else in the form (e.g. the validation summary) takes the full row. */
.gform_wrapper.gform_wrapper.inline-submit_wrapper form > :not(.gform-body):not(.gform-footer) {
    grid-column: 1 / -1;
}

.gform_wrapper.gform_wrapper.inline-submit_wrapper .gform-body .ginput_container::after {
    display: none;
}

.gform_wrapper.gform_wrapper.gform_wrapper.inline-submit_wrapper.inline-submit_wrapper .gform-body .gfield input[type=email] {
    padding-right: var(--form-field-padding-x);
}

.gform_wrapper.gform_wrapper.inline-submit_wrapper .gform-footer {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    padding: 0;
    position: static;
    white-space: normal;
    width: auto;
}

.gform_wrapper.gform_wrapper.gform_wrapper.inline-submit_wrapper .gform-footer .button,
.gform_wrapper.gform_wrapper.gform_wrapper.inline-submit_wrapper .gform-footer .button:hover {
    --button-padding: 0;
    background: none;
    border-color: transparent;
    color: var(--color-heading);
    font-size: 0;
    /* The field's height, so the tap target is as tall as the field. */
    height: calc(1.5rem + 2 * var(--form-field-padding-y, 0.75rem) + 2px);
    width: calc(1.5rem + 2 * var(--form-field-padding-y, 0.75rem) + 2px);
}

.gform_wrapper.gform_wrapper.gform_wrapper.inline-submit_wrapper .gform-footer .button::before {
    background: currentColor;
    content: "";
    height: 1.75rem;
    -webkit-mask: var(--inline-submit-arrow) center / contain no-repeat;
    mask: var(--inline-submit-arrow) center / contain no-repeat;
    transition: transform 0.25s cubic-bezier(.19, 1, .22, 1);
    width: 1.75rem;
}

.gform_wrapper.gform_wrapper.gform_wrapper.inline-submit_wrapper .gform-footer .button:hover::before {
    transform: translateX(0.25rem);
}
