/* ═══════════════════════════════════════════════════════════
   RepEngine — Mobile-First Design System
   ═══════════════════════════════════════════════════════════ */

/* Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Design Tokens ──────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-glass: rgba(17, 24, 39, 0.7);

  /* Accent */
  --accent-primary: #8b5cf6;
  --accent-secondary: #ec4899;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #3b82f6;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #8b5cf6, #ec4899);
  --grad-success: linear-gradient(135deg, #10b981, #059669);
  --grad-gold: linear-gradient(135deg, #f59e0b, #d97706);

  /* Text */
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(139, 92, 246, 0.4);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, .5);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, .25);

  /* Layout */
  --nav-h: 56px;
  --bottom-nav-h: 64px;
  --container-max: 1120px;
}

/* ── Reset ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at top right, rgba(139, 92, 246, 0.15), transparent 40%),
    radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.1), transparent 40%),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 30px 30px, 30px 30px;
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* mobile: space for bottom nav */
  padding-bottom: calc(var(--bottom-nav-h) + 12px);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

a:hover {
  color: #a78bfa;
}

img {
  max-width: 100%;
  display: block;
}

ul,
ol {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: 16px;
  /* prevents iOS zoom */
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  width: 100%;
  transition: border-color .2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .15);
}

select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ── Typography ─────────────────────────────────────────── */
h1 {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

h4 {
  font-size: .95rem;
  font-weight: 600;
}

p {
  color: var(--text-secondary);
}

.text-primary {
  color: var(--text-primary) !important;
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-accent {
  color: var(--accent-primary) !important;
}

.text-success {
  color: var(--accent-success) !important;
}

.text-center {
  text-align: center;
}

.text-sm {
  font-size: .85rem;
}

.text-xs {
  font-size: .75rem;
}

.text-lg {
  font-size: 1.125rem;
}

.font-bold {
  font-weight: 700;
}

/* ── Layout ──────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

.page-content {
  min-height: calc(100vh - var(--nav-h) - var(--bottom-nav-h) - 80px);
  padding-top: .5rem;
}

.section {
  padding: 2rem 0;
}

.section-lg {
  padding: 3rem 0;
}

/* Flex */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: .25rem;
}

.gap-2 {
  gap: .5rem;
}

.gap-3 {
  gap: .75rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-6 {
  gap: 1.5rem;
}

/* Grid */
.grid {
  display: grid;
  gap: 1rem;
}

.grid-cols-1 {
  grid-template-columns: 1fr;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Spacing */
.mt-1 {
  margin-top: .25rem;
}

.mt-2 {
  margin-top: .5rem;
}

.mt-3 {
  margin-top: .75rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-6 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: .25rem;
}

.mb-2 {
  margin-bottom: .5rem;
}

.mb-3 {
  margin-bottom: .75rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.w-full {
  width: 100%;
}

/* ── Glass Card ─────────────────────────────────────────── */
.card {
  background: rgba(17, 24, 39, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1), border-color .3s, box-shadow .3s;
}

.card:hover {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 12px 40px 0 rgba(139, 92, 246, 0.15);
}

.card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 45px rgba(139, 92, 246, 0.25);
  border-color: rgba(236, 72, 153, 0.5);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: .9rem;
  border: none;
  transition: all .2s;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(139, 92, 246, .35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, .5);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-success {
  background: var(--grad-success);
  color: #fff;
}

.btn-danger {
  background: rgba(239, 68, 68, .15);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, .25);
}

.btn-sm {
  padding: .4rem .75rem;
  font-size: .8rem;
  min-height: 36px;
}

.btn-lg {
  padding: .85rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn:active {
  transform: scale(.97);
}

/* ── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .6rem;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.4;
}

.badge-primary {
  background: rgba(99, 102, 241, .25);
  color: #c7d2fe;
}

.badge-success {
  background: rgba(16, 185, 129, .25);
  color: #a7f3d0;
}

.badge-warning {
  background: rgba(245, 158, 11, .25);
  color: #fde68a;
}

.badge-danger {
  background: rgba(239, 68, 68, .25);
  color: #fecaca;
}

.badge-info {
  background: rgba(59, 130, 246, .25);
  color: #bfdbfe;
}

/* ── Tier Badges ────────────────────────────────────────── */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius-full);
  font-size: .85rem;
  font-weight: 700;
  border: 1.5px solid;
}

.tier-unranked {
  background: rgba(107, 114, 128, .2);
  border-color: #9ca3af;
  color: #f3f4f6;
}

.tier-bronze {
  background: rgba(205, 127, 50, .2);
  border-color: #dcb384;
  color: #fdf5eb;
}

.tier-silver {
  background: rgba(192, 192, 192, .2);
  border-color: #e2e8f0;
  color: #f8fafc;
}

.tier-gold {
  background: rgba(255, 215, 0, .2);
  border-color: #fde047;
  color: #fef9c3;
}

.tier-platinum {
  background: rgba(229, 228, 226, .2);
  border-color: #f1f5f9;
  color: #ffffff;
}

.tier-diamond {
  background: rgba(185, 242, 255, .2);
  border-color: #cffafe;
  color: #ecfeff;
}

/* ── Score Gauge ────────────────────────────────────────── */
.score-gauge {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(var(--accent-primary) 0deg,
      var(--accent-primary) var(--score-angle, 0deg),
      var(--bg-tertiary) var(--score-angle, 0deg),
      var(--bg-tertiary) 360deg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow-glow);
}

.score-gauge::before {
  content: '';
  position: absolute;
  width: 82%;
  height: 82%;
  background: var(--bg-secondary);
  border-radius: 50%;
}

.score-gauge-inner {
  position: relative;
  z-index: 1;
  text-align: center;
}

.score-value {
  font-size: 2.75rem;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

/* ── Stat Card (compact) ────────────────────────────────── */
.stat-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: .85rem;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.stat-card .stat-label {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* ── Skill Tag ──────────────────────────────────────────── */
.skill-tag {
  display: inline-block;
  padding: .2rem .55rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: .72rem;
  color: var(--text-secondary);
}

/* ── Progress Bar ───────────────────────────────────────── */
.progress {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: var(--radius-full);
  transition: width .6s ease-out;
}

/* ── Vote Bar ───────────────────────────────────────────── */
.vote-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.vote-bar-fill {
  height: 100%;
  background: var(--grad-success);
  transition: width .5s ease-out;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn .2s ease-out;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1.5rem;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp .3s ease-out;
}

/* ── Loading Spinner ────────────────────────────────────── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.loading-text {
  color: var(--text-muted);
  font-size: .85rem;
}

/* ── Footer ─────────────────────────────────────────────── */
.footer {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--accent-primary);
}

/* ── Dashboard Tabs ───────────────────────────────────────── */
.tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ── Form Group ─────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .35rem;
}

/* ══════════════════════════════════════════════════════════
   NAVIGATION — Mobile Bottom Nav + Desktop Top Nav
   ══════════════════════════════════════════════════════════ */

/* ── Mobile Top Bar ─────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(10, 14, 26, .92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

.topbar-brand {
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-wallet {
  background: var(--grad-primary);
  color: #fff;
  padding: .4rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: .8rem;
  border: none;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 2px 10px rgba(139, 92, 246, .3);
}

.topbar-wallet:hover {
  box-shadow: 0 4px 16px rgba(139, 92, 246, .5);
}

.topbar-wallet.connected {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-success);
  box-shadow: 0 0 12px rgba(16, 185, 129, .2);
}

/* ── Mobile Bottom Nav ──────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: rgba(10, 14, 26, .95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  height: var(--bottom-nav-h);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav .bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 56px;
}

.bottom-nav .bnav-item.active,
.bottom-nav .bnav-item:hover {
  color: var(--accent-primary);
}

.bottom-nav .bnav-icon {
  width: 24px;
  height: 24px;
  stroke-width: 1.8;
}

.bottom-nav .bnav-label {
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .02em;
}

/* ── Desktop Nav ────────────────────────────────────────── */
.desktop-nav {
  display: none;
  /* hidden on mobile by default */
}

/* ══════════════════════════════════════════════════════════
   DESKTOP BREAKPOINT  ( ≥ 769px )
   ══════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  body {
    padding-bottom: 0;
    /* no bottom nav on desktop */
  }

  /* Hide mobile elements */
  .topbar {
    display: none !important;
  }

  .bottom-nav {
    display: none !important;
  }

  /* Show desktop nav */
  .desktop-nav {
    display: block;
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(10, 14, 26, .92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
  }

  .dnav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: .85rem 1rem;
  }

  .dnav-brand {
    font-size: 1.35rem;
    font-weight: 800;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
  }

  .dnav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
  }

  .dnav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: .5rem .85rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: .9rem;
    transition: color .15s, background .15s;
  }

  .dnav-link:hover,
  .dnav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, .04);
  }

  .dnav-link.active {
    color: var(--accent-primary);
  }

  .dnav-wallet {
    background: var(--grad-primary);
    color: #fff;
    padding: .55rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    transition: all .2s;
    box-shadow: 0 3px 12px rgba(139, 92, 246, .3);
    margin-left: .5rem;
  }

  .dnav-wallet:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(139, 92, 246, .5);
  }

  .dnav-wallet.connected {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-success);
    box-shadow: 0 0 12px rgba(16, 185, 129, .2);
  }

  /* Desktop typography scale-up */
  h1 {
    font-size: 3rem;
  }

  h2 {
    font-size: 1.85rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  .container {
    padding: 0 2rem;
  }

  .section {
    padding: 3rem 0;
  }

  .section-lg {
    padding: 5rem 0;
  }

  /* Desktop grid columns */
  .md-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .md-grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .md-grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Desktop modal */
  .modal-overlay {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius-xl);
    max-width: 560px;
  }

  /* Score gauge size up */
  .score-gauge {
    width: 200px;
    height: 200px;
  }

  .score-value {
    font-size: 3.5rem;
  }
}

/* ──  Small phones fix  (< 375px)  ──────────────────────── */
@media (max-width: 374px) {
  html {
    font-size: 14px;
  }

  .container {
    padding: 0 .75rem;
  }

  .card {
    padding: 1rem;
  }
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  to {
    background-position: 200% 0;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .5;
  }
}

.fade-in {
  animation: fadeIn .5s ease-out;
}

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── Safe Area (iPhone X+) ──────────────────────────────── */
@supports (padding: max(0px)) {
  .bottom-nav {
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
}