/* common.css - Styles partagés TV et Mobile — Design Wii U */

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg:           #080b18;
  --color-surface:      #111827;
  --color-surface-2:    #192038;
  --color-border:       #1e2d52;
  --color-primary:      #7c3aed;
  --color-primary-dark: #4c1d95;
  --color-primary-edge: #3b1578;
  --color-primary-glow: rgba(124,58,237,0.45);
  --color-secondary:    #0f3460;
  --color-accent:       #f59e0b;
  --color-accent-dark:  #b45309;
  --color-accent-edge:  #92400e;
  --color-accent-glow:  rgba(245,158,11,0.45);
  --color-success:      #22c55e;
  --color-danger:       #ef4444;
  --color-text:         #f0f4ff;
  --color-text-muted:   #7e8ab8;
  --color-white:        #ffffff;

  --radius-sm:   8px;
  --radius-md:   16px;
  --radius-lg:   24px;
  --radius-xl:   40px;
  --radius-full: 9999px;

  --shadow-card: 0 8px 40px rgba(0,0,0,0.65), 0 2px 8px rgba(0,0,0,0.4);
  --shadow-glow-primary: 0 0 40px rgba(124,58,237,0.5);
  --shadow-glow-accent:  0 0 40px rgba(245,158,11,0.5);
  --shadow-relief-sm:
    0 1px 0 rgba(255,255,255,0.18) inset,
    0 -2px 0 rgba(0,0,0,0.45) inset,
    0 4px 0 rgba(0,0,0,0.35),
    0 6px 18px rgba(0,0,0,0.5);
  --shadow-relief-lg:
    0 2px 0 rgba(255,255,255,0.18) inset,
    0 -3px 0 rgba(0,0,0,0.5) inset,
    0 6px 0 rgba(0,0,0,0.35),
    0 10px 28px rgba(0,0,0,0.55);

  --font-title: 'Nunito', 'Trebuchet MS', sans-serif;
  --font-body:  'Nunito', 'Segoe UI', sans-serif;

  --transition-fast: 0.12s ease;
  --transition-med:  0.28s ease;
  --transition-slow: 0.5s ease;
}

html, body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  overflow: hidden;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Tactile : pas de zoom double-tap, pas de menu contextuel, pas de rebond */
  touch-action: manipulation;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

/* Empêche la sélection de texte/images sur toute l'interface tactile */
img, svg, button, .mobile-screen, .tv-screen {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* …mais on réautorise la saisie dans les champs */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* ---- Grain texture (overlay global) ---- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.78' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)' opacity='0.09'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: screen;
  opacity: 0.6;
}

/* ---- Typographie ---- */
h1, h2, h3, h4 {
  font-family: var(--font-title);
  font-weight: 800;
  line-height: 1.2;
}

/* ---- Utilitaires ---- */
.hidden {
  display: none !important;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.text-center {
  text-align: center;
}

/* ---- Boutons — Style Wii U relief ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  outline: none;
  transform: translateY(0);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    filter var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* Brillance glossy (sheen) */
.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.24) 0%,
    rgba(255,255,255,0.05) 80%,
    transparent 100%
  );
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
}

.btn:hover {
  transform: translateY(-3px);
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(3px) !important;
  filter: brightness(0.92);
}

/* Vague ripple (injectée via JS) */
.btn-ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.28);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple-expand 0.6s ease-out forwards;
  pointer-events: none;
  z-index: 2;
}

.btn-primary {
  background: linear-gradient(145deg, var(--color-primary) 0%, #5b21b6 100%);
  color: var(--color-white);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.22) inset,
    0 -3px 0 rgba(0,0,0,0.5) inset,
    0 5px 0 var(--color-primary-edge),
    0 8px 22px rgba(124,58,237,0.55);
}

.btn-primary:hover {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.22) inset,
    0 -3px 0 rgba(0,0,0,0.5) inset,
    0 8px 0 var(--color-primary-edge),
    0 14px 30px rgba(124,58,237,0.65);
}

.btn-primary:active {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.15) inset,
    0 -1px 0 rgba(0,0,0,0.5) inset,
    0 1px 0 var(--color-primary-edge),
    0 3px 12px rgba(124,58,237,0.35);
}

.btn-secondary {
  background: linear-gradient(145deg, var(--color-surface-2) 0%, var(--color-surface) 100%);
  color: var(--color-text);
  border: 2px solid var(--color-border);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.1) inset,
    0 -2px 0 rgba(0,0,0,0.45) inset,
    0 4px 0 rgba(0,0,0,0.3),
    0 6px 16px rgba(0,0,0,0.4);
}

.btn-secondary:hover {
  background: linear-gradient(145deg, #253050 0%, #1a2236 100%);
  border-color: #3a4870;
}

.btn-secondary:active {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 -1px 0 rgba(0,0,0,0.45) inset,
    0 1px 0 rgba(0,0,0,0.3),
    0 2px 8px rgba(0,0,0,0.3);
}

.btn-accent {
  background: linear-gradient(145deg, var(--color-accent) 0%, #d97706 100%);
  color: #0a0b14;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.25) inset,
    0 -3px 0 rgba(0,0,0,0.4) inset,
    0 5px 0 var(--color-accent-edge),
    0 8px 22px rgba(245,158,11,0.55);
}

.btn-accent:hover {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.25) inset,
    0 -3px 0 rgba(0,0,0,0.4) inset,
    0 8px 0 var(--color-accent-edge),
    0 14px 30px rgba(245,158,11,0.65);
}

.btn-accent:active {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.18) inset,
    0 -1px 0 rgba(0,0,0,0.4) inset,
    0 1px 0 var(--color-accent-edge),
    0 3px 12px rgba(245,158,11,0.35);
}

.btn-large {
  font-size: 1.4rem;
  padding: 18px 48px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

/* ---- Cards ---- */
.card {
  background: linear-gradient(145deg, var(--color-surface-2) 0%, var(--color-surface) 100%);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    var(--shadow-card);
  padding: 24px;
}

/* ---- Avatar joueur ---- */
.player-avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06), 0 4px 14px rgba(0,0,0,0.5);
}

/* ---- Fond animé — orbes Wii U ---- */
.bg-animated {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
  will-change: transform;
}

.bg-orb-1 {
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  top: -200px;
  left: -150px;
  animation: orb-drift-1 22s ease-in-out infinite;
}

.bg-orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #0f3460 0%, transparent 70%);
  bottom: -200px;
  right: -100px;
  animation: orb-drift-2 28s ease-in-out infinite;
}

.bg-orb-3 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #1a4a8a 0%, transparent 70%);
  top: 40%;
  left: 40%;
  transform: translate(-50%, -50%);
  animation: orb-drift-3 18s ease-in-out infinite;
}

/* Versions petites pour Mobile */
.bg-orb-sm.bg-orb-1 { width: 350px; height: 350px; top: -100px; left: -80px; filter: blur(60px); }
.bg-orb-sm.bg-orb-2 { width: 300px; height: 300px; bottom: -100px; right: -60px; filter: blur(60px); }
.bg-orb-sm.bg-orb-3 { width: 250px; height: 250px; filter: blur(50px); }

/* ---- Grille diagonale animée ---- */
.bg-grid {
  position: absolute;
  /* inset négatif → l'élément est ~2.8× la taille du parent :
     une fois tourné à 45°, ses bords couvrent tous les coins du conteneur */
  inset: -70%;
  background-image:
    linear-gradient(rgba(255,255,255,0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 1cm 1cm;
  /* rotation → grille orthogonale vue à 45° = losanges */
  transform: rotate(45deg);
  /* déplacement vers la droite dans l'espace local = déplacement en bas-droite
     dans l'espace écran (après rotation 45°).
     1cm de déplacement = exactement 1 cellule → loop parfait. */
  animation: grid-flow 9s linear infinite;
  pointer-events: none;
  will-change: background-position;
}

@keyframes grid-flow {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 1cm 0, 1cm 0; }
}

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.05); opacity: 0.85; }
}

@keyframes bounce-in {
  0%   { transform: scale(0.3); opacity: 0; }
  55%  { transform: scale(1.08); opacity: 1; }
  75%  { transform: scale(0.93); }
  100% { transform: scale(1); }
}

@keyframes bounce-in-down {
  0%   { transform: translateY(-80px) scale(0.8); opacity: 0; }
  60%  { transform: translateY(12px) scale(1.05); opacity: 1; }
  80%  { transform: translateY(-6px) scale(0.98); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes shimmer {
  0%   { background-position: -400% center; }
  100% { background-position: 400% center; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes flash-gold {
  0%, 100% { box-shadow: 0 0 20px rgba(245,158,11,0.3); }
  50%       { box-shadow: 0 0 60px rgba(245,158,11,0.9), 0 0 100px rgba(245,158,11,0.4); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-8px); }
  75%       { transform: translateX(8px); }
}

@keyframes score-fly-in {
  from { transform: translateY(-30px) scale(0.5); opacity: 0; }
  60%  { transform: translateY(4px) scale(1.15); opacity: 1; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Vague ripple — part de 12px, s'étend sur ~360px */
@keyframes ripple-expand {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0.45; }
  60%  { opacity: 0.2; }
  100% { transform: translate(-50%, -50%) scale(30); opacity: 0; }
}

/* Orbes fond animé */
@keyframes orb-drift-1 {
  0%   { transform: translate(0, 0) scale(1); }
  20%  { transform: translate(90px, -60px) scale(1.1); }
  45%  { transform: translate(-50px, 80px) scale(0.92); }
  70%  { transform: translate(70px, 50px) scale(1.06); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes orb-drift-2 {
  0%   { transform: translate(0, 0) scale(1); }
  30%  { transform: translate(-90px, 60px) scale(0.9); }
  60%  { transform: translate(70px, -50px) scale(1.12); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes orb-drift-3 {
  0%   { transform: translate(-50%, -50%) scale(1); }
  35%  { transform: translate(calc(-50% + 80px), calc(-50% + 60px)) scale(0.94); }
  70%  { transform: translate(calc(-50% - 60px), calc(-50% - 50px)) scale(1.08); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.animate-fadeInUp   { animation: fadeInUp 0.45s cubic-bezier(0.22,1,0.36,1) both; }
.animate-fadeIn     { animation: fadeIn 0.35s ease both; }
.animate-bounce-in  { animation: bounce-in 0.55s cubic-bezier(0.36,0.07,0.19,0.97) both; }
.animate-pulse      { animation: pulse 2s ease-in-out infinite; }
.animate-shimmer    {
  background-size: 400% 100%;
  animation: shimmer 2.5s ease infinite;
}

/* ---- Overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* ---- Thèmes couleurs ---- */
.theme-soiree_amis     { --theme-color: #9b59b6; }
.theme-vacances        { --theme-color: #f39c12; }
.theme-cuisine         { --theme-color: #e74c3c; }
.theme-travail         { --theme-color: #3498db; }
.theme-sport           { --theme-color: #2ecc71; }
.theme-technologie     { --theme-color: #1abc9c; }
.theme-vie_quotidienne { --theme-color: #e67e22; }
.theme-nature          { --theme-color: #27ae60; }
.theme-amour           { --theme-color: #e91e63; }
.theme-enfance         { --theme-color: #ff9800; }

/* ---- Badge type question ---- */
.question-type-badge {
  padding: 6px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-white);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.12) inset;
}

.badge-vote       { background: linear-gradient(135deg,#9b59b6,#7d3cad); }
.badge-selfie     { background: linear-gradient(135deg,#e74c3c,#c0392b); }
.badge-dessin     { background: linear-gradient(135deg,#3498db,#2176ae); }
.badge-legende    { background: linear-gradient(135deg,#f39c12,#d68910); }
.badge-estimation { background: linear-gradient(135deg,#2ecc71,#1e9b56); }

/* ---- Spinner ---- */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.12);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 16px var(--color-primary-glow);
}

/* ---- Toast ---- */
.toast {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-weight: 700;
  font-size: 1rem;
  z-index: 500;
  animation: fadeInUp 0.3s ease both;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.08) inset;
}

/* ========================================
   FONDU D'ENTRÉE ENTRE ÉCRANS (TV + mobile)
======================================== */
@keyframes screen-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.tv-screen.screen-enter,
.mobile-screen.screen-enter {
  animation: screen-fade-in 0.26s ease both;
}
