/**
 * SHARED CARD SYSTEM
 * Unified card design for consistent UI/UX across all sections
 */

/* Base Card System */
.shared-card {
    display: block;
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    height: 100%;
    min-height: 340px; /* Increased further to prevent icon cutoff */
    overflow: hidden;
}

.shared-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

/* Card Content Structure */
.shared-card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 2;
    padding-top: 8px; /* Add top padding to prevent cutoff */
}

.shared-card-icon {
    width: 64px;
    height: 64px;
    margin: 4px 0 20px 0; /* Add top margin to prevent cutoff */
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(102, 126, 234, 0.1);
    flex-shrink: 0;
}

.shared-card-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.shared-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 12px 0;
    line-height: 1.4; /* Improved line height */

    /* Text overflow handling with better spacing */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 50px; /* Increased for better spacing */
    max-height: 50px; /* Prevent expansion beyond 2 lines */
}

.shared-card-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 0;
    flex-grow: 1;
    margin-top: 8px; /* Add spacing from title */

    /* Text overflow handling with fade effect */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    max-height: 66px; /* 3 lines × 22px with better spacing */
}

/* Fade effect for overflow text */
.shared-card-description::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30%;
    height: 21px;
    background: linear-gradient(to right, transparent, white);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.shared-card-description.text-overflow::after {
    opacity: 1;
}

/* Category-specific styling */
.shared-card.category-web-dev .shared-card-icon {
    background: rgba(102, 126, 234, 0.1);
}

.shared-card.category-mobile .shared-card-icon {
    background: rgba(240, 147, 251, 0.1);
}

.shared-card.category-ml .shared-card-icon {
    background: rgba(79, 172, 254, 0.1);
}

.shared-card.category-cloud .shared-card-icon {
    background: rgba(67, 233, 123, 0.1);
}

/* Hover effects */
.shared-card.category-web-dev:hover {
    border-left: 4px solid #667eea;
}

.shared-card.category-mobile:hover {
    border-left: 4px solid #f093fb;
}

.shared-card.category-ml:hover {
    border-left: 4px solid #4facfe;
}

.shared-card.category-cloud:hover {
    border-left: 4px solid #43e97b;
}

/* Background decoration */
.shared-card-bg {
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 50%;
    transform: translate(40px, -40px);
    transition: all 0.3s ease;
    z-index: 1;
}

.shared-card:hover .shared-card-bg {
    transform: translate(20px, -20px) scale(1.2);
}

/* Text Overflow Solutions */

/* 1. Tooltip for full text on hover */
.shared-card-tooltip {
    position: absolute;
    bottom: calc(100% + 10px); /* Better spacing */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px; /* More padding */
    border-radius: 8px;
    font-size: 13px;
    white-space: normal; /* Allow wrapping */
    max-width: 280px; /* Limit width */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000; /* Higher z-index */
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.shared-card-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.shared-card:hover .shared-card-tooltip {
    opacity: 1;
}

/* 2. Expandable description */
.shared-card-description.expandable {
    cursor: pointer;
    transition: max-height 0.3s ease;
}

.shared-card-description.expandable.expanded {
    -webkit-line-clamp: none;
    max-height: none;
}

.shared-card-description.expandable::before {
    content: '... Read more';
    position: absolute;
    bottom: 0;
    right: 0;
    background: white;
    color: #667eea;
    font-weight: 500;
    padding-left: 10px;
}

.shared-card-description.expandable.expanded::before {
    content: ' Show less';
}

/* Responsive Design */
@media (max-width: 991px) {
    .shared-card {
        min-height: 260px;
        padding: 20px;
    }

    .shared-card-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 16px;
    }

    .shared-card-icon img {
        width: 32px;
        height: 32px;
    }

    .shared-card-title {
        font-size: 16px;
        min-height: 40px;
    }

    .shared-card-description {
        font-size: 13px;
        max-height: 57px; /* 3 lines × 19px */
    }
}

@media (max-width: 767px) {
    .shared-card {
        min-height: 240px;
        padding: 16px;
    }

    .shared-card-title {
        font-size: 15px;
        min-height: 36px;
    }

    .shared-card-description {
        font-size: 12px;
        max-height: 54px; /* 3 lines × 18px */
    }
}

/* Grid Layout for Cards */
.shared-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 40px;
    padding: 0 8px; /* Prevent edge cutoff */
    box-sizing: border-box;
}

/* Prevent card overflow and cutoff */
.course-categories-wrapper {
    overflow: visible !important;
    padding: 30px 0; /* Increased vertical padding */
}

.course-categories .container {
    overflow: visible !important;
}

.course-categories .section {
    overflow: visible !important;
}

/* Ensure course categories section has enough space */
.course-categories-collection-list-wrapper {
    overflow: visible !important;
    margin-top: 20px;
}

/* Fix any potential parent container overflow issues */
.course-categories-content {
    overflow: visible !important;
}

.section.course-categories {
    overflow: visible !important;
    padding: 40px 0; /* Extra section padding */
}

@media (max-width: 991px) {
    .shared-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 767px) {
    .shared-cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}