/* ==========================================================================
   NASEF Arena — design tokens & base styles
   ========================================================================== */

:root {
  /* Surfaces — cool near-black with subtle blue undertone */
  --bg-deep: #07090F;
  --bg-base: #0B0F18;
  --bg-raised: #121826;
  --bg-elevated: #1A2233;
  --bg-overlay: rgba(8, 11, 18, 0.78);

  /* Borders */
  --border-soft: #1C2233;
  --border: #242C40;
  --border-strong: #34405E;

  /* Text */
  --text: #F2F4FA;
  --text-secondary: #A4ADC4;
  --text-muted: #6A748F;
  --text-faint: #444C66;

  /* NASEF brand */
  --nasef-orange: #F26822;
  --nasef-orange-soft: #FF8443;
  --nasef-orange-glow: rgba(242, 104, 34, 0.32);
  --nasef-deep: #BD4910;

  /* Esports neon accents */
  --neon-cyan: #4FE3FF;
  --neon-cyan-soft: rgba(79, 227, 255, 0.18);
  --neon-magenta: #FF4D9F;
  --neon-violet: #9B6DFF;
  --neon-lime: #B5F23B;

  /* Status */
  --live: #FF3B5C;
  --success: #2DD478;
  --warning: #F7B928;
  --danger: #F2455F;

  /* Game accent (overridden per-game) */
  --game-accent: var(--nasef-orange);

  /* Type */
  --font-display: "Inter", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "Inter", system-ui, sans-serif;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Shadows */
  --sh-card: 0 1px 0 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px -16px rgba(0, 0, 0, 0.6);
  --sh-glow-orange: 0 0 0 1px rgba(242, 104, 34, 0.4), 0 0 24px -4px rgba(242, 104, 34, 0.5);
  --sh-glow-cyan: 0 0 0 1px rgba(79, 227, 255, 0.4), 0 0 24px -4px rgba(79, 227, 255, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  margin: 0;
  font-weight: 800;
}

button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* Subtle grid backdrop used throughout app */
.bg-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
}

.bg-noise::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='0.6'/></svg>");
  mix-blend-mode: overlay;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--nasef-orange);
  border-color: var(--nasef-orange);
  color: #14060A;
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--nasef-orange-soft);
  border-color: var(--nasef-orange-soft);
  box-shadow: var(--sh-glow-orange);
}
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-raised); }
.btn.danger { color: var(--danger); border-color: rgba(242, 69, 95, 0.3); }
.btn.danger:hover { background: rgba(242, 69, 95, 0.1); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.lg { padding: 12px 20px; font-size: 14px; }
.btn.icon { padding: 8px; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.card-header h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  font-weight: 600;
}
.card-body { padding: 20px; }

/* ==========================================================================
   Form
   ========================================================================== */

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--nasef-orange);
  box-shadow: 0 0 0 3px rgba(242, 104, 34, 0.15);
}
.label {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

/* ==========================================================================
   Badges & pills
   ========================================================================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.badge.live {
  background: rgba(255, 59, 92, 0.15);
  color: var(--live);
  border-color: rgba(255, 59, 92, 0.3);
}
.badge.live .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); animation: livePulse 1.4s ease-in-out infinite; }
.badge.upcoming { background: var(--neon-cyan-soft); color: var(--neon-cyan); border-color: rgba(79, 227, 255, 0.3); }
.badge.complete { background: rgba(45, 212, 120, 0.12); color: var(--success); border-color: rgba(45, 212, 120, 0.3); }
.badge.warning { background: rgba(247, 185, 40, 0.12); color: var(--warning); border-color: rgba(247, 185, 40, 0.3); }
.badge.orange { background: rgba(242, 104, 34, 0.12); color: var(--nasef-orange-soft); border-color: rgba(242, 104, 34, 0.3); }

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* ==========================================================================
   Avatar + school crest placeholder
   ========================================================================== */

.crest {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--c1, #2A3344) 0%, var(--c2, #1A2233) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.02em;
  border: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.crest::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
.crest.lg { width: 56px; height: 56px; font-size: 20px; border-radius: var(--r-md); }
.crest.xl { width: 88px; height: 88px; font-size: 32px; border-radius: var(--r-lg); }
.crest.sm { width: 28px; height: 28px; font-size: 11px; }

.crest.crest-logo { background: transparent !important; border: none !important; overflow: visible; }
.crest.crest-logo::after { display: none; }

/* NASEF logo mark — placeholder until brand assets uploaded */
.nasef-mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}
.nasef-mark .nasef-glyph {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--nasef-orange) 0%, #FF4F1F 100%);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: #14060A;
  font-size: 14px;
  font-weight: 800;
  position: relative;
  box-shadow: 0 0 0 1px rgba(255, 132, 67, 0.4), 0 4px 16px -4px rgba(242, 104, 34, 0.6);
}

/* ==========================================================================
   Layout helpers
   ========================================================================== */

.row { display: flex; align-items: center; gap: 12px; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.divider { height: 1px; background: var(--border-soft); }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.upper { text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; font-weight: 600; }
.h-display { font-family: var(--font-display); font-weight: 600; }

/* ==========================================================================
   Scrollbars
   ========================================================================== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; border: 2px solid transparent; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-base);
  position: sticky; top: 0; z-index: 1;
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  vertical-align: middle;
}
.table tr:hover td { background: var(--bg-elevated); }
.table tr:last-child td { border-bottom: 0; }

/* ==========================================================================
   Lobby page wallpaper — mounted on <body> by pages/lobby.jsx (useEffect adds
   .lobby-active). It lives here, not inside the lobby React tree, because
   .app-main has a transform-based fade-in animation that would otherwise
   reduce a position:fixed wallpaper to that element's box (instead of the viewport).

   Stacked backgrounds, top-to-bottom:
     1. radial-gradient — soft dim (lighter in center, heavier at edges)
     2. linear-gradient — flat 70% dim, mimicking the original opacity:0.3 wallpaper
     3. url(page-bg.png) — the actual SSBU wallpaper image
   ========================================================================== */
body.lobby-active::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 1200px 800px at 50% 30%, rgba(7,9,15,0.4) 0%, rgba(7,9,15,0.72) 70%, rgba(7,9,15,0.9) 100%),
    linear-gradient(rgba(7,9,15,0.7), rgba(7,9,15,0.7)),
    url(assets/page-bg.png) center / cover no-repeat;
}
/* Let the wallpaper show through .app-shell (sidebar + topbar still cover their
   own slices because they have explicit opaque backgrounds). */
body.lobby-active .app-shell { background: transparent; }


/* ==========================================================================
   Animation utility
   ========================================================================== */

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.24s ease both; }

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

@keyframes heroGlow {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes heroSpin {
  to { transform: rotate(360deg); }
}
@keyframes heroShimmer {
  0% { transform: translateX(0); opacity: 0; }
  20% { opacity: 1; }
  60% { opacity: 1; }
  100% { transform: translateX(380%); opacity: 0; }
}
@keyframes heroFloat1 {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(1deg); }
}
@keyframes heroFloat2 {
  0%, 100% { transform: translateY(-3px) rotate(2deg); }
  50% { transform: translateY(3px) rotate(-1deg); }
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,92,0.45); }
  50% { box-shadow: 0 0 0 6px rgba(255,59,92,0); }
}
@keyframes heroFeedIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}
