/**
 * Composants réutilisables — DueFon Flèche
 *
 * §6 du design system (brief 04). Mis à jour par §6.7 du delta v3 (MappingCard
 * à venir au palier 4).
 */

/* === Boutons === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  min-height: 58px;
  width: 100%;
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 160ms ease, filter 120ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn--primary {
  background: linear-gradient(180deg, var(--accent-red-bright), var(--accent-red) 55%, var(--accent-red-dark));
  color: #fff;
  box-shadow: var(--sh-btn);
  border: 1px solid rgba(255, 43, 57, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.btn--primary:active {
  transform: translateY(1px);
  filter: brightness(0.9);
  box-shadow: 0 2px 10px rgba(229, 9, 20, 0.4);
}

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

.btn--secondary:active {
  background: var(--bg-surface);
  transform: translateY(1px);
}

/* === Tuile (Home grid) === */

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(229, 9, 20, 0.08), transparent 60%),
    var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  aspect-ratio: 1;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 80ms ease, border-color 120ms ease, box-shadow 160ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.tile:active {
  border-color: var(--accent-red);
  box-shadow: var(--glow-red);
  transform: scale(0.97);
}

/* Tuile pleine largeur (ex : Mes amis, feature sociale mise en avant) */
.tile--wide {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  flex-direction: row;
  justify-content: flex-start;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
}

/* Icône SVG (remplace les emojis, rouge/noir cohérent) */
.tile__svg {
  width: 34px;
  height: 34px;
  stroke: var(--accent-red);
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 0 8px rgba(229, 9, 20, 0.45));
}

.tile__label {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

/* === Indicateur de connexion (pastille + label explicite) === */

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.conn__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.conn__lbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.conn--ok .conn__dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(45, 182, 124, 0.6);
  animation: pulse 2s ease-in-out infinite;
}

.conn--ok .conn__lbl {
  color: var(--accent-green);
}

.conn--off .conn__dot {
  background: var(--text-muted);
}

.conn--off .conn__lbl {
  color: var(--text-muted);
}

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

/* === Toast === */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + var(--s-6));
  max-width: calc(100% - var(--s-6));
  z-index: 1000;
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  padding: var(--s-3) var(--s-4);
  font-family: var(--f-body);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}

.toast-fade-enter-active,
.toast-fade-leave-active {
  transition: opacity 250ms ease, transform 250ms ease;
}

.toast-fade-enter-from,
.toast-fade-leave-to {
  opacity: 0;
  transform: translate(-50%, 8px);
}

/* === État vide (EmptyState) === */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-3);
  padding: var(--s-6) var(--s-4);
  margin: auto 0; /* centre verticalement dans l'espace dispo */
}

.empty-state__mark {
  width: 92px;
  height: 92px;
  opacity: 0.9;
  filter: drop-shadow(0 0 22px rgba(229, 9, 20, 0.4)) grayscale(0.15);
  animation: emptyFloat 4s ease-in-out infinite;
}

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

.empty-state__title {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  margin: 0;
}

.empty-state__text {
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 280px;
  margin: 0;
}

/* === Bulle feedback (flottante) === */

.feedback-bubble {
  position: fixed;
  right: calc(var(--safe-right) + var(--s-4));
  bottom: calc(var(--safe-bottom) + var(--s-5));
  z-index: 950;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(180deg, var(--accent-red-bright), var(--accent-red) 60%, var(--accent-red-dark));
  border: 1px solid rgba(255, 43, 57, 0.5);
  box-shadow: var(--sh-btn);
  transition: transform 80ms ease, filter 120ms ease;
}

.feedback-bubble:active {
  transform: scale(0.92);
  filter: brightness(0.9);
}

/* === Formulaire feedback === */

.feedback {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 6, 10, 0.85);
  padding: var(--s-5);
  overflow-y: auto;
}

.feedback__card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: var(--s-6);
  background: var(--bg-surface);
  border: 1px solid var(--accent-red);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-red), var(--sh-overlay);
}

.feedback__title {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
  margin-bottom: var(--s-2);
}

.feedback__label {
  font-family: var(--f-body);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: var(--s-3);
}

.feedback__darts {
  display: flex;
  gap: var(--s-2);
  justify-content: center;
}

.rating-dart {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: color 120ms ease, transform 80ms ease;
}

.rating-dart:active {
  transform: scale(0.9);
}

.rating-dart--on {
  color: var(--accent-red);
  filter: drop-shadow(0 0 8px rgba(229, 9, 20, 0.5));
}

.feedback__rating-hint {
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.feedback__textarea {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  color: var(--text-primary);
  font-family: var(--f-body);
  font-size: 15px;
  outline: none;
  resize: vertical;
  min-height: 88px;
}

.feedback__textarea:focus {
  border-color: var(--accent-red);
}

.feedback .btn--primary {
  margin-top: var(--s-3);
}

.feedback__cancel {
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--text-muted);
  padding: var(--s-2);
}

/* === GifOverlay (gamification, non bloquant) === */

.gif-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  pointer-events: none; /* non bloquant : l'app reste utilisable */
}

.gif-overlay__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  width: 80%;
  max-width: 320px;
  padding: var(--s-6);
  background: var(--bg-overlay);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-overlay);
}

.gif-overlay__img {
  width: 100%;
  max-height: 50vh;
  border-radius: var(--r-md);
}

.gif-overlay__emoji {
  font-size: 96px;
  line-height: 1;
}

.gif-overlay__label {
  font-family: var(--f-display);
  font-size: 40px;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: 0.02em;
}

.overlay-pop-enter-active {
  animation: overlayPop 200ms ease-out;
}
.overlay-pop-leave-active {
  animation: overlayPop 300ms ease-in reverse;
}

@keyframes overlayPop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* === Modal Inviter (en partie) === */

.invite {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 6, 10, 0.8);
  padding: var(--s-5);
}

.invite__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  max-width: 340px;
  padding: var(--s-6);
  background: var(--bg-surface);
  border: 1px solid var(--accent-red);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-red), var(--sh-overlay);
}

.invite__title {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.invite__code {
  font-family: var(--f-display);
  font-size: 52px;
  letter-spacing: 0.12em;
  color: var(--accent-red);
  text-shadow: var(--glow-red);
}

.invite__hint {
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

/* === Modale fin de partie (terminer / quitter) === */

.endgame {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 6, 10, 0.85);
  padding: var(--s-5);
}

.endgame__card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 100%;
  max-width: 340px;
  padding: var(--s-6);
  background: var(--bg-surface);
  border: 1px solid var(--accent-red);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-red), var(--sh-overlay);
  text-align: center;
}

.endgame__title {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--s-2);
}

.endgame__hint {
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 var(--s-2);
}

.endgame__cancel {
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--text-muted);
  padding: var(--s-2);
  margin-top: var(--s-1);
}

/* === Invite de vérification (compte) === */

.verify {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 6, 10, 0.85);
  padding: var(--s-5);
}

.verify__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  max-width: 360px;
  padding: var(--s-6);
  background: var(--bg-surface);
  border: 1px solid var(--accent-red);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-red), var(--sh-overlay);
  text-align: center;
}

.verify__badge {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent-red-bright), var(--accent-red-dark));
  box-shadow: var(--glow-red);
}

.verify__title {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.verify__reason {
  font-family: var(--f-body);
  font-size: 15px;
  color: var(--text-primary);
  margin: 0;
}

.verify__how {
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.verify__go {
  margin-top: var(--s-2);
}

.verify__later {
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--text-muted);
  padding: var(--s-2);
}

/* === Modale Groupe (nommer / enregistrer / inviter) === */

.group-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 6, 10, 0.85);
  padding: var(--s-5);
  overflow-y: auto;
}

.group-modal__card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: var(--s-5);
  background: var(--bg-surface);
  border: 1px solid var(--accent-red);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-red), var(--sh-overlay);
}

.group-modal__title {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}

.group-modal__label {
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--text-secondary);
}

.group-modal__input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  color: var(--text-primary);
  font-family: var(--f-title);
  font-weight: 500;
  font-size: 18px;
  outline: none;
  min-height: 52px;
}

.group-modal__input:focus {
  border-color: var(--accent-red);
}

.group-modal__members {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.group-modal__members-label {
  font-family: var(--f-body);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.group-modal__members-names {
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--text-secondary);
}

.group-modal__divider {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-2);
  color: var(--text-muted);
  font-family: var(--f-title);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.group-modal__divider::before,
.group-modal__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.group-modal__code {
  font-family: var(--f-display);
  font-size: 40px;
  letter-spacing: 0.12em;
  color: var(--accent-red);
  text-shadow: var(--glow-red);
  text-align: center;
}

.group-modal__hint {
  font-family: var(--f-body);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

/* === Scanner QR === */

.qr-scanner {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.qr-scanner__view {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--accent-red);
  box-shadow: var(--glow-red);
}

.qr-scanner__view video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.qr-scanner__status {
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}

/* === Liste « Mes parties » === */

.game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.game-row__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.game-row__mode {
  font-family: var(--f-title);
  font-weight: 600;
  font-size: 16px;
  color: var(--accent-red);
}

.game-row__players {
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-row__actions {
  display: flex;
  gap: var(--s-2);
  flex-shrink: 0;
}

.game-row__join,
.game-row__cancel {
  font-family: var(--f-title);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3);
  min-height: 40px;
  cursor: pointer;
}

.game-row__join {
  background: var(--accent-red);
  color: #fff;
}

.game-row__cancel {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* === Keypad === */

.keypad {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--bg-deep);
}

.keypad--disabled {
  opacity: 0.4;
  pointer-events: none;
}

.keypad__mult {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--s-2);
}

/* Grille Cricket : 15-20 sur 3 colonnes */
.keypad__cricket {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
}

.keypad__mult-btn {
  font-family: var(--f-title);
  font-weight: 500;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s-3);
  min-height: 44px;
  cursor: pointer;
  transition: background 80ms ease, color 80ms ease;
}

.keypad__mult-btn--active {
  background: var(--accent-red);
  color: var(--text-primary);
  border-color: var(--accent-red);
  box-shadow: 0 2px 8px rgba(230, 57, 70, 0.4);
}

.keypad__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-2);
}

.keypad__special {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
}

.keypad__key {
  font-family: var(--f-display);
  font-size: 24px;
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-height: 56px;
  cursor: pointer;
  transition: background 50ms ease, transform 80ms ease;
  position: relative;
  overflow: hidden;
}

.keypad__key:active {
  background: var(--bg-surface);
  transform: scale(0.95);
}

.keypad__key--miss {
  background: #000;
  color: var(--text-muted);
  font-size: 18px;
}

.keypad__key--bull {
  background: var(--bg-surface);
  border: 2px solid var(--accent-red);
  font-size: 18px;
}

.keypad__key--wide {
  font-family: var(--f-title);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.keypad__key--flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
  animation: keyFlash 150ms ease-out;
}

@keyframes keyFlash {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* === Cible ami (toggle on/off en partie — ajouter un ami, brief #5) === */

.friend-target {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: transparent;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease, transform 80ms ease;
}

.friend-target:active {
  transform: scale(0.88);
}

/* Ami actif : flèche rouge sang qui « décoche » */
.friend-target--on {
  color: #fff;
  border-color: var(--accent-red);
  background: var(--accent-red);
  box-shadow: var(--glow-red);
}

/* Variante compacte (têtes de colonne Cricket) */
.friend-target--sm {
  width: 24px;
  height: 24px;
  margin-top: 2px;
}

/* === PlayerCard === */

.player-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  transition: opacity 200ms ease;
}

.player-card--current {
  background: var(--bg-surface);
  border-left: 4px solid var(--player-color, var(--accent-red));
}

.player-card--inactive {
  background: transparent;
  opacity: 0.55;
}

.player-card__header {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.player-card__chip {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-card--current .player-card__chip {
  width: 32px;
  height: 32px;
}

.player-card__name {
  font-family: var(--f-title);
  font-weight: 500;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.player-card--current .player-card__name {
  font-size: 18px;
  color: var(--text-primary);
}

.player-card--inactive .player-card__name {
  font-size: 14px;
  color: var(--text-secondary);
}

.player-card__turn {
  margin-left: auto;
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--text-muted);
}

.player-card__score {
  font-family: var(--f-display);
  line-height: 1;
}

.player-card--current .player-card__score {
  font-size: 120px;
  color: var(--text-primary);
  margin-top: var(--s-2);
  text-shadow: 0 0 30px rgba(229, 9, 20, 0.35), 0 4px 0 rgba(0, 0, 0, 0.5);
}

.player-card--inactive .player-card__score {
  font-size: 48px;
  color: var(--text-secondary);
}
