/* =====================================================
   SOLO LEVELLING — Main CSS
   ===================================================== */

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

html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  touch-action: none;
  background: #050810;
  color: #fff;
  font-family: 'Rajdhani', 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent iOS zoom on input focus */
input, select, textarea { font-size: 16px !important; }

/* ---- Layout ---- */
#app { width: 100%; height: 100%; display: flex; overflow: hidden; }

.scroll-area {
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: none;
}

@media (max-width: 1023px) {
  .scroll-area::-webkit-scrollbar { display: none; }
  .scroll-area { scrollbar-width: none; }
}

@media (min-width: 1024px) {
  .scroll-area::-webkit-scrollbar { width: 4px; }
  .scroll-area::-webkit-scrollbar-track { background: transparent; }
  .scroll-area::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.2); border-radius: 2px; }
}

/* ---- Typography ---- */
.font-orbitron { font-family: 'Orbitron', sans-serif; }
.font-rajdhani { font-family: 'Rajdhani', sans-serif; }
.font-mono { font-family: 'Share Tech Mono', monospace; }

/* ---- Colors ---- */
:root {
  --cyan: #00d4ff;
  --violet: #7c3aed;
  --gold: #fbbf24;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f97316;
  --pink: #ec4899;
  --blue: #3b82f6;
  --bg: #050810;
  --bg-card: rgba(13,20,40,0.8);
  --border: rgba(0,212,255,0.08);
}

/* ---- Tap Feedback ---- */
.tap {
  transition: transform .15s cubic-bezier(.32,.72,0,1), opacity .15s;
  cursor: pointer;
  user-select: none;
}
.tap:active { transform: scale(.94); opacity: .80; }
.tap-card { transition: transform .2s cubic-bezier(.32,.72,0,1), box-shadow .2s; cursor: pointer; }
.tap-card:active { transform: scale(.985); }

/* ---- Glow Effects ---- */
.glow-cyan  { box-shadow: 0 0 20px rgba(0,212,255,0.3); }
.glow-violet{ box-shadow: 0 0 20px rgba(124,58,237,0.3); }
.glow-gold  { box-shadow: 0 0 20px rgba(251,191,36,0.3); }
.glow-green { box-shadow: 0 0 20px rgba(16,185,129,0.3); }

/* ---- Skeleton Loading ---- */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: 8px;
}

/* ---- XP Bar Shimmer ---- */
@keyframes xpShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
.xp-shimmer {
  position: absolute;
  top: 0; bottom: 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  animation: xpShimmer 2s infinite;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease both; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.slide-up { animation: slideUp .4s cubic-bezier(.32,.72,0,1) both; }

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,212,255,0); }
  50%       { box-shadow: 0 0 0 8px rgba(0,212,255,0.08); }
}
.pulse-border { animation: pulse-border 2s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-6px); }
}
.float { animation: float 3s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* Level-up bounce */
@keyframes luBounce {
  0%   { transform: scale(.5) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(3deg); opacity: 1; }
  80%  { transform: scale(.95) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.lu-bounce { animation: luBounce .7s cubic-bezier(.34,1.56,.64,1) both; }

/* Toast slide */
@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}
.toast-in  { animation: toastIn  .35s cubic-bezier(.32,.72,0,1) both; }
.toast-out { animation: toastOut .3s  cubic-bezier(.32,.72,0,1) both; }

/* ---- Cards ---- */
.rpg-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
}
.rpg-card-lg { border-radius: 24px; padding: 28px; }

/* ---- Buttons ---- */
.btn-primary {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
}
.btn-primary:hover  { opacity: .9; }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 10px;
  color: var(--cyan);
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all .2s;
}
.btn-ghost:hover { background: rgba(0,212,255,0.08); }

/* ---- Form Inputs ---- */
.rpg-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(5,8,16,0.8);
  border: 1px solid rgba(0,212,255,0.12);
  border-radius: 10px;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.rpg-input:focus { border-color: rgba(0,212,255,0.4); }
.rpg-input::placeholder { color: #374151; }

/* ---- Badge / Chip ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ---- Rank Colors ---- */
.rank-e { color: #9ca3af; border-color: rgba(156,163,175,0.3); }
.rank-d { color: #3b82f6; border-color: rgba(59,130,246,0.3); }
.rank-c { color: #10b981; border-color: rgba(16,185,129,0.3); }
.rank-b { color: #f97316; border-color: rgba(249,115,22,0.3); }
.rank-a { color: #ef4444; border-color: rgba(239,68,68,0.3); }
.rank-s { color: #fbbf24; border-color: rgba(251,191,36,0.3); }
.rank-national { color: #a855f7; border-color: rgba(168,85,247,0.3); }
.rank-monarch   { color: #fff;    border-color: rgba(255,255,255,0.3); }

/* ---- Progress Bar ---- */
.progress-track {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1.2s cubic-bezier(.34,1.56,.64,1);
}

/* ---- Sidebar Nav Link ---- */
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  color: #4b5563;
  text-decoration: none;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 14px;
  transition: all .2s;
  cursor: pointer;
}
.nav-link:hover  { background: rgba(0,212,255,0.06); color: #9ca3af; }
.nav-link.active { background: rgba(0,212,255,0.1); color: #00d4ff; border: 1px solid rgba(0,212,255,0.15); }

/* ---- Bottom Nav Item ---- */
.bot-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  padding: 6px 4px;
  cursor: pointer;
  color: #4b5563;
  transition: color .2s;
  font-family: 'Orbitron', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.bot-nav-item.active { color: #00d4ff; }
.bot-nav-item span:first-child { font-size: 22px; }

/* ---- Grid helpers ---- */
@media (max-width: 640px) {
  .sm-stack { grid-template-columns: 1fr !important; }
  .sm-2col  { grid-template-columns: 1fr 1fr !important; }
}

/* ---- Auth Page ---- */
.auth-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(5,8,16,0.9);
  border: 1px solid rgba(0,212,255,0.12);
  border-radius: 12px;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.auth-input:focus {
  border-color: rgba(0,212,255,0.4);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.08);
}
.auth-input::placeholder { color: #374151; }

.auth-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
}
.auth-btn:hover  { opacity: .9; }
.auth-btn:active { transform: scale(.98); }
.auth-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.error-msg {
  padding: 10px 14px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 10px;
  color: #ef4444;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
}

/* ---- Particle Canvas ---- */
#particleCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---- Safe Area ---- */
.safe-top    { padding-top:    env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* ---- Utility ---- */
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-glow-cyan { text-shadow: 0 0 12px rgba(0,212,255,0.5); }
.text-glow-gold { text-shadow: 0 0 12px rgba(251,191,36,0.5); }

/* ---- Layout Fixes (override inline styles) ---- */
#app          { position: relative; z-index: 1; }
#mainWrapper  { flex: 1; min-width: 0; overflow: hidden; }
#mainContent  { padding: 20px; }
@media (max-width: 1023px) {
  #mainContent { padding: 12px; }
}

/* ---- Horizontal Scroll Container (week strip, etc.) ---- */
.h-scroll {
  overflow-x: scroll;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }

/* ---- Mobile : réduire mainWrapper pour qu'il s'arrête au-dessus de la nav ---- */
/*
 * Le bottom nav est position:fixed et recouvre l'écran.
 * padding-bottom sur mainWrapper réduit la zone flex des enfants :
 * mainContent s'arrête exactement au bord supérieur de la nav.
 * Cela règle le problème pour les contenus courts ET longs.
 */
@media (max-width: 1023px) {
  #mainWrapper {
    padding-bottom: calc(58px + env(safe-area-inset-bottom));
  }
  #mainContent {
    padding-bottom: 20px !important; /* respiration en bas du dernier élément */
  }
}

/* ---- PWA / Safe Area top ---- */
@supports (padding-top: env(safe-area-inset-top)) {
  #topBar { padding-top: calc(env(safe-area-inset-top) + 12px); }
}
