/* Scoped container to prevent code leaking into other parts of Elementor */
.hmk-cards-wrapper {
    --primaryColor: #B4853E; /* Your Brand Gold */
    --brand-navy: #1C2539;
    --bg-card: #FFFFFF;
    --text-muted: #6B7280;
    
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Grid Layout Matrix */
.hmk-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 Columns on PC */
    column-gap: 1.4rem;
    row-gap: 1.4rem; /* Handles gaps gracefully if multiple rows exist */
    width: 100%;
}

/* Equal Heights Rule 1: Stretch the anchor tag to fill grid height natively */
.hmk-card-link {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    height: 100%; 
    color: inherit;
}

/* Base Card Style Properties */
.hmk-cards-wrapper .hmk-course-card {
    background-color: var(--bg-card);
    border: 1px solid rgba(17, 22, 29, 0.04);
    box-shadow: 0px 1px 1px 0px rgba(17, 22, 29, 0.08);
    transition: all 0.3s 0s ease-out;
    box-sizing: border-box;
    border-radius: 0.9375rem;
    margin: 0rem;
    padding: 0.9375rem;
    
    /* Equal Heights Rule 2: Push content downwards cleanly */
    display: flex;
    flex-direction: column;
    height: 100%; 
    flex-grow: 1;
}

/* Card Hover Treatment */
.hmk-cards-wrapper .hmk-course-card:hover {
    border: 1px solid rgba(3, 31, 66, 0.08);
    box-shadow: 0px 6px 10px 0px rgba(10, 29, 58, 0.1);
}

/* Image Box Mask + Performance Aspect Ratio Safeguard */
.hmk-cards-wrapper .img-container {
    overflow: hidden !important;
    border-radius: 0.5375rem;
    width: 100%;
    position: relative;
    /* Reserves the exact 16:9 vertical space BEFORE image loads to prevent CLS layout shift */
    aspect-ratio: 16 / 9; 
    background-color: #f3f4f6; /* Placeholder skeleton background color */
}

/* Core Image Asset Rules */
.hmk-cards-wrapper .img-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    overflow: hidden !important;
    transition: transform 0.5s ease;
}

/* Smooth Hover Scale Engine */
.hmk-cards-wrapper .hmk-course-card:hover .img-container img {
    transform: scale(1.04) !important;
}

/* Flex text engine wrapper to bind title and metadata tightly */
.hmk-cards-wrapper .card-content-box {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-top: 0.85rem;
}

/* Typography Settings with CSS Line Clamping Safety */
.hmk-cards-wrapper .hmk-card-title {
    color: var(--brand-navy);
    padding: 0.125rem 0.625rem 0.3425rem 0.625rem;
    font-size: 1.1rem;
    font-weight: 400;
    text-transform: capitalize;
    margin: 0;
    line-height: 1.4;
    transition: color 0.3s ease;
    
    /* Layout Safety: Caps text at 2 lines maximum, adds '...' for overflowing titles */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: Outfit !important;
    flex-grow: 1; /* Pushes the metadata container perfectly to the bottom line */
}

/* Text Hover Transition Engine */
.hmk-cards-wrapper .hmk-course-card:hover .hmk-card-title {
    color: var(--primaryColor);
}

/* "Student First" Metadata Bar Styling */
.hmk-cards-wrapper .card-metadata-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    padding: 0.5rem 0.625rem 0.125rem 0.625rem;
    border-top: 1px solid rgba(17, 22, 29, 0.05);
    margin-top: 0.5rem;
}

.hmk-cards-wrapper .meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.hmk-cards-wrapper .meta-icon {
    width: 14px;
    height: 14px;
    color: var(--primaryColor); /* Uses gold for clean visual accents */
    flex-shrink: 0;
}

/* Search input styling */
.hmk-cards-wrapper .hmk-course-search-container {
    margin-bottom: 1rem;
    margin-top: 1rem;
}

.hmk-cards-wrapper .hmk-course-search {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(17, 22, 29, 0.1);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--brand-navy);
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.hmk-cards-wrapper .hmk-course-search:focus {
    outline: none;
    border-color: var(--primaryColor);
    box-shadow: 0 0 0 3px rgba(180, 133, 62, 0.1);
}

/* Focus styles for accessibility */
.hmk-card-link:focus-visible {
    outline: 2px solid var(--primaryColor);
    outline-offset: 4px;
    border-radius: 8px;
}

/* Custom Category Bar Section from plan */
.custom-category-section {
    --brand-navy: #1C2539;
    --brand-gold: #B4853E;
    --text-main: #FFFFFF;
    font-family: 'Playfair Display', serif;
    margin: 0 auto;
    margin-bottom: 2rem;
}

.category-bar-link {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    /* Rich navy gradient to give it depth similar to the original image */
    background: linear-gradient(135deg, var(--brand-navy) 0%, #28344E 100%);
    color: var(--text-main);
    text-decoration: none;
    padding: 1.25rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(28, 37, 57, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Gold accent line on the left edge */
.category-bar-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background-color: var(--brand-gold);
    transition: width 0.3s ease;
}

/* Hover effects for a premium interactive feel */
.category-bar-link:hover, .category-bar-link:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(28, 37, 57, 0.25);
    outline: none;
}

.category-bar-link:hover::before, .category-bar-link:focus-visible::before {
    width: 10px; /* Expands the gold accent slightly on hover */
}

.category-bar-link:focus-visible {
    outline: 2px solid var(--brand-gold);
    outline-offset: 4px;
}

.category-icon {
    width: 32px;
    height: 32px;
    color: var(--text-main);
    z-index: 1; /* Keeps icon above background elements */
}

.category-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    z-index: 1;
}

/* --- Responsive Breakpoints for Tablet Devices --- */
@media (max-width: 1024px) {
    .hmk-cards-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 Columns on Tablet */
    }
    
    .hmk-cards-wrapper .hmk-course-card {
        padding: 0.85rem;
    }
    
    .hmk-cards-wrapper .hmk-card-title {
        font-size: 1.05rem;
        padding: 0.125rem 0.5rem 0.3rem 0.5rem;
    }
}

/* --- Responsive Breakpoints for Small/Mobile Screens --- */
@media (max-width: 768px) {
    .category-bar-link {
        padding: 1rem 1.5rem;
        gap: 1rem;
    }
    
    .category-text {
        font-size: 1.25rem; /* Scales text down for mobile */
    }
    
    .category-icon {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 667px) {
    .hmk-cards-grid {
        grid-template-columns: 1fr; /* 1 Column on Mobile */
    }
    
    .hmk-cards-wrapper .hmk-course-card {
        padding: 0.75rem;
    }
    
    .hmk-cards-wrapper .hmk-card-title {
        font-size: 1rem;
        padding: 0.125rem 0.35rem 0.25rem 0.35rem;
    }

    .hmk-cards-wrapper .card-metadata-bar {
        gap: 0.6rem;
    }
}