/*---*\
Image Buttons
Image button cards in a grid or slider with a red angled title bar and a
desktop hover panel (description or related links plus Learn More).

KEY FEATURES:
- Optional background graphic on either background color, rendered from the media library
- Slanted bottom uses .section-slanted in global.css. Horizontal overflow is clipped so the slider track does not widen the page, and vertical overflow stays visible so the wedge can hang below
- Grid: 1 card per row below 1200px (title bar only, no photo), 3 per row at 1200px+
- Rows with fewer than 3 cards are centered
- At 1200px+, title bars in a row grow to the tallest label so a two-line title does not leave the other bars short
- Slider: fixed-width centered slides so neighbors peek, external arrows, no autoplay. Slick slides stretch so bars fill to the card bottom (keeps rounded corners) and match the tallest label
- Grid and slider below 1200px show Learn More in the title bar. The hover panel is desktop only. Cards without a link are static (no Learn More, no title chevron)

IMPLEMENTATION NOTES:
- The inner wrapper uses CSS Grid (not flex) because the CTA has to move
  between the header row on desktop and below the cards on smaller screens
- Card link selectors are prefixed with .image-buttons to beat the global
  .bg-charcoal a color rules
- Depends on fx_slick for the slider layout
\*---*/

.image-buttons {
    position: relative;
    overflow-x: clip;
    overflow-y: visible;
}

.image-buttons__graphic-wrap {
    position: absolute;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.image-buttons__graphic {
    position: absolute;
    width: auto;
    max-width: none;
    height: auto;
    color: var(--color-tertiary);
    opacity: 0.05;
    pointer-events: none;
}

.image-buttons__graphic path {
    fill: currentColor;
}

.image-buttons.bg-charcoal .image-buttons__graphic {
    color: var(--color-primary-contrast);
}

.image-buttons.bg-charcoal .image-buttons__graphic path {
    fill: var(--color-primary-contrast);
}

.image-buttons__graphic--start {
    top: -46px;
    left: -56%;
}

.image-buttons__graphic--end {
    right: -8%;
    bottom: 0;
    display: none;
}

.image-buttons .container {
    position: relative;
    z-index: 1;
}

.image-buttons__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "intro"
        "list"
        "cta";
    row-gap: 32px;
}

.image-buttons--slider .image-buttons__inner {
    grid-template-areas:
        "intro"
        "list"
        "nav"
        "cta";
}

.image-buttons__intro {
    grid-area: intro;
    min-width: 0;
}

.image-buttons__intro > :last-child {
    margin-bottom: 0;
}

.image-buttons__cta-wrap {
    grid-area: cta;
    justify-self: center;
}

.image-buttons__cta {
    white-space: nowrap;
}

.image-buttons__list {
    grid-area: list;
    min-width: 0;
}

.image-buttons--grid .image-buttons__list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.image-buttons--grid .image-button {
    flex: 0 0 100%;
}

.image-button {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: 0 0 var(--radius-card) var(--radius-card);
    overflow: hidden;
    color: var(--color-primary-contrast);
}

.image-buttons .image-button__media {
    position: relative;
    display: none;
    aspect-ratio: 400 / 30;
    background-color: transparent;
}

.image-buttons--slider .image-button__media {
    display: block;
}

.image-button__img {
    display: none !important;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-buttons--grid .image-button__img {
    height: auto;
}

.image-buttons .image-button__bar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0;
    min-height: 115px;
    padding: 28px 25px 20px 24px;
    border-radius: 0 0 var(--radius-card) var(--radius-card);
    background-image: var(--gradient-red);
    color: var(--color-primary-contrast);
    text-decoration: none;
    clip-path: polygon(0 10px, 70% 10px, 75% 0, 100% 0, 100% 100%, 0 100%);
    /* clip-path: polygon(0 8px, 60% 8px, 72% 0, 100% 0, 100% 100%, 0 100%); */
}

.image-buttons--slider .image-button__bar {
    margin-top: -29px;
    /* clip-path: polygon(0 29px, 52% 29px, 66% 0, 100% 0, 100% 100%, 0 100%); */
}

.image-buttons .image-button__bar:hover,
.image-buttons .image-button__bar:focus-visible {
    color: var(--color-primary-contrast);
}

.image-buttons .image-button__bar:focus-visible {
    outline: 3px solid var(--color-secondary);
    outline-offset: -6px;
}

.image-button__bar-text {
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 0;
    padding-top: var(--space-paragraph);
    max-width: 285px;
}

.image-button__title {
    margin: 0;
    color: var(--color-primary-contrast);
    font-size: 18px;
    font-weight: var(--font-weight-heading);
    line-height: 28px;
}

.image-button__title .icon-chevron-double-right:before {
    font-size: 20px;
    position: absolute;
    top: 2px;
    left: 18px;
}

.image-buttons--slider .image-button__title {
    font-size: 24px;
}

.image-button__chevron {
    flex: 0 0 auto;
    font-size: 20px;
    transition: transform 0.2s ease;
}

.image-buttons .image-button__bar:hover .image-button__chevron,
.image-buttons .image-button__bar:hover .image-button__bar-more .icon-chevron-double-right,
.image-buttons .image-button__bar:focus-visible .image-button__bar-more .icon-chevron-double-right {
    transform: translateX(4px);
}

.image-button__bar-more {
    display: none;
}

.image-buttons--grid .image-button__bar,
.image-buttons--slider .image-button__bar {
    flex-wrap: wrap;
}

.image-buttons--grid .image-button__bar-text,
.image-buttons--slider .image-button__bar-text {
    flex: 1 1 auto;
}

.image-buttons--grid .image-button__chevron,
.image-buttons--slider .image-button__chevron {
    display: none;
}

.image-buttons--grid .image-button__bar-more,
.image-buttons--slider .image-button__bar-more {
    display: inline-flex;
    flex: 0 0 100%;
    align-items: center;
    gap: var(--button-gap);
    color: var(--color-primary-contrast);
    font-family: var(--font-button);
    font-size: var(--button-font-size);
    font-weight: var(--font-weight-button);
    letter-spacing: var(--letter-spacing-button);
    line-height: var(--line-height-button);
    text-transform: uppercase;
}

.image-buttons--grid .image-button__bar-more .icon-chevron-double-right,
.image-buttons--slider .image-button__bar-more .icon-chevron-double-right {
    font-size: var(--button-arrow-size);
    transition: transform 0.2s ease;
}

.image-button__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 67px;
    height: 50px;
    color: var(--color-primary-contrast);
}

.image-button__icon--svg {
    background-color: var(--color-primary-contrast);
    -webkit-mask-image: var(--image-button-icon);
    mask-image: var(--image-button-icon);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
}

.image-button__icon--font svg {
    display: block;
    width: 100%;
    height: auto;
}

.image-button__icon--font svg path {
    fill: currentColor;
}

.image-button__hover {
    display: none;
}

.image-buttons--slider .image-buttons__list {
    margin: 0 -6px;
}

.image-buttons--slider .slick-list {
    overflow: visible;
}

.image-buttons--slider .slick-track {
    display: flex;
    align-items: stretch;
}

/* Beat slick.css (.slick-initialized .slick-slide { display: inline-block }) so slides stretch. */
.image-buttons--slider .slick-initialized .slick-slide {
    display: flex;
    float: none;
    height: auto;
}

.image-buttons--slider .slick-initialized .slick-slide .image-button {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Keep the photo from stretching with the equal-height slide; only the title bar grows.
   min-height: 0 lets aspect-ratio win over the image's intrinsic height in a flex column. */
.image-buttons--slider .image-button__media {
    flex: 0 0 auto;
    min-height: 0;
    overflow: hidden;
}

.image-buttons--slider .image-button {
    width: min(400px, calc(100vw - 2 * var(--container-gutter)));
    margin: 0 6px;
}

.image-buttons__nav {
    grid-area: nav;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.image-buttons__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 17px;
    border: 0;
    border-radius: var(--radius-small);
    background-color: var(--color-tertiary);
    color: var(--color-primary-contrast);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.image-buttons__arrow i {
    font-size: 30px;
}

.image-buttons__arrow:hover,
.image-buttons__arrow:focus-visible {
    background-color: var(--color-primary);
    color: var(--color-primary-contrast);
}

.image-buttons__arrow:focus-visible {
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
}

.image-buttons.bg-charcoal .image-buttons__arrow {
    background-color: var(--color-tertiary-dark);
}

.image-buttons.bg-charcoal .image-buttons__arrow:hover,
.image-buttons.bg-charcoal .image-buttons__arrow:focus-visible {
    background-color: var(--color-primary);
}

.image-button__links li {
    margin-bottom: 0;
}

.image-button--no-image.image-button .image-button__media {
    background-color: var(--color-paragraph);
}

.image-button--no-image.image-button .image-button__media .image-button__img {
    object-fit: contain;
}

/* Grid: the icon spans both the title row and the Learn More row */
@media (max-width: 1199px) {
    .image-buttons .image-button__bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 20px;
    }

    .image-buttons .image-button__bar-text,
    .image-buttons .image-button__bar-more {
        grid-column: 1;
    }

    .image-buttons .image-button__icon {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: stretch;
        height: auto;
    }
}

@media (min-width: 768px) {
    .image-buttons--grid .image-buttons__inner {
        grid-template-areas:
            "intro"
            "list"
            "cta";
    }

    .image-buttons__graphic--start {
        top: -5px;
        left: -33%;
    }    

    .image-buttons--grid .image-buttons__cta-wrap {
        justify-self: center;
    }

    .image-buttons--grid .image-buttons__list {
        gap: var(--space-grid);
    }

    .image-buttons--slider .image-buttons__list {
        margin: 0 -16px;
    }

    .image-button__img {
        display: block !important;
    }

    .image-buttons--grid .image-button__img {
        height: 100%;
    }    

    .image-button {
        border-radius: var(--radius-card);
    }

    .image-button__title {
        font-size: 24px;
    }

    .image-buttons--slider .image-button {
        width: min(662px, calc(100vw - 2 * var(--container-gutter)));
        margin: 0 16px;
    }

    .image-buttons .image-button__media {
        display: block;
        aspect-ratio: 662 / 200;        
    }

    .image-buttons--grid.image-buttons .image-button__media {
        height: 184px;
    }

    .image-buttons .image-button__bar {
        min-height: 147px;
        margin-top: -29px;
        padding: 30px 28px 28px;
        clip-path: polygon(0 29px, calc(100% - 170px) 29px, calc(100% - 95px) 0, 100% 0, 100% 100%, 0 100%);
        height: 147px;
        align-items: center;
        gap: 0;
    }

    /* Slider peers share one track height; let the bar fill so bottoms stay rounded. */
    .image-buttons--slider .image-button__bar {
        flex-grow: 1;
        height: auto;
    }

    .image-buttons__nav {
        gap: var(--space-grid);
    }

    .image-buttons--slider.image-buttons--has-cta .image-buttons__inner {
        grid-template-columns: auto auto;
        justify-content: center;
        align-items: center;
        column-gap: var(--space-grid);
        grid-template-areas:
            "intro intro"
            "list list"
            "cta nav";
    }

    .image-buttons--slider.image-buttons--has-cta .image-buttons__cta-wrap {
        justify-self: end;
    }

    .image-buttons--slider.image-buttons--has-cta .image-buttons__nav {
        justify-content: flex-start;
        align-items: center;
    }

    /* Tablet controls row: arrows are 48px, the CTA is 40px and sits on their center */
    .image-buttons--slider.image-buttons--has-cta .image-buttons__cta {
        box-sizing: border-box;
        height: 40px;
        padding-top: 9px;
        padding-bottom: 9px;
    }
}

@media (min-width: 1200px) {
    .image-buttons__inner {
        row-gap: var(--space-content);
    }

    .image-buttons__graphic {
        width: 52%;
    }    

    .image-buttons__graphic--start {
        top: -61px;
        left: -15%;
        width: 851px;
        height: 644px;
        object-fit: contain;
    }

    .image-buttons--slider .image-buttons__graphic-wrap--flag .image-buttons__graphic--start {
        bottom: -261px;
    }

    .image-buttons__graphic--end {
        bottom: 103px;
        right: -22%;
        width: 665px;
        height: 503px;
        display: block;
    }

    .image-buttons--slider .image-button {
        width: min(400px, calc(100vw - 2 * var(--container-gutter)));
        margin: 0 16px;
    }

    .image-buttons--slider .image-button__bar {
        clip-path: polygon(0 29px, 52% 29px, 66% 0, 100% 0, 100% 100%, 0 100%);
    }    

    .image-buttons--grid.image-buttons .image-button__media {
        height: 230px;
    }    

    .image-buttons__arrow {
        padding: 13px 22px;
    }    

    .image-buttons--grid .image-buttons__inner {
        grid-template-areas:
            "intro"
            "list";
    }

    .image-buttons--slider .image-buttons__inner {
        grid-template-areas:
            "intro"
            "list"
            "nav";
    }

    .image-buttons--has-cta .image-buttons__inner,
    .image-buttons--slider.image-buttons--has-cta .image-buttons__inner {
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: var(--space-grid);
        grid-template-areas:
            "intro cta"
            "list list"
            "nav nav";
    }

    /* Grid has no arrow row. An empty nav track still keeps the row-gap, which pads the bottom of the cards. */
    .image-buttons--grid.image-buttons--has-cta .image-buttons__inner {
        grid-template-areas:
            "intro cta"
            "list list";
    }

    .image-buttons--has-cta .image-buttons__intro {
        max-width: 832px;
    }

    .image-buttons--grid .image-buttons__cta-wrap,
    .image-buttons--slider .image-buttons__cta-wrap {
        justify-self: end;
        align-self: end;
    }

    .image-buttons--grid .image-buttons__list {
        justify-content: center;
    }

    .image-buttons--grid .image-button {
        flex: 0 0 calc((100% - 2 * var(--space-grid)) / 3);
    }

    .image-buttons .image-button__media {
        display: block;
        aspect-ratio: 400 / 232;
    }    

    .image-buttons .image-button__bar {
        flex-grow: 1;
        margin-top: -29px;
        min-height: 99px;
        height: auto;
        padding: 29px 25px 20px 15px;
        clip-path: polygon(0 29px, 52% 29px, 66% 0, 100% 0, 100% 100%, 0 100%);
    }

    .image-buttons--grid .image-button__chevron,
    .image-buttons--slider .image-button__chevron {
        display: inline;
        position: relative;
    }

    .image-buttons--grid .image-button__bar-more,
    .image-buttons--slider .image-button__bar-more {
        display: none;
    }

    .image-button__hover {
        position: absolute;
        z-index: 2;
        right: 0;
        bottom: 0;
        left: 0;
        display: flex;
        flex-direction: column;
        gap: 13px;
        height: 252px;
        padding: 30px 25px 20px 15px;
        background-image: var(--gradient-red);
        clip-path: polygon(0 29px, 52% 29px, 66% 0, 100% 0, 100% 100%, 0 100%);
        opacity: 0;
        visibility: hidden;
        transform: translateY(24px);
        transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
    }

    .image-button--no-icon .image-button__hover {
        padding-top: 50px;
    }

    .image-button:hover .image-button__hover,
    .image-button:focus-within .image-button__hover {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition-delay: 0s;
    }

    .image-button--static:not(:hover) .image-button__hover {
        visibility: hidden;
    }

    .image-button--static .image-button__hover {
        height: auto;
    }    

    .image-button__hover-head {
        display: flex;
        flex-shrink: 0;
        align-items: flex-end;
        justify-content: space-between;
        gap: 20px;
    }

    .image-button__hover-title {
        margin: 0;
        color: var(--color-primary-contrast);
        font-family: var(--font-heading);
        font-size: 24px;
        font-weight: var(--font-weight-heading);
        line-height: var(--line-height-heading);
    }

    /* The icon is 50px and a one-line title is 28.8px, bottom-aligned.
       20px fits in that gap, so a one-line title stays put and only a
       wrapped title moves down off the slant. */
    .image-button:not(.image-button--no-icon) .image-button__hover-title {
        padding-top: 20px;
    }

    .image-button__description {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        margin: 0;
        overflow: hidden;
        color: var(--color-primary-contrast);
        font-size: 18px;
        line-height: var(--line-height-body);
    }

    .image-buttons .image-button--static .image-button__description {
        display: block;
        -webkit-line-clamp: unset;
        max-height: calc(var(--line-height-body) * 4em);
        padding-right: 10px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .image-buttons .image-button__links {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        gap: 8px;
        min-height: 0;
        margin: 0;
        padding: 0 10px 0 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        list-style: none;
        font-size: 18px;
        line-height: var(--line-height-body);
    }

    .image-buttons .image-button__links::-webkit-scrollbar,
    .image-buttons .image-button--static .image-button__description::-webkit-scrollbar {
        width: 6px;
    }

    .image-buttons .image-button__links::-webkit-scrollbar-track,
    .image-buttons .image-button--static .image-button__description::-webkit-scrollbar-track {
        background-color: var(--color-primary-dark);
        border-radius: 10px;
    }

    .image-buttons .image-button__links::-webkit-scrollbar-thumb,
    .image-buttons .image-button--static .image-button__description::-webkit-scrollbar-thumb {
        background-color: var(--color-primary-contrast);
        border-radius: 10px;
    }

    /* Chrome 121+ ignores ::-webkit-scrollbar when scrollbar-color is set */
    @supports not selector(::-webkit-scrollbar) {
        .image-buttons .image-button__links,
        .image-buttons .image-button--static .image-button__description {
            scrollbar-color: var(--color-primary-contrast) var(--color-primary-dark);
            scrollbar-width: thin;
        }
    }

    .image-buttons .image-button__label,
    .image-buttons .image-button__link {
        color: var(--color-primary-contrast);
    }

    .image-buttons .image-button__link {
        text-decoration: none;
    }

    .image-buttons .image-button__link:hover,
    .image-buttons .image-button__link:focus-visible {
        color: var(--color-secondary);
        text-decoration-color: var(--color-secondary);
    }

    .image-buttons .image-button__more {
        display: inline-flex;
        align-items: center;
        gap: var(--button-gap);
        margin-top: auto;
        align-self: flex-start;
        color: var(--color-primary-contrast);
        font-family: var(--font-button);
        font-size: var(--button-font-size);
        font-weight: var(--font-weight-button);
        letter-spacing: var(--letter-spacing-button);
        line-height: var(--line-height-button);
        text-decoration: none;
        text-transform: uppercase;
    }

    .image-buttons .image-button__links + .image-button__more {
        flex-shrink: 0;
        margin-top: 0;
    }

    .image-buttons .image-button__more .icon-chevron-double-right {
        font-size: var(--button-arrow-size);
        transition: transform 0.2s ease;
    }

    .image-buttons .image-button__more:hover,
    .image-buttons .image-button__more:focus-visible {
        color: var(--color-primary-contrast);
    }

    .image-buttons .image-button__more:hover .icon-chevron-double-right,
    .image-buttons a.image-button__hover:hover .image-button__more .icon-chevron-double-right {
        transform: translateX(4px);
    }

    .image-buttons a.image-button__hover {
        text-decoration: none;
    }

    .image-buttons .image-button__link:focus-visible,
    .image-buttons .image-button__more:focus-visible {
        outline: 2px solid var(--color-secondary);
        outline-offset: 2px;
    }

    /* The panel's clip-path cuts off an outside outline. */
    .image-buttons a.image-button__hover:focus-visible {
        outline: 2px solid var(--color-secondary);
        outline-offset: -4px;
    }

    .image-buttons__nav,
    .image-buttons--slider.image-buttons--has-cta .image-buttons__nav {
        justify-content: flex-end;
        gap: var(--space-grid);
    }

    .image-buttons--slider.image-buttons--has-cta .image-buttons__inner {
        justify-content: stretch;
        align-items: stretch;
    }

    .image-buttons--slider.image-buttons--has-cta .image-buttons__cta {
        height: auto;
        padding-top: var(--button-padding-y);
        padding-bottom: var(--button-padding-y);
    }
}
