/* Compact market page filters (Win, Goals, BTTS, Corners, Cards) */

.market-filters-wrap {
    position: sticky;
    /* Dock flush under the measured nav. Extra sticky `top` offset created a
       transparent gap where match rows painted behind the rounded filter card. */
    top: var(--snx-global-header-height, 70px);
    z-index: 50;
    margin-bottom: 12px;
}

/* Phone + tablet: scroll with page (avoids rows showing through sticky wrap).
   Desktop (≥1134) keeps sticky. */
@media (max-width: 1133px) {
    .market-filters-wrap {
        position: relative;
        top: auto;
    }
}

/* Desktop: hide the sticky bar on scroll-down without collapsing layout.
   Transform the inner card only — transforming the sticky wrap would break stickiness. */
@media (min-width: 1134px) {
    .market-filters-wrap {
        /* Padding lives on the wrap (not the inner card) so the stuck band is
           opaque — rows cannot show through the rounded card corners. */
        padding-top: 12px;
        /* Pull wrap padding into the container's 12px top pad at rest so
           page-top spacing is unchanged; when stuck the 12px pad is inside
           the opaque band. */
        margin-top: -12px;
        background: var(--match-dark-bg, #000);
        box-sizing: border-box;
    }

    .market-filters-wrap .market-filters {
        transition: transform 250ms ease, opacity 250ms ease;
    }

    .market-filters-wrap.is-scroll-hidden {
        pointer-events: none;
        /* Let rows occupy the viewport slot while the inner card is tucked away. */
        background: transparent;
    }

    .market-filters-wrap.is-scroll-hidden .market-filters {
        transform: translate3d(0, calc(-100% - 12px), 0);
        opacity: 0;
    }
}

@media (min-width: 1134px) and (prefers-reduced-motion: reduce) {
    .market-filters-wrap .market-filters {
        transition: opacity 200ms ease;
    }

    .market-filters-wrap.is-scroll-hidden .market-filters {
        transform: none;
    }
}

.market-filters {
    background: var(--match-card-bg, #1a1a1a);
    border: 1px solid var(--match-border, #2a2a2a);
    border-radius: 10px;
    padding: 8px 10px;
}

.market-filters__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.market-filters__group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0;
}

.market-filters__group--grow {
    flex: 1 1 160px;
    min-width: 120px;
}

.market-filters__select,
.market-filters__input {
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--match-border, #2a2a2a);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary, #fff);
    font-size: 12px;
    font-weight: 600;
    outline: none;
    min-width: 0;
}

.market-filters__select-wrap {
    position: relative;
    flex: 1 1 180px;
    min-width: 140px;
}

.market-filters__select-wrap .market-filters__select {
    width: 100%;
}

.market-filters__select[data-scrollable-select][size] {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: min(280px, 50vh);
    overflow-y: auto;
    z-index: 300;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.market-filters__select[data-scrollable-select][size]::-webkit-scrollbar {
    width: 6px;
}

.market-filters__select[data-scrollable-select][size]::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.market-filters__select {
    cursor: pointer;
    max-width: 100%;
}

.market-filters__select.filter-item-league {
    min-width: 140px;
    flex: 1 1 180px;
}

.market-filters__input {
    width: 100%;
    cursor: text;
}

.market-filters__input::placeholder {
    color: var(--text-muted, #888);
    opacity: 0.85;
}

/* iOS/Safari zooms focused inputs under 16px — match header-search anti-zoom */
@media (max-width: 1024px) {
    .market-filters__input,
    #match_search.market-filters__input,
    #match_search.filter-select,
    #match_search {
        font-size: 16px !important;
    }
}

.market-filters__select:focus,
.market-filters__input:focus {
    border-color: var(--match-green, #4a7c59);
}

.market-filters__days {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.market-filters__day-btn {
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--match-border, #2a2a2a);
    background: transparent;
    color: var(--text-muted, #888);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
}

.market-filters__day-btn:hover {
    color: var(--text-primary, #fff);
    border-color: rgba(255, 255, 255, 0.22);
}

.market-filters__day-btn.active {
    background: var(--match-green, #4a7c59);
    border-color: var(--match-green, #4a7c59);
    color: #fff;
}

/* Phase B — day pill touch sizing @ mobile/tablet (desktop ≥1134 unchanged) */
@media (max-width: 1133px) {
    .market-filters__day-btn {
        height: auto;
        min-height: 36px;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Beat body.layout-wide .filter-tab { min-height: 34px !important } in market-pages-accessibility.css */
    body.layout-wide .market-filters__day-btn.filter-tab,
    body.layout-wide .market-filters__toolbar .market-filters__day-btn {
        min-height: 36px !important;
        height: auto !important;
        box-sizing: border-box;
    }
}

.market-filters__day-btn--calendar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.market-filters__date-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Flatpickr — only the next 14 days are selectable; others stay greyed out */
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #6b7280 !important;
    opacity: 0.45;
    cursor: not-allowed;
}

.flatpickr-day.flatpickr-disabled:hover {
    background: transparent !important;
    border-color: transparent !important;
}

[data-theme="light"] .flatpickr-day.flatpickr-disabled,
[data-theme="light"] .flatpickr-day.prevMonthDay,
[data-theme="light"] .flatpickr-day.nextMonthDay {
    color: #94a3b8 !important;
}

.market-filters__side {
    display: inline-flex;
    border: 1px solid var(--match-border, #2a2a2a);
    border-radius: 8px;
    overflow: hidden;
}

.market-filters__side-btn {
    height: 34px;
    padding: 0 10px;
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

.market-filters__side-btn + .market-filters__side-btn {
    border-left: 1px solid var(--match-border, #2a2a2a);
}

.market-filters__side-btn.active {
    background: rgba(74, 124, 89, 0.25);
    color: #fff;
}

.market-filters__line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.market-filters__ou {
    display: inline-flex;
    border: 1px solid var(--match-border, #2a2a2a);
    border-radius: 8px;
    overflow: hidden;
}

.market-filters__ou-btn {
    height: 34px;
    padding: 0 10px;
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

.market-filters__ou-btn + .market-filters__ou-btn {
    border-left: 1px solid var(--match-border, #2a2a2a);
}

.market-filters__ou-btn.active {
    background: rgba(74, 124, 89, 0.25);
    color: #fff;
}

.market-filters__stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--match-border, #2a2a2a);
    border-radius: 8px;
    overflow: hidden;
}

.market-filters__step-btn {
    width: 32px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-primary, #fff);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.market-filters__step-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.market-filters__line-label {
    min-width: 36px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    padding: 0 4px;
}

.market-filters__toggle {
    display: none;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--match-border, #2a2a2a);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary, #fff);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
}

.market-filters__toggle[aria-expanded="true"] {
    border-color: var(--match-green, #4a7c59);
    color: #fff;
}

.market-filters__chips {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
}

.market-filters__chips.is-visible {
    display: flex;
}

.active-filters-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--match-border, #2a2a2a);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary, #ccc);
    font-weight: 600;
    font-size: 10px;
    line-height: 1.2;
}

.market-filters__panel {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--match-border, #2a2a2a);
    gap: 8px;
    flex-direction: column;
}

.market-filters__panel.is-open {
    display: flex;
    animation: snx-filters-panel-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes snx-filters-panel-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .market-filters__panel.is-open {
        animation: none;
    }
}

.market-filters__panel-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.market-filters__panel-row--days {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.market-filters__panel-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #888);
}

.market-filters__days--panel {
    width: 100%;
}

.market-filters__panel-row .market-filters__select,
.market-filters__panel-row .market-filters__input {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
}

.market-filters__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.market-ad-slot:not(.is-enabled) {
    display: none;
    min-height: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

/* Enabled market + all snx slot sizing: see static/css/snx-ad-slots.css */

/* Desktop PASS layout @ ≥820px — toolbar row, no mobile panel */
@media (min-width: 820px) {
    .market-filters__panel {
        display: none !important;
    }

    .market-filters__toggle {
        display: none !important;
    }

    .market-filters__toolbar--desktop-only {
        display: flex;
    }
}

/*
 * Phase C.1 — mobile ≤767px: day pills live in the Filters panel only.
 * Toolbar: league + search + Filters toggle. Active day surfaced via chips row.
 */
@media (max-width: 767px) {
    .market-filters__toggle {
        display: inline-flex;
        align-items: center;
        flex: 0 0 auto;
    }

    .market-filters__toolbar .market-filters__group--collapse-mobile {
        display: flex;
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        order: 1;
    }

    /* Hide persistent toolbar day row — panel copy is the sole mobile control */
    .market-filters__toolbar .market-filters__days--collapse-mobile {
        display: none !important;
    }

    .market-filters__toolbar .market-filters__group--search-mobile {
        flex: 1 1 120px;
        min-width: 0;
        order: 2;
    }

    .market-filters__toggle {
        order: 3;
    }

    /* League select stays in toolbar; panel league row remains hidden */
    .market-filters__panel > .market-filters__panel-row.market-filters__group--collapse-mobile {
        display: none;
    }

    .market-filters__panel .market-filters__days--panel {
        display: flex;
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }

    .market-filters__panel .market-filters__day-btn {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        padding: 0 8px;
    }

    .market-filters__panel .market-filters__day-btn--calendar {
        flex: 1.2 1 auto;
    }
}

/*
 * Tablet intermediate 768–819px: compact toolbar row with inline day pills
 * (horizontal scroll). No Filters panel toggle.
 */
@media (min-width: 768px) and (max-width: 819px) {
    .market-filters__panel {
        display: none !important;
    }

    .market-filters__toggle {
        display: none !important;
    }

    .market-filters__toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .market-filters__toolbar::-webkit-scrollbar {
        display: none;
    }

    .market-filters__toolbar .market-filters__days--collapse-mobile {
        display: inline-flex;
        flex: 0 0 auto;
        flex-wrap: nowrap;
        max-width: none;
        order: 0;
        margin-top: 0;
    }

    .market-filters__toolbar .market-filters__group--collapse-mobile,
    .market-filters__toolbar .market-filters__group--search-mobile {
        flex: 0 0 auto;
        order: 0;
    }
}

/* Tablet: same viewport-safe Flatpickr as phones (≤767 in responsive-typography.css).
   At exactly 768px Flatpickr otherwise anchors to the Date button (rightMost). */
@media (min-width: 768px) and (max-width: 1023px) {
    .flatpickr-calendar,
    .flatpickr-calendar.open {
        --fp-width: min(calc(100vw - 24px), 294px);
        --fp-cell: calc(var(--fp-width) / 7);
        position: fixed !important;
        left: 50% !important;
        right: auto !important;
        top: auto !important;
        bottom: 10px !important;
        transform: translateX(-50%) !important;
        border-radius: 14px !important;
        /* Prevent FP open animation from replacing translateX(-50%) (iOS reopen slide) */
        animation: none !important;
    }

    .flatpickr-calendar:before,
    .flatpickr-calendar:after {
        display: none !important;
    }
}

/* Tablet + mobile: tighten prediction list headings */
@media (max-width: 1133px) {
    body.layout-wide .card > h3,
    body.layout-wide .card h3,
    body.layout-wide .sidebar-title {
        font-size: 13px;
        letter-spacing: 0.04em;
        line-height: 1.35;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }
}

[data-theme="light"] .market-filters {
    background: #fff;
    border-color: #e2e8f0;
}

[data-theme="light"] .market-filters__select[data-scrollable-select][size] {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

[data-theme="light"] .market-filters__select[data-scrollable-select][size]::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .market-filters__select,
[data-theme="light"] .market-filters__input,
[data-theme="light"] .market-filters__toggle,
[data-theme="light"] .market-filters__day-btn,
[data-theme="light"] .market-filters__side,
[data-theme="light"] .market-filters__ou,
[data-theme="light"] .market-filters__stepper {
    border-color: #e2e8f0;
    color: #1f2937;
}

[data-theme="light"] .market-filters__day-btn.active,
[data-theme="light"] .market-filters__side-btn.active,
[data-theme="light"] .market-filters__ou-btn.active {
    color: #fff;
}

[data-theme="light"] .active-filters-chip {
    border-color: #e2e8f0;
    color: #475569;
    background: #f8fafc;
}
