.ssb-image-text {
    --ssb-image-text-pad: 3rem;
    --ssb-image-text-gap: 4rem;

    padding: var(--ssb-image-text-pad) 0;
}

/*
 * Padding.
 *
 * One token, re-pointed. Three places read it — the band itself, and the
 * content and the grid in the Fill layouts, where the padding moves
 * inside so the picture can reach the band's edges — so a variant that
 * set `padding` directly would have to find all three and would come
 * apart the next time one of them moved.
 *
 * Medium restates the 3rem above rather than leaving the base rule to
 * cover it. They are the same number, but a variant with no rule of its
 * own is one a child theme cannot hang anything on, and the 3rem itself
 * stays in one place for anyone changing it.
 *
 * Small and Large are on the shared spacing scale; 3rem is not, which is
 * why Medium carries a literal. Changing it to --space-xl would make
 * every one of these blocks a third taller on every site at once.
 */
/*
 * 0px, not 0.
 *
 * Both of these tokens are lengths that end up inside min() and calc(),
 * and a bare 0 there is a <number>, not a <length> -- the whole function
 * is invalid and the declaration is thrown away. The collapsed gap below
 * was doing exactly that: min(0, 2rem) never parsed, and None came out
 * at zero only because the rule it was meant to override happened to say
 * zero too. Right answer, no rule behind it.
 */
.ssb-image-text--pad-none {
    --ssb-image-text-pad: 0px;
}

.ssb-image-text--pad-small {
    --ssb-image-text-pad: var(--space-lg, 2rem);
}

.ssb-image-text--pad-medium {
    --ssb-image-text-pad: 3rem;
}

.ssb-image-text--pad-large {
    --ssb-image-text-pad: var(--space-2xl, 6rem);
}


/*
 * Gap.
 *
 * The space *between* the two columns, which Padding is not and never
 * was -- that one is the space above and below, inside the band. The two
 * were asked to do each other's job often enough that the answer is a
 * second control rather than a better sentence in the help text.
 *
 * Medium is 4rem, the single hard-coded value this grid carried before
 * this was a choice, and it is the default for the usual reason: ACF
 * hands a new field's default to every block saved before the field
 * existed, so the only safe default is the one that changes nothing.
 *
 * Collapsed to one column the gap becomes vertical space between the
 * picture and the words. It is capped there rather than ignored -- see
 * the container query further down.
 */
.ssb-image-text--gap-none {
    --ssb-image-text-gap: 0px;
}

.ssb-image-text--gap-small {
    --ssb-image-text-gap: var(--space-lg, 2rem);
}

.ssb-image-text--gap-medium {
    --ssb-image-text-gap: 4rem;
}

.ssb-image-text--gap-large {
    --ssb-image-text-gap: var(--space-2xl, 6rem);
}


/* Fill the space
   --------------------------------------------------------------------------
   "Fill the space" used to mean only that the picture was cropped to its
   cell. The cell was still inside the container and inside the band's
   vertical padding, so a Fill image sat in the middle of the right half
   with the background showing above, below and beside it — which is not
   what filling a space looks like.

   Side by side, Fill now gives the media the whole half: the full height
   of the band, and out to the edge of the window on its own side.

   The band's padding moves onto the text column rather than being
   removed, so the words keep the air they had and only the picture loses
   it. The gap goes with it on the media side for the same reason — a gap
   between the text and a picture that runs to the edge of the window is
   a gap in the wrong place.

   The bleed distance is the space between the grid's edge and the
   window's. Contained, that is half of whatever the window has over the
   container width, with the gutter as the floor on a narrow screen; full
   width, it is just the gutter. max() covers both without the block
   needing to know which it is, and #primary carries overflow-x: clip in
   design-system.css, so the overhang cannot produce a horizontal
   scrollbar.

   Stacked is excluded: above and below there is no half to fill, and the
   gallery and video variants bring their own framing.
   ========================================================================== */

.ssb-image-text--media-image.ssb-image-text--fit-cover:not(.ssb-image-text--stacked) {
    padding-block: 0;
}

.ssb-image-text--media-image.ssb-image-text--fit-cover:not(.ssb-image-text--stacked) .ssb-image-text__content {
    padding-block: var(--ssb-image-text-pad);
}

/*
 * The stretch that used to be here is further down, under "Fill the
 * space", scoped to Match text height.
 *
 * Here it applied to every Fill block whatever its Image Shape, and a
 * stretched grid item has a height handed to it by the row — which is a
 * definite height, so the aspect-ratio on a Square or a 16:9 had nothing
 * left to decide. A Square beside three paragraphs came out 624 by 632.
 *
 * The scoped rule was written as the replacement for this one and this
 * one was never deleted, so for every fixed shape it went on winning on
 * specificity: four classes against the two the alignment rules carry.
 * Nothing about either rule looked wrong on its own.
 */

/*
 * Nothing here sets a height: the media cell is a grid item stretched to
 * the row, and the row is as tall as the text column beside it.
 * min-height keeps it sensible when there is very little text.
 */
.ssb-image-text--media-image.ssb-image-text--fit-cover:not(.ssb-image-text--stacked) .ssb-image-text__media {
    --ssb-image-text-bleed: max(
        var(--block-padding-x, 80px),
        calc((100vw - var(--container-width, 1200px)) / 2)
    );
}

/*
 * Contained only. Full Width has no container to escape — the grid is
 * already at the window's edge — and the negative margin there pushed the
 * picture 200px past it, measured at a 1600px window.
 */
.ssb-image-text--contained.ssb-image-text--media-image.ssb-image-text--fit-cover.ssb-image-text--right .ssb-image-text__media {
    margin-inline-end: calc(var(--ssb-image-text-bleed) * -1);
}

.ssb-image-text--contained.ssb-image-text--media-image.ssb-image-text--fit-cover.ssb-image-text--left .ssb-image-text__media {
    margin-inline-start: calc(var(--ssb-image-text-bleed) * -1);
}

/*
 * Collapsed to one column there is no half to fill, so the bleed goes —
 * and it has to go by the same 800px the grid collapses at, which is a
 * container query on the block's own width rather than the window's. A
 * media query here would have guessed.
 *
 * It was 50px of overhang at 375px: the floor above is the desktop
 * gutter, the container is on the mobile one, and the difference hung off
 * the right-hand edge of the page.
 */
/*
 * No bleed inside a Contained Section.
 *
 * The bleed distance is measured from the window's edge, which holds
 * wherever the block sits in a centered container of the standard width —
 * at the top level, and inside a Full Section, whose inner is exactly
 * that. A Contained Section is not: its band stays in the content column
 * and is inset again by its own gutter, so the sum overshoots and the
 * picture lands past the band but short of the window, which is neither.
 *
 * Six classes, because the rules it overrides carry five and a descendant
 * selector has to clear them.
 */
.ssb-section--contained .ssb-image-text--contained.ssb-image-text--media-image.ssb-image-text--fit-cover.ssb-image-text--right .ssb-image-text__media,
.ssb-section--contained .ssb-image-text--contained.ssb-image-text--media-image.ssb-image-text--fit-cover.ssb-image-text--left .ssb-image-text__media {
    margin-inline: 0;
}

@container (max-width: 800px) {

    /*
     * The same five classes the rules above carry. A container query adds
     * no weight of its own, so a four-class rule in here loses to them and
     * the overhang stays exactly as it was.
     */
    .ssb-image-text--contained.ssb-image-text--media-image.ssb-image-text--fit-cover.ssb-image-text--right .ssb-image-text__media,
    .ssb-image-text--contained.ssb-image-text--media-image.ssb-image-text--fit-cover.ssb-image-text--left .ssb-image-text__media {
        margin-inline: 0;
    }

    /*
     * The air round a Fill band, once it is one column.
     *
     * This used to put padding-block back on the block root, and could
     * never have worked: container-type is on .ssb-image-text__inner, and
     * a container query only reaches that element's descendants. The root
     * is its ancestor, so the rule matched nothing and the band kept the
     * padding-block: 0 that Fill sets at full width -- picture flush to
     * the top edge, buttons flush to the bottom, with a background color
     * making it obvious. The companion rule below it worked all along,
     * because the content column is a descendant.
     *
     * The space goes on the grid instead, which is inside the container
     * and still inside the band, so the background runs behind it.
     */
    .ssb-image-text--media-image.ssb-image-text--fit-cover:not(.ssb-image-text--stacked) .ssb-image-text__grid {
        padding-block: var(--ssb-image-text-pad);
    }

    .ssb-image-text--media-image.ssb-image-text--fit-cover:not(.ssb-image-text--stacked) .ssb-image-text__content {
        padding-block: 0;
    }

    /*
     * Section Height is dropped at this width too, but not from here —
     * the rule it has to beat is further down the file and a container
     * query carries no weight of its own, so a reset written here loses
     * the tie on source order. It is at the end of the Section Height
     * section instead.
     */

}

/*
 * Full Width had no rule of its own anywhere in this stylesheet, so the
 * only thing it did was skip the container — which left the words running
 * into the edge of the window with no gutter at all. The text column gets
 * one here. The picture is meant to reach the edge; the reading is not.
 */
.ssb-image-text--full .ssb-image-text__content {
    padding-inline: var(--block-padding-x, 80px);
}

@media (max-width: 768px) {

    .ssb-image-text--full .ssb-image-text__content {
        padding-inline: var(--block-padding-x-mobile, 30px);
    }

}

/* Backgrounds
   --------------------------------------------------------------------------
   Each surface sets its own text color alongside it, so an unreadable
   pairing is not something the editor can produce. Blocks set a surface and
   never a text color — that is the rule in CLAUDE.md, and this block used
   to break it by taking any hex from a color picker and setting no text
   color at all.

   --color-text and --color-heading are re-pointed for the subtree as well
   as `color`, the way the Section block does it, so the headings, eyebrow
   and anything nested inside follow the band rather than only the
   paragraphs.
   ========================================================================== */

.ssb-image-text--bg-base {
    background-color: var(--color-surface, #fff);
    color: var(--color-on-surface, var(--color-text));
    --color-text: var(--color-on-surface, #333);
    --color-heading: var(--color-on-surface, #333);
}

.ssb-image-text--bg-subtle {
    background-color: var(--color-surface-subtle, #f4f4f5);
    color: var(--color-on-subtle, var(--color-text));
    --color-text: var(--color-on-subtle, #333);
    --color-heading: var(--color-on-subtle, #333);
}

.ssb-image-text--bg-primary {
    background-color: var(--color-primary);
    color: var(--color-on-primary, #fff);
    --color-text: var(--color-on-primary, #fff);
    --color-heading: var(--color-on-primary, #fff);
}

.ssb-image-text--bg-secondary {
    background-color: var(--color-secondary);
    color: var(--color-on-secondary, #fff);
    --color-text: var(--color-on-secondary, #fff);
    --color-heading: var(--color-on-secondary, #fff);
}

.ssb-image-text--bg-dark {
    background-color: var(--color-surface-dark, var(--color-dark));
    color: var(--color-on-dark, #fff);
    --color-text: var(--color-on-dark, #fff);
    --color-heading: var(--color-on-dark, #fff);
}

/* Buttons on a colored band
   --------------------------------------------------------------------------
   A solid brand button on a brand-colored band is a button-shaped hole:
   measured on Granada, .btn--primary on the Primary surface is 1.00:1
   against it, on Secondary 2.14:1 and on Dark 2.70:1. WCAG 1.4.11 asks
   3:1 of a control's boundary against what is next to it, and the first
   of those is not a contrast problem so much as an invisible button.

   So on a colored band the solid button inverts: the fill becomes that
   surface's text color and the label becomes the surface. Those two are
   already a vetted pair — they are what the band draws its own words
   with — so the button inherits a ratio somebody has already checked
   rather than one that needs checking per theme.

   The outline button needs the opposite fix. .btn--secondary is
   transparent with a currentColor border, which follows the band and is
   right; its hover in design-system.css inverts to
   `background: var(--color-text)` with a `--color-light` label, and on a
   dark band --color-text is already light, so hovering it turns a white
   button white-on-white. Here the hover keeps the label and fills behind
   it with the surface instead.

   Two classes, which clears .btn--primary and .btn--secondary wherever
   they are written: design-system.css is one class in the head, and a
   block stylesheet that restyles its own buttons prints later, in the
   body.
   ========================================================================== */

.ssb-image-text--bg-primary .btn--primary {
    background: var(--color-on-primary, #fff);
    color: var(--color-primary);
}

.ssb-image-text--bg-secondary .btn--primary {
    background: var(--color-on-secondary, #fff);
    color: var(--color-secondary);
}

.ssb-image-text--bg-dark .btn--primary {
    background: var(--color-on-dark, #fff);
    color: var(--color-surface-dark, var(--color-dark));
}

.ssb-image-text--bg-primary .btn--secondary:hover,
.ssb-image-text--bg-primary .btn--secondary:focus-visible {
    background: var(--color-primary);
    color: var(--color-on-primary, #fff);
}

.ssb-image-text--bg-secondary .btn--secondary:hover,
.ssb-image-text--bg-secondary .btn--secondary:focus-visible {
    background: var(--color-secondary);
    color: var(--color-on-secondary, #fff);
}

.ssb-image-text--bg-dark .btn--secondary:hover,
.ssb-image-text--bg-dark .btn--secondary:focus-visible {
    background: var(--color-surface-dark, var(--color-dark));
    color: var(--color-on-dark, #fff);
}


.ssb-image-text__grid {
    display: grid;
    gap: var(--ssb-image-text-gap);
}

/*
 * Fractions, not percentages.
 *
 * 40% + 60% is 100% of the grid, and then the gap is added on top -- so
 * the two tracks plus the space between them came to 1264px inside a
 * 1200px grid, and the text column ran 64px past the container's right
 * edge. It never showed as a scrollbar, because #primary carries
 * overflow-x: clip, so the column was simply wider and further right
 * than the ratio said, silently, on every 40/60 and 60/40 block.
 *
 * An fr track is a share of what is left *after* the gap, which is why
 * 50/50 was right all along -- it was the only one written in fr. 2fr/3fr
 * is 40/60 of the remainder and 3fr/2fr is 60/40, and both stay correct
 * whatever the gap is set to.
 *
 * minmax(0, ...) on all six: an fr track will not shrink below the width
 * of its contents, so one long unbroken word or a wide <pre> in the text
 * column would push the layout out again from the other direction.
 */
.ssb-image-text--50-50 .ssb-image-text__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.ssb-image-text--40-60 .ssb-image-text__grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}

.ssb-image-text--60-40 .ssb-image-text__grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

.ssb-image-text--left .ssb-image-text__media {
    order: 1;
}

.ssb-image-text--left .ssb-image-text__content {
    order: 2;
}

.ssb-image-text--right .ssb-image-text__media {
    order: 2;
}

.ssb-image-text--right .ssb-image-text__content {
    order: 1;
}

.ssb-image-text--align-top .ssb-image-text__grid {
    align-items: start;
}

.ssb-image-text--align-center .ssb-image-text__grid {
    align-items: center;
}

.ssb-image-text--align-bottom .ssb-image-text__grid {
    align-items: end;
}

/*
 * height: auto is doing real work here, not tidying up.
 *
 * wp_get_attachment_image() always writes width and height attributes on
 * the <img>, and those map to CSS as presentational hints. Author CSS
 * beats them, so `width: 100%` replaced the width hint — but with no
 * author height, the height hint stood, and the picture rendered at the
 * container's width by its own pixel height. A 2000x1270 seating chart in
 * a 1120px column came out 1120x1270: squashed sideways and stretched
 * down the page.
 *
 * The browser does derive an aspect-ratio from those same two attributes,
 * which is what keeps the shape, but that only applies while the height
 * is auto. Saying so is what switches it on.
 *
 * The Fill rules further down set an explicit height at higher weight, so
 * they are unaffected.
 */
.ssb-image-text__media img,
.ssb-image-text__slide img {
    width: 100%;
    height: auto;
    display: block;
}

/*
 * Natural means the file's own size, up to the width available.
 *
 * `width: 100%` above stretched a single image to the column whatever
 * size had been chosen for it, so Image Size only ever decided which file
 * was downloaded — a Medium picked for a 600px column arrived as 300px of
 * image blown up to 600, which is the setting appearing to do nothing
 * while quietly costing sharpness.
 *
 * max-width keeps a file larger than the column from overflowing it, so
 * the only blocks that move are the ones that were being scaled up.
 *
 * Only the single-image case. A gallery slide is a carousel cell and has
 * to fill the width it is given, or Flickity sizes it to the picture and
 * the slides stop lining up.
 */
.ssb-image-text--media-image.ssb-image-text--fit-natural .ssb-image-text__media > img {
    width: auto;
    max-width: 100%;
}

/*
 * The face, size, weight, uppercase and letter-spacing come from the
 * shared .eyebrow rule in design-system.css, which the markup now also
 * carries. Only the color and the gap are this block's.
 *
 * The color comes from the shared --color-eyebrow rather than a private
 * token. This block used to declare --ssb-image-text-eyebrow and point it
 * at --color-primary, with a comment saying a background variant could
 * move it "the way the CTA block does". There were no background variants
 * — the block took any hex from a color picker — so nothing ever did, and
 * the moment surfaces arrived the eyebrow would have stayed the brand
 * color on a Primary band and 1.72:1 on a Dark one.
 *
 * design-system.css already answers that for every block at once, by
 * setting --color-eyebrow to currentColor on the colored surfaces. Using
 * the shared token means this block gets that for free, and a child theme
 * wanting a different accent on Dark sets one thing rather than two that
 * can disagree.
 *
 * So no color rule here at all: .eyebrow's own
 * `color: var(--color-eyebrow, var(--color-primary))` applies, which is
 * the same color as before on a light surface.
 */
.ssb-image-text__eyebrow {
    margin-bottom: .5rem;
}

.ssb-image-text__title {
    margin-bottom: 1rem;
}

.ssb-image-text__subtitle {
    margin-bottom: 1rem;
}

.ssb-image-text__body {
    margin-bottom: 2rem;
}

.ssb-image-text__buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.ssb-image-text__testimonial blockquote {
    margin: 0 0 1rem;
}

.ssb-image-text__testimonial cite {
    font-style: normal;
}

.ssb-image-text__testimonial cite span {
    display: block;
}

/* Narrow
   --------------------------------------------------------------------------
   Sized against the block's own width, not the window's.

   This matters most in the editor. The block editor is not always in an
   iframe, and when it is not, a media query still measures the whole
   window while the canvas beside the sidebars is far narrower. The result
   is two columns squeezed to half their intended width in the editor and
   one full-width column on the real page at the same measurement. A
   container query asks the block how wide it actually is, so the preview
   and the page agree at any canvas width.

   The !important stays. These rules have to beat the --50-50 / --40-60 /
   --60-40 modifiers, which name two classes apiece; a container query adds
   no specificity of its own, so without it this would come down to source
   order.
   ========================================================================== */

.ssb-image-text__inner {
    container-type: inline-size;
}

/*
 * 800px, not 991px.
 *
 * 991 was collapsing layouts that had no business collapsing. Measured:
 * a block 940px wide — which is an ordinary editor canvas with the
 * settings sidebar open — went to a single 940px column at about 118
 * characters a line. Two columns at that width give 59 and are the
 * easier read, so the rule was not protecting anyone from anything; it
 * was turning a working layout into a worse one and doing it only in the
 * editor, where the canvas is narrower than the page. That is the whole
 * of "it looks different in the backend".
 *
 * 800 is where two columns genuinely stop working: a 50/50 split leaves
 * 368px a side, about 46 characters, which is the bottom of comfortable.
 * Below that they stack.
 */
@container (max-width: 800px) {

    .ssb-image-text__grid {
        grid-template-columns: minmax(0, 1fr) !important;

        /*
         * Capped, not replaced. Stacked, the gap is the space between the
         * picture and the words, and 6rem of it on a phone is a scroll
         * between the two halves of one idea -- but None still has to mean
         * none, which a flat 2rem here did not.
         */
        gap: min(var(--ssb-image-text-gap), 2rem);
    }

    /*
     * Collapsed, the text has the block's whole width, and a line of
     * prose across all of it is hard to track back to the start of the
     * next one. The stacked layouts further down cap their measure for
     * this reason; a collapsed side-by-side needs the same cap.
     */
    .ssb-image-text__content {
        max-width: 68ch;
    }

    /*
     * Only the side-by-side layouts. Their order is a consequence of
     * which side the image is on, and once the columns stack there are no
     * sides left for it to mean anything.
     *
     * Above and Below are different: the editor picked an order outright,
     * and it is just as true at 390px as at 1400px. Unscoped, this reset
     * flipped every "Below" block to media-above on every phone and
     * tablet, and only came right past 992px — so it looked correct to
     * whoever built the page and wrong to most people reading it.
     */
    .ssb-image-text:not(.ssb-image-text--stacked) .ssb-image-text__media,
    .ssb-image-text:not(.ssb-image-text--stacked) .ssb-image-text__content {
        order: initial !important;
    }

}

/*
 * Browsers without container queries keep the old behavior rather than
 * none at all.
 */
@supports not (container-type: inline-size) {

    @media (max-width: 800px) {

        .ssb-image-text__grid {
            grid-template-columns: minmax(0, 1fr) !important;

            /*
             * Capped, not replaced. Stacked, the gap is the space between the
             * picture and the words, and 6rem of it on a phone is a scroll
             * between the two halves of one idea -- but None still has to mean
             * none, which a flat 2rem here did not.
             */
            gap: min(var(--ssb-image-text-gap), 2rem);
        }

        .ssb-image-text__content {
            max-width: 68ch;
        }

        /* Side-by-side only, for the reason given in the block above. */
        .ssb-image-text:not(.ssb-image-text--stacked) .ssb-image-text__media,
        .ssb-image-text:not(.ssb-image-text--stacked) .ssb-image-text__content {
            order: initial !important;
        }

    }

}

/* ==========================================================================
   Media fit

   Natural is the default and unchanged: the picture keeps its own
   proportions and the column is as tall as the image.

   Fill crops the picture to cover its space, anchored to the focal point
   set on the attachment in the Media Library. --ssb-focal is written onto
   each <img> by render.php, so every image in a gallery keeps its own.

   The Natural rule itself is at the top of this file. A second copy sat
   here setting the same two properties to the same values — harmless
   until one of them was edited and the other was not.
   ========================================================================== */


/* Fill the space
   --------------------------------------------------------------------------
   The extra class on the section outranks the --align-* rules above, which
   set align-items on the same element at the same weight.

   Only for "Match text height". That shape has no height of its own — it
   is defined as whatever the words beside it come to — so the two columns
   must stretch to meet, and Top, Center and Bottom have no spare room to
   work in.

   A fixed shape is the opposite: a Square or a 16:9 knows exactly how
   tall it is, the two columns are different heights, and the shorter one
   has somewhere to go. Stretching both was overriding the alignment the
   editor had chosen and pinning the text to the top of a tall row —
   which is what "the vertical alignment does not work" was.
   ========================================================================== */

.ssb-image-text.ssb-image-text--fit-cover.ssb-image-text--ratio-auto .ssb-image-text__grid {
    align-items: stretch;
}

/*
 * Single image: the cell stretches to the row height, which the text
 * column sets, and the picture fills whatever that turns out to be. The
 * min-height stops it collapsing when there is very little text.
 */
.ssb-image-text--media-image.ssb-image-text--fit-cover .ssb-image-text__media {
    position: relative;
    min-height: var(--ssb-image-text-fill-h, 320px);
}


/* Section Height
   --------------------------------------------------------------------------
   A floor under the band, not a height. The grid can always grow past it,
   so a long paragraph or a reader at 200% zoom makes the band taller
   rather than running out of it — a fixed height here would clip the
   words, and the point of the control is the opposite case: a short
   paragraph leaving the picture stunted.

   320px is the floor Auto has always had, so a block that does not choose
   is unchanged.

   100svh rather than 100vh for Full Screen: on a phone 100vh is the
   window with the address bar hidden, which is taller than what is
   actually on screen when the page loads.
   ========================================================================== */

.ssb-image-text--fill-h-medium {
    --ssb-image-text-fill-h: 480px;
}

.ssb-image-text--fill-h-tall {
    --ssb-image-text-fill-h: 640px;
}

.ssb-image-text--fill-h-screen {
    --ssb-image-text-fill-h: 100vh;
    --ssb-image-text-fill-h: 100svh;
}

.ssb-image-text--fit-cover .ssb-image-text__grid {
    min-height: var(--ssb-image-text-fill-h, auto);
}

/*
 * The words, now that there is room under them to move in.
 *
 * The grid has to stay stretched or the picture stops filling, so the
 * alignment goes on the text cell with align-self. Without this the text
 * cell stretches too and the words pin to the top of a tall band, which
 * is the same fault the Fill section above describes for fixed shapes.
 *
 * Scoped away from Auto rather than applied to every Fill block: at Auto
 * the row is the text's own height, so this would be invisible in almost
 * every case and would quietly recenter the few blocks whose text runs
 * shorter than the 320px floor.
 */
.ssb-image-text--fit-cover:not(.ssb-image-text--fill-h-auto) .ssb-image-text__content {
    align-self: center;
}

.ssb-image-text--fit-cover:not(.ssb-image-text--fill-h-auto).ssb-image-text--align-top .ssb-image-text__content {
    align-self: start;
}

.ssb-image-text--fit-cover:not(.ssb-image-text--fill-h-auto).ssb-image-text--align-bottom .ssb-image-text__content {
    align-self: end;
}

/*
 * One column, so the floor goes.
 *
 * It is not holding a picture up beside the words any more, it is empty
 * space under a stack that is already tall enough — and Full Screen on a
 * phone would be a screenful of background before anyone reached the
 * text. The picture keeps the floor the block has always given it at this
 * width.
 *
 * This sits at the end of the section on purpose. The rule it overrides
 * has the same two classes and a container query adds no weight of its
 * own, so the two tie and source order decides. Written up with the other
 * mobile rules — which come earlier in the file — it would lose, which is
 * exactly what it did on the first pass: 640px of band on a 375px phone.
 */
@container (max-width: 800px) {

    .ssb-image-text--fit-cover .ssb-image-text__grid {
        min-height: 0;
    }

}

.ssb-image-text--media-image.ssb-image-text--fit-cover .ssb-image-text__media > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--ssb-focal, center center);
}

/*
 * Gallery: each slide is its own box, so the shape comes from the ratio
 * rather than from the row.
 */
/*
 * width is what stops the slides vanishing a moment after the page
 * settles.
 *
 * Flickity's Cell.create() puts every cell at position: absolute. An
 * absolutely positioned box with no width of its own shrink-wraps to its
 * in-flow content -- and under Fill the only child is the image, which
 * this block takes out of flow two rules down. So the cell measured 0
 * wide, the aspect-ratio turned that into 0 tall, and setGallerySize()
 * wrote height: 0 onto the viewport. The pictures showed while the markup
 * was still plain and disappeared the moment Flickity took over.
 *
 * Natural was unaffected: there the image stays in flow, so the cell has
 * something to shrink-wrap to.
 */
.ssb-image-text--media-gallery.ssb-image-text--fit-cover .ssb-image-text__slide {
    position: relative;
    width: 100%;
}

.ssb-image-text--media-gallery.ssb-image-text--fit-cover .ssb-image-text__slide img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--ssb-focal, center center);
}


/* Fixed shapes
   --------------------------------------------------------------------------
   A ratio replaces the row-height behavior, so min-height goes back to 0.

   max-width matters as much as the ratio. A box with both a ratio and a
   minimum height will satisfy the minimum by growing WIDER — a 16:9 box
   held to 240px tall works out 427px across, which on a 390px phone ran
   off the side of the page and took the whole document with it. Capped
   here, the width wins and the height is whatever the ratio makes it.
   ========================================================================== */

.ssb-image-text--fit-cover.ssb-image-text--ratio-16-9 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-16-9 .ssb-image-text__slide,
.ssb-image-text--fit-cover.ssb-image-text--ratio-4-3 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-4-3 .ssb-image-text__slide,
.ssb-image-text--fit-cover.ssb-image-text--ratio-1-1 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-1-1 .ssb-image-text__slide,
.ssb-image-text--fit-cover.ssb-image-text--ratio-3-4 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-3-4 .ssb-image-text__slide {
    max-width: 100%;
}

.ssb-image-text--fit-cover.ssb-image-text--ratio-16-9 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-16-9 .ssb-image-text__slide {
    aspect-ratio: 16 / 9;
    min-height: 0;
}

.ssb-image-text--fit-cover.ssb-image-text--ratio-4-3 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-4-3 .ssb-image-text__slide {
    aspect-ratio: 4 / 3;
    min-height: 0;
}

.ssb-image-text--fit-cover.ssb-image-text--ratio-1-1 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-1-1 .ssb-image-text__slide {
    aspect-ratio: 1 / 1;
    min-height: 0;
}

.ssb-image-text--fit-cover.ssb-image-text--ratio-3-4 .ssb-image-text__media,
.ssb-image-text--fit-cover.ssb-image-text--ratio-3-4 .ssb-image-text__slide {
    aspect-ratio: 3 / 4;
    min-height: 0;
}

/*
 * A gallery has no media wrapper of its own to shape — the slides carry
 * the ratio — so the wrapper is left alone.
 */
.ssb-image-text--media-gallery.ssb-image-text--fit-cover .ssb-image-text__media {
    aspect-ratio: auto;
}


/* Stacked
   ========================================================================== */

/*
 * Only "Match text height" wants a floor on a phone. Stacked, there is no
 * text column to take the height from, so without one the picture can
 * collapse to almost nothing.
 *
 * Naming the ratio here is what keeps it to that case. Written as plain
 * `.fit-cover .media` it weighed exactly the same as the `min-height: 0`
 * in each fixed-shape rule above and, being further down the file, won —
 * putting the floor back on shapes that had deliberately dropped it, and
 * pushing a 16:9 box out to 427px on a 390px screen.
 */
@media (max-width: 768px) {

    .ssb-image-text--media-image.ssb-image-text--fit-cover.ssb-image-text--ratio-auto .ssb-image-text__media {
        min-height: 240px;
    }

}


/* ==========================================================================
   Additional content

   A "read more" button under the text that opens the overflow copy in a
   dialog, so a long passage does not stretch the block.
   ========================================================================== */

.ssb-image-text__more {
    margin-top: var(--space-md);
}

/*
 * The button sits with the other buttons, so it needs no width of its own
 * — .btn handles the rest.
 */
.ssb-image-text__more-button {
    cursor: pointer;
}


/* Dialog
   ========================================================================== */

.ssb-image-text__modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
}

/*
 * Written with the class attached so it always outranks the base rule,
 * whatever order the stylesheets end up in.
 */
.ssb-image-text__modal[hidden] {
    display: none;
}

/*
 * Never in the editor, whatever state the markup is in.
 *
 * view.js no longer wires the trigger there, so nothing should be able
 * to open this — but an `inset: 0` element loose on the editor canvas
 * covers every block on the page and takes the editor with it, and that
 * is too expensive a failure to leave resting on one guard in one
 * script. The canvas carries .editor-styles-wrapper whether or not it
 * is iframed, and nothing on the front end carries it.
 */
.editor-styles-wrapper .ssb-image-text__modal {
    display: none;
}

.ssb-image-text__modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    opacity: 0;
    transition: opacity var(--transition-fast, .2s ease);
}

.ssb-image-text__modal.is-open .ssb-image-text__modal-backdrop {
    opacity: 1;
}

.ssb-image-text__modal-panel {
    position: relative;
    box-sizing: border-box;
    width: min(100%, 680px);
    max-height: 85vh;

    /*
     * Long copy scrolls inside the panel. overflow makes this a scrollable
     * region, which has to be reachable by keyboard — view.js puts focus
     * on the panel when it opens, which satisfies that.
     */
    overflow-y: auto;

    padding: var(--space-xl);
    background: var(--color-light);
    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity var(--transition-fast, .2s ease),
        transform var(--transition-fast, .2s ease);
}

.ssb-image-text__modal.is-open .ssb-image-text__modal-panel {
    opacity: 1;
    transform: translateY(0);
}

.ssb-image-text__modal-panel:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -4px;
}

.ssb-image-text__modal-close {
    position: absolute;
    top: var(--space-xs);
    right: var(--space-xs);
    box-sizing: border-box;

    /* 44px, so it clears the WCAG 2.5.8 target size on touch. */
    width: 44px;
    height: 44px;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: 0;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--color-text);
    cursor: pointer;
}

.ssb-image-text__modal-close:hover,
.ssb-image-text__modal-close:focus-visible {
    color: var(--color-primary);
}

.ssb-image-text__modal-title {
    margin: 0 0 var(--space-sm);

    /* Clear of the close button. */
    padding-right: var(--space-xl);
}

.ssb-image-text__modal-body > :first-child {
    margin-top: 0;
}

.ssb-image-text__modal-body > :last-child {
    margin-bottom: 0;
}

/*
 * Stops the page scrolling behind the dialog.
 */
body.ssb-modal-open {
    overflow: hidden;
}

@media (max-width: 768px) {

    .ssb-image-text__modal-panel {
        padding: var(--space-lg) var(--space-md);
        max-height: 90vh;
    }

}

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

    .ssb-image-text__modal-backdrop,
    .ssb-image-text__modal-panel {
        transition: none;
    }

}


/* ==========================================================================
   Video
   --------------------------------------------------------------------------
   The still and a play button, wrapped in a plain link to the video. The
   theme's lightbox (state-street-core/assets/js/video-lightbox.js) picks
   the link up and opens it in the shared dialog, so nothing is requested
   from YouTube or Vimeo until somebody presses play. With JavaScript off
   the link simply goes to the video.
   ========================================================================== */

.ssb-image-text__video {
    position: relative;
    display: block;
    color: inherit;
    text-decoration: none;

    /* The still is the target, so the whole of it has to be clickable —
       far past the 44px of WCAG 2.5.8. */
    line-height: 0;
}

.ssb-image-text__video:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
}

/* Stands in for the still when none was uploaded. */
.ssb-image-text__video-plate {
    display: block;
    aspect-ratio: 16 / 9;
    width: 100%;
    background: var(--color-dark);
}

.ssb-image-text__video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    translate: -50% -50%;

    display: grid;
    place-items: center;

    width: 72px;
    height: 72px;
    border-radius: 50%;

    background: var(--color-primary);

    transition:
        transform var(--transition-fast, .2s ease),
        background-color var(--transition-fast, .2s ease);
}

/* The triangle. Drawn with borders so there is no image to load and
   nothing to go missing. */
.ssb-image-text__video-play::after {
    content: "";
    border-left: 20px solid var(--color-light, #fff);
    border-block: 12px solid transparent;

    /* Optically centered: a triangle's visual center sits left of its box. */
    margin-left: 5px;
}

.ssb-image-text__video:hover .ssb-image-text__video-play {
    transform: scale(1.06);
}

/*
 * A still is usually busy, so the button needs an edge of its own against
 * whatever is behind it — WCAG 1.4.11 wants 3:1 for a control, and no
 * single color can promise that over an arbitrary photograph.
 */
.ssb-image-text__video-play {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .9);
}

@media (max-width: 768px) {

    .ssb-image-text__video-play {
        width: 56px;
        height: 56px;
    }

    .ssb-image-text__video-play::after {
        border-left-width: 16px;
        border-block-width: 10px;
        margin-left: 4px;
    }

}

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

    .ssb-image-text__video-play {
        transition: none;
    }

    .ssb-image-text__video:hover .ssb-image-text__video-play {
        transform: none;
    }

}


/* ==========================================================================
   Stacked — media above or below the text
   --------------------------------------------------------------------------
   One column. The split ratio and vertical alignment classes are not
   printed in this mode, so nothing here has to undo them.
   ========================================================================== */

.ssb-image-text--stacked .ssb-image-text__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
}

.ssb-image-text--top .ssb-image-text__media {
    order: 1;
}

.ssb-image-text--top .ssb-image-text__content {
    order: 2;
}

.ssb-image-text--bottom .ssb-image-text__media {
    order: 2;
}

.ssb-image-text--bottom .ssb-image-text__content {
    order: 1;
}

/*
 * The media runs the full width; the text does not. A line of prose across
 * 1200px is hard to track back to the start of the next line, so the
 * measure is capped while the picture keeps the room.
 */
.ssb-image-text--stacked .ssb-image-text__content {
    max-width: 68ch;
}

/*
 * Buttons sit under the text rather than beside the picture here, so they
 * get a little more room above them.
 */
.ssb-image-text--stacked .ssb-image-text__buttons {
    margin-top: 1.5rem;
}


/* Enlarge Images on Click
   --------------------------------------------------------------------------
   The gallery slides, when the block is set to open them full size. Same
   affordance as the Services cards -- a zoom-in cursor and a magnifier in
   the corner -- so the two behave alike wherever they meet on a page.
   ========================================================================== */

.ssb-image-text__zoom {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;

    /* A button now, matching the Gallery's trigger, so it needs the reset. */
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: inherit;
    cursor: zoom-in;
}

.ssb-image-text__zoom-icon {
    position: absolute;
    right: .75rem;
    bottom: .75rem;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, .65);
    opacity: 0;
    transition: opacity var(--transition-fast, .2s);
}

/* The glass: a ring and a handle. */
.ssb-image-text__zoom-icon::before {
    content: "";
    position: absolute;
    top: .55rem;
    left: .55rem;
    width: .75rem;
    height: .75rem;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.ssb-image-text__zoom-icon::after {
    content: "";
    position: absolute;
    right: .6rem;
    bottom: .6rem;
    width: .45rem;
    height: 2px;
    background: #ffffff;
    transform: rotate(45deg);
    transform-origin: right center;
}

/*
 * Shown on hover and on keyboard focus both. A touch screen has no hover
 * at all, so it stays visible there -- an affordance only mouse users
 * ever see is not one.
 */
.ssb-image-text__zoom:hover .ssb-image-text__zoom-icon,
.ssb-image-text__zoom:focus-visible .ssb-image-text__zoom-icon {
    opacity: 1;
}

@media (hover: none) {

    .ssb-image-text__zoom-icon {
        opacity: 1;
    }

}

.ssb-image-text__zoom:focus-visible {
    outline: 3px solid var(--color-primary, currentColor);
    outline-offset: 2px;
}

/*
 * Under Fill the slide's image is taken out of flow, so the link that now
 * wraps it needs the same treatment or it collapses the way the cell did
 * before it was given a width.
 */
.ssb-image-text--media-gallery.ssb-image-text--fit-cover .ssb-image-text__zoom {
    position: absolute;
    inset: 0;
}


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

    .ssb-image-text__zoom-icon {
        transition: none;
    }

}


/* Gallery before the carousel starts, in the editor
   --------------------------------------------------------------------------
   Flickity adds .flickity-enabled to the element it takes over. Until then
   the slides are ordinary block-level divs, so they stack -- which is what
   the editor showed when a preview was drawn before it could be measured.

   The ancestor class only exists in the block editor, so this is scoped to
   it on purpose: on the front end without JavaScript a stack of images is
   the right thing to fall back to, and hiding all but the first there
   would quietly drop the rest of the gallery.
   ========================================================================== */

.block-editor-block-list__layout
.ssb-image-text__gallery:not(.flickity-enabled)
.ssb-image-text__slide:not(:first-child) {
    display: none;
}


/* Gallery arrows
   --------------------------------------------------------------------------
   Flickity draws round arrows of its own. These are the Gallery block's --
   a square outline with a small chevron -- so a carousel reads the same
   wherever it appears, which is also why the shape is written out rather
   than inherited: the two blocks use different carousels underneath.
   ========================================================================== */

.ssb-image-text__gallery .flickity-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: 1px solid currentColor;
    border-radius: 0;
    box-shadow: none;
    color: inherit;
    transform: none;
    transition:
        background-color var(--transition-fast, .2s),
        border-color var(--transition-fast, .2s),
        color var(--transition-fast, .2s),
        opacity var(--transition-fast, .2s);
}

.ssb-image-text__gallery .flickity-button:hover:not(:disabled),
.ssb-image-text__gallery .flickity-button:focus-visible {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-light);
}

.ssb-image-text__gallery .flickity-button:disabled {
    opacity: .3;
    cursor: default;
}

/*
 * Flickity centers its buttons on the slide with a translate. The shape
 * above drops that, so the vertical centering is put back here rather than
 * left to the transform the reset removed.
 */
.ssb-image-text__gallery .flickity-prev-next-button {
    top: 50%;
    margin-top: -22px;
}

.ssb-image-text__gallery .flickity-prev-next-button.previous {
    left: var(--space-sm, 1rem);
}

.ssb-image-text__gallery .flickity-prev-next-button.next {
    right: var(--space-sm, 1rem);
}

/* Flickity's chevron is an SVG; this is the small one the Gallery uses. */
.ssb-image-text__gallery .flickity-button-icon {
    position: static;
    width: 40%;
    height: 40%;
    fill: currentColor;
}
