/* PlayerTeamSwitcher — LOBBY-only team picker shown to students.
 * Loaded by both web/index.html (during JoinFlow / waiting state) and
 * web/player.html (after HOST_PLAY_AGAIN reset). */

.player-team-switcher {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    padding: 1.5vh 2.5vw;
    box-sizing: border-box;
    flex-shrink: 0;
}

.player-team-switcher-title {
    font-weight: bold;
    text-transform: uppercase;
    color: #ffffff;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 1.5vh;
    font-size: 2.4vh;
}

.player-team-switcher-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    /* gap fallback for legacy browsers */
}

.player-team-switcher-buttons > * + * {
    margin-left: 1.6vh;
}
@supports (gap: 1px) {
    .player-team-switcher-buttons {
        gap: 1.6vh;
    }
    .player-team-switcher-buttons > * + * {
        margin-left: 0;
    }
}

.player-team-switcher-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 1 auto;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    transform: scale(0.92);
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.player-team-switcher-img-wrap {
    display: block;
    /* Fallback for browsers without min(): smaller fixed size. */
    width: 9vh;
    height: 9vh;
    box-sizing: border-box;
}
@supports (width: min(1px, 1px)) {
    .player-team-switcher-img-wrap {
        width: min(11vh, 18vw);
        height: min(11vh, 18vw);
    }
}

.player-team-switcher-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.player-team-switcher-label {
    margin-top: 0.8vh;
    font-family: var(--font-heading);
    font-size: 2.2vh;
    line-height: 1.1;
    color: #ffffff;
    text-shadow: 0 0.08em 0px black;
    -webkit-text-stroke: 0.08em black;
    paint-order: stroke fill;
    text-align: center;
    white-space: pre-line;
}

.player-team-switcher-btn:active {
    transform: scale(0.88);
}

.player-team-switcher-btn.is-selected {
    transform: scale(1.06);
    z-index: 1;
}

.player-team-switcher-btn.is-selected .player-team-switcher-img {
    filter:
        drop-shadow(3px 0 0 #00ff1a)
        drop-shadow(-3px 0 0 #00ff1a)
        drop-shadow(0 3px 0 #00ff1a)
        drop-shadow(0 -3px 0 #00ff1a);
    filter:
        drop-shadow(clamp(1.8px, 0.36vmin, 3px) 0 0 #00ff1a)
        drop-shadow(calc(-1 * clamp(1.8px, 0.36vmin, 3px)) 0 0 #00ff1a)
        drop-shadow(0 clamp(1.8px, 0.36vmin, 3px) 0 #00ff1a)
        drop-shadow(0 calc(-1 * clamp(1.8px, 0.36vmin, 3px)) 0 #00ff1a);
}

.player-team-switcher-btn.is-selected:active {
    transform: scale(1.02);
}

.player-team-switcher-btn.is-selected::after {
    content: "";
    position: absolute;
    top: -0.6vh;
    right: -0.8vh;
    width: 4.2vh;
    height: 4.2vh;
    border-radius: 50%;
    background-color: #24DB2A;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.5 13L9.5 18L19.5 7.5' fill='none' stroke='%23000000' stroke-width='6.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M4.5 13L9.5 18L19.5 7.5' fill='none' stroke='%23ffffff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 80%;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

/* Portrait phones: shrink everything so 4 buttons stay on one line without
 * horizontal scroll. */
@media (orientation: portrait) {
    /* Equal-width columns so a long label (e.g. "ORANGE TEAM") doesn't make
     * its button wider than the others — keeps gaps visually equal. */
    .player-team-switcher-btn {
        flex: 1 1 0;
        min-width: 0;
    }
    .player-team-switcher-img-wrap {
        width: 11vw;
        height: 11vw;
        border-radius: 12px;
    }
    .player-team-switcher-label {
        font-size: 3.4vw;
        margin-top: 0.6vh;
    }
    .player-team-switcher-title {
        font-size: 3.6vw;
        margin-bottom: 1vh;
    }
    .player-team-switcher-buttons > * + * {
        margin-left: 1.2vw;
    }
    .player-team-switcher-btn.is-selected::after {
        width: 4.2vw;
        height: 4.2vw;
        line-height: 4vw;
        font-size: 2.6vw;
        top: -0.6vw;
        right: -0.8vw;
    }
    @supports (gap: 1px) {
        .player-team-switcher-buttons {
            gap: 1.2vw;
        }
        .player-team-switcher-buttons > * + * {
            margin-left: 0;
        }
    }
}
