:root {
    /* Match Predictions / Matches / H2H card surfaces site-wide */
    --ti-bg: var(--match-dark-bg, #000000);
    --ti-card: var(--match-card-bg, #1a1a1a);
    --ti-card-raised: #1f1f1f;
    --ti-border: var(--match-border, #2a2a2a);
    --ti-border-hover: #3a3a38;
    --ti-green: var(--match-green, #4a7c59);
    --ti-green-dim: #375c43;
    --ti-amber: #c2924f;
    --ti-red: #c45c54;
    --ti-text: var(--text-primary, #f2f2f0);
    --ti-text-secondary: var(--text-secondary, #9a9a97);
    --ti-text-tertiary: var(--text-muted, #6b6b68);

    --ti-cat-goals: #c2924f;
    --ti-cat-h2h: #5b8fd4;
    --ti-cat-form: #9b7ed9;
    --ti-cat-attack: #4a9b6e;
    --ti-cat-defence: #c45c54;
    --ti-cat-timing: #4a9b9b;
    --ti-cat-streak: #8bb85c;
    --ti-strong: #c9a465;
}

[data-theme="light"] {
    --ti-bg: var(--match-dark-bg, #ffffff);
    --ti-card: var(--match-card-bg, #ffffff);
    --ti-card-raised: #f7f7f5;
    --ti-border: var(--match-border, #e2e8f0);
    --ti-border-hover: #cbd5e0;
    --ti-green: var(--match-green, #4a7c59);
}

.page-top-insights {
    background: var(--ti-bg);
}

.page-top-insights .container,
.page-top-insights .content {
    background: transparent;
}

body.page-top-insights.layout-wide .container {
    width: 100%;
    max-width: 852px !important;
    padding: 24px 16px 72px !important;
    gap: 0;
}

.page-top-insights .content {
    min-width: 0;
    width: 100%;
}

.ti-page,
.ti-page button,
.ti-page select {
    color: var(--ti-text);
    font-family: var(--font-body);
}

.ti-page *,
.ti-page *::before,
.ti-page *::after {
    box-sizing: border-box;
}

/*
 * Top Insights uses a `ti-*` class prefix that collides with Tabler Icons
 * (loaded globally in base.html). Neutralize glyph injection on page classes.
 */
.ti-page .ti-section::before,
.ti-page .ti-vs::before,
.ti-page .ti-select::before {
    content: none !important;
}

.ti-page-header {
    display: block;
    max-width: none;
    margin: 0 0 16px;
    padding: 0;
    background: transparent;
    color: var(--ti-text);
}

.ti-page-header h1 {
    margin: 0;
    color: var(--ti-text);
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.1;
}

.ti-page-header p {
    margin: 4px 0 0;
    color: var(--ti-text-secondary);
    font-size: 13.5px;
    line-height: 1.4;
}

.ti-section {
    margin: 0;
}

.ti-section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 8px;
}

.ti-section-heading h2 {
    margin: 0 !important;
    color: var(--ti-text-tertiary);
    font-size: 11px !important;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ti-section-heading::after,
.ti-section-label::after {
    height: 1px;
    flex: 1;
    background: var(--ti-border);
    content: "";
}

.ti-trending-track {
    display: grid;
    grid-auto-columns: minmax(240px, 38%);
    grid-auto-flow: column;
    gap: 8px;
    overflow-x: auto;
    padding: 0 0 4px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.ti-trending-track::-webkit-scrollbar {
    display: none;
}

.ti-trending-section {
    position: relative;
}

.ti-trending-section::after {
    position: absolute;
    right: 0;
    bottom: 4px;
    width: 36px;
    height: 108px;
    background: linear-gradient(90deg, transparent, var(--ti-bg));
    content: "";
    pointer-events: none;
}

.ti-trending-card {
    --category-color: var(--ti-green);
    display: flex;
    min-height: 108px;
    max-height: 120px;
    flex-direction: column;
    justify-content: space-between;
    padding: 9px 11px;
    border: 1px solid var(--ti-border);
    border-left: 3px solid var(--category-color);
    /* Square left corners so the accent reads as a flat tab, not a curved stroke */
    border-radius: 0 9px 9px 0;
    background: var(--ti-card-raised);
    color: var(--ti-text);
    cursor: pointer;
    scroll-snap-align: start;
    text-align: left;
    transition: border-color 0.15s ease;
}

.ti-trending-card:hover,
.ti-trending-card:focus-visible {
    border-color: var(--ti-border-hover);
    border-left-color: var(--category-color);
    outline: none;
}

.ti-trending-tag {
    margin-bottom: 3px;
    color: var(--category-color);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ti-hero-tag {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ti-strong-label {
    color: var(--ti-strong);
}

.ti-hero-tag-sep {
    color: var(--ti-text-tertiary);
}

.ti-category-label {
    color: var(--category-color);
}

.ti-trending-fixture-name {
    overflow: hidden;
    margin-bottom: 4px;
    color: var(--ti-text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ti-trending-text {
    display: block;
    overflow: hidden;
    color: var(--ti-text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ti-trending-text .ti-number-emphasis,
.ti-hero-text .ti-number-emphasis {
    color: var(--ti-strong);
    font-family: var(--font-accent);
    font-size: 1.06em;
    font-weight: 700;
}

.ti-support-text .ti-number-emphasis {
    color: var(--ti-text-secondary);
    font-family: var(--font-accent);
    font-size: 1.02em;
    font-weight: 650;
}

.ti-trending-kickoff {
    overflow: hidden;
    margin-top: 6px;
    color: var(--ti-text-tertiary);
    font-size: 10.5px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ti-trending-skeleton {
    min-height: 108px;
    border: 1px solid var(--ti-border);
    border-radius: 9px;
    background: var(--ti-card);
}

.ti-filter-shell {
    position: static;
    margin: 16px 0 18px;
    padding: 12px 14px;
    border: 1px solid var(--ti-border);
    border-radius: 10px;
    background: var(--ti-card);
}

.ti-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ti-filter-row + .ti-filter-row {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--ti-border);
}

.ti-filter-label {
    width: 74px;
    flex: 0 0 74px;
    color: var(--ti-text-tertiary);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ti-chip-group {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
}

.ti-filter-chip {
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--ti-border);
    border-radius: 6px;
    background: transparent;
    color: var(--ti-text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.ti-filter-chip:hover {
    border-color: var(--ti-border-hover);
    color: var(--ti-text);
}

.ti-filter-chip.is-active {
    border-color: var(--ti-green);
    background: color-mix(in srgb, var(--ti-green) 16%, transparent);
    box-shadow: 0 0 0 1px var(--ti-green);
    color: var(--ti-green);
    font-weight: 600;
}

.ti-select-wrap {
    display: block;
}

.ti-select {
    min-height: 34px;
    min-width: 210px;
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--ti-border);
    border-radius: 6px;
    appearance: none;
    background: var(--ti-card-raised);
    color: var(--ti-text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.ti-select:focus {
    border-color: var(--ti-green);
    outline: none;
}

.ti-section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    color: var(--ti-text-tertiary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ti-result-count {
    color: inherit;
}

.ti-fixture-feed,
.ti-status {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ti-status:empty {
    display: none;
}

.ti-fixture-card {
    --category-color: var(--ti-green);
    overflow: hidden;
    border: 1px solid var(--ti-border);
    border-left: 3px solid var(--category-color);
    /* Square left corners so the accent reads as a flat tab, not a curved stroke */
    border-radius: 0 10px 10px 0;
    background: var(--ti-card);
    scroll-margin-top: 16px;
    transition: border-color 0.15s ease;
}

.ti-fixture-card:hover,
.ti-fixture-card.is-targeted {
    border-color: var(--ti-border-hover);
    border-left-color: var(--category-color);
}

.ti-fixture-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px 9px;
    border-bottom: 1px solid var(--ti-border);
    background: var(--ti-card);
    color: var(--ti-text);
}

.ti-teams {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 700;
}

.ti-fixture-header > .ti-teams {
    width: auto;
}

.ti-team {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}

.ti-team-name {
    overflow: hidden;
    color: var(--ti-text);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ti-vs {
    flex: 0 0 auto;
    color: var(--ti-text-tertiary);
    font-size: 12px;
    font-weight: 500;
}

.ti-logo-shell {
    display: inline-flex;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ti-card-raised);
}

.ti-logo-shell--competition {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
}

.ti-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.ti-logo-shell--competition .ti-logo {
    width: 13px;
    height: 13px;
}

.ti-logo.is-hidden {
    display: none;
}

.ti-logo-placeholder {
    color: var(--ti-text-tertiary);
    font-family: var(--font-accent);
    font-size: 8px;
    font-weight: 700;
}

.ti-logo:not(.is-hidden) + .ti-logo-placeholder {
    display: none;
}

.ti-fixture-meta {
    display: block;
    width: auto;
    flex: 0 0 auto;
    text-align: right;
}

.ti-competition {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    color: var(--ti-text-tertiary);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ti-kickoff {
    margin-top: 2px;
    color: var(--ti-text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.ti-hero {
    padding: 10px 14px 8px;
    border-bottom: 0;
    background: var(--ti-card-raised);
}

.ti-hero-text {
    margin: 0;
    color: var(--ti-text);
    font-family: var(--font-heading);
    font-size: 15.5px;
    font-weight: 650;
    line-height: 1.35;
}

.ti-hero-evidence {
    margin-top: 4px;
    color: var(--ti-text-tertiary);
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.3;
}

.ti-supporting {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 14px 10px;
}

.ti-support-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--ti-text-secondary);
    font-size: 12.5px;
    line-height: 1.35;
}

.ti-support-row.is-collapsed {
    display: none;
}

.ti-support-dot {
    width: 4px;
    height: 4px;
    flex: 0 0 4px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--ti-text-tertiary);
}

.ti-support-text {
    min-width: 0;
}

.ti-support-more {
    align-self: flex-start;
    margin-top: 2px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ti-text-tertiary);
    cursor: pointer;
    font-size: 11.5px;
    font-weight: 600;
}

.ti-support-more:focus-visible {
    outline: 2px solid rgba(74, 124, 89, 0.55);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Phase A — expand touch area without enlarging text @ mobile/tablet */
@media (max-width: 1133px) {
    .ti-support-more {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
        padding: 8px 4px;
        box-sizing: border-box;
    }
}

.ti-support-more:hover {
    color: var(--ti-text-secondary);
}

.ti-card-footer {
    display: flex;
    justify-content: flex-end;
    padding: 8px 14px;
    border-top: 1px solid var(--ti-border);
    background: var(--ti-card);
}

.ti-analysis-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ti-text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.ti-fixture-card:hover .ti-analysis-link {
    color: var(--ti-green);
}

.ti-analysis-arrow {
    font-family: var(--font-accent);
    font-size: 13px;
}

.ti-loading-card,
.ti-state-card {
    padding: 18px 14px;
    border: 1px solid var(--ti-border);
    border-radius: 10px;
    background: var(--ti-card);
}

.ti-loading-line {
    height: 10px;
    margin-bottom: 10px;
    border-radius: 3px;
    background: var(--ti-card-raised);
}

.ti-loading-line--short {
    width: 34%;
}

.ti-loading-line--wide {
    width: 72%;
    height: 28px;
}

.ti-loading-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ti-loading-grid span {
    width: 82%;
    height: 8px;
    border-radius: 3px;
    background: var(--ti-card-raised);
}

.ti-state-card {
    text-align: center;
}

.ti-state-icon {
    margin-bottom: 8px;
    color: var(--ti-green);
}

.ti-state-card h3 {
    margin: 0 0 6px;
    color: var(--ti-text);
    font-family: var(--font-heading);
    font-size: 17px;
}

.ti-state-card p {
    margin: 0;
    color: var(--ti-text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.ti-retry-button {
    margin-top: 12px;
    padding: 8px 12px;
    border: 1px solid var(--ti-border);
    border-radius: 6px;
    background: transparent;
    color: var(--ti-text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.ti-retry-button:hover {
    border-color: var(--ti-green);
    color: var(--ti-text);
}

@media (max-width: 960px) {
    #tiDateFilters,
    #tiCategoryFilters {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    #tiDateFilters::-webkit-scrollbar,
    #tiCategoryFilters::-webkit-scrollbar {
        display: none;
    }

    #tiDateFilters .ti-filter-chip,
    #tiCategoryFilters .ti-filter-chip {
        flex: 0 0 auto;
    }
}

@media (max-width: 700px) {
    body.page-top-insights.layout-wide .container {
        padding: 18px 10px 80px !important;
    }

    .ti-page-header {
        margin-bottom: 12px;
    }

    .ti-page-header h1 {
        font-size: 28px;
    }

    .ti-section-heading {
        margin: 14px 0 7px;
    }

    .ti-trending-track {
        grid-auto-columns: 82%;
    }

    .ti-trending-section::after {
        height: 108px;
    }

    .ti-filter-shell {
        margin: 12px 0 14px;
        padding: 10px;
    }

    .ti-filter-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .ti-filter-row + .ti-filter-row {
        margin-top: 7px;
        padding-top: 7px;
    }

    .ti-filter-label {
        width: auto;
        flex-basis: auto;
    }

    .ti-chip-group {
        width: 100%;
    }

    .ti-filter-chip {
        min-height: 36px;
    }

    .ti-select-wrap,
    .ti-select {
        width: 100%;
    }

    .ti-select {
        min-height: 40px;
    }

    .ti-fixture-feed {
        gap: 8px;
    }

    .ti-fixture-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
        padding: 9px 12px 8px;
    }

    .ti-teams {
        width: 100%;
        align-items: flex-start;
        font-size: 13.5px;
    }

    .ti-team {
        min-width: 0;
        flex: 1 1 0;
        align-items: flex-start;
    }

    .ti-team:last-child {
        justify-content: flex-end;
        text-align: right;
    }

    .ti-team-name {
        overflow: visible;
        line-height: 1.25;
        text-overflow: clip;
        white-space: normal;
    }

    .ti-logo-shell {
        margin-top: 1px;
    }

    .ti-fixture-meta {
        width: 100%;
        padding-left: 28px;
        text-align: left;
    }

    .ti-competition {
        justify-content: flex-start;
    }

    .ti-hero {
        padding: 9px 12px 7px;
    }

    .ti-hero-text {
        font-size: 14.5px;
    }

    .ti-supporting {
        gap: 4px;
        padding: 7px 12px 8px;
    }

    .ti-support-row {
        font-size: 12px;
    }

    .ti-card-footer {
        min-height: 42px;
        align-items: center;
        padding: 7px 12px;
    }

    .ti-result-sort {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ti-page * {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
