/**
 * Search Page Styles
 * File: /wp-content/themes/wrestlerfinder/assets/css/search.css
 *
 * Depends on design-system.css for all custom property tokens.
 * Mobile-first: 390px base. Desktop breakpoint: 1024px.
 */

/* =============================================================================
   Search Page Layout
============================================================================= */

.wf-search-page {
    padding-bottom: var(--space-16);
}

.wf-search-header {
    padding-block: var(--space-8) var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.wf-search-header__title {
    font-family: var(--font-heading);
    font-size: var(--text-4xl);
    font-weight: 800;
    color: var(--color-text);
    line-height: 1;
    margin-bottom: var(--space-2);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.wf-search-header__sub {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-3);
}

.wf-search-header__sub strong {
    color: var(--color-primary);
    font-weight: 600;
}

.wf-search-coach-cta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    flex-wrap: wrap;
}

/* Search body — sidebar + results */
.wf-search-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: var(--space-6);
}

/* =============================================================================
   Sidebar Filters — Mobile (default)
============================================================================= */

.wf-search-filters {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 90vw;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    z-index: 200;
    overflow-y: auto;
    transform: translateX( -100% );
    transition: transform var(--transition-base);
    padding: var(--space-6);
    padding-bottom: var(--space-16);
}

.wf-search-filters--open {
    transform: translateX( 0 );
    box-shadow: var(--shadow-lg);
}

/* Overlay behind drawer */
.wf-filters-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba( 0, 0, 0, 0.6 );
    z-index: 199;
}

.wf-search-filters__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.wf-search-filters__title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wf-search-filters__clear {
    background: none;
    border: none;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.wf-search-filters__clear:hover {
    color: var(--color-primary);
}

.wf-search-filters__close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 32px;
    height: 32px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.wf-search-filters__close:hover {
    color: var(--color-text);
    background: var(--color-surface-3);
}

/* =============================================================================
   Facet Groups — Collapsible
============================================================================= */

.wf-facet-group {
    border-bottom: 1px solid var(--color-border-subtle);
    padding-block: var(--space-1);
}

.wf-facet-group:last-child {
    border-bottom: none;
}

.wf-facet-group__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: var(--space-3) 0;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
    transition: color var(--transition-fast);
}

.wf-facet-group__toggle:hover {
    color: var(--color-primary);
}

.wf-facet-group__arrow {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.wf-facet-group--collapsed .wf-facet-group__arrow {
    transform: rotate( -90deg );
}

.wf-facet-group__body {
    padding-bottom: var(--space-3);
}

/* Optional descriptor text inside a facet group — explains the facet to
   coaches before they see the checkbox list. Used on the "Placed At"
   facet, which needs a one-liner clarifying that it means "podium at
   these events," not "competed at." */
.wf-facet-group__desc {
    margin: 0 0 var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    line-height: 1.4;
}

/* =============================================================================
   FacetWP Overrides — Match Design System
============================================================================= */

/* =============================================================================
   FacetWP Checkbox — Plugin Override
   ===========================================================================
   Single block for .facetwp-checkbox covering all athlete-search facets
   (gender, weight class, grad year, state, college level, major). Plugin
   (FacetWP front.css) ships a default background-image PNG plus 20px
   padding-left + 4px margin-bottom on the wrapper at base specificity.
   !important is used on every plugin-overriding line because the plugin's
   stylesheet load order is not guaranteed across hosting environments — a
   cache-warm visitor could otherwise see the old visual. Justified here
   because we're overriding a third-party plugin's CSS we don't control.
   Same approach as the unified block in college-search.css.

   Athlete search uses no radio facets currently (verified in
   search-helpers.php), so .facetwp-radio is intentionally not styled here.
   If a radio facet is added to any page that loads search.css, mirror the
   college-search.css pattern: combine the two selectors as
   `.facetwp-radio, .facetwp-checkbox`.

   Property checklist explicitly covered: padding-left, margin,
   background-image, background-position, background-size, line-height.
   Position stays default (static) — plugin doesn't set it.
============================================================================= */

.facetwp-checkbox {
    /* Layout */
    display:        flex;
    align-items:    center;
    gap:            var(--space-2);
    line-height:    1.4;

    /* Spacing — !important kills plugin's padding-left: 20px and
       margin-bottom: 4px from front.css. */
    padding: var(--space-1) 0 !important;
    margin:  0              !important;

    /* Background — !important kills plugin's url(checkbox.png) shorthand.
       Explicit -position and -size are belt-and-suspenders in case a plugin
       update changes the shorthand structure. */
    background-image:    none  !important;
    background-position: 0 0   !important;
    background-size:     auto  !important;

    /* Typography + interaction */
    font-size:   var(--text-sm);
    color:       var(--color-text-muted);
    cursor:      pointer;
    user-select: none;
    transition:  color var(--transition-fast);
}

.facetwp-checkbox:hover {
    color: var(--color-text);
}

.facetwp-checkbox::before {
    content:        '';
    display:        inline-block;
    flex-shrink:    0;
    width:          16px;
    height:         16px;
    border:         1.5px solid var(--color-border);
    border-radius:  3px;
    background:     transparent;
    transition:     border-color var(--transition-fast), background var(--transition-fast);
}

.facetwp-checkbox.checked {
    color: var(--color-text);
    /* Override plugin's .checked variant (checkbox-on.png). */
    background-image: none !important;
}

.facetwp-checkbox.checked::before {
    border-color: var(--color-primary);
    background:   var(--color-primary);
}

.facetwp-checkbox .facetwp-counter {
    font-size:   var(--text-xs);
    color:       var(--color-text-subtle);
    margin-left: auto;
}

/* Slider (GPA, ACT) */
.facetwp-type-slider .noUi-target {
    background: var(--color-surface-3);
    border: none;
    box-shadow: none;
    height: 4px;
    border-radius: var(--radius-full);
}

.facetwp-type-slider .noUi-connect {
    background: var(--color-primary);
}

.facetwp-type-slider .noUi-handle {
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    border: 2px solid var(--color-bg);
    box-shadow: 0 0 0 1px var(--color-primary);
    cursor: grab;
    top: -7px;
    right: -9px;
}

.facetwp-type-slider .noUi-handle::before,
.facetwp-type-slider .noUi-handle::after {
    display: none;
}

.facetwp-type-slider .noUi-tooltip {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: var(--text-xs);
    padding: 2px 6px;
}

.facetwp-slider-reset {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-2);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.facetwp-slider-reset:hover {
    color: var(--color-primary);
}

/* Proximity */
.facetwp-type-proximity .facetwp-location {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

.facetwp-type-proximity .facetwp-location:focus {
    border-color: var(--color-primary);
}

.facetwp-type-proximity .facetwp-radius {
    margin-top: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    outline: none;
}

/* Per-page facet */
.facetwp-type-per_page select {
    padding: var(--space-1) var(--space-3);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    outline: none;
    cursor: pointer;
}

/* Pager */
.facetwp-type-pager .facetwp-pager {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.facetwp-pager .facetwp-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 var(--space-2);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    text-decoration: none;
}

.facetwp-pager .facetwp-page:hover {
    background: var(--color-surface-3);
    color: var(--color-text);
}

.facetwp-pager .active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-bg);
    font-weight: 600;
}

.facetwp-pager .active:hover {
    background: var(--color-teal-hover);
    border-color: var(--color-teal-hover);
    color: var(--color-bg);
}

/* =============================================================================
   Results Area
============================================================================= */

.wf-search-results {
    min-width: 0;
}

.wf-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.wf-results-bar__count {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.wf-results-bar__per-page {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.wf-search-pagination {
    margin-top: var(--space-8);
    display: flex;
    justify-content: center;
}

/* =============================================================================
   Athlete Cards Grid
============================================================================= */

.wf-athlete-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* facetwp_display('template', ...) wraps output in .facetwp-template —
   inherit the flex column layout so athlete cards stack correctly */
.wf-athlete-grid .facetwp-template {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* =============================================================================
   Athlete Card
============================================================================= */

.wf-athlete-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

.wf-athlete-card:hover {
    transform: translateY( -2px );
    box-shadow: var(--shadow-md);
    border-color: var(--color-border-subtle);
}

/* Pro athletes are differentiated by the PRO pill overlaid on the avatar
   in athlete-card.php — no separate card-level accent. See CSS Gotchas
   on why we avoid colored left-edge strips for status differentiation. */

.wf-athlete-card__link {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    text-decoration: none;
    color: inherit;
}

/* Photo */
.wf-athlete-card__photo-wrap {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
}

.wf-athlete-card__photo {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--color-surface-2);
}

/* Initials fallback when no avatar is set — same dimensions + circular
   shape as .wf-athlete-card__photo above so the card layout doesn't shift.
   Matches the teal-on-bg pattern used by .wf-coach-dash__avatar-initials. */
.wf-athlete-card__photo-initials {
    display:         flex;
    align-items:     center;
    justify-content: center;
    width:           80px;
    height:          80px;
    border-radius:   var(--radius-full);
    background:      var(--color-primary);
    color:           var(--color-bg);
    font-family:     var(--font-heading);
    font-weight:     700;
    font-size:       var(--text-xl);
    text-transform:  uppercase;
    letter-spacing:  0.02em;
}

.wf-athlete-card__pro-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--color-primary);
    color: var(--color-bg);
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 2px 5px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--color-bg);
}

/* Info */
.wf-athlete-card__info {
    flex: 1;
    min-width: 0;
}

.wf-athlete-card__name {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-1);
}

.wf-athlete-card__meta {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-2);
}

/* Stats row */
.wf-athlete-card__stats {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.wf-athlete-card__stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.wf-athlete-card__stat-value {
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
}

.wf-athlete-card__stat-label {
    font-size: 10px;
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1;
}

/* =============================================================================
   Placement Badges (reused from profile, used on cards)
============================================================================= */

.wf-badge {
    display: inline-block;
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: var(--radius-sm);
    line-height: 1;
    white-space: nowrap;
}

.wf-badge--sm {
    font-size: 10px;
    padding: 3px 6px;
}

.wf-badge--champion {
    background: linear-gradient( 135deg, #B8860B, #FFD700 );
    color: #1a1000;
}

.wf-badge--all-state {
    background: linear-gradient( 135deg, #708090, #C0C0C0 );
    color: #1a1a1a;
}

.wf-badge--placer {
    background: var(--color-teal-dim);
    color: var(--color-primary);
    border: 1px solid var(--color-teal-border);
}

.wf-badge--qualifier {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

/* =============================================================================
   No Results
============================================================================= */

.wf-no-results {
    text-align: center;
    padding: var(--space-16) var(--space-4);
}

.wf-no-results__message {
    font-size: var(--text-base);
    color: var(--color-text-muted);
    margin-bottom: var(--space-4);
}

/* =============================================================================
   Result Count Label
============================================================================= */

.wf-results-count {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.wf-results-count .facetwp-counts {
    font-weight: 600;
    color: var(--color-text);
}

/* =============================================================================
   Active Filter Chips
============================================================================= */

.wf-active-filters {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding-block: var(--space-3);
    border-bottom: 1px solid var(--color-border-subtle);
    margin-bottom: var(--space-4);
}

.wf-active-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.wf-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: var(--color-teal-dim);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    color: var(--color-primary);
    white-space: nowrap;
}

.wf-filter-chip__label {
    font-weight: 500;
}

.wf-filter-chip__remove {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: var(--text-sm);
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    opacity: 0.7;
    transition: opacity var(--transition-base);
}

.wf-filter-chip__remove:hover {
    opacity: 1;
}

.wf-active-filters__clear {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
    padding: 0;
    white-space: nowrap;
    text-decoration: underline;
    transition: color var(--transition-base);
}

.wf-active-filters__clear:hover {
    color: var(--color-text);
}

/* =============================================================================
   Mobile Filter Toggle — Fixed Bottom Bar
============================================================================= */

.wf-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    position: fixed;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX( -50% );
    z-index: 100;
    background: var(--color-primary);
    color: var(--color-bg);
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--space-3) var(--space-6);
    cursor: pointer;
    box-shadow: var(--shadow-teal);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.wf-filter-toggle:hover {
    background: var(--color-teal-hover);
    transform: translateX( -50% ) translateY( -2px );
}

.wf-filter-toggle__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--color-bg);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 800;
}

/* =============================================================================
   Desktop Layout — 1024px+
============================================================================= */

@media ( min-width: 1024px ) {

    .wf-search-body {
        grid-template-columns: 280px 1fr;
        gap: var(--space-8);
        align-items: start;
    }

    /* Sidebar is static on desktop — not a drawer */
    .wf-search-filters {
        position: sticky;
        top: var(--space-6);
        transform: none;
        border-right: none;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        background: var(--color-surface);
        padding: var(--space-5);
        max-height: calc( 100vh - var(--space-12) );
        overflow-y: auto;
        box-shadow: none;
        z-index: auto;
    }

    .wf-search-filters--open {
        transform: none;
        box-shadow: none;
    }

    .wf-search-filters__close {
        display: none;
    }

    /* Hide mobile drawer overlay on desktop */
    .wf-filters-open::after {
        display: none;
    }

    /* Hide mobile filter toggle on desktop */
    .wf-filter-toggle {
        display: none;
    }

}
