/* Container Base Styles */
.ggg-dynamic-list {
    /* Base class for all layouts (grid or inline) */
    width: 100%;
}

/* Grid/List Layout Container Styles (Default) */
.ggg-dynamic-list-grid {
    display: grid;
    /* gap, grid-template-columns, alignment controlled by Elementor selector */
}

/* Inline/Column Layout Container Styles (New) */
.ggg-dynamic-list-inline {
    display: flex;
    flex-wrap: wrap;
    /* gap, alignment controlled by Elementor selector */
}

/* Container Width Classes */
.ggg-container-width-auto .ggg-dynamic-list-grid {
    width: auto;
    display: inline-grid;
    justify-content: flex-start is the default for 'auto'
}

.ggg-container-width-full .ggg-dynamic-list-grid {
    width: 100%;
    display: grid;
}

/* Card Base Styles with Flexbox and Center Vertical Default */
.ggg-card {
    /* Container Styles */
    padding: 0; /* Default 0, controlled by Elementor */
    margin: 0; /* Default 0, controlled by Elementor */
    background: #fff;
    transition: all 0.3s;
    border: none;
    border-radius: 0;
    
    /* Flexbox for content order and vertical alignment */
    display: flex;
    flex-direction: column;
    
    /* Default fallback alignment for inner elements */
    text-align: center;
    justify-content: flex-start; /* Default vertical alignment */
    
    /* Flex item specific styles for inline layout */
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: auto;
}

/* Vertical Alignment Classes for Cards (Controlled by Position-based Alignment) */
.ggg-card[class*="justify-content-flex-start"] {
    justify-content: flex-start;
}

.ggg-card[class*="justify-content-center"] {
    justify-content: center;
}

.ggg-card[class*="justify-content-flex-end"] {
    justify-content: flex-end;
}

.ggg-card[class*="justify-content-space-between"] {
    justify-content: space-between;
}

/* Horizontal Alignment Classes for Cards (Only used as fallback `text-align`) */
.ggg-card[class*="text-align-left"] {
    text-align: left;
}

.ggg-card[class*="text-align-center"] {
    text-align: center;
}

.ggg-card[class*="text-align-right"] {
    text-align: right;
}

/* Ensure content elements take up full width (block) */
.ggg-card > * {
    width: 100%;
}

/* --- Image Container Styles --- */
.ggg-card-image {
    /* Image is now aligned using align-self on the image wrapper */
    display: flex; /* Changed from inline-flex to flex for align-self to work better on cross-axis */
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 0;
    padding: 0;
    
    /* Alignment is now set by Elementor using align-self: flex-start/center/flex-end */
    align-self: center; /* Default for the image container */
}

.ggg-card-image img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
    padding: 0;
}

/* Image Alignment Modifiers (controlled by Elementor: ggg-img-align-flex-start/center/flex-end) */
/* The prefix_class in PHP already handles the align-self property on .ggg-card-image. */

/* FIXED: Image Mask Styles - Image adapts to mask container */
.ggg-image-mask-circle .ggg-card-image {
    border-radius: 50%;
    /* Force fixed aspect ratio for circle */
    aspect-ratio: 1 / 1;
}
.ggg-image-mask-circle .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.ggg-image-mask-square .ggg-card-image {
    border-radius: 0;
    /* Force fixed aspect ratio for square */
    aspect-ratio: 1 / 1;
}
.ggg-image-mask-square .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.ggg-image-mask-rectangle .ggg-card-image {
    border-radius: 0;
    /* Force fixed aspect ratio for rectangle (4:3) */
    aspect-ratio: 4 / 3;
}
.ggg-image-mask-rectangle .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.ggg-image-mask-rounded .ggg-card-image {
    border-radius: 15%;
    /* Force fixed aspect ratio for rounded square */
    aspect-ratio: 1 / 1;
}
.ggg-image-mask-rounded .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15%;
}

.ggg-image-mask-star .ggg-card-image {
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    -webkit-clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    /* Force fixed aspect ratio for star */
    aspect-ratio: 1 / 1;
}
.ggg-image-mask-star .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    -webkit-clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.ggg-image-mask-triangle .ggg-card-image {
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    -webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    /* Force fixed aspect ratio for triangle */
    aspect-ratio: 1 / 0.866; /* Equilateral triangle ratio */
}
.ggg-image-mask-triangle .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    -webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.ggg-image-mask-hexagon .ggg-card-image {
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    -webkit-clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    /* Force fixed aspect ratio for hexagon */
    aspect-ratio: 1 / 0.866; /* Hexagon ratio */
}
.ggg-image-mask-hexagon .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    -webkit-clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

/* Ensure custom mask also maintains proper image fitting */
.ggg-image-mask-custom .ggg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Text Elements --- (Alignment is controlled by Elementor via text-align) */
.ggg-card-title {
    font-size: 18px;
    margin: 0; 
    padding: 0;
}

.ggg-card-subtitle {
    font-size: 14px;
    color: #666;
    margin: 0;
    padding: 0;
}

.ggg-card-description {
    font-size: 13px;
    color: #333;
    margin: 0;
    padding: 0;
}

/* --- Button Styles --- */
.ggg-card-button {
    display: inline-block;
    padding: 10px 18px;
    background: var(--e-global-color-primary);
    color: var(--e-global-color-text);
    border: none;
    border-radius: 0;
    text-decoration: none;
    transition: all 0.3s;
    text-align: center;
    
    /* Alignment is now controlled by Elementor via align-self */
    align-self: center;
}

.ggg-card-button:hover {
    background: transparent;
    color: var(--e-global-color-primary);
    border: solid 1px var(--e-global-color-primary);
}

/* Responsive adjustments */
@media (max-width: 767px) {
    /* Retained fallback to center alignment on mobile, but Elementor controls should take precedence */
    .ggg-card {
        text-align: center;
    }
    
    .ggg-card-button {
        align-self: center;
    }
    
    /* Ensure masks maintain proportions on mobile */
    .ggg-image-mask-circle .ggg-card-image,
    .ggg-image-mask-square .ggg-card-image,
    .ggg-image-mask-rounded .ggg-card-image,
    .ggg-image-mask-star .ggg-card-image,
    .ggg-image-mask-triangle .ggg-card-image,
    .ggg-image-mask-hexagon .ggg-card-image {
        aspect-ratio: 1 / 1;
    }
    
    .ggg-image-mask-rectangle .ggg-card-image {
        aspect-ratio: 4 / 3;
    }
}