/* Wrapper */
.species-compat {
    margin: 1.5rem 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #222;
    max-width: 100%;
    overflow: visible;
}

/* Main grid: desktop/tablet */
.species-compat--grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: visible;
}

.species-compat__row {
    display: contents;
}

/* Header cells */
.species-compat__row--header .species-compat__cell {
    background: #f8f9fa;
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 2px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    text-align: center;
    font-size: 13px;
}
.species-compat__row--header .species-compat__cell:last-child {
    border-right: none;
}

/* Body cells */
.species-compat__row--body .species-compat__cell {
    padding: 14px;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #f0f0f0;
    vertical-align: top;
}
.species-compat__row--body .species-compat__cell:last-child {
    border-right: none;
}

/* Species list cell (left column) */
.species-compat__cell--selector {
    background: #f8f9fa;
    overflow: visible !important;
}

/* Species list container */
.species-compat__species-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: none;
    overflow-y: visible;
    padding-right: 6px;
}

/* Species buttons */
.species-compat__species-button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    background: #f9f9f9;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-align: left;
}
.species-compat__species-button:hover {
    background: #e8f4f8;
    border-color: #999;
    transform: translateY(-1px);
}
.species-compat__species-button.is-active {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
    box-shadow: 0 2px 4px rgba(0,124,186,0.3);
}

/* Result column backgrounds */
.species-compat__cell--yes {
    background: #d4edda;
}
.species-compat__cell--caution {
    background: #fff3cd;
}
.species-compat__cell--no {
    background: #f8d7da;
}

/* Lists inside result columns */
.species-compat__list {
    font-size: 13px;
    line-height: 1.5;
}
.species-compat__list > div {
    padding: 4px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.species-compat__list > div:last-child {
    border-bottom: none;
}

/* MOBILE LIST LAYOUT BASE (hidden on desktop by default) */
.species-compat--mobile-list {
    display: none;
}
.species-compat__mobile-item {
    margin-bottom: 10px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #fff;
}
.species-compat__mobile-results {
    display: none; /* shown when species is active */
}

/* ---------- MOBILE LAYOUT (≤ 480px) ---------- */
@media (max-width: 480px) {

    /* Hide desktop grid; show mobile list */
    .species-compat--grid-desktop {
        display: none;
    }
    .species-compat--mobile-list {
        display: block;
    }

    /* Make sure the wrapper uses full width without extra shadow/clipping */
    .species-compat--grid {
        display: none; /* safety: only mobile list used on phones */
    }

    .species-compat__species-button--mobile {
        padding: 12px 14px;
        font-size: 15px;
        width: 100%;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid #dee2e6;
        background: #f8f9fa;
    }
    .species-compat__species-button--mobile.is-active {
        background: #007cba;
        color: #fff;
        border-color: #007cba;
    }

    .species-compat__mobile-results {
        background: #fff;
        padding: 0;
    }

    .species-compat__mobile-results .species-compat__cell {
        border: none;
        padding: 16px;
    }

    .species-compat__mobile-results .species-compat__cell--yes {
        background: #d4edda;
        border-bottom: 2px solid #28a745;
    }
    .species-compat__mobile-results .species-compat__cell--caution {
        background: #fff3cd;
        border-bottom: 2px solid #ffc107;
    }
    .species-compat__mobile-results .species-compat__cell--no {
        background: #f8d7da;
    }

    .species-compat__list > div {
        padding: 6px 0;
        font-size: 14px;
    }

    /* Mobile headers for result sections */
    .species-compat__mobile-results .species-compat__cell--yes::before,
    .species-compat__mobile-results .species-compat__cell--caution::before,
    .species-compat__mobile-results .species-compat__cell--no::before {
        display: block;
        font-weight: 600;
        font-size: 16px;
        margin-bottom: 10px;
        padding-bottom: 6px;
    }

    .species-compat__mobile-results .species-compat__cell--yes::before {
        content: "✅ COMPATIBLE";
        border-bottom: 2px solid #28a745;
    }

    .species-compat__mobile-results .species-compat__cell--caution::before {
        content: "⚠️ CAUTION";
        border-bottom: 2px solid #ffc107;
    }

    .species-compat__mobile-results .species-compat__cell--no::before {
        content: "❌ NOT COMPATIBLE";
        border-bottom: 2px solid #dc3545;
    }
}
