/* Main Grid Container */
.m3-team-grid {
    display: grid;
    width: 100%;
    /* Columns and Gaps are handled by Elementor settings, but we set safe defaults here */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Centered Layout (Flexbox) */
.m3-layout-centered {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    /* Grid properties overridden by Flex logic, but gap is inherited via selectors or inline vars */
}

.m3-layout-centered .m3-member-item {
    /* 
       Calc Width: 
       (100% - (Columns - 1) * Gap) / Columns 
       Using CSS Vars injected by Elementor Selectors
    */
    --cols: var(--m3-cols, 4);
    --gap: var(--m3-gap-x, 20px);

    width: calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
    margin: 0;
    /* Gaps handled by flex container gap property */
}

/* Individual Member Card */
/* Individual Member Card */
.m3-member-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Add max-height and margin/padding to transition for smooth collapse */
    transition:
        transform 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        opacity 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        box-shadow 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        max-height 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        margin 0.5s cubic-bezier(0.19, 1, 0.22, 1),
        padding 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    padding: 15px;
    /* background: #fff;  Removed to allow Elementor control (default transparent) */
    border-radius: 12px;

    /* Set a max-height large enough to fit content but allow animation */
    max-height: 800px;
    overflow: hidden;
    /* Prerequisite for max-height animation */
    transform-origin: center top;
}

.m3-member-item:hover {
    /* transform removed to allow Elementor control or flat design */
    /* box-shadow removed to allow Elementor control */
}

/* Image Styling */
.m3-member-image {
    margin-bottom: 15px;
    position: relative;
    display: inline-block;
}

.m3-member-image img {
    object-fit: cover;
    display: block;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.m3-member-item:hover .m3-member-image img {
    /* box-shadow removed */
}

/* Typography Defaults */
.m3-first-name {
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.2;
    color: #333;
}

.m3-last-name {
    font-weight: 400;
    font-size: 1.2rem;
    line-height: 1.2;
    margin-bottom: 5px;
    color: #333;
}

.m3-job-title {
    font-size: 0.95rem;
    color: #777;
    margin-top: 5px;
    font-weight: 300;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Hidden State and Animation */
.m3-member-item.m3-hidden {
    display: none !important;
    opacity: 0;
    transform: scale(0.95);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
}

/* Animation States */
.m3-member-item.m3-appearing {
    display: flex !important;
    opacity: 0;
    transform: translateY(30px);
    /* Prepare for expansion */
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.m3-member-item.m3-visible {
    display: flex !important;
    opacity: 1;
    transform: translateY(0) scale(1);
    max-height: 800px;
    /* Restore */
    padding: 15px;
    /* Restore (must match original) */
    margin: 0;
    /* Restore */
}

.m3-member-item.m3-hiding {
    display: flex !important;
    opacity: 0;
    transform: scale(0.9);

    /* Collapse layout */
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    pointer-events: none;
}

/* Button Container */
.m3-button-wrapper {
    width: 100%;
    margin-top: 30px;
    clear: both;
}

/* Button Defaults */
.m3-show-more-btn {
    display: inline-block;
    padding: 14px 36px;
    background-color: #222;
    color: #fff;
    border: 2px solid #222;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border-radius: 50px;
    /* Pill shape for premium feel */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.m3-show-more-btn:hover {
    background-color: #fff;
    color: #222;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.m3-show-more-btn:active {
    transform: translateY(-1px);
}