/**
 * Design System Premium - Bulle TCG
 * Polices, couleurs, espacements, radius, animations
 * Inspiré par Pokemon TCG Pocket / Yu-Gi-Oh Master Duel
 */

/* ===============================================
   DESIGN SYSTEM - Variables globales
   =============================================== */
:root {
  /* === TYPOGRAPHIE === */
  /* Polices : 
     - Titres/UI : Inter (system-ui fallback)
     - Texte : Inter (system-ui fallback)
  */
  --font-display: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  
  /* Tailles de police */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  
  /* === PALETTE PASTEL PREMIUM === */
  /* Background - Gradient doux */
  --color-bg-start: #0f1629;
  --color-bg-mid: #1a2340;
  --color-bg-end: #0a0f1f;
  
  /* Primary - Bleu-Violet doux */
  --color-primary: #7c93f5;
  --color-primary-light: #a5b8ff;
  --color-primary-dark: #5670d9;
  --color-primary-glow: rgba(124, 147, 245, 0.25);
  
  /* Secondary - Rose pastel */
  --color-secondary: #f5a3c7;
  --color-secondary-light: #ffcce3;
  --color-secondary-dark: #d97ba6;
  
  /* Accent - Vert menthe */
  --color-accent: #7fd9ce;
  --color-accent-light: #a8f5e8;
  --color-accent-dark: #5bb7ad;
  
  /* Warning - Corail doux */
  --color-warning: #ffa98a;
  --color-warning-light: #ffc4ad;
  --color-warning-dark: #ff8866;
  
  /* Success - Vert émeraude */
  --color-success: #6ee7b7;
  --color-success-light: #a7f3d0;
  --color-success-dark: #34d399;
  
  /* Text */
  --color-text-primary: rgba(255, 255, 255, 0.96);
  --color-text-secondary: rgba(255, 255, 255, 0.72);
  --color-text-tertiary: rgba(255, 255, 255, 0.52);
  
  /* Surfaces */
  --color-surface: rgba(255, 255, 255, 0.06);
  --color-surface-hover: rgba(255, 255, 255, 0.1);
  --color-surface-active: rgba(255, 255, 255, 0.14);
  --color-surface-elevated: rgba(255, 255, 255, 0.08);
  
  /* Borders */
  --color-border: rgba(255, 255, 255, 0.12);
  --color-border-focus: var(--color-primary);
  
  /* === ESPACEMENTS (échelle 4px) === */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  
  /* === RADIUS === */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* === SHADOWS === */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.24);
  --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.32);
  
  /* Glow effects */
  --glow-primary: 0 0 20px var(--color-primary-glow);
  --glow-success: 0 0 20px rgba(110, 231, 183, 0.3);
  --glow-warning: 0 0 20px rgba(255, 169, 138, 0.3);
  
  /* === MOTION - Durées === */
  --duration-instant: 80ms;
  --duration-fast: 180ms;
  --duration-normal: 260ms;
  --duration-slow: 420ms;
  
  /* === MOTION - Easing === */
  --ease-premium: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* === LAYOUT === */
  --appH: 100vh;
  --topbarH: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  
  /* === Z-INDEX === */
  --z-base: 1;
  --z-elevated: 10;
  --z-dropdown: 100;
  --z-modal: 1000;
  --z-toast: 10000;
  --z-loader: 20000;
}

/* === RÉINITIALISATION & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text-primary);
  background: linear-gradient(
    135deg,
    var(--color-bg-start) 0%,
    var(--color-bg-mid) 50%,
    var(--color-bg-end) 100%
  );
  min-height: var(--appH);
  overflow: hidden;
  position: relative;
  
  /* Mobile fixes */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  /* Permettre le scroll dans les panels/modals */
  touch-action: auto;
}

/* Désactiver zoom, selection, scroll non voulus */
input, textarea, select {
  user-select: text;
  -webkit-user-select: text;
}

/* Permettre la sélection dans les panels et modals */
.panelBody,
.panelBody *,
.zone-modal-body,
.zone-modal-body *,
.card-modal-body,
.card-modal-body *,
.handCards,
.handCards * {
  user-select: text;
  -webkit-user-select: text;
}

/* Assurer que les conteneurs scrollables peuvent scroller */
.panelBody,
.zone-modal-body,
.card-modal-body,
.handCards {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* CRITICAL : Permettre scroll horizontal dans la main du joueur (mobile) */
.handDock .handCards {
  touch-action: pan-x !important;
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  overflow-y: hidden;
}

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

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

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

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

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

/* === UTILITAIRES === */
.fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-premium);
}

.fade-in-up {
  animation: fadeInUp var(--duration-normal) var(--ease-premium);
}

.fade-in-scale {
  animation: fadeInScale var(--duration-fast) var(--ease-premium);
}

/* Disabled state global */
[disabled], .disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Hidden */
[hidden] {
  display: none !important;
}

/* === SCROLLBARS PREMIUM === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: background var(--duration-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-light);
}
