/**
 * 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 auto 20px auto; /* Center align icon and 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;
}

/* Dark theme styling for why-choose-us cards (like Image #2) */
.why-choose-us-slider-mask.shared-cards-grid .shared-card,
.shared-cards-grid .shared-card.why-choose-us-card {
    /* Dark theme styling to match original design */
    background: #050f2c !important;
    border-radius: 20px !important;
    padding: 48px 30px 42px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
    transition: all 0.3s ease !important;
    border: none !important;
    backdrop-filter: none !important;
    color: #fff !important;
    min-height: 340px !important;
    display: block !important;
    position: relative !important;
    text-decoration: none !important;
}

.why-choose-us-slider-mask.shared-cards-grid .shared-card:hover,
.shared-cards-grid .shared-card.why-choose-us-card:hover {
    background: #050f2c !important;
    transform: translateY(-8px) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4) !important;
    border-color: transparent !important;
    text-decoration: none !important;
}

/* Dark theme text styling for why-choose-us cards */
.why-choose-us-slider-mask.shared-cards-grid .shared-card .shared-card-title,
.shared-cards-grid .shared-card.why-choose-us-card .shared-card-title {
    color: #fff !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    margin: 0 0 16px 0 !important;
    display: block !important;
    overflow: visible !important;
    text-overflow: initial !important;
    white-space: normal !important;
    -webkit-line-clamp: unset !important;
    max-height: none !important;
}

.why-choose-us-slider-mask.shared-cards-grid .shared-card .shared-card-description,
.shared-cards-grid .shared-card.why-choose-us-card .shared-card-description {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 15px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
    flex-grow: 1 !important;
    display: block !important;
    overflow: visible !important;
    text-overflow: initial !important;
    white-space: normal !important;
    -webkit-line-clamp: unset !important;
    max-height: none !important;
}

.why-choose-us-slider-mask.shared-cards-grid .shared-card .shared-card-icon,
.shared-cards-grid .shared-card.why-choose-us-card .shared-card-icon {
    background: #0080ff !important;
    border-radius: 16px !important;
    padding: 16px !important;
    width: 80px !important;
    height: 80px !important;
    margin: 0 auto 24px auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.why-choose-us-slider-mask.shared-cards-grid .shared-card .shared-card-icon img,
.shared-cards-grid .shared-card.why-choose-us-card .shared-card-icon img {
    width: 48px !important;
    height: 48px !important;
    filter: brightness(0) invert(1) !important;
}

.why-choose-us-slider-mask.shared-cards-grid .shared-card .shared-card-content,
.shared-cards-grid .shared-card.why-choose-us-card .shared-card-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    padding-top: 8px !important;
}

/* Neutral styling for why-choose-us cards (no category colors) */
.shared-card.why-choose-us-card .shared-card-icon {
    background: rgba(102, 126, 234, 0.1);
}

.shared-card.why-choose-us-card:hover {
    /* No border-left color - keep neutral */
}

/* Category-specific styling (for course categories only) */
.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 (for course categories only) */
.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 !important;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
    gap: 24px !important;
    margin-top: 40px !important;
    padding: 0 8px !important; /* Prevent edge cutoff */
    box-sizing: border-box !important;
    overflow: visible !important;
    height: auto !important;
    transform: none !important;
}


/* 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)) !important;
        gap: 20px !important;
    }

    .why-choose-us-slider-mask.shared-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
        gap: 20px !important;
    }
}

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

    .why-choose-us-slider-mask.shared-cards-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
}

/* Ensure the shared cards are being applied correctly */
.shared-card.why-choose-us-card {
    /* Remove debug border - styling handled by main overrides above */
}

/* Additional override for any remaining webflow conflicts */
.why-choose-us-slider-mask .shared-card * {
    box-sizing: border-box !important;
}

/* Force reset any webflow slider positioning */
.why-choose-us-slider-mask.shared-cards-grid * {
    position: static !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
}

/* Critical: Override webflow slider display properties for grid layout */
.why-choose-us-slider-mask.shared-cards-grid {
    /* Force grid layout over webflow slider */
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
    gap: 24px !important;

    /* Reset webflow slider styles */
    overflow: visible !important;
    white-space: normal !important;
    height: auto !important;
    position: static !important;
    z-index: auto !important;
    left: auto !important;
    right: auto !important;

    /* Grid container setup */
    width: 100% !important;
    margin: 0 !important;
    padding: 0 8px !important;
    box-sizing: border-box !important;
}

/* Reset any child slide styling that might interfere */
.why-choose-us-slider-mask.shared-cards-grid .shared-card {
    /* Override any potential webflow slide styling */
    display: block !important;
    position: relative !important;
    vertical-align: baseline !important;
    width: auto !important;
    height: auto !important;
    white-space: normal !important;
    text-align: left !important;

    /* Ensure grid item behaves correctly */
    grid-column: span 1 !important;
    margin: 0 !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
}