/* =====================================================================
   Blackjack — styles propres au jeu (préfixe bj-)
   La barre, le plein écran et les infobulles sont dans css/games.css.
   ===================================================================== */

/* Barre commune aux couleurs du jeu : feutrine et or */
.bj-jeu {
  --mg-jeu-largeur: 1204px; /* barre de 1180 px + marges de 12 px : ne pas changer */
  --mgb-fond:
    radial-gradient(
      120% 180% at 0% 0%,
      rgba(232, 200, 114, 0.22),
      transparent 55%
    ),
    linear-gradient(120deg, #06281c, #0c4a33);
  --mgb-accent: #e8c872;
  --mgb-titre: linear-gradient(100deg, #fff4d6, #e8c872 55%, #c99a3c);
  --mgb-police-titre: "Playfair Display", serif;
  --mgb-doux: #a9cdb9;
  --mg-fs-fond: #04170f;
  --mg-bulle-fond: #06281c;
  --bj-l: 96px; /* largeur d'une carte, posée par game.js */
  --bj-h: calc(var(--bj-l) * 1.4);
  --bj-or: #e8c872;
  --bj-rouge: #c8102e;
  --bj-noir: #1b1b2a;
}

.bj-jeu .mg-barre-titre {
  font-weight: 900;
}

.bj-jeu [hidden] {
  display: none !important;
}

/* ---------- La table ---------- */
.bj-zone {
  position: relative;
  box-sizing: border-box;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(var(--mg-barre-largeur, 1180px), calc(100vw - 24px));
  padding: 18px 22px 10px 22px;
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(
      70% 55% at 50% 40%,
      rgba(255, 255, 255, 0.07),
      transparent 70%
    ),
    radial-gradient(120% 90% at 50% 30%, #12784f 0%, #0c5a3b 55%, #073826 100%);
  box-shadow:
    inset 0 0 0 12px #4a2c17,
    inset 0 0 0 14px #c9a45c,
    inset 0 0 0 15px rgba(0, 0, 0, 0.4),
    inset 0 18px 50px rgba(0, 0, 0, 0.45),
    0 18px 40px -18px rgba(4, 23, 15, 0.8);
  color: #f3efe2;
  font-family: "Outfit", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Grain de la feutrine */
.bj-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: repeating-radial-gradient(
    circle at 30% 20%,
    rgba(255, 255, 255, 0.025) 0 1px,
    transparent 1px 3px
  );
}

/* Plein écran : la table prend toute la place sous la barre */
.bj-jeu.mg-fs .bj-zone {
  align-self: stretch;
  width: auto;
  flex: 1;
  min-height: 0;
}

/* ---------- Sabot et défausse ---------- */
.bj-sabot,
.bj-defausse {
  position: absolute;
  top: 26px;
  width: calc(var(--bj-l) * 0.8);
  height: calc(var(--bj-h) * 0.8);
}

.bj-sabot {
  right: 30px;
}

.bj-defausse {
  left: 30px;
  opacity: 0.9;
}

.bj-sabot-cartes,
.bj-defausse::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: var(--bj-dos);
  box-shadow:
    2px 2px 0 #f3efe2,
    4px 4px 0 #ddd6c2,
    6px 6px 0 #f3efe2,
    8px 8px 0 #ddd6c2,
    10px 10px 14px rgba(0, 0, 0, 0.45);
  transform: rotate(-8deg);
}

.bj-defausse::before {
  transform: rotate(9deg);
  box-shadow:
    -2px 2px 0 #f3efe2,
    -4px 4px 0 #ddd6c2,
    -6px 6px 12px rgba(0, 0, 0, 0.4);
}

.bj-defausse.vide::before {
  display: none;
}

.bj-sabot-jauge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -22px;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.bj-sabot-jauge i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--bj-or);
  transition: width 0.3s;
}

/* ---------- Mains ---------- */
.bj-croupier {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: calc(var(--bj-h) + 34px);
}

.bj-main {
  position: relative;
  height: var(--bj-h);
  transition: width 0.25s;
}

.bj-total {
  min-width: 34px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 0 0 1px rgba(232, 200, 114, 0.5);
  color: #fff;
  font-weight: 700;
  font-size: 0.95em;
  text-align: center;
}

.bj-total.saute {
  background: #8e1b24;
}

.bj-total.bj {
  background: linear-gradient(135deg, #f6dc8f, #c99a3c);
  color: #3a2a06;
}

.bj-milieu {
  position: relative;
  flex: 1;
  min-height: 46px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.bj-arc {
  width: min(640px, 70%);
  height: auto;
  overflow: visible;
}

.bj-arc text {
  fill: var(--bj-or);
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 34px;
  letter-spacing: 6px;
  opacity: 0.85;
}

.bj-regle {
  margin-top: -6px;
  color: rgba(232, 200, 114, 0.6);
  font-size: 0.8em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.bj-annonce {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  padding: 8px 26px;
  border-radius: 999px;
  background: rgba(4, 23, 15, 0.82);
  box-shadow:
    0 0 0 2px var(--bj-or),
    0 14px 30px -10px rgba(0, 0, 0, 0.7);
  color: var(--bj-or);
  font-family: "Playfair Display", serif;
  font-weight: 900;
  font-size: 1.7em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  transition:
    opacity 0.25s,
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bj-annonce.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.bj-annonce.perdu {
  color: #ff9a9a;
  box-shadow:
    0 0 0 2px #c8102e,
    0 14px 30px -10px rgba(0, 0, 0, 0.7);
}

.bj-joueur {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: calc(var(--bj-l) * 0.45);
  min-height: calc(var(--bj-h) + 74px);
}

.bj-main-j {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 0 8px;
  border-radius: 16px;
  transition:
    background 0.2s,
    box-shadow 0.2s,
    opacity 0.2s;
}

/* Main en cours quand il y en a plusieurs */
.bj-joueur.plusieurs .bj-main-j.active {
  background: rgba(232, 200, 114, 0.1);
  box-shadow: 0 0 0 2px rgba(232, 200, 114, 0.55);
}

.bj-joueur.plusieurs .bj-main-j.attente {
  opacity: 0.7;
}

.bj-mise-main {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  color: #fff;
  font-weight: 700;
  font-size: 0.95em;
}

.bj-resultat {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 30;
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1em;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-6deg);
  box-shadow: 0 8px 18px -6px rgba(0, 0, 0, 0.6);
  animation: bj-tampon 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bj-tampon {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-6deg) scale(1.8);
  }
}

.bj-resultat.gagne {
  background: #1f9d55;
  color: #fff;
}

.bj-resultat.perdu {
  background: #b3202c;
  color: #fff;
}

.bj-resultat.egal {
  background: #e9e4d4;
  color: #333;
}

.bj-resultat.bjk {
  background: linear-gradient(135deg, #f6dc8f, #c99a3c);
  color: #3a2a06;
}

/* ---------- Cartes ---------- */
.bj-jeu {
  /* Dos des cartes : treillis or sur bleu nuit */
  --bj-dos:
    repeating-linear-gradient(
      45deg,
      rgba(232, 200, 114, 0.35) 0 2px,
      transparent 2px 9px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(232, 200, 114, 0.35) 0 2px,
      transparent 2px 9px
    ),
    radial-gradient(circle at 50% 50%, #26407a, #142650);
}

.bj-carte {
  position: absolute;
  top: 0;
  width: var(--bj-l);
  height: var(--bj-h);
  perspective: 800px;
  transition: transform 0.42s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.bj-carte-in {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.bj-carte.cachee .bj-carte-in {
  transform: rotateY(180deg);
}

.bj-face,
.bj-dos {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--bj-l) * 0.08);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 6px 14px -4px rgba(0, 0, 0, 0.55);
}

.bj-face {
  background: linear-gradient(160deg, #ffffff, #f6f2e7);
  border: 1px solid #d9d2bd;
  box-sizing: border-box;
  color: var(--bj-noir);
  overflow: hidden;
}

.bj-face.rouge {
  color: var(--bj-rouge);
}

.bj-dos {
  transform: rotateY(180deg);
  background: var(--bj-dos);
  border: calc(var(--bj-l) * 0.05) solid #f3efe2;
  box-sizing: border-box;
}

/* Indices dans les coins */
.bj-coin {
  position: absolute;
  top: calc(var(--bj-l) * 0.05);
  left: calc(var(--bj-l) * 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: calc(var(--bj-l) * 0.2);
}

.bj-coin small {
  font-size: 0.8em;
}

.bj-coin.bas {
  top: auto;
  left: auto;
  bottom: calc(var(--bj-l) * 0.05);
  right: calc(var(--bj-l) * 0.06);
  transform: rotate(180deg);
}

/* Motifs des cartes numérotées */
.bj-pips {
  position: absolute;
  inset: 16% 25% 16% 25%;
}

.bj-pip {
  position: absolute;
  font-size: calc(var(--bj-l) * 0.2);
  line-height: 1;
  transform: translate(-50%, -50%);
}

.bj-pip.bas {
  transform: translate(-50%, -50%) rotate(180deg);
}

.bj-pip.as {
  font-size: calc(var(--bj-l) * 0.55);
}

/* Figures : un cadre doré, la lettre et l'enseigne */
.bj-figure {
  position: absolute;
  inset: 16% 18%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--bj-l) * 0.05);
  background:
    radial-gradient(
      circle at 50% 40%,
      rgba(255, 255, 255, 0.9),
      transparent 70%
    ),
    linear-gradient(160deg, #f8e7b0, #e3c06a);
  box-shadow:
    inset 0 0 0 2px #b88d33,
    inset 0 0 0 4px #fff7dc,
    inset 0 0 0 5px currentColor;
}

.bj-figure b {
  font-family: "Playfair Display", serif;
  font-weight: 900;
  font-size: calc(var(--bj-l) * 0.42);
  line-height: 1;
}

.bj-figure span {
  font-size: calc(var(--bj-l) * 0.22);
  line-height: 1;
}

.bj-figure i {
  font-style: normal;
  font-size: calc(var(--bj-l) * 0.12);
  font-family: "Playfair Display", serif;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* ---------- Jetons ---------- */
.bj-jeton,
.bj-mini {
  --c: #c8102e;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background:
    radial-gradient(
      circle,
      var(--c) 0 50%,
      #fff 50% 53%,
      var(--c) 53% 66%,
      transparent 66%
    ),
    repeating-conic-gradient(#fff 0 12deg, var(--c) 12deg 45deg);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.25),
    0 3px 0 rgba(0, 0, 0, 0.35),
    0 6px 10px -2px rgba(0, 0, 0, 0.45);
  color: #fff;
  font-weight: 800;
}

.j5 {
  --c: #c8102e;
}

.j25 {
  --c: #1c8a4c;
}

.j100 {
  --c: #23232e;
}

.j500 {
  --c: #6c3fb5;
}

.bj-jeton {
  width: 54px;
  height: 54px;
  margin: 0;
  padding: 0;
  border: none;
  font-family: inherit;
  font-size: 0.92em;
  cursor: pointer;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.15s;
}

.bj-jeton:hover:not(:disabled) {
  transform: translateY(-4px);
}

.bj-jeton:active:not(:disabled) {
  transform: scale(0.94);
}

.bj-jeton:disabled {
  opacity: 0.35;
  cursor: default;
}

.bj-jeton:focus-visible {
  outline: 3px solid var(--bj-or);
  outline-offset: 2px;
}

.bj-mini {
  width: var(--bj-jeton, 30px);
  height: var(--bj-jeton, 30px);
  font-size: 0.6em;
}

/* Piles de jetons : une colonne par valeur, chaque jeton un peu plus haut que le précédent */
.bj-piles {
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.bj-pile-jetons {
  position: relative;
  width: var(--bj-jeton, 30px);
  height: var(--bj-jeton, 30px);
}

.bj-pile-jetons .bj-mini {
  position: absolute;
  left: 0;
}

/* Cercle de mise (pendant la mise) */
.bj-cercle {
  position: absolute;
  left: 50%;
  bottom: calc(64px + var(--bj-h) * 0.45);
  z-index: 1;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 2px rgba(232, 200, 114, 0.7),
    inset 0 0 0 7px rgba(232, 200, 114, 0.12),
    inset 0 0 0 9px rgba(232, 200, 114, 0.5);
  cursor: pointer;
}

.bj-cercle::after {
  content: "MISE";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -22px;
  color: rgba(232, 200, 114, 0.7);
  font-size: 0.75em;
  letter-spacing: 0.3em;
  text-align: center;
}

.bj-pile {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.bj-pile {
  --bj-jeton: 38px;
}

.bj-pile .bj-mini {
  font-size: 0.72em;
}

.bj-mise-main {
  --bj-jeton: 26px;
}

.bj-pile-total {
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translateX(-50%);
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-weight: 700;
  font-size: 0.9em;
  white-space: nowrap;
}

/* ---------- Commandes ---------- */
.bj-bas {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
}

.bj-commandes {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.bj-jetons {
  display: flex;
  gap: 8px;
  margin-right: 8px;
}

.bj-btn {
  min-width: 104px;
  height: 44px;
  margin: 0;
  padding: 0 20px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 0 0 1.5px rgba(232, 200, 114, 0.7);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 1em;
  cursor: pointer;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.15s,
    box-shadow 0.15s,
    opacity 0.15s;
}

.bj-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
}

.bj-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.bj-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.bj-btn:focus-visible {
  outline: 3px solid var(--bj-or);
  outline-offset: 2px;
}

.bj-btn.or {
  background: linear-gradient(135deg, #f6dc8f, #c99a3c);
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.7);
  color: #3a2a06;
}

.bj-btn.or:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffe7a6, #d6a845);
}

.bj-btn.clair {
  min-width: 0;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35);
  font-weight: 600;
}

/* Le coup conseillé par le coach */
.bj-btn.conseil {
  box-shadow:
    inset 0 0 0 2px #f6dc8f,
    0 0 0 4px rgba(246, 220, 143, 0.35),
    0 0 22px 4px rgba(246, 220, 143, 0.5);
  animation: bj-conseil 1.2s ease-in-out infinite;
}

@keyframes bj-conseil {
  50% {
    box-shadow:
      inset 0 0 0 2px #f6dc8f,
      0 0 0 7px rgba(246, 220, 143, 0.25),
      0 0 30px 8px rgba(246, 220, 143, 0.6);
  }
}

.bj-question {
  margin-right: 6px;
  color: var(--bj-or);
  font-weight: 600;
}

.bj-coach-choix {
  position: absolute;
  left: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #d9e9df;
  font-weight: 600;
  font-size: 0.92em;
  cursor: pointer;
}

.bj-coach-msg {
  position: absolute;
  right: 24px;
  max-width: 240px;
  color: #f6dc8f;
  font-size: 0.9em;
  font-weight: 600;
  text-align: right;
}

/* ---------- Fenêtres : dans la table, la barre reste visible ---------- */
.bj-voile {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(2, 14, 9, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.bj-fen {
  box-sizing: border-box;
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 24px 18px 24px;
  border-radius: 22px;
  background: linear-gradient(180deg, #0f4a33, #082d1f);
  box-shadow:
    0 0 0 2px var(--bj-or),
    0 30px 60px -20px rgba(0, 0, 0, 0.8);
  color: #f3efe2;
  text-align: center;
  animation: bj-fen 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bj-fen {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
}

.bj-fen-titre {
  font-family: "Playfair Display", serif;
  font-weight: 900;
  font-size: 1.9em;
  color: var(--bj-or);
}

.bj-fen-sous {
  margin: 8px 0;
  color: #cfe0d5;
}

.bj-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 4px 0;
}

.bj-stats div {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
}

.bj-stats span {
  font-size: 0.75em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a9cdb9;
}

.bj-stats b {
  color: #fff;
  font-size: 1.35em;
}

.bj-fen-boutons {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

.bj-fen .btn-vert {
  min-width: 140px;
  background: linear-gradient(135deg, #f6dc8f, #c99a3c);
  color: #3a2a06;
}

/* ---------- Écran étroit ---------- */
@media (max-width: 760px) {
  .bj-zone {
    padding: 14px 12px 8px 12px;
  }

  .bj-sabot,
  .bj-defausse {
    top: 20px;
    transform: scale(0.7);
    transform-origin: top;
  }

  .bj-sabot {
    right: 16px;
  }

  .bj-defausse {
    left: 16px;
  }

  .bj-regle {
    display: none;
  }

  .bj-bas {
    flex-direction: column;
    gap: 6px;
  }

  .bj-coach-choix,
  .bj-coach-msg {
    position: static;
    max-width: none;
    text-align: center;
  }

  .bj-jeton {
    width: 44px;
    height: 44px;
  }

  .bj-btn {
    min-width: 0;
    height: 40px;
    padding: 0 14px;
  }

  .bj-annonce {
    font-size: 1.25em;
  }
}

/* Le site colore les <b> : les cartes gardent la couleur de leur enseigne */
.bj-coin b,
.bj-figure b,
.bj-stats b {
  color: inherit;
}

.bj-stats b {
  color: #fff;
}
