/**
 * Fits the legacy blocks into the epicpools theme: what TheeTheme7 provided around them. Hand-written, loaded after
 * the generated legacy-acfblocks.css.
 */

/*
 * TheeTheme7 Structure/head.php printed the Theme Settings colors as custom properties; the block CSS uses them
 * (buttons, links, hero, cards). Values copied from production (2026-10-29). The font properties were empty there,
 * so they're left undefined.
 */
:root {
    --theme-body-background-color: #ffffff;
    --theme-body-background-color-h: 0;
    --theme-body-background-color-s: 0%;
    --theme-body-background-color-l: 100%;
    --theme-body-background-color-yiq: #000000;
    --theme-body-background-color-yiq-h: 0;
    --theme-body-background-color-yiq-s: 0%;
    --theme-body-background-color-yiq-l: 0%;
    --theme-body-text-color: #363636;
    --theme-body-text-color-h: 0;
    --theme-body-text-color-s: 0%;
    --theme-body-text-color-l: 21%;
    --theme-body-text_alt-color: #949aa4;
    --theme-body-link-color: #38c4ea;
    --theme-body-link-color-h: 193;
    --theme-body-link-color-s: 81%;
    --theme-body-link-color-l: 57%;
    --theme-primary-background-color: #38c4ea;
    --theme-primary-background-color-h: 193;
    --theme-primary-background-color-s: 81%;
    --theme-primary-background-color-l: 57%;
    --theme-primary-background-color-yiq: #000000;
    --theme-primary-text-color: #000000;
    --theme-primary-text-color-h: 0;
    --theme-primary-text-color-s: 0%;
    --theme-primary-text-color-l: 0%;
    --theme-primary-link-color: #000000;
    --theme-secondary-background-color: #4c6783;
    --theme-secondary-background-color-h: 211;
    --theme-secondary-background-color-s: 27%;
    --theme-secondary-background-color-l: 41%;
    --theme-secondary-background-color-yiq: #ffffff;
    --theme-secondary-text-color: #ffffff;
    --theme-secondary-text-color-h: 0;
    --theme-secondary-text-color-s: 0%;
    --theme-secondary-text-color-l: 100%;
    --theme-secondary-link-color: #ffffff;
    --theme-button-border-radius: 3px;
}

/*
 * Widths. epicpools puts every top-level block in the content column (#main-content > *: 720px, auto margins, block
 * gap). TheeTheme7 rendered the hero and CTA blocks outside its page container and everything else inside
 * .container > .row > .col-12 (max 540/720/960px, 1.25rem gutters on both), and .section--full-width broke out of it.
 */
#main-content > :is(.section--acf-block, .section--hero) {
    --legacy-container: 100%;
    width: calc(var(--legacy-container) - 2.5rem);
    margin-block: 0;

    @media (width >= 576px) {
        --legacy-container: 540px;
    }

    @media (width >= 768px) {
        --legacy-container: 720px;
    }

    @media (width >= 992px) {
        --legacy-container: 960px;
    }
}

/*
 * Outside the page container: full width of <main>, no breakout needed. .hero-breadcrumbs is the bar the hero
 * template prints after the <header>.
 */
#main-content > :is(.section--full-width, .section--acf-block-call-to-action, .hero-breadcrumbs) {
    margin-block: 0;
    width: 100%;
    margin-inline: 0;
    left: auto;
    right: auto;
}

/* The same type, height and background as the epicpools/hero breadcrumbs bar. */
.hero-breadcrumbs {
    padding-block: 0.625rem;
    background: var(--wp--preset--color--primary-dark);
    border-block-start: 1px solid color-mix(in srgb, var(--wp--preset--color--white) 20%, transparent);

    .rank-math-breadcrumb p {
        color: var(--wp--preset--color--white);
        font-size: 0.8125rem;

        a {
            color: var(--wp--preset--color--accent);

            &:focus {
                text-decoration: underline;
            }
        }

        .separator {
            opacity: 0.5;
        }
    }
}

/*
 * Headings take the section's text color, as in TheeTheme7 (epicpools colors h1–h6 primary-dark through theme.json),
 * so they stay readable on dark backgrounds.
 */
:is(.section--color-scheme-light, .section--color-scheme-dark) :is(.section__heading, .section__content, .section__footer) :is(h1, h2, h3, h4, h5, h6) {
    color: inherit;
}

/* A hero with a form: the same layout as epicpools/hero with a form. */
.section--hero.section--has-form {
    .container-extended {
        max-width: calc(var(--wp--style--global--wide-size) + 2 * var(--gutter, 1.25rem));
        padding-inline: var(--gutter, 1.25rem);
    }

    .section__content {
        text-align: start;

        > .grid {
            gap: var(--wp--preset--spacing--md);

            @media (width >= 1024px) {
                grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
            }
        }

        .hero-title {
            margin-block: 0 var(--wp--preset--spacing--sm);
            font-size: var(--wp--preset--font-size--xx-large);
            line-height: 1.1;
            text-shadow: none;
        }

        .hero-text-content a {
            border-bottom: 0;
            text-decoration: underline dotted;
            text-underline-offset: 0.2em;

            &:hover,
            &:focus {
                text-decoration-style: solid;
                text-decoration-thickness: 2px;
            }
        }
    }

    &.section--has-background .container-extended {
        padding-block: var(--wp--preset--spacing--md);

        @media (width >= 768px) {
            padding-block: calc(var(--wp--preset--spacing--lg) * 0.8);
        }
    }
}

/*
 * The same navy card as epicpools/hero, on the wrapper: Gravity Forms replaces .gform_wrapper with the confirmation
 * message after an AJAX submit. Its per-form inline <style> sets its colors with an ID selector, so the colors go on
 * the elements. Change this together with epicpools-blocks/src/hero/style.css.
 */
.section--hero .hero-form {
    box-sizing: border-box;
    min-width: 0;
    padding: 1.5rem;
    border-radius: 0.75rem;
    background-color: var(--wp--preset--color--primary-dark);
    color: var(--wp--preset--color--white);
    text-align: start;

    @media (width >= 768px) {
        padding: 2rem;
    }

    /* A deactivated form prints no elements. */
    &:not(:has(*)) {
        display: none;
    }

    .gform_wrapper {
        --gf-form-gap-y: 1.25rem;
        --gf-form-footer-margin-y-start: 1.25rem;
        margin: 0;

        /*
         * The card from the generated CSS. Its backdrop-filter also made the wrapper the containing block of the
         * fixed reCAPTCHA badge, which then hung off the card.
         */
        border-radius: 0;
        background: none;
        box-shadow: none;
        backdrop-filter: none;

        .gform_heading {
            padding: 0;

            .gform_description {
                margin-block: 1em;
            }
        }

        /* The generated CSS makes every label bold. */
        :is(label, .gfield_label) {
            font-weight: var(--gf-local-font-weight);
        }

        /* The dashed underline of links in a color-scheme section. */
        a {
            border-bottom: 0;
        }

        :is(
            .gform-field-label,
            .gfield_label,
            .gform_title,
            .gform_description,
            .gfield_description,
            .gfield_validation_message,
            .gform_confirmation_message
        ) {
            color: var(--wp--preset--color--white);
        }

        .gfield_required {
            color: var(--wp--preset--color--accent);
        }

        /* Its red text is unreadable on the navy. */
        .gform_validation_errors {
            background-color: var(--wp--preset--color--white);
        }

        /* Underlined: the color alone doesn't set it apart from the white text. */
        .gfield_description a {
            color: var(--wp--preset--color--accent);
            text-decoration: underline;
        }

        /* The default focus ring is blue, about 1.7:1 on the navy. */
        .gform_fields,
        .gform_footer {
            --gf-ctrl-outline-color-focus: var(--wp--preset--color--accent);
        }

        .gform_title {
            margin-block: 0 0.5rem;
            font-size: var(--wp--preset--font-size--large);
        }

        /* Forms 7, 8 and 9 mark their short fields with these classes. */
        @media (width >= 600px) {
            .gform_fields .vl-half {
                grid-column: span 6;
            }
        }

        /*
         * The button's own rule is too specific to override, but it reads these vars, and this footer is closer to
         * the button than the inline <style>. In a column, the button stretches to the full width.
         */
        .gform_footer {
            --gf-ctrl-btn-bg-color-primary: var(--wp--preset--color--accent);
            --gf-ctrl-btn-bg-color-hover-primary: var(--wp--preset--color--accent-hover);
            --gf-ctrl-btn-bg-color-focus-primary: var(--wp--preset--color--accent-hover);
            --gf-ctrl-btn-border-color-primary: var(--wp--preset--color--accent);
            --gf-ctrl-btn-border-color-hover-primary: var(--wp--preset--color--accent-hover);
            --gf-ctrl-btn-border-color-focus-primary: var(--wp--preset--color--white);
            --gf-ctrl-btn-color-primary: var(--wp--preset--color--primary-dark);
            --gf-ctrl-btn-color-hover-primary: var(--wp--preset--color--primary-dark);
            --gf-ctrl-btn-color-focus-primary: var(--wp--preset--color--primary-dark);
            display: flex;
            flex-direction: column;
        }
    }
}
