/**
 * Team Pilot Cards — вертикальные карточки, пропорции Фибоначчи (8→377)
 *
 * Шкала: 8, 13, 21, 34, 55, 89, 144, 233, 377 px
 */

/* === Сетка: ширина колонки = 233px (Fib), зазор = 21px === */
.team-pilots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(233px, 1fr));
    gap: 21px;
    align-items: stretch;
    margin-bottom: 21px;
}

@media (min-width: 992px) {
    .team-pilots-grid {
        grid-template-columns: repeat(auto-fill, minmax(233px, calc((100% - 42px) / 3)));
    }
}

@media (max-width: 576px) {
    .team-pilots-grid {
        grid-template-columns: 1fr;
        gap: 13px;
    }
}

.team-pilot-card-wrap {
    min-width: 0;
}

/* === Карточка === */
.team-pilot-card {
    --tpc-f8: 8px;
    --tpc-f13: 13px;
    --tpc-f21: 21px;
    --tpc-f34: 34px;
    --tpc-f55: 55px;
    --tpc-f89: 89px;

    --tpc-text-strong: rgba(255, 255, 255, 1);
    --tpc-text-primary: rgba(255, 255, 255, 0.95);
    --tpc-text-muted: rgba(255, 255, 255, 0.78);
    --tpc-tile-bg: rgba(0, 0, 0, 0.28);
    --tpc-tile-border: rgba(255, 255, 255, 0.1);
    --tpc-footer-bg: rgba(0, 0, 0, 0.35);

    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: var(--tpc-f21);
    overflow: hidden;
    background: linear-gradient(
        165deg,
        var(--card-primary, #4169e1) 0%,
        var(--card-secondary, #7b68ee) 55%,
        color-mix(in srgb, var(--card-secondary, #7b68ee) 70%, #000) 100%
    );
    box-shadow:
        0 var(--tpc-f8) var(--tpc-f21) rgba(0, 0, 0, 0.18),
        0 0 var(--tpc-f34) var(--card-glow, rgba(65, 105, 225, 0.25)),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    isolation: isolate;
}

.team-pilot-card::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent var(--tpc-f13),
        rgba(255, 255, 255, 0.025) var(--tpc-f13),
        rgba(255, 255, 255, 0.025) var(--tpc-f21)
    );
    pointer-events: none;
}

.team-pilot-card:hover {
    transform: translateY(calc(var(--tpc-f8) * -0.75));
    box-shadow:
        0 var(--tpc-f13) var(--tpc-f34) rgba(0, 0, 0, 0.28),
        0 0 var(--tpc-f55) var(--card-glow, rgba(65, 105, 225, 0.35)),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.team-pilot-card[data-rank="Легенда"]::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
    animation: tpcLegendGlow 3s ease-in-out infinite;
}

@keyframes tpcLegendGlow {
    0%, 100% { box-shadow: inset 0 0 var(--tpc-f34) var(--rank-legend-glow); }
    50% { box-shadow: inset 0 0 var(--tpc-f55) var(--rank-legend-glow); }
}

.team-pilot-card.tpc-is-self {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 2px;
}

/* === Лента роли: padding 8×13 === */
.tpc-role-ribbon {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tpc-f8);
    padding: var(--tpc-f8) var(--tpc-f13);
    font-size: 0.6875rem; /* ~11px, между 8 и 13 */
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #111;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.tpc-role-ribbon.role-owner {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
}

.tpc-role-ribbon.role-captain {
    background: linear-gradient(135deg, #e8ecff 0%, #c7d2fe 100%);
    color: #1e2a5a;
}

.tpc-role-ribbon.role-driver {
    background: linear-gradient(135deg, #d4f8d4 0%, #a8e6cf 100%);
    color: #0d3d1f;
}

.tpc-role-ribbon.role-reserve {
    background: linear-gradient(135deg, #ffe0b2 0%, #ffab91 100%);
    color: #5d2e0a;
}

[data-theme="dark"] .tpc-role-ribbon {
    color: #111;
}

/* === Лицевая часть: padding 21×13 === */
.tpc-face {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: var(--tpc-f21) var(--tpc-f13) var(--tpc-f13);
    min-height: 0;
    gap: var(--tpc-f13);
}

.tpc-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--tpc-f8);
}

.tpc-elo-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.tpc-elo-value {
    font-size: var(--tpc-f34);
    font-weight: 800;
    line-height: 1;
    color: var(--tpc-text-strong);
    text-shadow: 0 2px var(--tpc-f13) rgba(0, 0, 0, 0.35);
    font-variant-numeric: tabular-nums;
}

.tpc-elo-rank {
    display: inline-block;
    margin-top: var(--tpc-f8);
    padding: var(--tpc-f8) var(--tpc-f13);
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--tpc-text-strong);
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.15);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpc-flag-wrap {
    flex-shrink: 0;
    padding: var(--tpc-f8);
    background: rgba(0, 0, 0, 0.22);
    border-radius: var(--tpc-f8);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.tpc-flag {
    display: block;
    width: var(--tpc-f34);
    height: 26px; /* 34×0.764 ≈ пропорция флага 4:3 */
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px var(--tpc-f8) rgba(0, 0, 0, 0.25);
}

/* Аватар: кольцо 89px (Fib) */
.tpc-avatar-zone {
    display: flex;
    justify-content: center;
    padding: 0;
}

.tpc-avatar-ring {
    --tpc-progress: 0;
    position: relative;
    width: var(--tpc-f89);
    height: var(--tpc-f89);
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(
        rgba(255, 255, 255, 0.92) calc(var(--tpc-progress) * 1%),
        rgba(255, 255, 255, 0.18) 0
    );
    box-shadow: 0 var(--tpc-f8) var(--tpc-f21) rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.tpc-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.tpc-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tpc-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--tpc-f34);
    color: rgba(255, 255, 255, 0.55);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.tpc-level-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    min-width: var(--tpc-f34);
    height: var(--tpc-f34);
    padding: 0 var(--tpc-f8);
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 3px var(--tpc-f13) rgba(102, 126, 234, 0.55);
}

/* Имя */
.tpc-identity {
    text-align: center;
    padding: 0 var(--tpc-f8);
    min-width: 0;
}

.tpc-name {
    margin: 0;
    font-size: 1rem; /* 16px ≈ между 13 и 21 */
    font-weight: 700;
    line-height: 1.3;
    color: var(--tpc-text-strong);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    word-break: break-word;
    overflow-wrap: break-word;
}

.tpc-division {
    display: inline-block;
    margin-top: var(--tpc-f8);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--tpc-text-muted);
}

.tpc-steam {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tpc-f8);
    margin-top: var(--tpc-f8);
    font-size: 0.75rem;
    color: var(--tpc-text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 var(--tpc-f8);
}

.tpc-steam i {
    flex-shrink: 0;
    color: var(--tpc-text-primary);
}

/* Статистика: 3 колонки, gap 8, высота ячейки 55 */
.tpc-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--tpc-f8);
}

.tpc-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--tpc-f8);
    border-radius: var(--tpc-f13);
    background: var(--tpc-tile-bg);
    border: 1px solid var(--tpc-tile-border);
    backdrop-filter: blur(4px);
    min-height: var(--tpc-f55);
    min-width: 0;
}

.tpc-stat-val {
    font-size: 1.3125rem; /* 21px */
    font-weight: 800;
    line-height: 1.1;
    color: var(--tpc-text-strong);
    font-variant-numeric: tabular-nums;
}

.tpc-stat-lbl {
    margin-top: var(--tpc-f8);
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--tpc-text-muted);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    white-space: nowrap;
}

.tpc-winrate {
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--tpc-text-muted);
    margin: calc(var(--tpc-f8) * -1) 0 0;
}

.tpc-winrate strong {
    color: var(--tpc-text-primary);
    font-weight: 800;
}

.tpc-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--tpc-f8);
    margin-top: auto;
    padding-top: var(--tpc-f8);
    min-width: 0;
}

.tpc-join {
    display: inline-flex;
    align-items: center;
    gap: var(--tpc-f8);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--tpc-text-muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpc-join i {
    flex-shrink: 0;
    color: var(--tpc-text-muted);
}

.tpc-profile-link {
    display: inline-flex;
    align-items: center;
    gap: var(--tpc-f8);
    padding: var(--tpc-f8) var(--tpc-f13);
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--tpc-text-strong);
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    transition: background 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.tpc-profile-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
}

.tpc-profile-link i {
    color: inherit;
}

/* Футер: padding 13×21 */
.tpc-controls {
    position: relative;
    z-index: 2;
    padding: var(--tpc-f13) var(--tpc-f21);
    background: var(--tpc-footer-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(6px);
}

.tpc-control-row {
    display: flex;
    gap: var(--tpc-f8);
    align-items: center;
}

.tpc-role-select {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.75rem;
    border-radius: var(--tpc-f8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.92);
    color: #212529;
}

[data-theme="dark"] .tpc-role-select {
    background: rgba(30, 30, 30, 0.92);
    color: #e8e8e8;
    border-color: rgba(255, 255, 255, 0.15);
}

.tpc-btn-remove {
    flex-shrink: 0;
    width: var(--tpc-f34);
    height: var(--tpc-f34);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--tpc-f8);
}

.tpc-self-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tpc-f8);
    width: 100%;
    padding: var(--tpc-f8) var(--tpc-f13);
    border-radius: var(--tpc-f8);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tpc-text-primary);
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed rgba(255, 255, 255, 0.28);
}

.tpc-self-badge i {
    color: rgba(255, 255, 255, 0.9);
}

.tpc-btn-leave {
    width: 100%;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--tpc-f8);
}

.tpc-controls .text-muted {
    color: rgba(255, 255, 255, 0.75);
}

[data-theme="light"] .tpc-controls .btn-outline-danger {
    background: rgba(255, 255, 255, 0.9);
}

/*
 * Светлая тема: .card i.bi в light.css красит иконки в серый.
 * Карточки пилотов — на цветном градиенте, иконки должны быть светлыми.
 */
[data-theme="light"] .team-pilot-card .tpc-face i.bi,
[data-theme="light"] .team-pilot-card .tpc-face .bi,
[data-theme="light"] .team-pilot-card .tpc-profile-link i.bi,
[data-theme="light"] .team-pilot-card .tpc-self-badge i.fas {
    color: rgba(255, 255, 255, 0.92);
}

[data-theme="light"] .team-pilot-card .tpc-role-ribbon i.fas {
    color: inherit;
}

[data-theme="light"] .team-pilot-card .tpc-steam i.bi::before,
[data-theme="light"] .team-pilot-card .tpc-join i.bi::before,
[data-theme="light"] .team-pilot-card .tpc-profile-link i.bi::before {
    color: rgba(255, 255, 255, 0.92);
}
