/* ═══════════════════════════════════════════
   COMPONENTS — Buttons, cards, nav, surfaces, animations
   ═══════════════════════════════════════════ */

/* ═══════ PERF: off-screen list items skip layout & paint ═══════
   content-visibility: auto lets the browser defer rendering work for items
   below the fold. contain-intrinsic-size gives a size hint so scroll height
   stays stable before items have ever been measured. Huge win on long lists.
   Scoped to row/card classes that actually repeat in scroll feeds. */
.match-row,
.slip-card,
.cs-game,
.cvt-game-card,
.cp-league-row,
.cp-lp-item,
.cpv-game {
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
}

/* ═══════ APP SHELL ═══════ */
.app {
  position: relative; z-index: 1;
  padding: 0 0 100px;
}

/* ═══════ HEADER ═══════ */
.header {
  padding: 14px 20px 0;
  display: flex; align-items: center; justify-content: space-between;
  opacity: 0; animation: fadeIn 0.5s cubic-bezier(0.22,1,0.36,1) 0.05s forwards;
}

.header-left { display: flex; align-items: center; gap: 12px; }

/* Brand logo */
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), var(--blue-bright));
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--blue-15);
}

.brand-logo-img {
  width: 22px; height: 22px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.brand-name {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.3px; color: var(--chalk);
  line-height: 1.2;
}

.brand-tagline {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.5px; color: var(--ghost);
}

.header-right { display: flex; gap: 8px; }

.hdr-btn {
  width: 42px; height: 42px;
  border-radius: 14px;
  background: var(--slab);
  border: 1px solid var(--dim);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  box-shadow: var(--card-shadow);
  position: relative;
}

.hdr-btn:active { transform: scale(0.92); background: var(--slate); }
.hdr-btn svg { width: 18px; height: 18px; color: var(--ghost); }

/* Theme toggle icons */
#themeToggle .icon-sun { display: none; }
#themeToggle .icon-moon { display: block; }
[data-theme="light"] #themeToggle .icon-sun { display: block; }
[data-theme="light"] #themeToggle .icon-moon { display: none; }

.hdr-btn .notif-dot {
  position: absolute; top: 10px; right: 10px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--loss);
  border: 2px solid var(--slab);
}

/* ═══════ STREAK BANNER ═══════ */
.streak-banner {
  margin: 16px 20px 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--streak-bg);
  border: 1px solid var(--blue-10);
  display: flex; align-items: center; gap: 12px;
  opacity: 0; animation: fadeIn 0.5s cubic-bezier(0.22,1,0.36,1) 0.1s forwards;
}

.streak-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--blue);
  display: grid; place-items: center;
  flex-shrink: 0;
}

.streak-icon svg { width: 18px; height: 18px; color: #fff; }
.streak-info { flex: 1; }

.streak-title {
  font-size: 13px; font-weight: 700;
  color: var(--chalk); line-height: 1.2;
}

.streak-sub {
  font-size: 11px; font-weight: 500;
  color: var(--ghost); margin-top: 1px;
}

.streak-badge {
  padding: 5px 12px;
  border-radius: 100px;
  background: var(--blue);
  color: #fff;
  font-size: 12px; font-weight: 700;
  letter-spacing: -0.3px;
}

/* ═══════ LEAGUE SELECTOR ═══════ */
.league-scroll {
  display: flex; gap: 18px;
  padding: 20px 20px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  opacity: 0; animation: fadeIn 0.5s cubic-bezier(0.22,1,0.36,1) 0.14s forwards;
}

.league-scroll::-webkit-scrollbar { display: none; }

.league-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 7px;
  flex-shrink: 0; cursor: pointer;
}

.league-icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--slab);
  border: 1.5px solid var(--dim);
  display: grid; place-items: center;
  transition: all 0.25s cubic-bezier(0.22,1,0.36,1);
  box-shadow: var(--card-shadow);
  position: relative;
}

.league-icon svg { width: 22px; height: 22px; color: var(--ghost); transition: color 0.2s; }

.league-icon-img {
  width: 28px; height: 28px;
  object-fit: contain;
}

.league-item.active .league-icon {
  border-color: var(--blue);
  background: var(--overlay);
  box-shadow: 0 0 0 4px var(--blue-10), var(--card-shadow);
  transform: translateY(-2px);
}

.league-item.active .league-icon svg { color: var(--blue); }

.league-item-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--ghost);
  text-align: center;
  transition: color 0.2s;
  max-width: 56px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.league-item.active .league-item-label { color: var(--blue); font-weight: 700; }
.league-item:active .league-icon { transform: scale(0.9); }

/* ═══════ LEAGUE SKELETON ═══════ */
@keyframes leagueSkelShimmer {
  0%   { background-position: -160px 0; }
  100% { background-position: 160px 0; }
}

.league-skel { pointer-events: none; }

.league-skel-icon {
  background: linear-gradient(90deg, var(--slab) 25%, var(--slate) 50%, var(--slab) 75%);
  background-size: 320px 100%;
  animation: leagueSkelShimmer 1.4s linear infinite;
  border-color: transparent !important;
}

.league-skel-label {
  width: 40px; height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--slab) 25%, var(--slate) 50%, var(--slab) 75%);
  background-size: 320px 100%;
  animation: leagueSkelShimmer 1.4s linear infinite 0.1s;
}

/* ═══════ MATCH AREA SKELETON ═══════ */
@keyframes mskShimmer {
  0%   { background-position: -300px 0; }
  100% { background-position: 300px 0; }
}

.msk-section { pointer-events: none; opacity: 1 !important; animation: none !important; }
.msk-section .league-header { cursor: default; }

.msk-badge {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--slab) 25%, var(--slate) 50%, var(--slab) 75%);
  background-size: 600px 100%;
  animation: mskShimmer 1.4s linear infinite;
  flex-shrink: 0;
}

.msk-lines { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.msk-line {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--slab) 25%, var(--slate) 50%, var(--slab) 75%);
  background-size: 600px 100%;
  animation: mskShimmer 1.4s linear infinite;
}
.msk-title { width: 60%; height: 11px; }
.msk-sub   { width: 35%; height: 9px; animation-delay: 0.08s; }

.msk-row { pointer-events: none; }

.msk-crest {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--slab) 25%, var(--slate) 50%, var(--slab) 75%);
  background-size: 600px 100%;
  animation: mskShimmer 1.4s linear infinite;
  flex-shrink: 0;
}

.msk-name {
  width: 72px; height: 10px;
  margin-top: 6px;
  animation-delay: 0.06s;
}

.msk-score {
  width: 44px; height: 20px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--slab) 25%, var(--slate) 50%, var(--slab) 75%);
  background-size: 600px 100%;
  animation: mskShimmer 1.4s linear infinite 0.12s;
}

/* ═══════ DATE PICKER ═══════ */
.date-strip {
  display: flex; gap: 6px;
  padding: 14px 20px 2px;
  overflow-x: hidden;
  scrollbar-width: none;
  opacity: 0; animation: fadeIn 0.5s cubic-bezier(0.22,1,0.36,1) 0.18s forwards;
}

.date-strip::-webkit-scrollbar { display: none; }

.date-cell {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 4px;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22,1,0.36,1);
  border: 1px solid transparent;
}

.date-cell:active { transform: scale(0.93); }

.date-day {
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.3px; text-transform: uppercase;
  color: var(--ghost); transition: color 0.2s;
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.date-num {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--chalk); line-height: 1.35;
  transition: all 0.2s;
}

.date-cell.active {
  background: var(--date-active-bg);
  border-color: var(--blue);
  box-shadow: 0 4px 14px var(--blue-20);
}

.date-cell.active .date-day { color: var(--date-active-text); opacity: 0.8; }
.date-cell.active .date-num { color: var(--date-active-text); }

/* ═══════ SEARCH ═══════ */
.search-row {
  padding: 14px 20px 0;
  display: flex; gap: 10px;
  opacity: 0; animation: fadeIn 0.5s cubic-bezier(0.22,1,0.36,1) 0.22s forwards;
}

.search-bar {
  flex: 1; display: flex;
  align-items: center; gap: 10px;
  padding: 0 16px; height: 46px;
  background: var(--slab);
  border: 1px solid var(--dim);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  transition: all 0.25s;
}

.search-bar:focus-within {
  border-color: var(--blue-20);
  box-shadow: 0 0 0 3px var(--blue-10), var(--card-shadow);
}

.search-bar svg { width: 18px; height: 18px; color: var(--ghost); flex-shrink: 0; }

.search-bar input {
  flex: 1; border: none; outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13px; font-weight: 500;
  color: var(--chalk);
}

.search-bar input::placeholder { color: var(--ghost); }

/* ═══════ SECTION LABEL ═══════ */
.section-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 8px;
  opacity: 0; animation: fadeIn 0.5s cubic-bezier(0.22,1,0.36,1) 0.25s forwards;
}

.section-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--ghost);
}

.section-line { flex: 1; height: 1px; background: var(--dim); }

.section-count {
  font-size: 11px; font-weight: 600;
  color: var(--blue);
}

/* ═══════ LEAGUE SECTIONS ═══════ */
.matches-area {
  padding: 0 16px;
  /* translateZ(0) removed — it forces the entire area into a GPU layer which,
     combined with per-section layers, exceeds iOS Safari's compositor budget. */
}

.league-section {
  contain: layout style; /* paint containment removed — creates too many compositor layers on iOS */
  margin-bottom: 12px;
  border-radius: 18px;
  background: var(--slab);
  border: 1px solid var(--dim);
  box-shadow: var(--card-shadow-lg);
  overflow: hidden;
  opacity: 0;
  animation: slideUp 0.5s cubic-bezier(0.22,1,0.36,1) forwards;
}

.league-section:nth-child(1) { animation-delay: 0.3s; }
.league-section:nth-child(2) { animation-delay: 0.38s; }
.league-section:nth-child(3) { animation-delay: 0.46s; }

/* Sections beyond the 6th skip the entrance animation — playing 30+ simultaneous
   CSS transforms creates a compositor layer per element which crashes iOS Safari. */
.league-section:nth-child(n+7) { animation: none; opacity: 1; }

.league-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-user-select: none; user-select: none;
}

.league-header:active { background: var(--slate); }

.league-badge {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
}

.league-badge-img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 3px;
}

.league-header-text { flex: 1; }

.league-title {
  font-size: 14px; font-weight: 700;
  color: var(--chalk); line-height: 1.2;
}

.league-count {
  font-size: 11px; font-weight: 500;
  color: var(--ghost); margin-top: 1px;
  display: flex; align-items: center; gap: 5px;
}

.pred-count {
  font-size: 10px; font-weight: 700;
  color: var(--blue);
  background: var(--blue-10);
  border: 1px solid var(--blue-15);
  border-radius: 100px;
  padding: 1px 6px;
  line-height: 1.4;
  flex-shrink: 0;
}

.league-chevron {
  width: 20px; height: 20px;
  color: var(--ghost);
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
  flex-shrink: 0;
}

.league-section.collapsed .league-chevron { transform: rotate(-90deg); }

.league-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.22,1,0.36,1);
}

.league-section.collapsed .league-body { grid-template-rows: 0fr; }

.league-body-inner { overflow: hidden; min-height: 0; }

/* ═══════ MATCH ROW ═══════ */
.match-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.match-row + .match-row,
.pred-panel + .match-row { border-top: 1px solid var(--dim); }

.match-row:active { background: var(--slate); }


.match-team { display: flex; align-items: center; gap: 10px; }
.match-team.away { flex-direction: row-reverse; text-align: right; }
.match-team.away .team-form { justify-content: flex-end; }

.team-crest {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--slate);
  border: 1px solid var(--dim);
  overflow: hidden;
}

.team-crest-img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 4px;
}

.team-name {
  font-size: 13px; font-weight: 600;
  color: var(--chalk); line-height: 1.2;
}

.team-form { display: flex; gap: 3px; margin-top: 3px; }

.form-dot { width: 5px; height: 5px; border-radius: 50%; }
.form-dot.w { background: var(--win); }
.form-dot.d { background: var(--draw); }
.form-dot.l { background: var(--loss); }

.match-center {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  padding: 0 6px; min-width: 66px;
}

.match-time {
  font-size: 18px; font-weight: 700;
  color: var(--chalk);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.match-status {
  font-size: 9px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--ghost);
}

.match-status.live-status {
  color: var(--loss);
  display: flex; align-items: center; gap: 4px;
}

.match-status.live-status::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--loss);
  animation: blink 1.2s infinite;
}



/* ═══════ BOTTOM NAV ═══════ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 6px 0 2px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}

.nav-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  cursor: pointer; padding: 6px 16px;
  -webkit-user-select: none; user-select: none;
  position: relative;
}

.nav-item:active { opacity: 0.5; }

.nav-item svg { width: 24px; height: 24px; color: var(--ghost); transition: color 0.2s; }

.nav-item-label {
  font-size: 10px; font-weight: 600;
  color: var(--ghost); letter-spacing: 0.2px;
  transition: color 0.2s;
}

.nav-item.active svg { color: var(--blue); }
.nav-item.active .nav-item-label { color: var(--blue); }

.nav-item.active::before {
  content: '';
  position: absolute; top: -6px;
  left: 50%; transform: translateX(-50%);
  width: 20px; height: 3px;
  background: var(--blue);
  border-radius: 0 0 3px 3px;
}

/* ═══════ FAB ═══════ */
.fab {
  position: fixed;
  bottom: max(72px, calc(60px + env(safe-area-inset-bottom)));
  right: 18px; z-index: 101;
  width: 54px; height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), var(--blue-bright));
  display: grid; place-items: center;
  box-shadow: var(--fab-shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: fabFloat 3s ease-in-out infinite 1s;
}

.fab:active { transform: scale(0.88) rotate(-8deg); }
.fab svg { width: 24px; height: 24px; color: #fff; }

/* ═══════ ANIMATIONS ═══════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

@keyframes fabFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ═══════ STATE UTILITIES ═══════ */
.fab-hidden { opacity: 0; pointer-events: none; transform: scale(0.8) !important; transition: opacity 0.2s, transform 0.2s !important; }
.nav-hidden { display: none; }

/* ═══════ MATCHES AREA TRANSITION ═══════ */
.matches-area {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ═══════ RESULT MATCH ROW ═══════ */
.result-row { cursor: default; }
.result-row::after { display: none; }


.team-crest.circular { border-radius: 50%; }

.match-ft {
  font-size: 9px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--ghost);
}

.match-final-score {
  font-size: 22px; font-weight: 700;
  color: var(--chalk);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* ═══════ PREDICTION RESULT PILL ═══════ */
.pred-result-pill {
  display: flex; align-items: center; gap: 7px;
  margin: 4px 16px 14px;
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--dim);
  background: var(--slate);
  font-size: 12px; font-weight: 500;
  color: var(--ghost);
}

.pred-check-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--win);
  color: #fff;
  font-size: 10px; font-weight: 800;
  flex-shrink: 0;
}

.pred-result-pill strong { color: var(--chalk); font-weight: 700; }

/* ═══════ SOCIAL CTA CARD ═══════ */
.cta-card {
  position: relative; overflow: hidden;
  margin: 0 0 12px;
  border-radius: 20px;
  padding: 22px 20px 20px;
  min-height: 152px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(135deg, #0538D6 0%, #0D4FF7 45%, #0891B2 80%, #06B6D4 100%);
  animation: slideUp 0.5s cubic-bezier(0.22,1,0.36,1) 0.1s both;
}

/* Decorative orbs */
.cta-card::before {
  content: '';
  position: absolute; top: -55px; right: -55px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  pointer-events: none;
}

.cta-card::after {
  content: '';
  position: absolute; bottom: -45px; left: 38%;
  width: 140px; height: 140px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.10);
  pointer-events: none;
}

.cta-heading {
  font-size: 15px; font-weight: 700;
  color: #fff;
  line-height: 1.4;
  max-width: 75%;
  position: relative; z-index: 1;
}

.cta-btn-wrap {
  position: relative; z-index: 1;
  display: flex; justify-content: center;
  margin-top: 14px;
}

.cta-follow-btn {
  padding: 12px 28px;
  border-radius: 100px;
  border: none; outline: none;
  background: #fff;
  color: var(--blue);
  font-family: var(--font);
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.15s, opacity 0.15s;
}

.cta-follow-btn:active { transform: scale(0.96); opacity: 0.85; }

/* ═══════ EMPTY LEAGUE BADGE ═══════ */
.league-empty-badge {
  padding: 5px 13px;
  border-radius: 100px;
  border: 1px solid var(--dim);
  background: var(--slate);
  font-size: 11px; font-weight: 600;
  color: var(--ghost);
  white-space: nowrap;
  margin-right: 4px;
}

/* ═══════ iOS — REDUCE COMPOSITOR LAYERS ═══════
   iOS Safari (WKWebView) has a hard limit on GPU-composited layers.
   Exceeding it crashes the WebContent process ("a problem occurred").
   Infinite animations are killed globally in theme.css. Here we just
   turn off containment (which creates isolated layers per section). */

.is-ios .league-section { contain: none; }
