/**
 * Text with Cards Layout Styles
 */
 .text-with-cards-wrapper {
    display: flex;
    flex-direction: column;
    
   

    .text-description {
        max-width: 60rem;
    }

    .cards-container {
        padding: 0;
        width: 100%;
        margin-top: 2.4rem;
        @media (min-width: 992px) {
            margin-top: 0;
        }
        
        /* No special handling needed here */
       

        .card-spacer {
            flex-grow: 1;
            aspect-ratio: 4/3; /* Match the image aspect ratio */
            width: 100%;
        }

        .card-item {
            user-select: none;
            border-bottom: 5px solid var(--color-black);
            box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.15);
            background-color: var(--color-white);
            padding: 2.4rem;
            margin: 0 2.4rem;
            /* Equal height setup - critical for JS height matching */
            display: flex;
            flex-direction: column;
            height: 100%; /* Base height */
            /* Standard transition for card movement */
            transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
            
            
            
            /* Base hover state for all cards */
            &.is-hovered {
                transform: translateY(-20px);
                box-shadow: 0px 6px 20px -6px rgba(0, 0, 0, 0.35);
                border-bottom-color: var(--color-garnet);
                
                /* Only change triangle background if it exists */
                .card-item-image-triangle { 
                    background-color: var(--color-garnet);
                    /* Standard transition timing */
                    transition: background-color 0.3s ease;
                    
                    &::after {
                        color: var(--color-white);
                        bottom: 4px;
                        right: 4px;
                    }
                }
                
                .card-item-title-triangle::after {
                    bottom: 4px;
                    right: 4px;
                }
                
                .card-item-content {
                    h3, .card-item-description {
                        color: var(--color-garnet);
                    }
                }
            }
           
            
            a {
                text-decoration: none;
            }
        }

        .card-item-image {
            aspect-ratio: 4/3;
            position: relative;
            width: 100%;
            background-color: var(--color-garnet);
            overflow: hidden;
            .card-item-image-triangle {
                position: absolute;
                bottom: -0.1rem;
                right: -0.1rem;
                aspect-ratio: 1/1;
                width: 6.3rem;
                height: 6.3rem;
                background-color: var(--color-white);
                clip-path: polygon(0 100%, 100% 0, 100% 100%);
                &::after {
                    content: '\e000';
                    font-family: "Font Awesome Kit";
                    font-weight: 400;
                    font-size: 2.4rem;
                    font-style: normal;
                    -webkit-font-smoothing: antialiased;
                    position: absolute;
                    bottom: 0;
                    right: 0;
                    color: var(--color-garnet);
                    z-index: 10;
                }
            }
            img {
                width: 100%;
                height: 100%;
                object-fit: cover;
                object-position: center;
            }
        }

        .card-item-content {
            padding: 1rem;
            /* Added flex grow to fill available space */
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            h3 {
                font-family: var(--serif);
                font-size: 2rem;
                line-height: 2.6rem;
                font-style: normal;
                font-weight: 700;
                margin: 0.8rem 0;
                /* overflow:hidden; */
                white-space: break-word;
                /* text-overflow: ellipsis; */
                position: relative;
                padding-right: 3rem;
                /* display: inline-block; */
                text-wrap: wrap;
                
                .card-item-title-triangle {
                    position: absolute;
                    right: 0;
                    top: 50%;
                    transform: translateY(-50%);
                    display: inline-block;
                    color: var(--color-garnet);
                    transition: transform 0.3s ease, color 0.3s ease, bottom 0.3s ease, right 0.3s ease;
                    
                    &::after {
                        content: '\e000';
                        font-family: "Font Awesome Kit";
                        font-weight: 400;
                        font-size: 2.4rem;
                        font-style: normal;
                        -webkit-font-smoothing: antialiased;
                        display: inline-block;
                        
                    }
                }
                
                @media (min-width: 992px) {  
                    font-size: 2.4rem;
                    line-height: 3rem;
                }
            }
            .card-item-description {
                font-family: var(--sans);
                font-size: 1.8rem;
                font-style: normal;
                font-weight: 400;
                line-height: 2.8rem;
                color: var(--color-black);
                white-space: normal;
                overflow: visible;
                
                /* Styling for truncated excerpts */
                &.truncated-excerpt {
                    position: relative;
                    display: -webkit-box;
                    -webkit-line-clamp: 3;
                    -webkit-box-orient: vertical;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    max-height: 8.4rem; /* 3 lines at 2.8rem line height */
                    
                    .truncation-indicator {
                        display: none; /* Hide the ellipsis since we're using CSS truncation */
                    }
                }
            }
        }
        /* Carousel container */
        .carousel-container {
            position: relative;
        }
        
        /* Apply a mask to the glide track on desktop only */
        @media (min-width: 992px) {
            /* Only apply to carousels with more than 3 slides */
            .glide:not(.has-three-or-less) .glide__track {
                /* Create a mask that fades out the right edge - even more subtle */
                -webkit-mask-image: linear-gradient(to right, black 98%, transparent 100%);
                mask-image: linear-gradient(to right, black 98%, transparent 100%);
            }
        }
        
        .glide {
            display: flex;
            flex-wrap: wrap;
            flex-direction: column-reverse;
        }
        .glide__track {
            margin-left: -2.4rem;
            margin-right: -2.4rem;
            width: 100%;
            
            /* No special handling needed here */
        }
        .glide__slide {
            aspect-ratio: 16/9;
            img {
                width: 100%;
                height: 100%;
                object-fit: cover;
                object-position: center;
            }
        }
        .glide__slides {
            padding: 4.4rem 0 0 0;
            cursor: pointer;
        }
        .glide__arrows {
            margin-top:var(--spacing-lg);
            color: var(--color-white);
            line-height: 1;
            display: flex;
            gap: 1.6rem;
            padding-bottom: 0rem;
            justify-content: flex-end; /* Position arrows on the right */
            width: auto; /* Don't take full width */
            margin-left: auto; /* Push to right side */
            margin-right: 2.4rem; /* Add some right margin */

            &.slides-1 {
                display: none;
            }
            &.slides-2 {
                display: none;
    
                @media (max-width: 600px) {
                    display: flex;
                }
            }
            &.slides-3 {
                display: none;
    
                @media (max-width: 992px) {
                    display: flex;
                }
            }
            button {
                background-color: var(--color-primary);
                border: 2px solid var(--color-white);
                border-radius: 50%;
                display: flex;
                justify-content: center;
                align-items: center;
                width: 3rem;
                height: 3rem;
                color: var(--color-white);
                cursor: pointer;
                transition: transform 0.15s ease-out;
                &.glide__arrow--left {
                    left: 2.4rem;
                }   
                &.glide__arrow--right {
                    right: 2.4rem;
                }
                &:hover {
                    transform: scale(1.1);
                    background-color: var(--color-garnet);
                }
                &:active {
                    transform: scale(1);
                }
            }
        }
    }
    
}

/* USCAA Sponsored Event Badge */
.uscaa-sponsored-event {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 80px;
    background-color: var(--color-garnet);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.uscaa-sponsored-event img {
    height:70px !important;
    width:auto !important;
    display:block;
}

/* External link styling for text_with_cards layout */
/* Style for external icon in cards with images */
.card-item-image.external-image {
    position: relative;
}

.card-item-image.external-image .external-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    color: var(--color-garnet);
    font-size: 2rem;
    z-index: 10;
    bottom:2px;
    right:2px;
    /* Standard transition timing */
    transition: bottom 0.3s ease, right 0.3s ease, color 0.3s ease;
}

/* Style for external icon in cards without images */
.card-item-title-triangle.external-triangle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-block;
    color: var(--color-garnet);
}

.card-item-title-triangle.external-triangle .external-icon {
    font-size: 2.4rem;
    transition: bottom 0.3s ease, right 0.3s ease, color 0.3s ease;
}

/* Hover effect for external icons in cards */
.card-item.is-hovered .external-icon {
    bottom: 5px;
    right: 5px;
}

.card-item.is-hovered .card-item-image-triangle .external-icon,
.card-item.is-hovered .card-item-image.external-image .external-icon {
    color: var(--color-white);
}

.card-item.is-hovered .card-item-title-triangle .external-icon {
    bottom: 5px;
    right: 5px;
}

/* Remove the after pseudo-element content for external links */
.card-item.external-link-card .card-item-image-triangle::after,
.card-item.external-link-card .card-item-title-triangle::after {
    content: none !important;
}

.glide__arrows {
    display: block;
   padding-bottom:2rem;
}

 /* Styles for cards grid layout */
 .cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: var(--spacing-xl);
    width: 100%;
    padding: 0;
    
    @media (max-width: 1200px) {
        grid-template-columns: repeat(2, 1fr);
    }
    
    @media (max-width: 767px) {
        grid-template-columns: 1fr;
    }
    
    .card-item {
        margin: 0 !important;   
        list-style: none;
        min-width: 0; /* Prevent overflow */
        width: 100%; /* Ensure card takes full width of grid cell */
    }
    
    /* Scale down cards in admin preview */
    .is-preview &, body.wp-admin & {
        .card-item {
            margin:0 !important;
            transform: scale(0.8);
            transform-origin: center top;
        }
    }
}

/* Special styling for layouts with 3 or fewer cards */
.text-with-cards.has-three-or-less {
    @media(min-width:992px){
        .glide__arrows{
            display:none;
        }    
        .glide__slides{
            width:100% !important;
            margin:0 auto;
            padding-left:0px !important;
            padding-right:0px !important;
            overflow: visible !important;
        }
        .glide__track{
            margin-left:auto;
            margin-right:auto;
            overflow: visible !important;
        }
        .card-item{
            margin:0 !important;
            width:32% !important; 
        }
        #card-item-1{
            margin-left:2% !important;
            margin-right:2% !important;
        }
    }
}
@media(max-width:991px){
    .text-with-cards.carousel-style{
        .glide__track{
          overflow:visible !important;
        }
        .glide__slides{
            overflow:visible !important;
        }
    }
}
