﻿/* Tournament listing v3 - status pills + tournament cards (Tournament/Index2, TournamentSearch AJAX, TournamentByOrg).
   Markup: Views/Tournament/_TournamentsList.cshtml (+ its JS twin Scripts/tournament/tournament-list-v3.js).
   Loaded AFTER tournaments.css; it does not use the legacy .tournament-row-v3 / .event-card / .status-tab rules.

   THEMING: this file defines NO colours. Every colour, radius, spacing and shadow comes from theme-v2.css
   (--color-*, --tint-*, --v3-panel-*, --v3-tile-*, --radius-*, --spacing-*), so the dark/light switch and any
   palette change made in theme-v2.css reach these cards with no edit here. Do not add a #hex / rgb() literal;
   if a new colour is needed, add a token to theme-v2.css first.
   Roles: primary action + active pill = --color-button-primary-*, in progress = success, registration open =
   warning, not started = info, completed / registration closed = muted. Registration and competition are
   separate chips and are never merged.
   Layout is container-query based (the centre column is narrow on every viewport in the 3-column layout):
   narrow = stacked, >=560px = info on top and summary | actions below, >=880px = info | summary | actions. */

.tlv {
    color: var(--color-text-primary);
    min-width: 0;
}

/* ---------------------------------------------------------------- status filter pills */
.tlv-filters {
    margin-bottom: var(--spacing-md);
}

.tlv-pills {
    display: flex;
    gap: var(--spacing-sm);
    overflow-x: auto;
    padding: 2px 2px var(--spacing-xs);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.tlv-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tlv-pill:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
}

.tlv-pill.active {
    background: var(--color-button-primary-bg);
    border-color: var(--color-button-primary-bg);
    color: var(--color-button-primary-text);
}

.tlv-pill:focus-visible {
    outline: 2px solid var(--color-input-focus-border);
    outline-offset: 2px;
}

.tlv-pill__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 20%, transparent);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tlv-pill__count[hidden] {
    display: none;
}

/* ---------------------------------------------------------------- list + card shell */
.tlv .tournaments-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    container-type: inline-size;
    container-name: tlv;
}

.tlv-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--v3-panel-bg);
    border: 1px solid var(--v3-panel-border);
    border-radius: var(--v3-panel-radius);
    box-shadow: var(--v3-panel-shadow);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.tlv-card:hover {
    border-color: var(--color-border);
}

/* Phase accent on the left edge (ongoing / upcoming / completed) */
.tlv-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 16px;
    bottom: 16px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--color-text-muted);
}

.tlv-card--ongoing::before { background: var(--color-success); }
.tlv-card--upcoming::before { background: var(--color-info); }
.tlv-card--completed::before { background: var(--color-text-muted); opacity: 0.6; }

/* ---------------------------------------------------------------- Area A: tournament information */
.tlv-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.tlv-datebadge {
    flex: 0 0 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--v3-tile-bg);
    border: 1px solid var(--color-border);
    line-height: 1;
}

.tlv-datebadge__month {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-info);
}

.tlv-datebadge__day {
    margin-top: 3px;
    font-size: 17px;
    font-weight: 800;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

/* Fixed 4:3 frame, cover-cropped: posters of any ratio are never stretched */
.tlv-poster {
    flex: 0 0 96px;
    aspect-ratio: 4 / 3;
    display: flex;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--v3-tile-bg);
    border: 1px solid var(--color-border-light);
}

.tlv-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tlv-poster__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--color-text-muted);
    background: linear-gradient(135deg, var(--v3-tile-bg), var(--color-surface));
}

.tlv-info__body {
    flex: 1 1 auto;
    min-width: 0;
}

.tlv-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.tlv-tag {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--tint-neutral-bg);
    color: var(--color-text-secondary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.tlv-tag--id {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.tlv-tag--phase.tlv-tag--ongoing { background: var(--tint-success-bg); color: var(--color-success); }
.tlv-tag--phase.tlv-tag--upcoming { background: var(--tint-info-bg); color: var(--color-info); }
.tlv-tag--phase.tlv-tag--completed { background: var(--tint-neutral-bg); color: var(--color-text-muted); }

.tlv-title {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-text-primary);
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tlv-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.tlv-meta i {
    width: 12px;
    margin-right: 4px;
    text-align: center;
    color: var(--color-text-muted);
}

/* ---------------------------------------------------------------- Area B: event summary */
.tlv-summary {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-width: 0;
}

.tlv-summary__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-sm);
}

.tlv-summary__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.tlv-summary__total {
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

/* Competition-status bar: the three segments add up to the event count. Registration is NOT part of it. */
.tlv-statusbar {
    display: flex;
    gap: 2px;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--color-border-light);
}

.tlv-statusbar__seg {
    flex-basis: 0;
    min-width: 6px;
}

.tlv-seg--inprogress { background: var(--color-success); }
.tlv-seg--notstarted { background: var(--color-info); }
.tlv-seg--completed { background: var(--color-text-muted); }

.tlv-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.tlv-legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tlv-legend strong {
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.tlv-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.tlv-summary .sc-regbar-wrap {
    margin-top: 2px;
}

/* ---------------------------------------------------------------- status chips (registration / competition) */
.tlv-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    height: 22px;
    padding: 0 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tlv-chip i {
    flex: 0 0 auto;
    font-size: 10px;
}

.tlv-chip--reg-open {
    background: var(--tint-warning-bg);
    border-color: color-mix(in srgb, var(--color-warning) 30%, transparent);
    color: var(--color-warning);
}

.tlv-chip--reg-closed,
.tlv-chip--comp-completed {
    background: var(--tint-neutral-bg);
    border-color: var(--color-border-light);
    color: var(--color-text-muted);
}

.tlv-chip--comp-inprogress {
    background: var(--tint-success-bg);
    border-color: color-mix(in srgb, var(--color-success) 30%, transparent);
    color: var(--color-success);
}

.tlv-chip--comp-notstarted {
    background: var(--tint-info-bg);
    border-color: color-mix(in srgb, var(--color-info) 30%, transparent);
    color: var(--color-info);
}

/* ---------------------------------------------------------------- Area C: actions + buttons */
.tlv-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.tlv-actions .sc-btn--primary {
    flex: 1 1 auto;
}

/* Buttons are the shared components-v2.css .sc-btn (--primary / --secondary / --sm); only the events toggle needs its own bits */
.tlv .tlv-toggle:hover:not(:disabled):not(.is-disabled) i {
    transform: none;
}

.tlv-toggle.is-open {
    border-color: var(--color-button-primary-bg);
}

.tlv .tlv-toggle.is-open:not(:disabled):not(.is-disabled) i {
    transform: rotate(180deg);
}

.tlv-toggle__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 12%, transparent);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- expanded events */
.tlv-events {
    grid-column: 1 / -1;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-light);
}

.tlv-events[hidden] {
    display: none;
}

.tlv-events__empty {
    padding: 12px 0;
    text-align: center;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ---------------------------------------------------------------- empty / loading / error */
.tlv .no-tournaments,
.tlv-loading {
    padding: 48px var(--spacing-md);
    text-align: center;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text-secondary);
}

.tlv .no-tournaments i,
.tlv-loading i {
    display: block;
    margin-bottom: var(--spacing-md);
    font-size: 44px;
    color: var(--color-text-muted);
}

.tlv-loading i {
    font-size: 28px;
}

.tlv .no-tournaments.is-error i {
    color: var(--color-danger);
}

.tlv .no-tournaments h3 {
    margin: 0 0 var(--spacing-sm);
    font-size: 16px;
    color: var(--color-text-primary);
}

.tlv .no-tournaments p,
.tlv-loading p {
    margin: 0;
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ---------------------------------------------------------------- responsive (container = .tournaments-grid) */
@container tlv (max-width: 440px) {
    .tlv-card {
        padding: 12px;
    }

    .tlv-poster {
        flex-basis: 76px;
    }

    .tlv-title {
        font-size: 15px;
    }
}

@container tlv (min-width: 560px) {
    .tlv-card {
        grid-template-columns: minmax(0, 1fr) 176px;
        grid-template-areas:
            "info info"
            "summary actions";
        align-items: start;
    }

    .tlv-info { grid-area: info; }
    .tlv-summary { grid-area: summary; }
    .tlv-actions { grid-area: actions; flex-direction: column; }
    .tlv-events { grid-area: auto; grid-column: 1 / -1; }

    .tlv-poster {
        flex-basis: 132px;
    }
}

@container tlv (min-width: 880px) {
    .tlv-card {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 176px;
        grid-template-areas: "info summary actions";
        align-items: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tlv *,
    .tlv *::before {
        transition: none !important;
    }
}
