﻿.ipa-highlight {
    color: var(--mud-palette-tertiary);
}

.matrix-icon-button .mud-icon-root {
    font-size: var(--icon-size) !important;
    width: var(--icon-size) !important;
    height: var(--icon-size) !important;
}

.popover-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: transparent;
}

.articulation-stack {
    width: 100%;
    align-items: center !important;
    justify-content: center;
    text-align: center;
}

.articulation-label {
    width: 100%;
    text-align: center;
}

.ipa-header-cell {
    text-align: center !important;
    font-weight: 800 !important;
}

.ipa-table-wrapper {
    width: 100%;
}

/* IPA Matrix Table */
.ipa-table {
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

    /* MudTable root internals */
    .ipa-table .mud-table-container {
        background: transparent;
    }

    .ipa-table table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }

    /* Header */
    .ipa-table thead {
        background: #00000030;
    }

    .ipa-table th {
        font-weight: 700;
        font-size: 0.95rem;
        letter-spacing: 0.02em;
        padding: 16px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        white-space: nowrap;
    }

    /* Cells */
    .ipa-table td {
        font-size: 0.95rem;
        padding: 22px 20px;
        vertical-align: middle;
        border-color: rgba(255, 255, 255, 0.08) !important;
    }

    /* Rows */
    .ipa-table tbody tr {
        transition: background-color 160ms ease, transform 160ms ease;
    }

        .ipa-table tbody tr:nth-child(even) {
            background: #00000016;
        }

        .ipa-table tbody tr:hover {
            background-color: color-mix( in srgb, var(--mud-palette-primary) 20%, var(--mud-palette-background) );
        }

/* IPA column */
.ipa-cell {
    width: 110px;
    font-size: 1.15rem !important;
    font-weight: 700;
}

/* Images */
.matrix-image {
    object-fit: contain;
    display: block;
    margin-inline: auto;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.25));
}

/* Stack content in cells */
.ipa-table .mud-stack {
    align-items: flex-start;
    gap: 10px;
}

/* Examples column */
.ipa-table td[data-label="Examples"] {
    line-height: 1.6;
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.example-text {
    overflow-wrap: anywhere;
    word-break: normal;
}

/* Mobile: IPA table becomes clean centered cards */
@media (max-width: 640px) {

    .ipa-table-wrapper {
        width: 100%;
        display: grid;
        justify-items: center;
        padding-inline: 12px;
        box-sizing: border-box;
    }

        .ipa-table-wrapper > .ipa-table,
        .ipa-table.mud-table {
            width: min(100%, 560px) !important;
            max-width: 560px !important;
            margin-inline: auto !important;
            flex: 0 0 auto !important;
            border: none !important;
            box-shadow: none !important;
            border-radius: 0 !important;
            overflow: visible !important;
        }

    .ipa-table .mud-table-container {
        width: 100% !important;
        max-width: 560px !important;
        margin-inline: auto !important;
        overflow: visible !important;
    }

    /* Hide table header completely */
    .ipa-table thead,
    .ipa-table .mud-table-head {
        display: none !important;
    }

    .ipa-table table,
    .ipa-table tbody {
        display: block !important;
        width: 100% !important;
        max-width: 560px !important;
        margin-inline: auto !important;
    }

    .ipa-table table {
        border-collapse: separate;
        border-spacing: 0;
    }

    /* Each IPA row becomes one card */
    .ipa-table tbody tr {
        display: grid !important;
        grid-template-columns: 1fr;
        width: 100% !important;
        max-width: 560px !important;
        margin: 0 auto 18px auto !important;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
        transition: background-color 160ms ease, transform 160ms ease;
    }

        .ipa-table tbody tr:nth-child(even) {
            background: #00000016;
        }

        .ipa-table tbody tr:hover {
            background-color: color-mix( in srgb, var(--mud-palette-primary) 20%, var(--mud-palette-background) );
        }

    /* Reset desktop cell behavior */
    .ipa-table tbody td {
        display: grid !important;
        grid-template-columns: 110px minmax(0, 1fr);
        align-items: center;
        gap: 18px;
        width: 100% !important;
        box-sizing: border-box;
        padding: 18px 20px;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

        .ipa-table tbody td:last-child {
            border-bottom: none !important;
        }

        .ipa-table tbody td::before {
            content: attr(data-label);
            grid-column: 1;
            font-size: 0.78rem;
            font-weight: 800;
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }

        /*
       Robust mobile layout:
       Every direct child of a table cell goes into the right content column.
       The generated label stays in the left title column.
    */
        .ipa-table tbody td > * {
            grid-column: 2;
            min-width: 0;
        }

    /* IPA symbol */
    .ipa-table .ipa-cell {
        display: grid !important;
        grid-template-columns: 110px minmax(0, 1fr);
        align-items: center;
        width: 100% !important;
        font-size: 1.9rem !important;
        font-weight: 800;
        line-height: 1;
    }

        .ipa-table .ipa-cell > * {
            justify-self: center;
            text-align: center;
        }

    /* Mouth/Tongue layout inside the right column */
    .ipa-table .mud-stack {
        align-items: center !important;
        justify-content: center;
        justify-self: center;
        gap: 10px;
        text-align: center;
        width: 100%;
    }

    .ipa-table .matrix-image {
        width: 88px !important;
        height: 88px !important;
        object-fit: contain;
        margin: 0 auto;
        filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.28));
    }

    .ipa-table td[data-label="Examples"] {
        font-size: 1rem;
        line-height: 1.5;
    }

        .ipa-table td[data-label="Examples"] .examples-list {
            grid-column: 2;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-self: center;
            width: 100%;
            gap: 6px;
            min-width: 0;
            text-align: center;
        }

        .ipa-table td[data-label="Examples"] .example-text {
            width: 100%;
            text-align: center;
            overflow-wrap: anywhere;
            word-break: normal;
        }
}
