/**
 * Services Grid Block - Frontend Styles with Centered Incomplete Rows
 * Place this file in your theme's /blocks/services-grid/ directory
 */

/* CSS Variables */
:root {
    --services-primary-blue: #3258c2;
    --services-dark-blue: #1a2b5a;
    --services-light-gray: #f8f9fa;
    --services-text-dark: #333333;
    --services-text-light: #ffffff;
}

/* Services Section */
.wp-block-custom-services-grid {
    padding: 80px 20px;
    background-color: var(--services-light-gray);
}

.wp-block-custom-services-grid.alignfull {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

.wp-block-custom-services-grid.alignwide {
    margin-left: calc(25% - 25vw);
    margin-right: calc(25% - 25vw);
    max-width: 100vw;
}

/* Container */
.wp-block-custom-services-grid .services-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Title and Intro */
.wp-block-custom-services-grid .services-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    color: var(--services-dark-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.wp-block-custom-services-grid .services-intro {
    max-width: 800px;
    margin: 0 auto 50px;
    text-align: center;
    font-size: 16px;
    line-height: 1.8;
    color: var(--services-text-dark);
}

/* Services Grid - Using Flexbox for Better Centering */
.wp-block-custom-services-grid .services-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

/* Grid Item Width Based on Columns */
.wp-block-custom-services-grid .services-grid--cols-1 .service-card {
    flex: 0 1 100%;
    max-width: 600px;
}

.wp-block-custom-services-grid .services-grid--cols-2 .service-card {
    flex: 0 1 calc(50% - 10px);
    max-width: 500px;
}

.wp-block-custom-services-grid .services-grid--cols-3 .service-card {
    flex: 0 1 calc(33.333% - 14px);
    max-width: 380px;
}

.wp-block-custom-services-grid .services-grid--cols-4 .service-card {
    flex: 0 1 calc(25% - 15px);
    max-width: 280px;
}

/* Service Card Base */
.wp-block-custom-services-grid .service-card {
    padding: 40px 30px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    border-radius: 8px;
    min-height: 100%;
}

/* Card Styles - Filled */
.wp-block-custom-services-grid .service-card--filled {
    background-color: var(--services-primary-blue);
    color: var(--services-text-light);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.wp-block-custom-services-grid .service-card--filled:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

/* Card Styles - Outlined */
.wp-block-custom-services-grid .service-card--outlined {
    background-color: #ffffff;
    border: 2px solid var(--services-primary-blue);
    color: var(--services-primary-blue);
}

.wp-block-custom-services-grid .service-card--outlined:hover {
    background-color: var(--services-primary-blue);
    color: var(--services-text-light);
    transform: translateY(-5px);
}

.wp-block-custom-services-grid .service-card--outlined:hover .service-title,
.wp-block-custom-services-grid .service-card--outlined:hover .service-description {
    color: var(--services-text-light);
}

/* Card Styles - Minimal */
.wp-block-custom-services-grid .service-card--minimal {
    background-color: #ffffff;
    color: var(--services-text-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.wp-block-custom-services-grid .service-card--minimal:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    transform: translateY(-3px);
}

/* Service Icon */
.wp-block-custom-services-grid .service-icon {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Icon Sizes */
.wp-block-custom-services-grid .service-card--icon-small .service-icon {
    font-size: 32px;
    width: 50px;
    height: 50px;
}

.wp-block-custom-services-grid .service-card--icon-medium .service-icon {
    font-size: 40px;
    width: 60px;
    height: 60px;
}

.wp-block-custom-services-grid .service-card--icon-large .service-icon {
    font-size: 48px;
    width: 70px;
    height: 70px;
}

/* Icon Types */
.wp-block-custom-services-grid .service-icon-emoji {
    display: inline-block;
    line-height: 1;
}

.wp-block-custom-services-grid .service-icon .dashicons {
    width: auto;
    height: auto;
    font-size: inherit;
}

.wp-block-custom-services-grid .service-icon img {
    max-width: 100%;
    height: auto;
}

.wp-block-custom-services-grid .service-icon-svg {
    width: 100%;
    height: 100%;
}

.wp-block-custom-services-grid .service-icon-svg svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* Service Title */
.wp-block-custom-services-grid .service-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.3;
}

.wp-block-custom-services-grid .service-card--filled .service-title {
    color: inherit;
}

.wp-block-custom-services-grid .service-card--outlined .service-title {
    color: inherit;
}

.wp-block-custom-services-grid .service-card--minimal .service-title {
    color: var(--services-dark-blue);
}

/* Service Description */
.wp-block-custom-services-grid .service-description {
    font-size: 14px;
    line-height: 1.6;
    margin-top: 10px;
    opacity: 0.9;
}

/* Service Link Arrow */
.wp-block-custom-services-grid .service-link-arrow {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 20px;
    font-weight: bold;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

.wp-block-custom-services-grid a.service-card:hover .service-link-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Link styling for cards */
.wp-block-custom-services-grid a.service-card {
    cursor: pointer;
}

.wp-block-custom-services-grid a.service-card * {
    pointer-events: none;
}

/* Alternative Grid Layout Using CSS Grid with Centering (Optional Enhancement) */
@supports (display: grid) {
    /* For browsers that support modern grid features */
    .wp-block-custom-services-grid .services-grid--cols-3:has(.service-card:nth-child(5):last-child),
    .wp-block-custom-services-grid .services-grid--cols-3:has(.service-card:nth-child(8):last-child) {
        /* Special handling for 5 or 8 items in 3-column grid */
    }
    
    .wp-block-custom-services-grid .services-grid--cols-4:has(.service-card:nth-child(5):last-child),
    .wp-block-custom-services-grid .services-grid--cols-4:has(.service-card:nth-child(6):last-child),
    .wp-block-custom-services-grid .services-grid--cols-4:has(.service-card:nth-child(7):last-child) {
        /* Special handling for 5, 6, or 7 items in 4-column grid */
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .wp-block-custom-services-grid .services-grid--cols-4 .service-card {
        flex: 0 1 calc(50% - 10px);
        max-width: 400px;
    }
    
    .wp-block-custom-services-grid .services-grid--cols-3 .service-card {
        flex: 0 1 calc(50% - 10px);
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .wp-block-custom-services-grid {
        padding: 60px 20px;
    }
    
    .wp-block-custom-services-grid .services-title {
        font-size: 28px;
        margin-bottom: 20px;
    }
    
    .wp-block-custom-services-grid .services-intro {
        font-size: 14px;
        margin-bottom: 40px;
    }
    
    .wp-block-custom-services-grid .services-grid--cols-4 .service-card,
    .wp-block-custom-services-grid .services-grid--cols-3 .service-card,
    .wp-block-custom-services-grid .services-grid--cols-2 .service-card {
        flex: 0 1 100%;
        max-width: 500px;
    }
    
    .wp-block-custom-services-grid .service-card {
        padding: 30px 25px;
    }
    
    .wp-block-custom-services-grid .service-title {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .wp-block-custom-services-grid .services-container {
        padding: 0 15px;
    }
    
    .wp-block-custom-services-grid .service-card {
        padding: 25px 20px;
    }
    
    /* Adjust icon sizes on mobile */
    .wp-block-custom-services-grid .service-card--icon-large .service-icon {
        font-size: 40px;
        width: 60px;
        height: 60px;
    }
}

/* Print Styles */
@media print {
    .wp-block-custom-services-grid {
        background-color: white !important;
    }
    
    .wp-block-custom-services-grid .service-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}