/* ==========================================================================
   PERMYAKBET — EDITORIAL SPORTS ANALYTICS & TERMINAL DESIGN SYSTEM
   The Athletic & Bloomberg Sports Doctrine • Human Craft & Mathematical Precision
   WCAG 2.2 AA/AAA Compliant | 8dp Rhythm | Dual Theme (Terminal Dark & Editorial Light)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700;800&family=Space+Grotesk:wght@500;600;700;800&display=swap');

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS (LIGHT & DARK ROOTS)
   -------------------------------------------------------------------------- */
:root, [data-theme="light"] {
  /* Surface Layers (Editorial Canvas / High-Contrast Paper) */
  --bg-page: #f6f8fa;
  --bg-page-alt: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-card-muted: #f1f5f9;
  --bg-ticker: #0f172a;
  --text-ticker: #f8fafc;
  
  /* Borders & Dividers (Precise Hairline Borders) */
  --border-card: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-focus: #2563eb;
  
  /* Typography Scale (WCAG AAA Contrast) */
  --text-primary: #0f172a;       /* 15.5:1 against white */
  --text-secondary: #334155;     /* 7.5:1 against white */
  --text-muted: #64748b;         /* 4.8:1 against white */
  --text-inverse: #ffffff;
  
  /* Brand Accents (Cobalt Blue & Dark Ink) */
  --brand-primary: #1d4ed8;
  --brand-primary-hover: #1e40af;
  --brand-primary-light: #eff6ff;
  --brand-primary-border: #bfdbfe;
  
  /* Semantic Status Tokens (WCAG 2.2 AA/AAA Compliant) */
  --color-success: #047857;      /* 5.2:1 against #ecfdf5 */
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;
  
  --color-warning: #b45309;      /* 4.8:1 against #fffbeb */
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  
  --color-danger: #b91c1c;       /* 5.9:1 against #fef2f2 */
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  
  --color-vip: #b45309;
  --color-vip-bg: #fffbeb;
  --color-vip-border: #fde68a;
  
  /* Header & Navigation */
  --header-bg: rgba(255, 255, 255, 0.94);
  --header-border: #e2e8f0;
  
  /* Elevation & Shadows (Tailored, Sharp, No Fuzzy Glow) */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.03);
  --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.04), 0 1px 2px -1px rgba(15, 23, 42, 0.02);
  --shadow-card-hover: 0 4px 10px -2px rgba(15, 23, 42, 0.08);
  --shadow-modal: 0 16px 32px -6px rgba(15, 23, 42, 0.16);

  /* Precise Architectural Radii (Human Craft - NOT AI Bulky Blobs) */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* 8dp Spatial Rhythm Tokens */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
}

[data-theme="dark"] {
  /* Surface Layers (Bloomberg / Financial Terminal Canvas) */
  --bg-page: #0b0f15;
  --bg-page-alt: #101520;
  --bg-card: #141b27;
  --bg-card-hover: #182232;
  --bg-card-muted: #0d121c;
  --bg-ticker: #070a0e;
  --text-ticker: #e2e8f0;
  
  /* Borders & Dividers */
  --border-card: #202b3c;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  /* Typography Scale (WCAG AAA Contrast) */
  --text-primary: #f8fafc;       /* 16.5:1 against #141b27 */
  --text-secondary: #94a3b8;     /* 6.7:1 against #141b27 */
  --text-muted: #8b9db7;         /* 6.2:1 against #141b27 (WCAG AA Compliant) */
  --text-inverse: #0b0f15;
  
  /* Brand Accents */
  --brand-primary: #2563eb;
  --brand-primary-hover: #3b82f6;
  --brand-primary-light: rgba(37, 99, 235, 0.14);
  --brand-primary-border: rgba(37, 99, 235, 0.35);
  
  /* Semantic Status Tokens */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-success-border: rgba(16, 185, 129, 0.28);
  
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-warning-border: rgba(245, 158, 11, 0.28);
  
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-danger-border: rgba(239, 68, 68, 0.28);
  
  --color-vip: #f59e0b;
  --color-vip-bg: rgba(245, 158, 11, 0.12);
  --color-vip-border: rgba(245, 158, 11, 0.28);
  
  /* Header & Navigation */
  --header-bg: rgba(11, 15, 21, 0.94);
  --header-border: #1e2838;
  
  /* Elevation & Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.45);
  --shadow-card-hover: 0 4px 12px 0 rgba(0, 0, 0, 0.55);
  --shadow-modal: 0 20px 30px -5px rgba(0, 0, 0, 0.7);

  /* Precise Architectural Radii */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
}

/* --------------------------------------------------------------------------
   2. GLOBAL BASE & TYPOGRAPHY
   -------------------------------------------------------------------------- */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  line-height: 1.55;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.12s ease;
}

.font-heading {
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  letter-spacing: -0.03em;
  font-feature-settings: "ss01" 1, "cv01" 1;
}

.font-mono, .tabular-nums {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --------------------------------------------------------------------------
   3. ACCESSIBILITY & FOCUS VISIBLE (WCAG 2.2)
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   4. LIVE SPORTS TICKER RIBBON (Top Running Match Bar)
   -------------------------------------------------------------------------- */
.ticker-wrap {
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-ticker);
  color: var(--text-ticker);
  border-bottom: 1px solid var(--border-card);
  font-size: 11px;
  position: relative;
  user-select: none;
  contain: paint;
}

.ticker-wrap::before,
.ticker-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 36px;
  z-index: 2;
  pointer-events: none;
}
.ticker-wrap::before {
  left: 0;
  background: linear-gradient(to right, var(--bg-ticker), transparent);
}
.ticker-wrap::after {
  right: 0;
  background: linear-gradient(to left, var(--bg-ticker), transparent);
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 7px 0;
  animation: tickerMarquee 35s linear infinite;
  will-change: transform;
}

.ticker-wrap:hover .ticker-track {
  animation-play-state: paused;
}

@keyframes tickerMarquee {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 2px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}

.ticker-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ef4444;
  animation: pulseLive 1.8s infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes pulseLive {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
}

/* --------------------------------------------------------------------------
   5. UTILITY CLASSES & SURFACE TOKENS
   -------------------------------------------------------------------------- */
.bg-theme-page { background-color: var(--bg-page); }
.bg-theme-page-alt { background-color: var(--bg-page-alt); }
.bg-theme-card { background-color: var(--bg-card); }
.bg-theme-card-hover:hover { background-color: var(--bg-card-hover); }
.border-theme-card { border-color: var(--border-card); }
.border-theme-subtle { border-color: var(--border-subtle); }
.text-theme-primary { color: var(--text-primary); }
.text-theme-secondary { color: var(--text-secondary); }
.text-theme-muted { color: var(--text-muted); }

/* Navigation Blur Header */
.glass-nav {
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--header-border);
}

/* Precise Terminal Card */
.card-terminal {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card-terminal:hover {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: var(--shadow-card-hover);
}

/* Card Shadow (Backwards compatibility) */
.card-shadow {
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card-shadow:hover {
  box-shadow: var(--shadow-card-hover);
}

/* Odds Pill (High-Precision Terminal Metric) */
.odds-pill {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
  background-color: var(--bg-page-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-card);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
}

.odds-pill:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

/* Form Guide Mini Badges (W / D / L in Russian: В / Н / П) */
.form-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.form-badge-w {
  background-color: #059669;
  color: #ffffff;
}

.form-badge-d {
  background-color: #64748b;
  color: #ffffff;
}

.form-badge-l {
  background-color: #dc2626;
  color: #ffffff;
}

/* xG Distribution Track Bar */
.xg-bar-container {
  display: flex;
  height: 6px;
  width: 100%;
  background-color: var(--border-card);
  border-radius: 3px;
  overflow: hidden;
  gap: 2px;
}

.xg-bar-home {
  background-color: #2563eb;
  transition: width 0.3s ease;
}

.xg-bar-away {
  background-color: #64748b;
  transition: width 0.3s ease;
}

/* Status Badges (Sharp & Crisp) */
.badge-plus {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-vip {
  background-color: var(--color-vip-bg);
  color: var(--color-vip);
  border: 1px solid var(--color-vip-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-live {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-soon {
  background-color: var(--bg-card-muted);
  color: var(--text-muted);
  border: 1px solid var(--border-card);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
}

/* Light / Dark Mode Hero Image Swapping */
.hero-img-light { display: block; }
.hero-img-dark { display: none; }
[data-theme="dark"] .hero-img-light { display: none; }
[data-theme="dark"] .hero-img-dark { display: block; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb { background: var(--border-card); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Modal Backdrop & Transitions */
.modal-backdrop {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  transform: scale(0.98) translateY(6px);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-content {
  transform: scale(1) translateY(0);
}

/* Interactive touch target discipline */
button, a, input, select {
  touch-action: manipulation;
}


