/* --- BASE GRID LOGIC --- */
.team-grid {
    display: grid;
    gap: 15px;
    width: 100%;
}

/* 1. Full Version (No CTA) - Max 4 Wide (Larger Cards) */
.no-cta .team-grid { 
    grid-template-columns: repeat(4, 1fr); 
}

/* 2. Home Version (With CTA) - Max 5 Wide (Smaller Cards) */
.has-cta .team-grid { 
    grid-template-columns: repeat(5, 1fr); 
}

/* --- RESPONSIVE SCALING & BALANCING --- */

/* Tablet / Desktop Small (1200px) */
@media (max-width: 1200px) {
    .no-cta .team-grid { grid-template-columns: repeat(3, 1fr); }
    .has-cta .team-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Tablet (992px) */
@media (max-width: 992px) {
    .no-cta .team-grid { grid-template-columns: repeat(2, 1fr); }
    .has-cta .team-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- MOBILE GRID REFINEMENT (HIGH SPECIFICITY) --- */

@media (max-width: 768px) {
    /* Target the wrapper + grid to beat theme overrides */
    .team-grid-wrapper .team-grid { 
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 10px !important;
    }

    /* Logic for 7 staff + 1 CTA = 8 boxes (2x4 grid) */
    .has-cta .team-card:nth-child(8),
    .has-cta .team-card:nth-child(9) {
        display: none !important;
    }

    /* Keep CTA visible as the 10th item (which moves to 8th spot visually) */
    .has-cta .team-card.join-card {
        display: flex !important;
    }

    .team-name { font-size: 0.8rem; }
    .team-role { font-size: 0.5rem; }
    .join-text { font-size: 0.9rem; }
}

/* Ensure 2-columns stays locked for all smaller phones */
@media (max-width: 480px) {
    .team-grid-wrapper .team-grid { 
        grid-template-columns: 1fr 1fr !important; 
    }
}

/* --- INDIVIDUAL CARD STYLES --- */
.team-card { 
    position: relative; 
    aspect-ratio: 1/1; 
    overflow: hidden; 
    background-color: #f0f0f0; 
}

.team-card img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    filter: grayscale(100%); 
    transition: all 0.5s ease; 
    display: block; 
}

.team-card:hover img { 
    filter: grayscale(0%); 
    transform: scale(1.05); 
}

/* Info Overlay */
.team-info { 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    padding: 1.2rem; 
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    opacity: 0; 
    transform: translateY(10px); 
    transition: 0.4s;
    z-index: 2;
    pointer-events: none; /* Prevents hover flickering */
}

.team-card:hover .team-info { 
    opacity: 1; 
    transform: translateY(0); 
}

/* Typography */
.team-name { 
    color: #fff; 
    display: block; 
    font-size: 0.9rem; 
    font-family: 'Inter', sans-serif; 
    font-weight: bold; 
    line-height: 1.2;
}

.team-role { 
    color: #ccc; 
    font-size: 0.55rem; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    font-family: 'Inter', sans-serif; 
    margin-top: 4px;
}

/* --- CTA CARD (JOIN CARD) --- */
.join-card { 
    background: #156c77; 
    text-align: center; 
}

.join-card a { 
    color: #fff !important; 
    text-decoration: none !important; 
    height: 100%; 
    width: 100%;
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    padding: 1rem;
    transition: background 0.3s ease;
}

.join-card:hover a {
    background: rgba(0, 0, 0, 0.1);
}

.join-text { 
    font-size: 1.1rem; 
    line-height: 1.1; 
    margin-bottom: 10px; 
    font-family: 'Inter', sans-serif; 
}

.join-arrow { 
    width: 35px; 
    height: 35px; 
    border: 1px solid rgba(255,255,255,0.4); 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1.1rem; 
    transition: transform 0.3s ease;
}

.join-card:hover .join-arrow {
    transform: translateX(5px);
    border-color: #fff;
}