/* WinMatic Mobile Overrides (v1)
   Goal: premium mobile UX (no overflow, stacked filters, readable cards)
*/

html, body {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

img, svg {
  max-width: 100%;
  height: auto;
}

/* Reduce “nested scroll” on mobile */
@media (max-width: 820px) {
  .matches-list {
    max-height: none !important;
    overflow: visible !important;
  }
}

/* Main mobile layout */
@media (max-width: 720px) {
  /* top bar */
  .topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 999 !important;
  }

  .topbar-left {
    gap: 10px !important;
  }

  .brand-name {
    font-size: 1rem !important;
    letter-spacing: 0.2px !important;
  }

  .brand-tagline {
    display: none !important;
  }

  /* Filters: make them stack nicely */
  .filters-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .select-group,
  .filter {
    width: 100% !important;
    min-width: 0 !important;
  }

  .select-field,
  .select-with-logo select,
  .filter input,
  .filter select,
  .filter button {
    width: 100% !important;
  }

  .filter input[type="range"] {
    width: 100% !important;
  }

  /* Cards: more comfortable spacing */
  .match-card {
    padding: 12px !important;
    border-radius: 16px !important;
  }

  /* Match header/body should not try to be 3 columns on phones */
  .match-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .match-body {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Hero section: stack */
  .hero-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .hero-center-teams {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: center !important;
    text-align: center !important;
  }

  .hero-stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Prevent long team names from breaking layout */
  .team-name,
  .match-team,
  .hero-center {
    min-width: 0 !important;
  }

  .team-name {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
  }
}

@media (max-width: 420px) {
  .match-value-pill {
    font-size: 0.72rem !important;
    padding: 0.22rem 0.55rem !important;
  }
}

/* ================================
   WinMatic Landing (index) Mobile Fix
   Targets wm-* hero + cards used on /static/index.html
   ================================ */

@media (max-width: 720px) {
  /* If reveal JS fails on mobile, never hide content */
  .wm-reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  /* Make room for bottom nav */
  .wm-landing-main {
    padding-bottom: 96px !important;
  }

  /* HERO: force single-column layout */
  .wm-hero {
    padding: 18px 0 10px !important;
  }

  .wm-hero-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .wm-hero-left,
  .wm-hero-right {
    min-width: 0 !important;
  }

  /* HERO typography */
  .wm-hero-title {
    font-size: 1.75rem !important;
    line-height: 1.12 !important;
    letter-spacing: -0.02em !important;
    margin: 10px 0 10px !important;
  }

  .wm-hero-subtitle {
    font-size: 0.98rem !important;
    line-height: 1.45 !important;
  }

  /* CTA buttons: full-width stack */
  .wm-button-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-top: 14px !important;
  }

  .wm-button {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Stat cards: 2-up grid on mobile */
  .wm-hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-top: 14px !important;
  }

  .wm-stat-card {
    padding: 12px !important;
    border-radius: 18px !important;
  }

  .wm-stat-value {
    font-size: 1.05rem !important;
  }

  /* Right-side live card: keep it compact and readable */
  .wm-live-card {
    border-radius: 20px !important;
  }

  .wm-live-badges {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .wm-live-team {
    min-width: 0 !important;
  }

  .wm-live-team-name {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 12ch !important;
  }

  /* Section spacing */
  .wm-section {
    padding: 18px 0 !important;
  }

  /* Feature cards become 1-column */
  .wm-feature-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

@media (max-width: 420px) {
  .wm-hero-title {
    font-size: 1.55rem !important;
  }

  .wm-hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .wm-live-team-name {
    max-width: 10ch !important;
  }
}

/* WM REVEAL HARD FIX (2026-01-11)
   Fixes: content appears then disappears on mobile/web.
   Rule: .wm-reveal is ALWAYS visible, regardless of JS state.
*/
.wm-reveal,
html.wm-js .wm-reveal,
html.wm-js .wm-reveal.wm-reveal--visible{
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

/* BEGIN WM MOBILE LANDING HERO v4 (2026-01-12)
   Fix: mobile.css must be last stylesheet + force hero/card layout on mobile. */

@media (max-width: 900px){

  /* HERO WRAPPER */
  .wm-hero{
    padding: 18px 14px 22px !important;
  }

  .wm-hero-left,
  .wm-hero-right{
    width: 100% !important;
    max-width: 100% !important;
  }

  .wm-hero-right{
    margin-top: 14px !important;
  }

  /* TYPOGRAPHY */
  .wm-hero-title{
    font-size: clamp(30px, 7.6vw, 44px) !important;
    line-height: 1.05 !important;
    letter-spacing: -0.02em !important;
    margin: 10px 0 10px !important;
  }

  .wm-hero-sub{
    font-size: 15px !important;
    line-height: 1.45 !important;
    margin: 0 0 14px !important;
  }

  /* CTAs: full-width app buttons */
  .wm-hero-ctas{
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
    margin-top: 12px !important;
  }

  .wm-btn-primary,
  .wm-btn-secondary{
    width: 100% !important;
    justify-content: center !important;
    padding: 14px 16px !important;
    border-radius: 16px !important;
    min-height: 48px !important;
  }

  /* BENEFIT CARDS: single column, readable */
  .wm-hero-card-grid{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-top: 14px !important;
  }

  .wm-hero-card{
    padding: 14px !important;
    border-radius: 18px !important;
  }

  .wm-hero-card-header{
    margin-bottom: 8px !important;
  }

  .wm-hero-card-label{
    font-size: 12px !important;
    letter-spacing: .08em !important;
    text-transform: uppercase !important;
  }

  .wm-hero-card-value{
    font-size: 18px !important;
    line-height: 1.15 !important;
  }

  .wm-hero-card-row{
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
    flex-wrap: wrap !important;
  }

  .wm-hero-card-footer{
    margin-top: 10px !important;
    padding-top: 10px !important;
    border-top: 1px solid rgba(255,255,255,.06) !important;
  }

  /* METRICS: horizontal swipe row */
  .wm-hero-metrics-row{
    display: flex !important;
    overflow-x: auto !important;
    gap: 12px !important;
    padding: 6px 2px 10px !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .wm-hero-metric{
    flex: 0 0 78% !important;
    min-width: 240px !important;
    scroll-snap-align: start;
    padding: 14px !important;
    border-radius: 18px !important;
  }

  .wm-hero-metric-value{
    font-size: 22px !important;
    line-height: 1.1 !important;
  }

  .wm-hero-metric-label{
    font-size: 12px !important;
  }

  .wm-hero-metric-sub{
    font-size: 13px !important;
  }

  /* TESTIMONIAL */
  .wm-hero-testimonials{
    margin-top: 14px !important;
  }

  .wm-hero-testimonial-card{
    padding: 14px !important;
    border-radius: 18px !important;
  }

  /* optional: keep 4 cards above fold (rest still accessible elsewhere / via other sections) */
  .wm-hero-card-grid .wm-hero-card:nth-child(n+5){
    display: none !important;
  }
}

@media (max-width: 420px){
  .wm-hero{
    padding: 16px 12px 20px !important;
  }
  .wm-hero-title{
    font-size: clamp(28px, 8.2vw, 40px) !important;
  }
  .wm-hero-metric{
    flex-basis: 88% !important;
    min-width: 220px !important;
  }
}
/* END WM MOBILE LANDING HERO v4 */

/* === WM PORTRAIT FIX (STATS-AI) START === */
@media (max-width: 520px) {
  html, body { overflow-x: hidden !important; }
  *, *::before, *::after { box-sizing: border-box !important; }

  /* Stack common desktop grids into 1 col */
  .wm-hero, .wm-stats-grid, .wm-expand-grid, .wm-feature-grid,
  .wm-hero-card-main, .wm-hero-card-stats, .wm-hero-metrics-row,
  .wm-hero-right, .wm-hero-left {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Landing hero readability */
  .wm-hero-title { font-size: 34px !important; line-height: 1.06 !important; }
  .wm-hero-sub, .wm-hero-subtitle { font-size: 16px !important; line-height: 1.55 !important; }
  .wm-hero-ctas {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .wm-btn-primary, .wm-btn-secondary {
    width: 100% !important;
    justify-content: center !important;
    padding: 14px 14px !important;
    border-radius: 16px !important;
  }

  /* Cleaner cards (stats.ai-ish) */
  .wm-panel, .wm-hero-card, .wm-hero-testimonial-card, .wm-expand-box, .wm-feature-card, .wm-card {
    background: rgba(8, 12, 24, 0.78) !important;
    border: 1px solid rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 10px 28px rgba(0,0,0,0.45) !important;
  }
  .wm-hero-testimonial-card, .wm-hero-testimonial-card * { opacity: 1 !important; }

  /* Predictor filters: no overflow in portrait */
  .filters-row { flex-wrap: wrap !important; gap: 10px !important; }
  .filter { width: 100% !important; }
  .filter input[type="range"] { width: 100% !important; }

  /* Avoid bottom-nav covering content */
  body { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important; }
}
/* === WM PORTRAIT FIX (STATS-AI) END === */


/* === WM MOBILE BASELINE (STATS-AI) v3 START === */
@media (max-width: 560px) {
  html, body { overflow-x: hidden !important; }
  *, *::before, *::after { box-sizing: border-box !important; }

  /* Force common desktop grids to stack */
  .wm-hero,
  .wm-hero-card-grid,
  .wm-feature-grid,
  .wm-expand-grid,
  .wm-stats-grid,
  .wm-hero-metrics-row,
  .wm-hero-card-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Better spacing */
  .wm-section { padding: 18px 14px !important; }
  .wm-hero { padding: 18px 0 14px !important; }

  /* Cleaner “stats.ai” cards */
  .wm-panel,
  .wm-hero-card,
  .wm-hero-testimonial-card,
  .wm-expand-box,
  .wm-feature-card,
  .wm-card {
    background: rgba(10, 14, 26, 0.82) !important;
    border: 1px solid rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 10px 24px rgba(0,0,0,0.40) !important;
  }

  /* Make text readable (your testimonials were too faint on mobile) */
  .wm-hero-testimonial-card, .wm-hero-testimonial-card * { opacity: 1 !important; }

  /* Generic “bad pages” fixes: wide tables & cards */
  table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  th, td { white-space: nowrap !important; }

  /* Predictor / value filters usually overflow: force wrap */
  .filters-row, .controls-row, .toolbar, .filters, .filter-row {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .filter, .control, .field {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Prevent bottom nav from covering content */
  body { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important; }
}
/* === WM MOBILE BASELINE (STATS-AI) v3 END === */

/* === WM GLOBAL PORTRAIT FIX v4 START ===
   Fix: pages bad in portrait (good in landscape)
   Cause: desktop grids/fixed widths/min-widths still apply
   Goal: force 1-col layout + prevent overflow everywhere
*/
@media (max-width: 600px) {
  html, body { overflow-x: hidden !important; }
  *, *::before, *::after { box-sizing: border-box !important; }
  img, svg { max-width: 100% !important; height: auto !important; }

  /* Core layout padding */
  main, .main, .wm-landing-main, .wm-page, .page, .content {
    padding-left: 14px !important;
    padding-right: 14px !important;
    max-width: 100% !important;
  }

  /* LANDING HERO: force to single column (fixes card clipping) */
  .wm-hero {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    padding: 18px 0 16px !important;
    align-items: start !important;
  }
  .wm-hero-left, .wm-hero-right { width: 100% !important; min-width: 0 !important; }
  .wm-hero-right { justify-content: stretch !important; }
  .wm-hero-card {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
  }

  /* Internal hero stats grid: allow shrink without overflow */
  .wm-hero-card-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 10px !important;
  }
  .wm-hero-card-row { min-width: 0 !important; }
  .wm-hero-card-value, .wm-hero-card-label {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Make most page grids collapse in portrait (keeps results OK) */
  .main [class*="grid"]:not(.wm-hero-card-grid),
  main  [class*="grid"]:not(.wm-hero-card-grid),
  .wm-page [class*="grid"]:not(.wm-hero-card-grid) {
    grid-template-columns: 1fr !important;
  }

  /* Wrap toolbars/rows */
  .main [class*="row"],
  main  [class*="row"],
  .wm-page [class*="row"],
  .filters-row, .controls-row, .toolbar, .filters, .filter-row {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  /* Tables: always scroll instead of breaking layout */
  table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  th, td { white-space: nowrap !important; }

  /* Predictor/value controls: stop overflow */
  .filter, .control, .field { width: 100% !important; min-width: 0 !important; }
  input, select, button { max-width: 100% !important; }

  /* Stats.ai-ish: reduce glow, increase contrast on cards */
  .wm-panel, .wm-card, .wm-hero-card, .wm-expand-box, .wm-feature-card {
    background: rgba(10, 14, 26, 0.84) !important;
    border: 1px solid rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 10px 24px rgba(0,0,0,0.40) !important;
  }
}
/* === WM GLOBAL PORTRAIT FIX v4 END === */

/* === WM PREDICTOR + VALUE MOBILE FIX v1 START === */
@media (max-width: 600px) {

  /* Bottom nav: make it smaller (portrait + landscape) */
  .wm-bottom-nav{
    left: 10px !important;
    right: 10px !important;
    padding: 8px 8px !important;
    border-radius: 18px !important;
    gap: 6px !important;
  }
  .wm-bottom-link{
    padding: 8px 6px !important;
    border-radius: 14px !important;
    gap: 4px !important;
  }
  .wm-bottom-ico svg{ width: 18px !important; height: 18px !important; }
  .wm-bottom-text{ font-size: 0.72rem !important; }

  /* In landscape: hide labels so nav stops eating the screen */
  @media (max-height: 450px) {
    .wm-bottom-text{ display:none !important; }
    .wm-bottom-link{ padding: 10px 6px !important; }
    body{ padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
  }

  /* Predictor “accuracy + controls” should stack */
  .accuracy-header{
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
  }
  .accuracy-ring{
    width: 160px !important;
    height: 160px !important;
    margin: 0 auto !important;
  }
  .accuracy-controls{ width: 100% !important; }
  .accuracy-row{
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .select-group, .select-with-logo{
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Match cards: compact header row, smaller orbs, no overflow */
  .wm-match-card{
    padding: 12px 12px !important;
    border-radius: 18px !important;
  }
  .wm-match-row{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .wm-team-col{
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-width: 0 !important;
  }
  .wm-team-col--away{
    flex-direction: row-reverse !important;
    justify-content: space-between !important;
  }

  .wm-orb{
    width: 52px !important;
    height: 52px !important;
    flex: 0 0 auto !important;
  }

  .wm-team-meta{ min-width: 0 !important; }
  .wm-team-name{
    font-size: 16px !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 68vw !important;
  }
  .wm-team-prob{ font-size: 18px !important; }

  /* Collapse expanded details unless the card is expanded (keeps list tight) */
  .wm-match-card:not(.is-expanded) .wm-match-expanded{
    display: none !important;
  }

  /* When expanded: keep stats usable, not 1-item-per-row tall */
  .wm-stats-grid{
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .wm-stat-box{ padding: 10px 10px !important; border-radius: 14px !important; }
  .wm-stat-label{ font-size: 12px !important; }
  .wm-stat-value{ font-size: 14px !important; }

  /* Big decorative logos in expanded view: shrink */
  .team-logo-orb-lg{ width: 72px !important; height: 72px !important; }
  .team-logo-initial-lg{ width: 72px !important; height: 72px !important; font-size: 26px !important; }

}
/* === WM PREDICTOR + VALUE MOBILE FIX v1 END === */


/* === WM CARD TOGGLE + COLLAPSE STYLE START === */
.wm-match-expanded { display: none; }
.wm-match-card.is-expanded .wm-match-expanded { display: block; }

.wm-card-toggle{
  position: absolute;
  top: 12px;
  right: 12px;
  border: 1px solid rgba(148,163,184,.20);
  background: rgba(2,6,23,.55);
  color: rgba(226,232,240,.95);
  border-radius: 999px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  backdrop-filter: blur(14px);
}

.wm-card-toggle:active{ transform: scale(.98); }

@media (max-width: 600px){
  .wm-match-card{ padding: 12px 12px !important; }
  .wm-orb{ width: 52px !important; height: 52px !important; }
}
/* === WM CARD TOGGLE + COLLAPSE STYLE END === */


/* WM_MODAL_CSS_V1 */
.wm-modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,.55);
  padding: 14px;
  z-index: 9999;
}
.wm-modal-overlay.is-open { display: flex; }

.wm-modal-sheet {
  width: min(520px, 100%);
  max-height: 82vh;
  overflow: auto;
  border-radius: 18px;
  background: #0f1a33;
  border: 1px solid rgba(75,121,255,.45);
  box-shadow: 0 16px 60px rgba(0,0,0,.55);
}

.wm-modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 10px 10px 0 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(11,18,32,.65);
  color: #e6edf7;
  font-size: 22px;
  line-height: 34px;
}

.wm-modal-body { padding: 10px 14px 16px 14px; color:#e6edf7; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial; }

.wm-modal-title { font-size: 16px; font-weight: 800; }
.wm-modal-title span { opacity:.6; font-weight: 600; }
.wm-modal-sub { margin-top: 4px; font-size: 12px; opacity: .7; }

.wm-modal-kpi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.wm-kpi {
  background: #0b1326;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 10px 12px;
}
.wm-kpi-label { font-size: 11px; opacity:.7; }
.wm-kpi-val { font-size: 14px; font-weight: 800; margin-top: 4px; }

.wm-modal-card {
  background: #0b1326;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 10px 0;
}
.wm-modal-card-title { font-size: 12px; font-weight: 800; margin-bottom: 8px; opacity: .9; }

.wm-modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.wm-modal-grid .k { font-size: 11px; opacity: .7; }
.wm-modal-grid .v { font-size: 13px; font-weight: 800; margin-top: 2px; }

.wm-modal-text { font-size: 12px; opacity: .85; line-height: 1.45; }
