/* ============================================
   MOBILE CARD PROPORTION FIXES
   ============================================ */

/* ===========================================
   CRITICAL FIXES FOR CARD PROPORTIONS
   =========================================== */

@media (max-width: 768px) {

    /* ========================================
       FIX 1: REDUCE IMAGE HEIGHTS ON MOBILE
       ======================================== */

    /* All card images - reduce from 200px to 120px */
    .service-card img,
    .portfolio-item img,
    .product-card img,
    .blog-card img,
    .testimonial-card img,
    [class*="card"] img {
        height: 120px !important;
        max-height: 120px !important;
        min-height: 120px !important;
        width: 100% !important;
        object-fit: cover !important;
    }

    /* Service/feature cards - even smaller icons */
    .service-card .icon,
    .feature-card .icon {
        height: auto !important;
        max-height: 48px !important;
        width: 48px !important;
    }

    /* ========================================
       FIX 2: BETTER CARD PADDING BALANCE
       ======================================== */

    /* All cards - unified padding */
    .service-card,
    .portfolio-item,
    .product-card,
    .blog-card,
    .testimonial-card,
    .card,
    [class*="card"] {
        padding: 1rem !important;
    }

    /* Card content sections - reduce spacing */
    .card-content,
    .card-body,
    [class*="card-content"],
    [class*="card-body"] {
        padding: 0.75rem !important;
        padding-top: 0.5rem !important;
    }

    /* ========================================
       FIX 3: OPTIMIZE GRID FOR PROPORTIONS
       ======================================== */

    /* Reduce grid gaps for more card space */
    .grid,
    div.grid,
    section .grid,
    .container .grid,
    .cards-grid {
        gap: 0.75rem !important;
        column-gap: 0.75rem !important;
        row-gap: 1rem !important;
    }

    /* Portfolio grid specifically */
    .portfolio-grid,
    .services-grid,
    .products-grid,
    .blog-grid {
        gap: 0.75rem !important;
    }

    /* ========================================
       FIX 4: TEXT SIZING IN CARDS
       ======================================== */

    /* Card titles - smaller but readable */
    .card h3,
    .card-title,
    .service-card h3,
    .portfolio-item h3,
    .product-card h3 {
        font-size: 0.9375rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.375rem !important;
        font-weight: 600 !important;
    }

    /* Card descriptions */
    .card p,
    .card-description,
    .service-card p,
    .portfolio-item p,
    .product-card p {
        font-size: 0.8125rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.5rem !important;
    }

    /* Card metadata (price, date, etc) */
    .card-meta,
    .card-footer,
    .product-price,
    .blog-date {
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
    }

    /* ========================================
       FIX 5: BETTER VERTICAL SPACING IN CARDS
       ======================================== */

    /* Space between image and content */
    .card img + *,
    .card-image + * {
        margin-top: 0.625rem !important;
    }

    /* Space between title and description */
    .card h3 + p,
    .card-title + .card-description {
        margin-top: 0.375rem !important;
    }

    /* ========================================
       FIX 6: CARD ASPECT RATIO OVERRIDE
       ======================================== */

    /* Override aspect ratio for better proportions */
    .portfolio-item img,
    .product-card img {
        aspect-ratio: 4 / 3 !important;
        height: auto !important;
        max-height: 140px !important;
    }

    /* Blog cards - wider ratio */
    .blog-card img {
        aspect-ratio: 16 / 10 !important;
        height: auto !important;
        max-height: 120px !important;
    }

    /* Service cards - no aspect ratio, use icon */
    .service-card img {
        aspect-ratio: auto !important;
    }

    /* ========================================
       FIX 7: PREVENT TEXT OVERFLOW
       ======================================== */

    /* Truncate long titles */
    .card h3,
    .card-title {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
    }

    /* Truncate descriptions */
    .card p,
    .card-description {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
    }

    /* ========================================
       FIX 8: CARD MIN/MAX HEIGHT
       ======================================== */

    /* Set minimum card height for consistency */
    .card,
    .service-card,
    .portfolio-item,
    .product-card,
    .blog-card {
        min-height: 220px !important;
        max-height: 320px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Image container fixed portion */
    .card-image,
    .card img {
        flex-shrink: 0 !important;
    }

    /* Content takes remaining space */
    .card-content,
    .card-body {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }

    /* ========================================
       FIX 9: BETTER BUTTON SIZING IN CARDS
       ======================================== */

    /* Card buttons - smaller on mobile */
    .card button,
    .card .btn,
    .card a.button {
        padding: 0.5rem 1rem !important;
        font-size: 0.8125rem !important;
        margin-top: 0.5rem !important;
        width: 100% !important;
    }

    /* ========================================
       FIX 10: SWIPER/CAROUSEL CARDS
       ======================================== */

    /* Swiper slides */
    .swiper-slide .card,
    .swiper-slide img {
        height: 140px !important;
        max-height: 140px !important;
    }
}

/* ========================================
   SMALL PHONES (≤375px)
   ======================================== */

@media (max-width: 375px) {

    /* Even smaller images */
    .card img,
    .portfolio-item img,
    .product-card img {
        height: 100px !important;
        max-height: 100px !important;
    }

    /* Tighter padding */
    .card,
    .service-card,
    .portfolio-item,
    .product-card {
        padding: 0.75rem !important;
    }

    /* Smaller text */
    .card h3 {
        font-size: 0.875rem !important;
    }

    .card p {
        font-size: 0.75rem !important;
    }

    /* Tighter gaps */
    .grid {
        gap: 0.5rem !important;
    }
}

/* ========================================
   ALTERNATIVE: SINGLE COLUMN OPTION
   ======================================== */

@media (max-width: 480px) {

    /* Option to switch to single column on very small screens */
    .force-single-column .grid,
    .single-column-mobile .grid {
        grid-template-columns: 1fr !important;
    }

    .force-single-column .card,
    .single-column-mobile .card {
        max-width: 100% !important;
    }

    .force-single-column .card img,
    .single-column-mobile .card img {
        height: 180px !important;
        max-height: 180px !important;
        aspect-ratio: 16 / 9 !important;
    }
}

/* ========================================
   SPECIFIC CARD TYPE FIXES
   ======================================== */

@media (max-width: 768px) {

    /* SERVICE CARDS */
    .service-card {
        text-align: center !important;
    }

    .service-card .icon,
    .service-card svg {
        margin: 0 auto 0.5rem !important;
        display: block !important;
    }

    .service-card h3 {
        margin-bottom: 0.5rem !important;
    }

    /* PORTFOLIO CARDS */
    .portfolio-item {
        position: relative !important;
    }

    .portfolio-item img {
        border-radius: 8px 8px 0 0 !important;
    }

    .portfolio-item-content {
        padding: 0.75rem !important;
    }

    /* PRODUCT CARDS */
    .product-card {
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    .product-card img {
        border-radius: 8px 8px 0 0 !important;
    }

    .product-price {
        font-weight: 700 !important;
        color: var(--color-accent) !important;
        font-size: 1rem !important;
        margin-top: auto !important;
    }

    /* BLOG CARDS */
    .blog-card img {
        border-radius: 8px 8px 0 0 !important;
    }

    .blog-card-content {
        padding: 0.75rem !important;
    }

    .blog-date {
        color: var(--color-gray) !important;
        margin-bottom: 0.375rem !important;
    }

    /* TESTIMONIAL CARDS */
    .testimonial-card {
        padding: 1rem !important;
        text-align: left !important;
    }

    .testimonial-card img {
        width: 48px !important;
        height: 48px !important;
        max-height: 48px !important;
        border-radius: 50% !important;
        margin-bottom: 0.75rem !important;
    }

    .testimonial-text {
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
        margin-bottom: 0.75rem !important;
    }

    .testimonial-author {
        font-size: 0.8125rem !important;
        font-weight: 600 !important;
    }
}

/* ========================================
   HOVER/ACTIVE STATES (MOBILE)
   ======================================== */

@media (max-width: 768px) {

    /* Better touch feedback */
    .card:active,
    .service-card:active,
    .portfolio-item:active {
        transform: scale(0.97) !important;
        opacity: 0.9 !important;
    }

    /* No hover effects on mobile */
    .card:hover {
        transform: none !important;
    }
}

/* ========================================
   CARD LOADING STATES
   ======================================== */

@media (max-width: 768px) {

    /* Skeleton cards */
    .card-skeleton {
        min-height: 220px !important;
        background: var(--glass-bg) !important;
        border-radius: 12px !important;
    }

    .card-skeleton-image {
        height: 120px !important;
        background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.1) 25%,
            rgba(255, 255, 255, 0.2) 50%,
            rgba(255, 255, 255, 0.1) 75%
        ) !important;
        background-size: 200% 100% !important;
        animation: loading-shimmer 1.5s infinite !important;
    }
}

/* ========================================
   DEBUGGING (Remove in production)
   ======================================== */

/* Uncomment to visualize card boundaries */
/*
@media (max-width: 768px) {
    .card,
    .service-card,
    .portfolio-item {
        outline: 1px solid red !important;
    }

    .card img {
        outline: 1px solid blue !important;
    }

    .card-content,
    .card-body {
        outline: 1px solid green !important;
    }
}
*/
