.cgd-container {
    display: grid;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.cgd-category-item {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cgd-category-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.cgd-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 aspect ratio (square) */
    overflow: hidden;
}

.cgd-category-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s ease;
    box-sizing: border-box;
}

.cgd-category-item:hover .cgd-category-image {
    transform: scale(1.05);
}

/* Title styles */
.cgd-category-title {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    box-sizing: border-box;
}

/* Title position: hover */
.cgd-title-hover .cgd-category-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    padding: calc(0.5em + 2px); /* Dynamic padding based on font size */
    line-height: 1.2;
}

.cgd-title-hover .cgd-category-item:hover .cgd-category-title {
    opacity: 1;
    transform: translateY(0);
}

/* Title position: below (outside image) */
.cgd-title-below .cgd-category-title {
    position: static;
    display: block;
    margin-top: 10px;
    background: none;
    color: inherit;
    text-align: center;
    width: 100%;
    padding: calc(0.3em + 2px); /* Dynamic padding based on font size */
    line-height: 1.2;
}

/* Title position: active_hover (always visible) */
.cgd-title-active_hover .cgd-category-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    transition: background-color 0.3s ease;
    opacity: 1 !important; /* Force visibility */
    transform: none !important; /* Prevent transform changes */
    padding: calc(0.5em + 2px); /* Dynamic padding based on font size */
    line-height: 1.2;
}

.cgd-title-active_hover .cgd-category-item:hover .cgd-category-title {
    background-color: rgba(0, 0, 0, 0.9);
}

/* Background styles */
.cgd-background-white {
    background-color: #ffffff;
}

.cgd-background-pattern {
    background-image: url('../images/pattern-bg.png');
    background-repeat: repeat;
}

/* Links */
.cgd-category-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* Lazy loading */
.cgd-lazy {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.cgd-lazy.loaded {
    opacity: 1;
}
