/* ============================================================
   FOOTY TIPPING — Theme System & Utility Classes
   Premium AFL tipping app aesthetic
   ============================================================ */

/* ---- Theme: Dark ---- */
[data-theme="dark"] {
  --bg-primary:      #0f172a;
  --bg-secondary:    #1e293b;
  --bg-card:         rgba(30, 41, 59, 0.7);
  --bg-card-hover:   rgba(30, 41, 59, 0.9);

  --text-primary:    #f1f5f9;
  --text-secondary:  #cbd5e1;
  --text-muted:      #64748b;

  --accent:          #3b82f6;
  --accent-hover:    #60a5fa;
  --accent-glow:     rgba(59, 130, 246, 0.35);

  --border:          rgba(148, 163, 184, 0.12);
  --border-hover:    rgba(148, 163, 184, 0.25);

  --success:         #22c55e;
  --danger:          #ef4444;
  --warning:         #f59e0b;

  --glass-bg:        rgba(15, 23, 42, 0.55);
  --glass-border:    rgba(148, 163, 184, 0.08);

  --shadow:          0 8px 32px rgba(0, 0, 0, 0.4);

  --nav-bg:          rgba(15, 23, 42, 0.82);
  --nav-border:      rgba(59, 130, 246, 0.15);

  --gradient-start:  #1e293b;
  --gradient-end:    #0f172a;

  --ring-color:      rgba(59, 130, 246, 0.5);
}

/* ---- Theme: Soft ---- */
[data-theme="soft"] {
  --bg-primary:      #e8eef5;
  --bg-secondary:    #dce5f0;
  --bg-card:         rgba(220, 229, 240, 0.65);
  --bg-card-hover:   rgba(220, 229, 240, 0.85);

  --text-primary:    #334155;
  --text-secondary:  #475569;
  --text-muted:      #94a3b8;

  --accent:          #6488b4;
  --accent-hover:    #5078a8;
  --accent-glow:     rgba(100, 136, 180, 0.25);

  --border:          rgba(148, 163, 184, 0.3);
  --border-hover:    rgba(148, 163, 184, 0.5);

  --success:         #22c55e;
  --danger:          #f87171;
  --warning:         #fbbf24;

  --glass-bg:        rgba(232, 238, 245, 0.5);
  --glass-border:    rgba(148, 163, 184, 0.18);

  --shadow:          0 8px 32px rgba(51, 65, 85, 0.08);

  --nav-bg:          rgba(220, 229, 240, 0.82);
  --nav-border:      rgba(100, 136, 180, 0.15);

  --gradient-start:  #dce5f0;
  --gradient-end:    #e8eef5;

  --ring-color:      rgba(100, 136, 180, 0.4);
}

/* ---- Theme: Team (full team colour takeover) ---- */
[data-theme="team"] {
  --bg-primary:      var(--team-primary, #0f172a);
  --bg-secondary:    var(--team-primary-dark, #1e293b);
  --bg-card:         rgba(255, 255, 255, 0.08);
  --bg-card-hover:   rgba(255, 255, 255, 0.12);

  --text-primary:    #ffffff;
  --text-secondary:  rgba(255, 255, 255, 0.85);
  --text-muted:      rgba(255, 255, 255, 0.5);

  --accent:          var(--team-secondary, #FFD700);
  --accent-hover:    var(--team-tertiary, var(--team-secondary, #FFD700));
  --accent-glow:     var(--team-secondary-glow, rgba(255, 215, 0, 0.3));

  --border:          rgba(255, 255, 255, 0.1);
  --border-hover:    rgba(255, 255, 255, 0.2);

  --success:         #22c55e;
  --danger:          #ef4444;
  --warning:         #f59e0b;

  --glass-bg:        rgba(0, 0, 0, 0.2);
  --glass-border:    rgba(255, 255, 255, 0.08);

  --shadow:          0 8px 32px rgba(0, 0, 0, 0.5);

  --nav-bg:          var(--team-primary-dark, rgba(0, 0, 0, 0.8));
  --nav-border:      var(--team-secondary-dim, rgba(255, 255, 255, 0.1));

  --ring-color:      var(--team-secondary-glow, rgba(255, 215, 0, 0.5));
}

/* ============================================================
   Base & Global
   ============================================================ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg-secondary);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 9999px;
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* ============================================================
   Glassmorphism
   ============================================================ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.glass-sm {
  background: var(--glass-bg);
  backdrop-filter: blur(8px) saturate(1.3);
  -webkit-backdrop-filter: blur(8px) saturate(1.3);
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.glass-nav {
  background: var(--nav-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--nav-border);
}

/* ============================================================
   Card Hover
   ============================================================ */
.card-hover {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.12),
    0 0 0 1px var(--border-hover);
}

/* ============================================================
   Gradient Text
   ============================================================ */
.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover), #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-gold {
  background: linear-gradient(135deg, #f59e0b, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
  50%      { box-shadow: 0 0 24px var(--accent-glow); }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out both;
}

.animate-slide-up {
  animation: slideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-slide-down {
  animation: slideDown 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-scale-in {
  animation: scaleIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Staggered children */
.stagger > :nth-child(1) { animation-delay: 0.05s; }
.stagger > :nth-child(2) { animation-delay: 0.10s; }
.stagger > :nth-child(3) { animation-delay: 0.15s; }
.stagger > :nth-child(4) { animation-delay: 0.20s; }
.stagger > :nth-child(5) { animation-delay: 0.25s; }
.stagger > :nth-child(6) { animation-delay: 0.30s; }
.stagger > :nth-child(7) { animation-delay: 0.35s; }
.stagger > :nth-child(8) { animation-delay: 0.40s; }

/* ============================================================
   Theme Transition
   ============================================================ */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition: background-color 0.4s ease,
              color 0.4s ease,
              border-color 0.4s ease,
              box-shadow 0.4s ease,
              fill 0.4s ease,
              stroke 0.4s ease !important;
}

/* ============================================================
   Glow Effects
   ============================================================ */
.glow {
  box-shadow:
    0 0 12px var(--accent-glow),
    0 0 40px rgba(59, 130, 246, 0.06);
}

.glow-pulse {
  animation: pulse-glow 2.5s ease-in-out infinite;
}

.glow-text {
  text-shadow: 0 0 20px var(--accent-glow);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.25s ease;
}

.btn-glass:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

/* ============================================================
   Flash Messages
   ============================================================ */
.flash-message {
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: slideDown 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flash-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: var(--success);
}

.flash-danger,
.flash-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.flash-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--warning);
}

.flash-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--accent);
}

/* ============================================================
   Miscellaneous
   ============================================================ */
.divider {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--border),
    transparent
  );
}

.shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-card) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

/* Focus ring for accessibility */
.focus-ring:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 0.375rem;
}

/* Active nav link */
.nav-link-active {
  color: var(--accent) !important;
  position: relative;
}

.nav-link-active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--accent);
  border-radius: 9999px;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Stat card number */
.stat-number {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Score badge */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.score-badge-up {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}

.score-badge-down {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

/* ============================================================
   Mobile Bottom Navigation
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-top: 1px solid var(--nav-border);
  padding: 0.5rem 0;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
  /* Ensure it sits above iOS Safari toolbar */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.25rem 0;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav a.active {
  color: var(--accent);
}

.bottom-nav a svg {
  width: 22px;
  height: 22px;
}

/* Sticky submit button for tipping on mobile */
.mobile-sticky-submit {
  position: sticky;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}

@media (min-width: 768px) {
  .mobile-sticky-submit {
    position: static;
    bottom: auto;
  }
}

/* ============================================================
   Mobile Responsive Overrides
   ============================================================ */
@media (max-width: 767px) {
  /* Space for bottom nav */
  main {
    padding-bottom: 80px !important;
  }

  /* Touch-friendly tap targets */
  button, a, select, input[type="submit"] {
    min-height: 44px;
  }

  /* Reduce card hover effects on mobile (no hover on touch) */
  .card-hover:hover {
    transform: none;
    box-shadow: var(--shadow);
  }

  /* Smaller blobs on mobile to reduce GPU load */
  .blob-1 { width: 300px; height: 300px; }
  .blob-2 { width: 250px; height: 250px; }
  .blob-3 { width: 175px; height: 175px; }
}

/* ============================================================
   Team Theme — Utility Overrides
   ============================================================ */
[data-theme="team"] .btn-gradient {
  background: linear-gradient(135deg, var(--team-secondary), var(--team-tertiary, var(--team-secondary)));
  color: var(--team-primary);
}
[data-theme="team"] .btn-gradient:hover {
  box-shadow: 0 8px 25px var(--team-secondary-glow);
}
[data-theme="team"] .gradient-text {
  background: linear-gradient(135deg, var(--team-secondary), var(--team-tertiary, #fff), var(--team-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="team"] .glass {
  background: rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="team"] .glass-nav {
  background: var(--team-primary-dark);
}

/* ============================================================
   Dark / Soft — Team accent on gradient buttons
   ============================================================ */
[data-theme="dark"] .btn-gradient,
[data-theme="soft"] .btn-gradient {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
}
