/**
 * Team Info Modal Styles
 *
 * Overlay + card modal for team schedule and roster/stats.
 * Loaded conditionally when [usau_results] shortcode is present.
 *
 * Design follows specimens/team-modal-refined.html — Data Sheet body
 * (segmented pill tabs, dense tables, mono numerics, two-polarity heat-map)
 * with a clean Broadsheet identity header.
 *
 * @package Condor
 */

@keyframes team-modal-skeleton-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

body.team-modal-open {
    overflow: hidden;
}

.team-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;

    &.is-open {
        opacity: 1;
        visibility: visible;

        .team-modal__card {
            transform: translateY(0);
        }
    }

    .team-modal__overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
    }

    .team-modal__card {
        position: relative;
        z-index: 1;
        background: var(--wp--preset--color--white);
        border-radius: 12px;
        width: 100%;
        max-width: 960px;
        max-height: 85vh;
        min-height: 90dvh;
        display: flex;
        flex-direction: column;
        box-shadow:
            0 30px 80px -20px rgba(0, 0, 0, 0.30),
            0 10px 30px -10px rgba(0, 0, 0, 0.15);
        overflow: hidden;
        transform: translateY(8px);
        transition: transform 0.2s ease;
    }

    .team-modal__close {
        position: absolute;
        top: 16px;
        right: 16px;
        z-index: 2;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: none;
        background: rgba(0, 0, 0, 0.06);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s ease;

        &:hover {
            background: rgba(0, 0, 0, 0.12);
        }

        &::before,
        &::after {
            content: "";
            position: absolute;
            width: 14px;
            height: 2px;
            background: var(--wp--preset--color--slate);
            border-radius: 1px;
        }

        &::before { transform: rotate(45deg); }
        &::after { transform: rotate(-45deg); }
    }

    /* Header — identity row (no logo placeholder; element omitted when missing) */
    .team-modal__header {
        padding: 22px 32px 0;
    }

    .team-modal__identity {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .team-modal__logo {
        width: 52px;
        height: 52px;
        border-radius: 6px;
        object-fit: contain;
        background: var(--wp--preset--color--off-white);
        border: 1px solid var(--wp--preset--color--hairline, var(--wp--preset--color--light-gray));
        flex-shrink: 0;
    }

    .team-modal__id {
        flex: 1;
        min-width: 0;
    }

    .team-modal__title-row {
        display: flex;
        align-items: baseline;
        gap: 10px;
        flex-wrap: wrap;
        margin-bottom: 2px;
    }

    .team-modal__name {
        font-family: var(--wp--preset--font-family--heading);
        font-weight: 700;
        font-size: 26px;
        line-height: 1.1;
        letter-spacing: -0.015em;
        color: var(--color-usau-blue);
        margin: 0;
    }

    .team-modal__location {
        font-size: 16px;
        color: var(--wp--preset--color--slate);
        font-weight: 500;
    }

    .team-modal__info {
        margin-top: 16px;
        padding: 16px 0 0 0;
        border-top: 1px solid var(--wp--preset--color--hairline, var(--wp--preset--color--light-gray));
        font-size: 15px;
        line-height: 1.6;
        color: var(--wp--preset--color--charcoal);
        white-space: pre-line;
    }

    .team-modal__info.is-empty {
        display: none;
    }

    /* Tabs — segmented pill control */
    .team-modal__tabs {
        display: flex;
        padding: 14px 32px 12px;
    }

    .team-modal__tab-group {
        display: inline-flex;
        padding: 3px;
        background: var(--wp--preset--color--warm-gray, #e5e2dc);
        border-radius: 8px;
    }

    .team-modal__tab {
        background: none;
        border: none;
        padding: 8px 18px;
        font-family: var(--wp--preset--font-family--heading);
        font-size: 14px;
        font-weight: 600;
        color: var(--wp--preset--color--charcoal);
        cursor: pointer;
        border-radius: 6px;
        transition:
            background 0.15s ease,
            color 0.15s ease;

        &:hover:not(.is-active) {
            color: var(--color-usau-blue);
        }

        &.is-active {
            background: var(--wp--preset--color--white);
            color: var(--color-usau-blue);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
        }
    }

    .team-modal__body {
        flex: 1;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 0 32px 28px;
    }

    .team-modal__tab-panel {
        display: none;

        &.is-active {
            display: block;
        }
    }

    /* Schedule — dense data sheet */
    .team-modal__schedule {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;

        thead th {
            font-family: var(--wp--preset--font-family--heading);
            font-size: 13px;
            font-weight: 600;
            color: var(--wp--preset--color--mid-gray);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            padding: 12px 10px 10px;
            text-align: left;
            border-bottom: 1px solid var(--wp--preset--color--light-gray);
            white-space: nowrap;

            &.col-score {
                text-align: right;
            }
        }

        tbody {
            td {
                padding: 12px 10px;
                border-bottom: 1px solid var(--wp--preset--color--hairline, #ececec);
                vertical-align: middle;
            }

            tr:hover td {
                background: rgba(41, 100, 168, 0.04);
            }

            tr:last-child td {
                border-bottom: none;
            }
        }

        td.col-time {
            font-family: var(--wp--preset--font-family--mono, ui-monospace, Menlo, monospace);
            font-size: 13px;
            font-weight: 600;
            color: var(--wp--preset--color--mid-gray);
            width: 90px;
            white-space: nowrap;

            strong {
                color: var(--wp--preset--color--slate);
                margin-right: 6px;
                font-weight: 700;
            }
        }

        td.col-opponent {
            font-family: var(--wp--preset--font-family--heading);
            font-size: 16px;
            font-weight: 600;
            color: var(--wp--preset--color--slate);
        }

        td.col-score {
            text-align: right;
            font-family: var(--wp--preset--font-family--mono, ui-monospace, Menlo, monospace);
            font-weight: 600;
            font-size: 15px;
            color: var(--wp--preset--color--slate);
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
            width: 110px;
        }

        td.col-field {
            font-family: var(--wp--preset--font-family--mono, ui-monospace, Menlo, monospace);
            color: var(--wp--preset--color--charcoal);
            font-weight: 500;
            font-size: 13px;
        }

        td.col-round {
            font-family: var(--wp--preset--font-family--body);
            color: var(--wp--preset--color--charcoal);
            font-weight: 500;
            font-size: 13px;
        }
    }

    /* Fused W/L pip in the score cell */
    .team-modal__pip {
        display: inline-block;
        width: 16px;
        height: 16px;
        border-radius: 3px;
        margin-left: 10px;
        font-family: var(--wp--preset--font-family--heading);
        font-size: 11px;
        font-weight: 700;
        text-align: center;
        line-height: 16px;
        vertical-align: 1px;
    }

    .team-modal__pip--w {
        background: var(--wp--preset--color--green, #166534);
        color: var(--wp--preset--color--white);
    }

    .team-modal__pip--l {
        background: var(--wp--preset--color--bright-red);
        color: var(--wp--preset--color--white);
    }

    .team-modal__pip--pending {
        background: transparent;
        border: 1px dashed var(--wp--preset--color--light-gray);
        color: var(--wp--preset--color--mid-gray);
        font-size: 10px;
    }

    /* Roster — dense + two-polarity heat-map */
    .team-modal__roster {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;

        thead th {
            font-family: var(--wp--preset--font-family--heading);
            font-size: 13px;
            font-weight: 600;
            color: var(--wp--preset--color--mid-gray);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            padding: 12px 10px 10px;
            border-bottom: 1px solid var(--wp--preset--color--light-gray);
            text-align: left;
            white-space: nowrap;
            user-select: none;

            &[data-sortable] {
                cursor: pointer;

                &:hover {
                    color: var(--color-usau-blue);
                }
            }

            &.col-stat {
                text-align: right;
            }
        }

        .th-sort {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .sort-icon {
            width: 12px;
            height: 12px;
            flex-shrink: 0;
            opacity: 0.3;
            transition: opacity 0.15s ease;
            color: var(--wp--preset--color--light-gray);
        }

        th[aria-sort] .sort-icon {
            opacity: 1;
            color: var(--color-usau-blue);
        }

        th[aria-sort="ascending"] .sort-icon {
            transform: rotate(180deg);
        }

        tbody {
            td {
                padding: 11px 10px;
                border-bottom: 1px solid var(--wp--preset--color--hairline, #ececec);
                vertical-align: middle;
            }

            tr:hover td {
                background: rgba(41, 100, 168, 0.03);
            }

            tr:last-child td {
                border-bottom: none;
            }
        }

        .col-jersey {
            font-family: var(--wp--preset--font-family--mono, ui-monospace, Menlo, monospace);
            font-size: 13px;
            color: var(--wp--preset--color--mid-gray);
            width: 36px;
        }

        .col-name {
            font-family: var(--wp--preset--font-family--heading);
            font-size: 15px;
            font-weight: 600;
            color: var(--wp--preset--color--slate);
        }

        .col-stat {
            text-align: right;
            font-family: var(--wp--preset--font-family--mono, ui-monospace, Menlo, monospace);
            font-weight: 600;
            font-size: 14px;
            font-variant-numeric: tabular-nums;
            color: var(--wp--preset--color--slate);
            width: 60px;

            &.is-zero {
                color: var(--wp--preset--color--light-gray);
                font-weight: 400;
            }
        }

        /* Heat-map — green for "good" stats (G/A/D) */
        .col-stat.heat-good-1 { background: rgba(22, 101, 52, 0.06); }
        .col-stat.heat-good-2 { background: rgba(22, 101, 52, 0.12); }
        .col-stat.heat-good-3 {
            background: rgba(22, 101, 52, 0.20);
            color: var(--wp--preset--color--green, #166534);
        }

        /* Heat-map — amber for "watch-out" stats (TO) */
        .col-stat.heat-warn-1 { background: rgba(146, 64, 14, 0.06); }
        .col-stat.heat-warn-2 { background: rgba(146, 64, 14, 0.12); }
        .col-stat.heat-warn-3 {
            background: rgba(146, 64, 14, 0.20);
            color: var(--wp--preset--color--amber, #92400e);
        }
    }

    .team-modal__coaches {
        margin-top: 16px;
        padding-top: 12px;
        border-top: 1px solid var(--wp--preset--color--hairline, var(--wp--preset--color--light-gray));
        font-size: 14px;
        color: var(--wp--preset--color--charcoal);

        strong {
            font-weight: 600;
            color: var(--wp--preset--color--slate);
        }
    }

    .team-modal__skeleton {
        background: #eee;
        border-radius: 4px;
        animation: team-modal-skeleton-pulse 1.5s ease-in-out infinite;
    }

    .team-modal__skeleton-line {
        height: 14px;
        margin-bottom: 8px;

        &--meta {
            width: 60%;
        }
    }

    .team-modal__skeleton-tab {
        width: 90px;
        height: 32px;
        border-radius: 6px;
    }

    .team-modal__skeleton-table {
        padding: 16px 0;
    }

    .team-modal__skeleton-row {
        display: flex;
        gap: 12px;
        padding: 10px 0;
        border-bottom: 1px solid var(--wp--preset--color--hairline, #ececec);
    }

    .team-modal__skeleton-cell {
        height: 14px;

        &--time { width: 90px; }
        &--opponent { flex: 1; }
        &--score { width: 110px; }
        &--field { width: 50px; }
        &--round { width: 90px; }
    }

    .team-modal__error {
        padding: 32px 24px;
        text-align: center;
        color: var(--wp--preset--color--mid-gray);
        font-size: 14px;
    }

    /* Mobile — bottom sheet */
    @media (max-width: 640px) {
        align-items: flex-end;

        .team-modal__card {
            max-width: 100%;
            max-height: 90vh;
            border-radius: 12px 12px 0 0;
            transform: translateY(16px);
        }

        &.is-open .team-modal__card {
            transform: translateY(0);
        }

        .team-modal__header {
            padding: 20px 16px 0;
        }

        .team-modal__info {
            margin-top: 14px;
            padding: 12px 16px 0;
        }

        .team-modal__tabs {
            padding: 14px 16px 12px;
        }

        .team-modal__body {
            padding: 0 16px 20px;
            overflow-x: auto;
        }

        .team-modal__schedule,
        .team-modal__roster {
            min-width: 560px;
        }
    }
}
