/* trutourney.css - TruTourney Tournament Simulator Styles */

/* ===== Keyframe Animations ===== */
@keyframes tourney-row-fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tourney-section-fade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes live-pulse-glow {
    0%, 100% { box-shadow: 0 0 4px rgba(231, 76, 60, 0.3); }
    50% { box-shadow: 0 0 12px rgba(231, 76, 60, 0.6); }
}

@keyframes vs-pulse-anim {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes matchup-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Page Background ===== */
.trutourney-page {
    /* padding-top inherited from body via --header-height in style.css */
    background: linear-gradient(rgba(244,244,249,0.72), rgba(244,244,249,0.85)),
                url('/media/artwork/tourney-hero-bg.webp') center top/cover no-repeat;
    background-color: var(--tr-bg-page);
    background-attachment: fixed;
}

@media (max-width: 768px) {
    .trutourney-page {
        background-image: linear-gradient(rgba(244,244,249,0.78), rgba(244,244,249,0.9)),
                          url('/media/artwork/tourney-hero-bg-mobile.webp');
        background-attachment: scroll;
    }
}

.trutourney-main-content {
    padding-top: 1.5rem;
    color: var(--tr-text-primary);
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Section Cards ===== */
.tourney-section {
    opacity: 0;
    transition: opacity 0.6s ease-out;
    contain: layout style;
}

.tourney-section.visible {
    opacity: 1;
}

/* ===== Section Titles with Gradient Underline ===== */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--header-bg, var(--tr-text-primary));
    padding-bottom: 0.5rem;
    position: relative;
    border-bottom: none;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--tr-blue), var(--tr-blue-dark) 60%, transparent);
    border-radius: 2px;
}

/* ===== Date Navigation ===== */
.date-navigation {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
}

.date-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-nav-btn {
    background: linear-gradient(135deg, var(--tr-blue), var(--tr-blue-dark));
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

@media (hover: hover) {
    .date-nav-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(52, 152, 219, 0.3);
    }
}

.date-nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.date-selector {
    padding: 0.45rem 1rem;
    border: 1px solid var(--border-color, var(--tr-border));
    border-radius: 6px;
    font-size: 1rem;
    min-width: 150px;
}

.simulation-info {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ===== Mode Badges ===== */
.mode-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 5px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.mode-badge.projected {
    background: var(--tr-blue);
    color: white;
}

.mode-badge.official {
    background: var(--tr-success);
    color: white;
}

.mode-badge.live {
    background: var(--tr-red);
    color: white;
    animation: live-pulse-glow 2s ease-in-out infinite;
}

/* ===== Championship Section ===== */
.championship-section {
    background: var(--tr-bg-card);
    border-radius: var(--tr-radius-lg);
    border: 1px solid var(--tr-border-light);
    box-shadow: var(--tr-shadow-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.championship-chart {
    min-height: 200px;
}

.championship-bar-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.championship-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--tr-radius-sm);
    transition: background var(--tr-transition-fast);
    cursor: pointer;
}

@media (hover: hover) {
    .championship-bar-row:hover {
        background: rgba(59, 130, 246, 0.04);
    }
    .championship-bar-row:hover .champ-bar {
        filter: brightness(1.1);
    }
}

/* Rank badge (circular medal-colored for top 3, slate for rest) */
.champ-rank-badge {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    font-size: 10px;
    color: #fff;
}

/* Seed text (plain, not a badge) */
.champ-seed-text {
    font-size: 10px;
    font-weight: 500;
    color: var(--tr-text-muted);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.champ-team-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
    display: none;
}

.champ-team-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--tr-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 112px;
    flex-shrink: 0;
}

/* Advancement table team logo + name */
.adv-team-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 6px;
    display: none;
}

.adv-team-name {
    /* default: visible */
}

.champ-bar-wrapper {
    flex-grow: 1;
    background: var(--tr-border-light);
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
}

.champ-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.2s;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.champ-bar-label {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}

.champ-probability {
    width: 48px;
    text-align: right;
    font-weight: 700;
    font-size: 11px;
    color: var(--tr-text-secondary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ===== Region Tabs ===== */
.region-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1rem;
}

.region-tab {
    padding: 6px 12px;
    border: 1px solid var(--tr-border);
    background: var(--tr-bg-card);
    border-radius: var(--tr-radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--tr-text-secondary);
    transition: all var(--tr-transition-fast);
}

@media (hover: hover) {
    .region-tab:hover {
        border-color: var(--tr-blue);
    }
}

.region-tab.active {
    background: var(--tr-blue);
    color: white;
    border-color: var(--tr-blue);
    box-shadow: var(--tr-shadow-sm);
}

/* Region tab divider (separates region tabs from status filters) */
.region-tab-divider {
    color: #ccc;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    padding: 0 0.15rem;
}

.region-tab.status-filter {
    font-style: italic;
    font-size: 0.8rem;
}

/* ===== Probabilities Table ===== */
.probabilities-section {
    background: var(--tr-bg-card);
    border-radius: var(--tr-radius-lg);
    border: 1px solid var(--tr-border-light);
    box-shadow: var(--tr-shadow-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
    min-height: 300px;
}

.table-wrapper {
    overflow-x: auto;
}

.sim-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sim-results-table th {
    background: linear-gradient(to right, #334155, #1e293b);
    color: white;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 12px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sim-results-table th.col-team {
    text-align: left;
}

.sim-results-table td {
    padding: 8px 12px;
    text-align: center;
    border-bottom: 1px solid var(--tr-border-light);
}

/* Alternating row colors */
.sim-results-table tbody tr.row-alt {
    background: rgba(248, 250, 252, 0.3);
}

.sim-results-table tbody tr {
    transition: background var(--tr-transition-fast);
}

@media (hover: hover) {
    .sim-results-table tbody tr:not(.team-eliminated):hover {
        background: rgba(59, 130, 246, 0.04);
    }
}

.sim-results-table .col-seed {
    width: 50px;
}

.sim-results-table .col-team {
    text-align: left;
    min-width: 140px;
    font-weight: 600;
    font-size: 12px;
}

.sim-results-table td.col-team {
    color: var(--tr-text-primary);
}

.sim-results-table .col-region {
    width: 75px;
    font-size: 11px;
}

.sim-results-table td.col-region {
    color: var(--tr-text-secondary);
}

.sim-results-table .col-prob {
    width: 55px;
    font-variant-numeric: tabular-nums;
}

/* Champion column header - amber gradient */
.sim-results-table th.col-champ {
    background: linear-gradient(to right, #d97706, #b45309);
    color: #ffffff;
}

/* Seed badges in table (circular) */
.seed-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: #94a3b8;
}

/* Probability cell value (styled inline by JS) */
.prob-cell {
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Eliminated team row */
.team-eliminated {
    opacity: 0.4;
}

.team-eliminated td {
    text-decoration: line-through;
}

.team-eliminated td.col-champ {
    background: var(--tr-border-light) !important;
    color: #aaa;
    text-shadow: none;
}

.eliminated-tag {
    display: inline-block;
    background: var(--tr-red);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 5px;
    vertical-align: middle;
    text-decoration: none;
}

/* ===== Matchup Calculator ===== */
.matchup-section {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.matchup-calculator {
    /* nested inside section card */
}

.matchup-inputs {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.team-select-card {
    border-left: 4px solid var(--accent-color, var(--tr-blue));
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.team-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color, var(--tr-border));
    border-left: none;
    border-radius: 0 8px 8px 0;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
}

.vs-label {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--header-bg, var(--tr-text-primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.vs-label.vs-pulse {
    animation: vs-pulse-anim 0.8s ease-out;
}

.calculate-btn {
    background: linear-gradient(135deg, var(--tr-blue), var(--tr-blue-dark));
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.calculate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (hover: hover) {
    .calculate-btn:not(:disabled):hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    }
}

.matchup-result {
    padding: 1rem;
    background: var(--tr-bg-card-alt, #f8f9fa);
    border-radius: 8px;
    text-align: center;
}

.matchup-result.matchup-result-animate {
    animation: matchup-fade-in 0.4s ease-out;
}

.matchup-placeholder {
    color: var(--text-secondary, #666);
    font-style: italic;
    font-size: 0.9rem;
}

.matchup-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.matchup-teams-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.matchup-team {
    text-align: center;
}

.matchup-team-name {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 0.3rem;
}

.matchup-win-prob {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.matchup-win-prob.matchup-favorite {
    color: var(--tr-success);
}

.matchup-win-prob.matchup-underdog {
    color: var(--tr-red);
}

/* Matchup team logo */
.matchup-team-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 0.4rem;
}

.matchup-vs {
    font-size: 1.25rem;
    color: var(--text-secondary, #666);
    font-weight: 600;
}

/* Tug-of-war probability bar */
.tug-of-war-container {
    padding: 0 1rem;
}

.tug-of-war-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--tr-border-light);
}

.tug-bar-a,
.tug-bar-b {
    height: 100%;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.tug-bar-a {
    border-radius: 5px 0 0 5px;
}

.tug-bar-b {
    border-radius: 0 5px 5px 0;
}

.tug-bar-favorite {
    background: linear-gradient(90deg, var(--tr-success), var(--tr-success));
}

.tug-bar-underdog {
    background: linear-gradient(90deg, var(--tr-red-dark), var(--tr-red));
}

/* ===== Methodology Section ===== */
.methodology-section {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.methodology-section p {
    margin-bottom: 0.75rem;
    line-height: 1.7;
    color: var(--text-secondary, #555);
    font-size: 0.9rem;
}

.methodology-section p:last-child {
    margin-bottom: 0;
}

/* ===== Loading State ===== */
.loading-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary, #666);
    font-style: italic;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .date-navigation {
        flex-direction: column;
        padding: 0.75rem 1rem;
    }

    .matchup-inputs {
        flex-wrap: wrap;
    }

    .team-select-card {
        flex: 1 1 40%;
        min-width: 120px;
    }

    .calculate-btn {
        flex: 1 1 100%;
    }

    .matchup-team-logo {
        width: 48px;
        height: 48px;
    }

    .matchup-teams-row {
        gap: 1rem;
    }

    .matchup-win-prob {
        font-size: 1.5rem;
    }

    .champ-seed-text {
        display: none;
    }

    /* Mobile: show logo, hide name in championship odds */
    .champ-team-logo {
        display: block;
    }

    .champ-team-name {
        display: none;
    }

    .champ-probability {
        width: 40px;
        font-size: 10px;
    }

    /* Mobile: show logo, hide name in advancement probabilities */
    .adv-team-logo {
        display: inline-block;
    }

    .adv-team-name {
        display: none;
    }

    .col-team {
        min-width: auto !important;
        width: 28px !important;
        padding: 4px 2px !important;
    }

    .sim-results-table {
        font-size: 0.8rem;
    }

    .sim-results-table th,
    .sim-results-table td {
        padding: 0.5rem 0.3rem;
    }
}

@media (max-width: 480px) {
    .champ-rank-badge {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .tourney-section {
        opacity: 1;
        transform: none;
    }
}
