.ssb-cta {

    /*
     * Everything that changes with the background is a token, so a variant
     * is a short list of overrides rather than a second copy of the rules.
     * The default is no color at all: a banner with only a photograph
     * behind it, which is what this block did before the option existed.
     */
    --ssb-cta-surface: transparent;

    /*
     * Dark by default, because with no color and no image the banner is
     * transparent and what shows through is the page. This block used to
     * be light unconditionally, which meant a banner with no image was
     * white text on a white page — invisible. The two dark backgrounds and
     * a background image each flip it back to light below.
     */
    --ssb-cta-fg: var(--color-text);
    --ssb-cta-eyebrow: var(--color-primary);

    /*
     * What sits on top of --ssb-cta-fg: the outline button's label once it
     * fills in on hover. It used to be --ssb-cta-surface, which is right
     * for a flat background and wrong the moment there is a photograph —
     * the surface is then transparent, and a transparent label on a solid
     * white fill is an invisible word.
     */
    --ssb-cta-inverse: var(--color-light);

    /*
     * The primary button, as a pair, so a variant moves the fill and the
     * label together and cannot change one without the other.
     */
    --ssb-cta-button-bg: var(--color-primary);
    --ssb-cta-button-fg: var(--color-on-primary, #ffffff);

    /*
     * How wide the words are allowed to get.
     *
     * The column caps the whole stack so the banner reads as a centered
     * block rather than a line of text as wide as the window. The measure
     * caps the description more tightly still: it is the only part long
     * enough to need it, and a line much past this is one the eye loses
     * its place in on the way back.
     */
    --ssb-cta-column: 56rem;
    --ssb-cta-measure: 65ch;

    /*
     * A banner is a strip, not a section, so it does not take the 100px
     * the generic block padding gives a full section. That plus the
     * heading margin below was most of the gap between this and the
     * mockup.
     */
    --ssb-cta-padding-y: var(--space-xl);

    color: var(--ssb-cta-fg);
}

/* Backgrounds
   ========================================================================== */

.ssb-cta--bg-base {
    --ssb-cta-surface: var(--color-light);
    --ssb-cta-fg: var(--color-text);
    --ssb-cta-eyebrow: var(--color-primary);
    --ssb-cta-inverse: var(--color-light);
}

.ssb-cta--bg-subtle {
    --ssb-cta-surface: var(--color-surface-subtle);
    --ssb-cta-fg: var(--color-text);
    --ssb-cta-eyebrow: var(--color-primary);
    --ssb-cta-inverse: var(--color-surface-subtle);
}

.ssb-cta--bg-primary {
    --ssb-cta-surface: var(--color-primary);
    --ssb-cta-fg: var(--color-light);

    /* On the red there is nowhere for an accent to go: the gold manages
       only 2.1:1 against it. */
    --ssb-cta-eyebrow: var(--color-light);
    --ssb-cta-inverse: var(--color-primary);
}

.ssb-cta--bg-dark {
    --ssb-cta-surface: var(--color-dark);
    --ssb-cta-fg: var(--color-light);

    /* On the charcoal the gold reaches 5.8:1 and reads as the accent. */
    --ssb-cta-eyebrow: var(--color-highlight);
    --ssb-cta-inverse: var(--color-dark);
}

/*
 * A photograph is behind every word in the banner, so it decides the text
 * color whatever else was picked. The chosen color still paints under
 * the image.
 */
.ssb-cta--has-image {
    --ssb-cta-fg: var(--color-light);
    --ssb-cta-eyebrow: var(--color-light);
    --ssb-cta-inverse: var(--color-text);
}

/* Overlay
   --------------------------------------------------------------------------
   A wash of color between the photograph and the words, so the words stay
   readable over a busy picture.

   Each wash is a surface, and every surface in this framework is defined
   next to the text color that belongs on it. So a wash brings its own
   foreground rather than anyone having to check the pairing — including on
   a child theme that repaints Secondary, where a hand-picked text color
   would have gone stale without a word.

   The pairing holds at full strength and loosens as the slider comes down,
   because what is actually behind the text at 30% is part photograph. That
   is what the note on the opacity field is for.
   ========================================================================== */

.ssb-cta__overlay {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: var(--ssb-cta-overlay-opacity, .5);
    pointer-events: none;
}

/*
 * Two classes each, not one.
 *
 * An overlay only exists on a banner that already carries
 * .ssb-cta--has-image, and that rule above sets the same three tokens. At
 * one class apiece these would tie and the winner would be whichever was
 * written last — right today, and quietly wrong the first time someone
 * reorders this file. Pinning the image class into the selector settles it
 * on specificity instead, which no edit can reorder.
 */
.ssb-cta--has-image.ssb-cta--overlay-base {
    --ssb-cta-wash: var(--color-surface, #ffffff);
    --ssb-cta-fg: var(--color-on-surface, var(--color-text));
    --ssb-cta-inverse: var(--color-surface, #ffffff);
}

.ssb-cta--has-image.ssb-cta--overlay-subtle {
    --ssb-cta-wash: var(--color-surface-subtle, #f4f4f5);
    --ssb-cta-fg: var(--color-on-subtle, var(--color-text));
    --ssb-cta-inverse: var(--color-surface-subtle, #f4f4f5);
}

.ssb-cta--has-image.ssb-cta--overlay-primary {
    --ssb-cta-wash: var(--color-primary);
    --ssb-cta-fg: var(--color-on-primary, #ffffff);
    --ssb-cta-inverse: var(--color-primary);
}

/*
 * Not offered in the editor — the accent color is a mid-tone and a
 * mid-tone wash cannot carry a photograph to either end; it measured
 * 2.16, 1.62 and 3.65:1 over a dark, light and mid picture. Kept so a
 * value edited in by hand still paints a wash rather than nothing.
 */
.ssb-cta--has-image.ssb-cta--overlay-secondary {
    --ssb-cta-wash: var(--color-secondary);
    --ssb-cta-fg: var(--color-on-secondary, #ffffff);
    --ssb-cta-inverse: var(--color-secondary);
}

.ssb-cta--has-image.ssb-cta--overlay-dark {
    --ssb-cta-wash: var(--color-surface-dark, var(--color-dark));
    --ssb-cta-fg: var(--color-on-dark, #ffffff);
    --ssb-cta-inverse: var(--color-surface-dark, var(--color-dark));
}

/*
 * The eyebrow follows the wash rather than keeping the brand accent. Over
 * a blend of color and photograph there is no way to know what the accent
 * would measure, and the foreground is the one color the surface pair has
 * already answered for.
 */
.ssb-cta--has-overlay {
    --ssb-cta-eyebrow: var(--ssb-cta-fg);
}

.ssb-cta--has-overlay .ssb-cta__overlay {
    background-color: var(--ssb-cta-wash);
}

/*
 * The content has to sit above the wash rather than under it.
 */
.ssb-cta--has-overlay .ssb-cta__inner {
    position: relative;
    z-index: 1;
}

/* Text Only overlay
   --------------------------------------------------------------------------
   The wash in a panel behind the words instead of over the whole picture.

   The group is the panel. It only exists in this mode, so a banner left
   on Whole Banner has exactly the markup it always had.

   The group takes its own padding, because a wash tight to the text
   reads as a highlighter rather than a panel, and it sizes to its
   content rather than the column -- the point of this mode is that the
   rest of the photograph stays visible.
   ========================================================================== */

.ssb-cta__group {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    align-items: flex-start;
    padding: var(--space-lg);
}

/*
 * Above the wash. The overlay is the group's first child and absolutely
 * placed, so without this the words sit under it.
 */
.ssb-cta--overlay-covers-content .ssb-cta__content,
.ssb-cta--overlay-covers-content .ssb-cta__buttons {
    position: relative;
    z-index: 1;
}

.ssb-cta--overlay-covers-content.ssb-cta--center .ssb-cta__group {
    align-items: center;
    margin-inline: auto;
}

/*
 * Left aligned, the group is the whole of the row rather than one half
 * of a space-between pair: the buttons are inside it now, so there is
 * nothing to push apart.
 */
.ssb-cta--overlay-covers-content.ssb-cta--left .ssb-cta__inner {
    justify-content: flex-start;
}

/* Text
   --------------------------------------------------------------------------
   Named on each element rather than left to inherit. The block editor puts
   rules on bare headings inside its canvas, and an inherited color loses
   to any rule that matches the element itself.
   ========================================================================== */

.ssb-cta .ssb-cta__eyebrow {
    color: var(--ssb-cta-eyebrow);
}

.ssb-cta .ssb-cta__title,
.ssb-cta .ssb-cta__description {
    color: var(--ssb-cta-fg);
}

.ssb-cta .ssb-cta__description a {
    color: inherit;
    text-decoration: underline;
}

/* Buttons
   --------------------------------------------------------------------------
   Both buttons read from the same two tokens the text does, so a variant
   sets the tokens and never touches a button rule. What used to be here
   was six selectors doing that by hand, one pair per background, and it
   covered neither the image case nor an overlay.
   ========================================================================== */

.ssb-cta .btn--primary {
    background: var(--ssb-cta-button-bg);
    color: var(--ssb-cta-button-fg);
}

/*
 * .btn--outline is white wherever else it is used, which vanishes the
 * moment the banner is light. Here it follows the banner.
 */
.ssb-cta .btn--outline {
    color: var(--ssb-cta-fg);
    border-color: currentColor;
}

.ssb-cta .btn--outline:hover,
.ssb-cta .btn--outline:focus-visible {
    background: var(--ssb-cta-fg);
    color: var(--ssb-cta-inverse);
}

/*
 * The brand button turns white anywhere the banner has gone dark, which is
 * what the Form block does and for the same two reasons. On the red it is
 * a button-shaped hole. On the charcoal its edge measures 2.70:1, under
 * the 3:1 WCAG 1.4.11 asks of the boundary of a control — the label reads
 * but the button is hard to find.
 *
 * A photograph is the third case and it was missing: the old rule said
 * :not(.ssb-cta--has-image) on both lines, so a red banner with a picture
 * of a red auditorium on it kept a red button. The whole block already
 * forces its text to white over an image on the grounds that a photograph
 * cannot be measured; the button it sits beside deserves the same answer.
 */
.ssb-cta--bg-primary .btn--primary,
.ssb-cta--bg-dark .btn--primary,
.ssb-cta--has-image .btn--primary {
    --ssb-cta-button-bg: var(--color-light);
    --ssb-cta-button-fg: var(--color-text);
}

/*
 * ...except under a pale wash, where white on near-white would put the
 * hole right back. Two classes, so this lands after the three above
 * whatever the order.
 *
 * The button becomes the exact inverse of the text rather than the brand
 * red, and that is the point: its edge against the banner then measures
 * whatever the text measures, which is the one number the surface pair
 * has already answered for. The brand red was measured here first and
 * came out at 1.52, 2.33 and 2.54:1 against a dark, mid and light
 * photograph under a pale wash — a red button on pink, well under the
 * 3:1 that WCAG 1.4.11 asks of a control's boundary.
 */
.ssb-cta--has-image.ssb-cta--overlay-base .btn--primary,
.ssb-cta--has-image.ssb-cta--overlay-subtle .btn--primary {
    --ssb-cta-button-bg: var(--ssb-cta-fg);
    --ssb-cta-button-fg: var(--ssb-cta-wash);
}

/*
 * ...and the brand red comes back once the wash is wound up far enough
 * to know what is behind the button.
 *
 * The rule above is right while the panel is part photograph — at half
 * strength the red measured 2.51:1 over a black picture, under the 3:1
 * of 1.4.11. It stops being right when the wash is solid: at 80% over
 * that same black picture the red measures 6.16:1 under the white wash
 * and 5.62 under the subtle one, and at 100% it is 9.90 and 9.01. The
 * inverse-of-the-text button was never the goal, only the safe answer
 * when the number could not be known.
 *
 * Whether 80% has been reached is a question about a number, which CSS
 * cannot ask — render.php adds the class.
 *
 * Four classes, so this lands after the two above whatever the order,
 * which is the discipline the overlay rules further up already set out.
 */
.ssb-cta--has-image.ssb-cta--overlay-base.ssb-cta--overlay-opaque .btn--primary,
.ssb-cta--has-image.ssb-cta--overlay-subtle.ssb-cta--overlay-opaque .btn--primary {
    --ssb-cta-button-bg: var(--color-primary);
    --ssb-cta-button-fg: var(--color-on-primary, var(--color-light, #fff));
}

.ssb-cta__background {
    position: relative;
    background-color: var(--ssb-cta-surface);
    background-size: cover;

    /* The image's focal point, from the Media Library. */
    background-position: var(--ssb-cta-focal, center);
}

/* Black and white
   --------------------------------------------------------------------------
   background-blend-mode rather than a filter, the same as the Hero.

   filter: grayscale(1) here would drain the overlay and every word in the
   banner with it -- unlike the Hero, this element is the parent of the
   content, not a sibling. Blending touches only the element's own
   background layers, so the text carries on as it was.

   Luminosity takes the lightness of the top layer and the hue and
   saturation of the bottom one. The bottom layer is this element's
   background-color, which is the chosen surface -- and two of those, the
   red and the gold, have saturation to give. Blended against them the
   photograph came out tinted rather than gray, which is not what the
   option says it does. So the bottom layer is pinned to black here: it
   has no hue or saturation to hand over whatever surface is chosen, and
   the result is the same picture, drained, on every one of them.

   That black would otherwise be what shows where the photograph is not --
   while it loads, or through a transparent PNG -- because the surface is
   painted on this element and nowhere else. So the section takes it too,
   just for this variant: invisible under a photograph that covers it, and
   the right color in the moment before one does.
   ========================================================================== */

.ssb-cta--grayscale {
    background-color: var(--ssb-cta-surface, transparent);
}

.ssb-cta--grayscale .ssb-cta__background {
    background-color: #000000;
    background-blend-mode: luminosity;
}

.ssb-cta--contained .ssb-cta__background {
    max-width: var(--container-width-lg);
    margin: 0 auto;
}

/*
 * The background runs edge to edge; the content does not. Same sum as
 * .container in the design system, so a CTA lines up with every other
 * block on the page rather than sitting 20px wider on each side.
 *
 * This is also what makes Left Aligned work: the text and the buttons are
 * pushed apart by space-between, and without a cap they were pushed to
 * opposite edges of the window.
 */
.ssb-cta__inner {
    box-sizing: border-box;
    max-width: calc(var(--container-width) + var(--block-padding-x) * 2);
    margin-inline: auto;
    padding: var(--ssb-cta-padding-y) var(--block-padding-x);
}

/*
 * Spacing only. The face, size, weight, uppercasing and tracking all come
 * from the theme's .eyebrow class, which the markup now carries alongside
 * this one — the same arrangement as the form and contact blocks. Setting
 * them here as well would tie with .eyebrow on specificity and win on
 * source order, which is how this one drifted out of step in the first
 * place.
 */
.ssb-cta__eyebrow {
    margin-bottom: var(--space-xs);
}

/*
 * margin-top: 0 is the whole reason this banner stood so tall.
 *
 * Only margin-bottom was ever named here, so the top came from the
 * browser's own h2 rule — 0.83em, which at this heading size is around
 * 40px of space nobody asked for, sitting between the eyebrow and the
 * title and unaffected by any token.
 */
.ssb-cta__title {
    margin-top: 0;
    margin-bottom: var(--space-sm);
    font-family: var(--font-heading);
    line-height: var(--line-height-heading);
}

.ssb-cta__description {
    margin-top: 0;
    margin-bottom: var(--space-md);
    font-family: var(--font-body);
    line-height: var(--line-height-body);

    /*
     * The description is the only part long enough to run away from the
     * reader, and the one that did: a single line the full width of the
     * window. This is the measure past which the eye starts missing its
     * place coming back to the left. It also lands the mockup's two lines.
     */
    max-width: var(--ssb-cta-measure);
}

/*
 * The description is a wysiwyg field, so what arrives is wrapped in <p>
 * and brings the browser's 1em top and bottom with it. Those stack onto
 * the margins above and were the other half of the extra height.
 */
.ssb-cta__description > :first-child {
    margin-top: 0;
}

.ssb-cta__description > :last-child {
    margin-bottom: 0;
}

.ssb-cta__buttons {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.ssb-cta--center {
    text-align: center;
}

/*
 * Centered, the stack is a column in the middle of the banner rather than
 * three lines each as wide as they happen to be. Without this the eyebrow
 * and the buttons were centered and the description was not — it simply
 * filled the width, which is what made the banner read as loose.
 */
.ssb-cta--center .ssb-cta__content {
    max-width: var(--ssb-cta-column);
    margin-inline: auto;
}

.ssb-cta--center .ssb-cta__description {
    margin-inline: auto;
}

.ssb-cta--center .ssb-cta__buttons {
    justify-content: center;
}

.ssb-cta--left .ssb-cta__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-xl);
}

.ssb-cta--left .ssb-cta__content {
    max-width: 700px;
}

.ssb-cta--left .ssb-cta__buttons {
    flex-shrink: 0;
}

@media (max-width: 768px) {

    .ssb-cta {
        --ssb-cta-padding-y: var(--space-lg);
    }

    .ssb-cta__inner {
        max-width: calc(var(--container-width) + var(--block-padding-x-mobile) * 2);
        padding:
            var(--ssb-cta-padding-y)
            var(--block-padding-x-mobile);
    }

    .ssb-cta--left .ssb-cta__inner {
        flex-direction: column;
        align-items: flex-start;
    }
}