/*
Theme Name:  CMG Kadence 2026
Template:    kadence
Description: CMG child theme for Pumps & Systems, based on Kadence.
Version:     1.0.0
Author:      Cahaba Media Group
*/

/* cmg-gradient-overlay — bottom-to-top dark gradient on Kadence imageoverlay cards.
   Kadence sets opacity:0 on .kt-image-overlay-color-wrapper via scoped block CSS;
   we override that and hide the solid color layer so only our gradient shows. */
.cmg-gradient-overlay .kt-image-overlay-color-wrapper {
    opacity: 1 !important;
}
.cmg-gradient-overlay .kt-image-overlay-color {
    display: none;
}
.cmg-gradient-overlay .kt-image-overlay-color-wrapper::before,
.cmg-gradient-overlay .kt-image-overlay-color-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}
.cmg-gradient-overlay .kt-image-overlay-color-wrapper::before {
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.80) 0px,
        rgba(0, 0, 0, 0.65) 40px,
        rgba(0, 0, 0, 0.35) 110px,
        rgba(0, 0, 0, 0.10) 190px,
        transparent 270px
    );
}
.cmg-gradient-overlay .kt-image-overlay-color-wrapper::after {
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.90) 0px,
        rgba(0, 0, 0, 0.80) 60px,
        rgba(0, 0, 0, 0.50) 140px,
        rgba(0, 0, 0, 0.15) 220px,
        transparent 310px
    );
    opacity: 0;
    transition: opacity 0.5s ease;
}
.cmg-gradient-overlay:hover .kt-image-overlay-color-wrapper::after {
    opacity: 1;
}

/* cmg-hover-reveal — headline always shown, subtitle slides in on hover.
   Overrides Kadence's default translate3d hiding (style-blocks-imageoverlay.css).
   The subtitle collapses to zero height so every headline sits at the same
   bottom position whatever the subhead length. These rules also sit in the
   homepage hero column's custom CSS; they live here too so the cards don't
   depend on that page content (an environment with a damaged copy of it
   showed a gap above the headline and empty space below it). */
.cmg-hover-reveal .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-title {
    transform: none;
    transition: transform 0.6s ease;
}
.cmg-hover-reveal .kt-image-overlay-wrap:is(:hover, :focus-within) .kt-image-overlay-message .image-overlay-title {
    transform: translateY(-0.25em);
}
.cmg-hover-reveal .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-subtitle {
    transform: none !important;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition:
        max-height 0.6s ease,
        opacity 0.6s ease,
        margin-top 0.6s ease;
}
.cmg-hover-reveal .kt-image-overlay-wrap:is(:hover, :focus-within) .kt-image-overlay-message .image-overlay-subtitle {
    max-height: 10em;
    opacity: 1;
    margin-top: 0.5em;
}

/* Hero image — a fixed box at every breakpoint: 2:1 desktop, 16:9 tablet, 3:2 mobile
   (the homepage lead stays 16:9 on phones too, as on gp26; see "Homepage hero image
   cards" below) (the ratios set on the hero Image Card, whose "Use ratio size" must stay OFF: the
   absence of kt-over-set-ratio is how this rule and cmg_thumbnail_override() tell the
   hero from grid cards).
   With a dynamic featured image Kadence ignores the card's fixed size and writes
   .kt-img-overlay{blockId}{postId} .kt-image-overlay-wrap .kt-block-intrisic { padding-bottom: <image h/w> }
   per post, so the hero took each lead image's own shape (78% for a 768x600 photo).
   aspect-ratio loses to padding-bottom+height:0, so padding-bottom is overridden
   directly with !important, and the image covers the box. */
.kb-query-item .kt-image-overlay-wrap .kt-block-intrisic:not(.kt-over-set-ratio) {
    padding-bottom: 50% !important;
}
.kb-query-item .kt-block-intrisic:not(.kt-over-set-ratio) img.kt-img-overlay {
    height: 100%;
    object-fit: cover;
}
/* cmg_thumbnail_override() wraps the hero <img> in <picture>, so Kadence's
   `.kt-block-intrisic > img` rules (absolute position, hover zoom) no longer match.
   Without position:absolute the height:100% above resolves to 0 and the image vanishes. */
.kt-block-intrisic > picture > img.kt-img-overlay {
    position: absolute;
    top: 0;
    left: 0;
}
.kt-image-overlay-wrap.kt-over-image-zoomin .kt-block-intrisic > picture > img {
    transform: scale(1);
    transition: transform .35s ease-in-out;
}
.kt-image-overlay-wrap.kt-over-image-zoomin:is(:hover, :focus-within) .kt-block-intrisic > picture > img {
    transform: scale(1.05);
}
@media (max-width: 1024px) {
    .kb-query-item .kt-image-overlay-wrap .kt-block-intrisic:not(.kt-over-set-ratio) {
        padding-bottom: 56.25% !important;
    }
}
@media (max-width: 767px) {
    .kb-query-item .kt-image-overlay-wrap .kt-block-intrisic:not(.kt-over-set-ratio) {
        padding-bottom: 66.67% !important;
    }
}

/* Sponsor badge — overlay hero cards (Image Card, Image Card Pair) */
.kb-query-item {
    position: relative;
}

.kb-query-item .cmg-sponsor-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.65);
    color: #fff !important;
    padding: 3px 10px;
    font-size: 11px !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 2px;
    pointer-events: none;
    margin: 0 !important;
    line-height: 1.6;
}

/* Homepage: Popular Topics intro (bordered lead-in) */
.gp26_pt_intro {
    max-width: 68ch;
    margin: 0 0 40px;
    padding: 4px 0 4px 20px;
    border-left: 4px solid var(--global-palette1);
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--global-palette5);
}

/* Homepage section header: title | short vertical rule | intro. Stacks on mobile. */
.cmg-section-head {
  align-items: center;
  gap: var(--global-kb-spacing-sm, 1.5rem);
  margin-bottom: var(--global-kb-spacing-lg, 2.5rem);
}
.cmg-section-head > .wp-block-kadence-advancedheading { margin: 0 !important; max-width: none; }
.cmg-section-head > h2.wp-block-kadence-advancedheading {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: var(--global-kb-spacing-sm, 1.5rem);
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.cmg-section-head > h2.wp-block-kadence-advancedheading::after {
  content: "";
  width: 2px;
  height: 2.5rem;
  background: var(--global-palette1);
}
.cmg-section-head > p.wp-block-kadence-advancedheading { flex: 1 1 0; min-width: 0; }
@media (max-width: 781px) {
  .cmg-section-head { flex-direction: column; align-items: flex-start; gap: var(--global-kb-spacing-xs, 1rem); }
  .cmg-section-head > h2.wp-block-kadence-advancedheading::after { display: none; }
}

/* Sponsored single without a gate form: the sidebar keeps a sponsor card (logo,
   byline, who provides it, optional link). See cmg_gate_form_placeholder() in
   functions.php. */
.cmg-cg-sponsor-card .cmg-cg-sponsor-logo,
.cmg-cg-has-logo > .cmg-cg-sponsor-logo { display: block; margin: 0 0 1em; }
.cmg-cg-sponsor-card .cmg-cg-download-intro { margin-bottom: 0; }
.cmg-cg-sponsor-card .cmg-cg-sponsor-visit { margin: 1em 0 0; font-weight: 600; }

/* Homepage Products carousel. A Kadence query block with the "cmg-carousel"
   class scrolls sideways instead of wrapping; js/cmg-carousel.js adds the
   prev/next arrows. Without JS the row still scrolls by swipe/trackpad. */
.cmg-carousel { position: relative; --cmg-carousel-gap: 1.5rem; --cmg-carousel-per-view: 4; }
.cmg-carousel .kb-query-grid-wrap.kb-query-grid-wrap {
  display: flex;
  /* !important: the query card's own inline CSS sets column-gap with equal
     specificity, and the card widths below depend on this gap. */
  gap: var(--cmg-carousel-gap) !important;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.cmg-carousel .kb-query-grid-wrap::-webkit-scrollbar { display: none; }
.cmg-carousel .kb-query-grid-wrap > .kb-query-item {
  flex: 0 0 calc((100% - (var(--cmg-carousel-per-view) - 1) * var(--cmg-carousel-gap)) / var(--cmg-carousel-per-view));
  min-width: 0;
  padding-bottom: var(--global-kb-spacing-xs, 1rem);
  scroll-snap-align: start;
}
@media (max-width: 1280px) { .cmg-carousel { --cmg-carousel-per-view: 3; } }
@media (max-width: 1024px) { .cmg-carousel { --cmg-carousel-per-view: 2.3; --cmg-carousel-gap: 1rem; } }
@media (max-width: 767px)  { .cmg-carousel { --cmg-carousel-per-view: 1.6; } }

.cmg-carousel-btn {
  position: absolute;
  top: var(--cmg-carousel-arrow-top, 30%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--global-palette7, #dee2e6);
  border-radius: 50%;
  background: var(--global-palette9, #fff);
  color: var(--global-palette3, #1a202c);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transform: translateY(-50%);
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}
.cmg-carousel-btn:hover,
.cmg-carousel-btn:focus-visible { background: var(--global-palette1, #12bfb8); border-color: var(--global-palette1, #12bfb8); color: #fff; }
.cmg-carousel-btn[disabled] { opacity: 0; pointer-events: none; }
.cmg-carousel-btn svg { width: 20px; height: 20px; }
.cmg-carousel-prev { left: -20px; }
.cmg-carousel-next { right: -20px; }
@media (max-width: 767px) { .cmg-carousel-btn { display: none; } }

/* Clamp a card description to two lines. */
.cmg-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* News images that don't suit a cover crop (small, or the wrong shape) are shown
   whole, never above their own size (--cmg-fi-w/-h), over a blurred copy of
   themselves (--blur), or on a flat panel when they have transparent areas
   (--flat). Classes are added in functions.php (cmg_news_image_treatment). */
.cmg-image-backdrop {
    position: absolute;
    inset: -48px;
    background-size: cover;
    background-position: center;
    filter: blur(24px) brightness(.85) saturate(1.15);
}

/* News single: 16:9 Kadence image block. Sets its own aspect ratio rather than
   relying on Kadence's padding-bottom box, since the image is taken out of flow. */
.cmg-featured-image--contain .kb-is-ratio-image {
    position: relative;
    height: auto;
    padding-bottom: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: inherit;
    background: var(--global-palette7);
}
.cmg-featured-image--contain .kb-is-ratio-image img.kb-img {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: auto;
    min-width: 0;
    width: min(100%, var(--cmg-fi-w));
    height: min(100%, var(--cmg-fi-h));
    object-fit: contain;
}
.cmg-featured-image--flat .kb-is-ratio-image {
    background: var(--global-palette8);
}
.cmg-featured-image--flat .kb-is-ratio-image img.kb-img {
    width: min(88%, var(--cmg-fi-w));
    height: min(80%, var(--cmg-fi-h));
}

/* ── Mobile/tablet menu drawer (as on gp26) ─────────────────────────────────
   The drawer (below the 1280px header switch) reuses the desktop mega-menu
   Elements. Their panel chrome, label sizes and hidden parts are set on each
   Element's tablet/mobile tabs in Kadence; this covers only what Kadence has
   no responsive option for. */
#mobile-drawer .mobile-navigation ul.sub-menu {
    padding-left: 0;
}
#mobile-drawer .sub-menu > li {
    padding: 0 0 12px 12px;
    margin: 0;
}
/* The drawer's divider goes under an open section's items, not its title. */
#mobile-drawer .mobile-menu-container > ul.menu > li:has(> .sub-menu.show-drawer) > .drawer-nav-drop-wrap {
    border-bottom-color: transparent;
}
#mobile-drawer .mobile-menu-container > ul.menu > li:has(> .sub-menu.show-drawer) > .drawer-nav-drop-wrap > a {
    padding-bottom: 12px;
}
#mobile-drawer .mobile-menu-container > ul.menu > li > .sub-menu.show-drawer {
    border-bottom: 1px solid var(--global-palette7);
}
/* Link lists: no per-link divider (Kadence's drawer adds one to every link),
   no desktop link padding or negative margin. */
#mobile-drawer .sub-menu .wp-block-kadence-navigation .kb-navigation.menu {
    margin: 0 !important;
    padding: 0;
}
#mobile-drawer .sub-menu .kb-navigation.menu > li {
    border: 0;
}
#mobile-drawer .sub-menu .kb-navigation.menu > li > .kb-link-wrap > a,
#mobile-drawer .sub-menu .kb-navigation.menu > li > a {
    padding: 9px 0 !important;
    border: 0 !important;
}
/* Info-box cards: icon + title only. */
#mobile-drawer .sub-menu .kt-blocks-info-box-link-wrap {
    border: 0 !important;
    gap: 10px;
}
#mobile-drawer .sub-menu .kt-blocks-info-box-media-container,
#mobile-drawer .sub-menu .kt-blocks-info-box-media {
    margin: 0 !important;
    padding: 0 !important;
}
#mobile-drawer .sub-menu .kt-blocks-info-box-title {
    margin: 0 !important;
    padding: 0 !important;
    font-weight: 500 !important;
}
#mobile-drawer .sub-menu .kt-blocks-info-box-title strong {
    font-weight: inherit;
}
#mobile-drawer .sub-menu .kt-blocks-info-box-text {
    display: none;
}

/* ── Homepage hero image cards (as on gp26) ─────────────────────────────────
   cmg-hero-lead / cmg-hero-pair and .cmg-card-kicker are added by
   cmg_home_hero_cards() in functions.php. */

/* Topic label above each card headline */
.cmg-card-kicker {
    display: block;
    margin: 0 0 6px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.9;
    /* one line: a wrapped label pushes the top of the card text out of view.
       width 0 / min-width 100%: the label takes the headline's width instead of
       widening the (shrink-to-fit) text box past the card edge. */
    width: 0;
    min-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lead story: bigger headline, excerpt always shown */
.home-hero-articles .cmg-hero-lead .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-title {
    font-size: clamp(24px, 2.3vw, 34px);
    line-height: 1.15;
}
.home-hero-articles .cmg-hero-lead .cmg-hover-reveal .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-subtitle {
    max-height: none;
    opacity: 1;
    margin-top: 0.25em;
    font-size: 16px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 46em;
}
/* Hero image cards: a lighter, shorter fade than the site-wide card gradient,
   sized to the text block rather than the image, plus a soft text shadow so the
   white text still holds up on bright photos. The hover fade still applies. */
.home-hero-articles .cmg-gradient-overlay .kt-image-overlay-color-wrapper::before {
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.72) 0%,
        rgba(0, 0, 0, 0.5) 22%,
        rgba(0, 0, 0, 0.18) 42%,
        transparent 58%
    );
}
/* the smaller cards' text fills more of the image, so their fade reaches higher */
.home-hero-articles .cmg-hero-pair .cmg-gradient-overlay .kt-image-overlay-color-wrapper::before {
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.75) 0%,
        rgba(0, 0, 0, 0.55) 35%,
        rgba(0, 0, 0, 0.2) 62%,
        transparent 80%
    );
}
.home-hero-articles .cmg-gradient-overlay .image-overlay-title,
.home-hero-articles .cmg-gradient-overlay .image-overlay-subtitle,
.home-hero-articles .cmg-gradient-overlay .cmg-card-kicker {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.home-hero-articles .cmg-hero-lead .kt-image-overlay-message {
    padding-bottom: 8px;
}
/* Hover: with the excerpt always shown, the card's headline-only lift pulled the
   headline away from its label and excerpt. Lift the whole text block instead. */
.home-hero-articles .cmg-hero-lead .cmg-hover-reveal .kt-image-overlay-wrap:is(:hover, :focus-within) .kt-image-overlay-message .image-overlay-title {
    transform: none;
}
.home-hero-articles .cmg-hero-lead .kt-image-overlay-inner {
    transition: transform 0.6s ease;
}
.home-hero-articles .cmg-hero-lead .kt-image-overlay-wrap:is(:hover, :focus-within) .kt-image-overlay-inner {
    transform: translateY(-0.4em);
}

/* Story cards under the lead: headline at most 3 lines */
@media (min-width: 768px) {
    .home-hero-articles .cmg-hero-pair .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-title {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 767px) {
    .home-hero-articles .cmg-hero-lead .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-title {
        font-size: 24px;
    }
    /* on a phone the text fills most of the lead, so the fade reaches higher */
    .home-hero-articles .cmg-hero-lead .cmg-gradient-overlay .kt-image-overlay-color-wrapper::before {
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.75) 0%,
            rgba(0, 0, 0, 0.55) 35%,
            rgba(0, 0, 0, 0.2) 62%,
            transparent 80%
        );
    }
    .home-hero-articles .cmg-hero-lead .kt-image-overlay-message {
        left: 16px;
        right: 16px;
        padding-bottom: 0;
    }
    .home-hero-articles .cmg-hero-lead .cmg-hover-reveal .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-subtitle {
        display: none;
    }
    /* Lead stays 16:9 on phones (other hero-style cards drop to 3:2, above) */
    .home-hero-articles .cmg-hero-lead .kb-query-item .kt-image-overlay-wrap .kt-block-intrisic:not(.kt-over-set-ratio) {
        padding-bottom: 56.25% !important;
    }

    /* Story cards under the lead: compact rows, thumbnail left, headline right */
    .home-hero-articles .cmg-hero-pair .kb-query-item {
        border-radius: 0;
        border-top: 1px solid var(--global-palette7, #e2e8f0);
        padding: 12px 0;
    }
    .home-hero-articles .cmg-hero-pair .kt-block-intrisic.kt-over-set-ratio {
        display: grid;
        grid-template-columns: 112px 1fr;
        gap: 14px;
        align-items: center;
        height: auto;
        padding-bottom: 0 !important;
        overflow: visible;
    }
    .home-hero-articles .cmg-hero-pair .kt-block-intrisic img.kt-img-overlay {
        position: static;
        width: 112px !important;
        height: 75px; /* 3:2 */
        object-fit: cover;
        border-radius: 4px;
    }
    .home-hero-articles .cmg-hero-pair .kt-image-overlay-color-wrapper {
        display: none;
    }
    .home-hero-articles .cmg-hero-pair .cmg-gradient-overlay .image-overlay-title,
    .home-hero-articles .cmg-hero-pair .cmg-gradient-overlay .cmg-card-kicker {
        text-shadow: none;
    }
    .home-hero-articles .cmg-hero-pair .kt-image-overlay-wrap {
        background: none;
    }
    .home-hero-articles .cmg-hero-pair .kt-imageoverlay-link {
        position: static;
        text-decoration: none;
    }
    /* keep the whole row (thumbnail too) clickable */
    .home-hero-articles .cmg-hero-pair .kt-imageoverlay-link::after {
        content: '';
        position: absolute;
        inset: 0;
    }
    .home-hero-articles .cmg-hero-pair .kt-image-overlay-message {
        position: static;
        padding: 0;
        background: none;
    }
    .home-hero-articles .cmg-hero-pair .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-title {
        color: var(--global-palette3);
        font-size: 16px;
        line-height: 1.3;
        padding: 0;
        transform: none;
    }
    .home-hero-articles .cmg-hero-pair .cmg-hover-reveal .kt-image-overlay-wrap .kt-image-overlay-message .image-overlay-subtitle {
        display: none;
    }
    .home-hero-articles .cmg-hero-pair .cmg-card-kicker {
        margin-bottom: 4px;
        /* undo the one-line label: in a row there's room for it to wrap normally */
        width: auto;
        min-width: 0;
        white-space: normal;
        color: var(--global-palette1);
        opacity: 1;
    }

    /* Latest News straight after the stories, ahead of the ad and Trending.
       The outer hero row holds Latest News and a column wrapping the inner row
       (stories | ad + Trending); flatten that column and inner row so all three
       sit in the outer row's own grid. Matched by the home-hero-* classes, not
       block IDs, which differ between environments. */
    .kb-row-layout-wrap:has(> .kt-row-column-wrap > .home-hero-news) > .kt-row-column-wrap > .wp-block-kadence-column:has(.home-hero-articles),
    .kb-row-layout-wrap:has(> .kt-row-column-wrap > .home-hero-news) > .kt-row-column-wrap > .wp-block-kadence-column:has(.home-hero-articles) > .kt-inside-inner-col,
    .kb-row-layout-wrap:has(> .kt-row-column-wrap > .home-hero-articles),
    .kb-row-layout-wrap:has(> .kt-row-column-wrap > .home-hero-articles) > .kt-row-column-wrap {
        display: contents;
    }
    /* !important: Kadence's right-to-left collapse sets order on these columns.
       Negative, to stay ahead of the grid's ::before (order 0), which would
       otherwise add an empty row and a gap above the lead. */
    .kt-row-column-wrap > .home-hero-articles { order: -3 !important; }
    .kt-row-column-wrap > .home-hero-news { order: -2 !important; }
    .kt-row-column-wrap > .wp-block-kadence-column:has(> .kt-inside-inner-col > .home-hero-trending) { order: -1 !important; }
}

/* Homepage news cards: 3:2 Kadence Post Grid thumbnails. Chained onto
   .kadence-post-image-intrisic to outrank Kadence Pro's post grid CSS, which
   loads after this file. */
.kadence-post-image-intrisic.cmg-thumb--contain .kadence-post-image-inner-intrisic {
    background: var(--global-palette7);
}
.kadence-post-image-intrisic.cmg-thumb--flat .kadence-post-image-inner-intrisic {
    background: var(--global-palette8);
}
.kadence-post-image-intrisic.cmg-thumb--contain .cmg-image-backdrop {
    inset: -24px;
    filter: blur(12px) brightness(.85) saturate(1.15);
}
.kadence-post-image-intrisic.cmg-thumb--contain .kadence-post-image-inner-intrisic a {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kadence-post-image-intrisic.cmg-thumb--contain .kadence-post-image-inner-intrisic img {
    flex: none;
    width: auto;
    height: auto;
    max-width: min(100%, var(--cmg-fi-w));
    max-height: min(100%, var(--cmg-fi-h));
}
.kadence-post-image-intrisic.cmg-thumb--flat .kadence-post-image-inner-intrisic img {
    max-width: min(86%, var(--cmg-fi-w));
    max-height: min(78%, var(--cmg-fi-h));
}

/* Image captions — minimal overlay along the bottom of the image.
   Covers the featured image in the single-post Elements (its <figcaption> is
   added by cmg_featured_image_caption() in functions.php) plus captions on
   core Image, Kadence Image and classic [caption] images in post content.
   The figure shrinks to the image so the overlay never runs past its edges. */
figure.wp-block-image:has(> figcaption),
figure.wp-block-kadence-image:has(figcaption),
.wp-caption {
    position: relative;
    width: fit-content;
    max-width: 100%;
}

figure.wp-block-kadence-image.cmg-article-featured-image {
    width: auto;
}

figure.wp-block-image:has(> figcaption) img,
figure.wp-block-kadence-image:has(figcaption) img,
.wp-caption img {
    display: block;
}

figure.wp-block-image > figcaption,
figure.wp-block-kadence-image figcaption,
.wp-caption .wp-caption-text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 24px 14px 8px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4) calc(100% - 24px), rgba(0, 0, 0, 0));
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    font-size: 12px;
    line-height: 1.4;
    text-align: left;
    border-radius: 0 0 5px 5px;
    pointer-events: none;
}

figure.wp-block-image > figcaption a,
figure.wp-block-kadence-image figcaption a,
.wp-caption .wp-caption-text a {
    color: #fff;
    pointer-events: auto;
}

/* Honoree grids in migrated articles (40 Under 40, Women in Business,
   RVeterans). The body markup is <div class="team"><div class="member">…;
   these are the old site's grid rules, scoped to article body content. */
:is(.kb-dynamic-html, .entry-content) .team {
    width: 100%;
    clear: both;
}

:is(.kb-dynamic-html, .entry-content) .member {
    display: inline-block;
    width: 20%;
    min-width: 230px;
    padding: 2% 2% 2% 0;
    vertical-align: top;
}

:is(.kb-dynamic-html, .entry-content) .member img {
    width: auto;
}

/* Honoree grids whose photos are the 300x300 files: as many equal columns as
   fit at 240px or more (three in the desktop article column), photos filling
   their column up to 300px. In-content ads take a full row of their own.
   Grids still holding the older 150px thumbnails keep the rules above. */
:is(.kb-dynamic-html, .entry-content) .team:has(img[src*="-300x300."]) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px 16px;
}

:is(.kb-dynamic-html, .entry-content) .team:has(img[src*="-300x300."]) > .member {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
}

:is(.kb-dynamic-html, .entry-content) .team:has(img[src*="-300x300."]) > :not(.member) {
    grid-column: 1 / -1;
    /* auto side margins would shrink a grid item to its content */
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

:is(.kb-dynamic-html, .entry-content) .member img[src*="-300x300."] {
    width: 100%;
    max-width: 300px;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
