/* =====================================================================
 * Team cards — far-view tile + close-view modal (Samarkand 2026)
 * Loaded on: /46th-olympiad-samarkand (hub), /46th-olympiad-samarkand/cards
 * Design tokens: gold brushed metal far-view, dark gold-bordered close-view
 * ===================================================================== */

/* ---------------------------------------------------------------------
 * CAROUSEL — hidden scrollbar, drag-to-scroll on the cards row only
 * --------------------------------------------------------------------- */
.team-cards-scroller {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Fade krawędzi — sygnalizuje że jest więcej kart poza widokiem. */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 32px, #000 calc(100% - 32px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 32px, #000 calc(100% - 32px), transparent 100%);
}
.team-cards-scroller::-webkit-scrollbar { display: none; height: 0; }

.team-cards-row {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.team-cards-row.is-dragging { cursor: grabbing; }
.team-cards-row.is-dragging .team-card-far { pointer-events: none; }
.team-cards-row .team-card-far { -webkit-user-drag: none; }
.team-cards-row .team-card-far img { -webkit-user-drag: none; pointer-events: none; }

/* ---------------------------------------------------------------------
 * FAR-VIEW (110×150) — matches doc/Samarakand/team_card_uzb_black.html
 * --------------------------------------------------------------------- */
.team-card-far {
    position: relative;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 24px 50px 28px 22px 16px;
    grid-template-areas:
        "seed    section"
        "flag    flag"
        "code    code"
        "avg-l   avg-v"
        "pl-l    pl-v";
    column-gap: 4px;
    row-gap: 0;
    width: 110px;
    height: 150px;
    padding: 4px 8px 6px;
    box-sizing: border-box;
    border-radius: 7px;
    background:
        linear-gradient(135deg,
            #6b4a17 0%,
            #b8862a 18%,
            #f3cf5e 38%,
            #fff1a8 50%,
            #f3cf5e 62%,
            #b8862a 82%,
            #6b4a17 100%);
}
/* Gradient variants — same lustrous gold palette, but angle and stop positions
   vary so each card feels hand-finished. Variant assigned deterministically
   from card ID. */
.team-card-far--g1 {
    background: linear-gradient(135deg,
        #6b4a17 0%,
        #b8862a 18%,
        #f3cf5e 38%,
        #fff1a8 50%,
        #f3cf5e 62%,
        #b8862a 82%,
        #6b4a17 100%);
}
.team-card-far--g2 {
    background: linear-gradient(150deg,
        #6b4a17 5%,
        #b8862a 22%,
        #f3cf5e 42%,
        #fff1a8 55%,
        #f3cf5e 68%,
        #b8862a 80%,
        #6b4a17 95%);
}
.team-card-far--g3 {
    background: linear-gradient(115deg,
        #6b4a17 0%,
        #b8862a 14%,
        #f3cf5e 34%,
        #fff1a8 46%,
        #f3cf5e 58%,
        #b8862a 84%,
        #6b4a17 100%);
}
.team-card-far--g4 {
    background: linear-gradient(160deg,
        #6b4a17 8%,
        #b8862a 26%,
        #f3cf5e 44%,
        #fff1a8 52%,
        #f3cf5e 60%,
        #b8862a 76%,
        #6b4a17 92%);
}
.team-card-far--g5 {
    background: linear-gradient(105deg,
        #6b4a17 0%,
        #b8862a 16%,
        #f3cf5e 36%,
        #fff1a8 48%,
        #f3cf5e 60%,
        #b8862a 80%,
        #6b4a17 100%);
    border: none;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
    line-height: 1;
}
.team-card-far:focus-visible {
    outline: none;
}

.tcf-seed {
    grid-area: seed;
    align-self: baseline;
    color: #f6e27a;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 24px;
}
.tcf-section {
    grid-area: section;
    align-self: baseline;
    justify-self: end;
    color: #000;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.09em;
    line-height: 24px;
}

.tcf-flag-wrap {
    grid-area: flag;
    align-self: center;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tcf-flag {
    width: 76px;
    height: 48px;
    object-fit: cover;
    border-radius: 1px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    background: #fff;
    display: block;
}

.tcf-code {
    grid-area: code;
    align-self: center;
    justify-self: center;
    color: rgba(0, 0, 0, 0.7);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.085em;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
/* Embossed separator line — fixed position on the card (same y for every card),
   regardless of code text rendering quirks. */
.team-card-far::after {
    content: '';
    position: absolute;
    left: 14px;
    right: 14px;
    top: 104px;
    height: 1px;
    background: rgba(0, 0, 0, 0.45);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

.tcf-stat { display: contents; }
.tcf-avg .tcf-lbl   { grid-area: avg-l; }
.tcf-avg .tcf-val   { grid-area: avg-v; }
.tcf-place .tcf-lbl { grid-area: pl-l; }
.tcf-place .tcf-val { grid-area: pl-v; }

.tcf-lbl {
    color: #000;
    font-size: 7px;
    font-weight: 500;
    letter-spacing: 0.057em;
    align-self: end;
    justify-self: start;
}
.tcf-val {
    color: #fff8c8;
    font-size: 13px;
    font-weight: 400;
    align-self: end;
    justify-self: end;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

/* CTA tile — appended after the carousel as the last "card" */
.team-card-far--cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: linear-gradient(135deg, #1a1a1d 0%, #2a2a2f 50%, #1a1a1d 100%);
    border: 1px dashed rgba(255, 215, 0, 0.5);
    color: #FFD700;
    text-align: center;
}
.team-card-far--cta::after {
    display: none;
}
.tcf-cta-arrow {
    font-size: 30px;
    line-height: 1;
    font-weight: 400;
}
.tcf-cta-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.25;
}
.team-card-far--cta:hover {
    border-color: #FFD700;
    background: linear-gradient(135deg, #1f1f22 0%, #303035 50%, #1f1f22 100%);
}

/* ---------------------------------------------------------------------
 * CLOSE-VIEW (modal + flip card)
 * --------------------------------------------------------------------- */
.tcc-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}
.tcc-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.tcc-card {
    position: relative;
    width: min(92vw, 480px);
    height: min(90vh, 640px);
    perspective: 1400px;
}

.tcc-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(.4, .2, .2, 1);
}
.tcc-card[data-flipped="true"] .tcc-inner {
    transform: rotateY(180deg);
}

.tcc-face {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 20px 20px 64px;
    background: #0A0A0B;
    border: 1px solid #FFD700;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 215, 0, 0.15);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #fff;
    font-family: 'Inter', system-ui, sans-serif;
}
.tcc-back {
    transform: rotateY(180deg);
}
/* Buttons (X + Flip) live inside each face so they rotate with the flip.
   To prevent backface bleed-through (Safari/Chrome bug with absolute children),
   we hide the buttons of the face currently turned away from the viewer. */
.tcc-face .tcc-close,
.tcc-face .tcc-flip-btn {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.tcc-card[data-flipped="false"] .tcc-back .tcc-close,
.tcc-card[data-flipped="false"] .tcc-back .tcc-flip-btn,
.tcc-card[data-flipped="true"]  .tcc-front .tcc-close,
.tcc-card[data-flipped="true"]  .tcc-front .tcc-flip-btn {
    visibility: hidden;
    pointer-events: none;
}

/* Close button — same gold-gradient background as the Flip button */
.tcc-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border: none;
    color: #0A0A0B;
    font-size: 20px;
    font-weight: 700;
    line-height: 32px;
    cursor: pointer;
    z-index: 20;
    text-align: center;
    padding: 0;
    font-family: Arial, sans-serif;
    transition: filter .15s, transform .15s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.tcc-close:hover { filter: brightness(1.1); }

/* AWERS (front) ---------------------------------------------------- */
.tcc-front-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    padding-right: 40px;
}
.tcc-edition,
.tcc-section-badge {
    color: #FFD700;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.tcc-section-badge { text-align: right; }

.tcc-identity {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}
.tcc-flag-large {
    width: 48px;
    height: 32px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    background: #fff;
    flex-shrink: 0;
}
.tcc-country {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.05;
    color: #fff;
}
@media (min-width: 768px) {
    .tcc-country { font-size: 28px; }
    .tcc-flag-large { width: 60px; height: 40px; }
}
.tcc-caption {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    margin-bottom: 16px;
}
.tcc-caption .host {
    color: #FFD700;
    font-weight: 600;
}

.tcc-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.tcc-stat-cell .lbl {
    display: block;
    color: rgba(255, 255, 255, 0.5);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.tcc-stat-cell .val {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
}
.tcc-stat-cell .val .hash {
    color: rgba(255, 255, 255, 0.5);
}

/* Live status box */
.tcc-live-box {
    margin: 14px 0;
    padding: 14px 16px;
    border: 1px solid #FFD700;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.05), rgba(255, 165, 0, 0.02));
    position: relative;
}
.tcc-live-box .label {
    color: #FFD700;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.tcc-live-box .headline {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
}
@media (min-width: 768px) {
    .tcc-live-box .headline { font-size: 30px; }
}
.tcc-live-box .detail {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-top: 4px;
}
.tcc-live-box .medal-icon {
    position: absolute;
    top: 14px;
    right: 14px;
    color: #FFD700;
    font-size: 22px;
}

.tcc-front-mid {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.tcc-coach {
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 10px;
}
.tcc-coach-info .lbl {
    color: rgba(255, 255, 255, 0.5);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.tcc-coach-info .val {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.tcc-flip-btn {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #0A0A0B;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: filter .15s, transform .15s;
    flex-shrink: 0;
}
.tcc-flip-btn:hover { filter: brightness(1.1); }
.tcc-flip-bottom {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.tcc-front-footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-top: 8px;
}

/* REWERS (back) --------------------------------------------------- */
.tcc-back-scroll {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    margin-right: -8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 215, 0, 0.4) transparent;
}
.tcc-back-scroll::-webkit-scrollbar { width: 6px; }
.tcc-back-scroll::-webkit-scrollbar-thumb { background: rgba(255, 215, 0, 0.4); border-radius: 3px; }
.tcc-back-scroll::-webkit-scrollbar-track { background: transparent; }

.tcc-back-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    padding-right: 40px;
}
.tcc-back-header .title {
    color: #FFD700;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.tcc-back-header .meta {
    color: rgba(255, 255, 255, 0.55);
    font-size: 10px;
}

.tcc-roster {
    margin-bottom: 14px;
}
.tcc-roster-row {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 6px 4px;
    border-radius: 4px;
    color: #fff;
    text-decoration: none;
    transition: background .15s;
    cursor: pointer;
}
.tcc-roster-row .board {
    color: #FFD700;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.tcc-roster-row .name {
    font-size: 13px;
    font-weight: 500;
}
.tcc-roster-row .name .title {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(255, 215, 0, 0.15);
    color: #FFD700;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    vertical-align: 1px;
}
.tcc-roster-row .stat {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tcc-section-title {
    color: #FFD700;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin: 12px 0 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tcc-history-summary {
    margin-bottom: 12px;
}
.tcc-history-summary-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: baseline;
    padding: 4px 0;
    font-size: 13px;
}
.tcc-history-summary-row .lbl {
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.tcc-history-summary-row .val {
    color: #fff;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.tcc-history-summary-row .val.tcc-medals {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    font-weight: 500;
}
.tcc-medal-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.tcc-history-empty {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    font-style: italic;
    font-weight: 400;
}

.tcc-section-subtitle {
    color: rgba(255, 215, 0, 0.7);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 8px 0 4px;
}

.tcc-history-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    padding: 4px 0;
    font-size: 13px;
}
.tcc-history-row .event {
    color: rgba(255, 255, 255, 0.85);
}
.tcc-history-row .event .dash {
    color: rgba(255, 255, 255, 0.3);
}
.tcc-history-row .place {
    color: rgba(255, 255, 255, 0.65);
    font-variant-numeric: tabular-nums;
}
.tcc-history-row .place.has-medal {
    color: #FFD700;
    font-weight: 700;
}

.tcc-best {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    padding: 10px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 12px;
}
.tcc-best-info .name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}
.tcc-best-info .meta {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
}

.tcc-great-book {
    display: block;
    margin-top: 10px;
    color: #FFD700;
    font-size: 12px;
    text-decoration: none;
    text-align: left;
}
.tcc-great-book:hover { text-decoration: underline; }

/* Lock scroll when modal open */
body.tcc-modal-open {
    overflow: hidden;
}
