/*
 * FAB-10 — « La Galerie » : salle des cartes (Collection, cartes Effet, Combattants).
 * Trois états : attente (velours et lueur, jamais le dessin 2D), 3d (scène WebGL sous des zones tactiles transparentes),
 * repli (même salle dessinée en CSS : sans WebGL, en mouvement réduit, ou si la 3D échoue).
 * Jetons de l'interface commune (FAB-07) ; aucun composant commun redéfini.
 */
.g3:not(.grid) { /* la grille « grid g3 » du jeu (3 colonnes) porte le même nom : ne jamais la toucher */
  --g3-velours: #101b52; --g3-velours-2: #0a1136; --g3-noyer: #5a3620; --g3-or: var(--fi-or, #e3b84f); --g3-chaud: #ffd9a0;
  position: relative; width: 100%; min-width: 0; height: 420px; min-height: 300px; overflow: hidden; isolation: isolate;
  border-radius: 14px; border: 2px solid var(--fi-or-profond, #a8791f);
  box-shadow: inset 0 0 0 1px rgba(255, 240, 190, .22), 0 10px 24px rgba(0, 0, 0, .5);
  background: radial-gradient(70% 60% at 50% 30%, #22327c 0%, var(--g3-velours) 48%, #060a26 100%);
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.g3-toile { position: absolute; inset: 0; opacity: 0; transition: opacity .6s ease; }
.g3-toile canvas { display: block; width: 100%; height: 100%; outline: none; }
.g3[data-mode="3d"] .g3-toile { opacity: 1; }
.g3[data-mode="3d"] { cursor: grab; } .g3.g3--glisse { cursor: grabbing; } .g3.g3--fixe { cursor: default; }
.g3-ombre { position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: linear-gradient(180deg, rgba(5, 8, 30, .78) 0, rgba(5, 8, 30, 0) 84px), linear-gradient(0deg, rgba(5, 8, 30, .82) 0, rgba(5, 8, 30, 0) 96px), radial-gradient(120% 90% at 50% 45%, transparent 62%, rgba(4, 6, 24, .5) 100%); }

/* Attente de la 3D : velours et lueur dorée (même convention que les autres scènes), les pièces restent invisibles. */
.g3[data-mode="attente"]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; border: 3px solid rgba(240, 200, 110, .25); border-top-color: #f0c86e; animation: g3-attente 1s linear infinite; pointer-events: none; z-index: 2; }
.g3[data-mode="attente"] .g3-pieces, .g3[data-mode="attente"] .g3-fleche, .g3[data-mode="attente"] .g3-piste { opacity: 0; }
@keyframes g3-attente { to { transform: rotate(360deg); } }

/* Outils posés sur le haut de la scène, plaque et piste en bas. */
.g3-haut { position: absolute; left: 0; right: 0; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px 14px; padding: 10px 12px 6px; }
.g3-haut:empty { display: none; }
.g3 .g3-titre { margin: 0; flex: 0 1 auto; min-width: 0; font-size: clamp(.95rem, 1.25vw, 1.2rem); line-height: 1.15; letter-spacing: .04em; text-shadow: 0 2px 6px #000; }
.g3-haut .fe-rail { flex: 0 1 auto; min-width: 0; margin: 0; }
/* Le « i » de la visite guidée (posé par le jeu près du premier titre) se range à droite des outils. */
.g3-haut .guide-heading { display: contents; }
.g3-haut .guide-help { order: 5; flex: none; margin: 0; }
/* … et se distingue du « i » des explications : un point d'interrogation. */
.g3-haut .guide-help > * { display: none; }
.g3-haut .guide-help::before { content: "?"; font: 700 1.25rem/1 var(--fi-titre, serif); }
.g3-haut .fi-btn { white-space: nowrap; flex: none; }
.g3-haut .fe-outils { flex: 1 1 220px; min-width: 0; justify-content: flex-end; }
.g3-haut .fe-recherche { flex: 0 1 300px; min-width: 110px; }
.g3-pied { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: grid; justify-items: center; gap: 5px; padding: 4px 12px 9px; pointer-events: none; }
.g3-pied > * { pointer-events: auto; }
.g3-plaque { margin: 0; min-height: 28px; max-width: min(92%, 520px); padding: 4px 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 700 .95rem/1.25 var(--fi-titre, serif); color: var(--fi-encre, #241a06); letter-spacing: .01em;
  background: linear-gradient(180deg, #fff6d2 0%, #e9c463 38%, #c2932f 100%); border: 1px solid #6e4d0e; border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -2px 3px rgba(90, 60, 6, .45), 0 4px 10px rgba(0, 0, 0, .6); }
.g3-plaque:empty { visibility: hidden; }
.g3-piste { position: relative; width: min(46%, 240px); height: 5px; border-radius: 3px; background: rgba(255, 240, 200, .16); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .6); }
.g3-piste i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; background: linear-gradient(180deg, #fff0b8, var(--g3-or)); box-shadow: 0 0 6px rgba(255, 214, 122, .7); }
.g3--fixe .g3-piste, .g3--fixe .g3-fleche { visibility: hidden; }
.g3-bas { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: center; }
.g3-bas:empty { display: none; }
.g3-note { margin: 0; display: flex; gap: 6px; align-items: center; color: var(--fi-texte, #f4ecd8); }
.g3-note .fi-ico { width: 14px; height: 14px; flex: none; color: var(--g3-or); }

/* Flèches : médaillons dorés, cible tactile de 48 px. */
.g3 .g3-fleche { position: absolute; top: 50%; z-index: 5; width: 48px; height: 48px; margin-top: -24px; padding: 0; display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; border: 2px solid #6e4d0e; color: var(--fi-encre, #241a06); font: 700 30px/1 var(--fi-titre, serif);
  background: radial-gradient(circle at 35% 28%, #fff6d2, #e3b84f 55%, #a8791f 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 5px 12px rgba(0, 0, 0, .6);
  transition: transform var(--fi-vite, .16s) var(--fi-courbe, ease), opacity var(--fi-vite, .16s); }
.g3 .g3-fleche span { margin-top: -5px; }
.g3-fleche--g { left: 8px; } .g3-fleche--d { right: 8px; }
.g3 .g3-fleche:hover:not(:disabled) { transform: scale(1.08); } .g3 .g3-fleche:active:not(:disabled) { transform: scale(.94); }
.g3 .g3-fleche:disabled { opacity: .22; cursor: default; }

/* Pièces en 3D : zones tactiles transparentes posées sur les cartes (clavier, lecteur d'écran, toucher). */
.g3 .g3-pieces { position: absolute; inset: 0; z-index: 2; display: block; padding: 0; margin: 0; overflow: hidden; }
.g3 .g3-piece { position: absolute; left: 0; top: 0; width: 0; height: 0; min-height: 0; padding: 0; margin: 0; display: block; border: 0; border-radius: 7px; background: none; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.g3[data-variante="combattants"] .g3-piece { cursor: zoom-in; }
.g3 .g3-piece::after { display: none; }
.g3 .g3-piece:focus-visible { outline: 3px solid var(--fi-focus, #9fd4ff); outline-offset: 5px; }
.g3-nom { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Sous chaque carte : petite plaque de laiton gravée à son nom, puis son cartel d'état ou de prix. */
.g3-cartels { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 4px); display: grid; justify-items: center; gap: 3px; width: max-content; max-width: 132%; pointer-events: none; }
.g3-cartel { max-width: 100%; padding: 1px 9px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 .7rem/1.25 var(--fi-titre, serif); letter-spacing: .02em; color: var(--fi-encre, #241a06);
  background: linear-gradient(180deg, #fff6d2 0%, #e9c463 42%, #b98a2c 100%); border: 1px solid #6e4d0e; border-radius: 2px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .65), 0 2px 4px rgba(0, 0, 0, .55); text-shadow: 0 1px 0 rgba(255, 246, 207, .6); }
.g3-cartels .g3-marque { position: static; transform: none; max-width: 100%; }
.g3-marque { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 5px); max-width: 150%; padding: 2px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;
  font: 700 .72rem/1.3 var(--fi-corps, sans-serif); color: #fff6dc; background: #162050; border: 1px solid var(--fi-or-profond, #a8791f); border-radius: 3px; box-shadow: 0 2px 5px rgba(0, 0, 0, .6); }
.g3-marque--prix { color: var(--fi-encre, #241a06); background: linear-gradient(180deg, #fff3c4, #e3b84f); border-color: #6e4d0e; }
.g3-marque--repos { color: #cfe0ff; } .g3-marque--travail { color: #ffd9a0; } .g3-marque--contrat { color: #ffc4c8; }
.g3-marque--voile { top: 50%; transform: translate(-50%, 46px); color: #dfe6ff; background: rgba(10, 16, 54, .92); border-color: #55619a; letter-spacing: .02em; }
.g3[data-mode="3d"] .g3-dessin { display: none; }
/* Éclair d'arrivée : la carte qui vole vers le joueur ouvre sa fiche dans la lumière. */
.g3-eclair { position: absolute; inset: 0; z-index: 6; pointer-events: none; opacity: 0; background: radial-gradient(60% 70% at 50% 50%, rgba(255, 250, 225, .95), rgba(255, 214, 122, .55) 45%, rgba(255, 214, 122, 0) 78%); }
.g3-eclair.actif { animation: g3-eclair .5s ease-out; }
@keyframes g3-eclair { 0% { opacity: .9; } 100% { opacity: 0; } }
.g3--envol .g3-cartels, .g3--envol .g3-fleche { opacity: .25; transition: opacity .2s; }

/* ─── Repli dessiné : la même salle en CSS (velours, corniche, étagères éclairées, lambris), les vraies cartes sur les tablettes. ─── */
.g3[data-mode="repli"] { cursor: default;
  background:
    linear-gradient(180deg, #2a180d 0, #5a3620 9px, #8a5a2c 10px, var(--g3-or) 11px, #6e4d0e 13px, transparent 14px),
    radial-gradient(90% 55% at 50% 0, rgba(255, 217, 160, .26), transparent 70%),
    repeating-linear-gradient(90deg, rgba(126, 148, 236, .05) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(60deg, rgba(126, 148, 236, .045) 0 1px, transparent 1px 34px), repeating-linear-gradient(-60deg, rgba(126, 148, 236, .045) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #17246a 0%, var(--g3-velours) 45%, var(--g3-velours-2) 100%); }
.g3[data-mode="repli"] .g3-toile { display: none; }
.g3[data-mode="repli"] .g3-pieces { top: var(--g3-haut, 58px); bottom: calc(var(--g3-bas, 60px) + 16px); display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--g3-rangs, 1), minmax(0, 1fr)); grid-template-columns: none; grid-auto-columns: max-content;
  gap: 26px 20px; justify-content: safe center; align-items: stretch; padding: 10px 62px 14px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--fi-or-profond, #a8791f) transparent; }
.g3[data-mode="repli"] .g3-piece { position: relative; width: auto; height: 100%; aspect-ratio: 86 / 117; scroll-snap-align: center; display: block; overflow: visible; }
.g3[data-mode="repli"] .g3-piece--honneur { grid-row: 1 / -1; align-self: center; height: min(100%, 300px); }
/* Faisceau du spot au-dessus de chaque pièce, tablette de noyer à liseré doré dessous. */
.g3[data-mode="repli"] .g3-piece::before { content: ""; position: absolute; left: 50%; top: -12px; width: 190%; height: 96%; transform: translateX(-50%); pointer-events: none;
  background: conic-gradient(from 160deg at 50% 0, transparent 0 5deg, rgba(255, 224, 160, .2) 11deg 29deg, transparent 35deg); }
.g3[data-mode="repli"] .g3-piece::after { content: ""; display: block; position: absolute; left: -11px; right: -11px; top: 100%; bottom: auto; height: 11px; margin-top: 3px;
  background: linear-gradient(180deg, #fff0b8 0 2px, var(--g3-or) 2px 3px, #7a4c2a 3px 8px, #3a2212 8px); box-shadow: 0 6px 9px rgba(0, 0, 0, .6); }
.g3[data-mode="repli"] .g3-dessin { position: relative; display: block; height: 100%; aspect-ratio: 86 / 117; }
.g3[data-mode="repli"] .g3-dessin > .fe-carte { height: 100%; }
.g3[data-mode="repli"] .g3-dessin > .fe-carte > img, .g3[data-mode="repli"] .g3-dessin > .fe-carte picture, .g3[data-mode="repli"] .g3-dessin .fe-portrait, .g3[data-mode="repli"] .g3-dessin .fe-carte-sans { height: 100%; width: 100%; }
.g3[data-mode="repli"] .g3-dessin > .fe-voile { width: 100%; height: 100%; aspect-ratio: auto; }
.g3[data-mode="repli"] .g3-cartels { top: auto; bottom: 4px; transform: translateX(-50%); }
.g3[data-mode="repli"] .g3-cartel { display: none; } /* la carte dessinée porte déjà son nom */
.g3[data-mode="repli"] .g3-marque { top: auto; bottom: 4px; transform: translateX(-50%); }
.g3[data-mode="repli"] .g3-cartels .g3-marque { transform: none; }
/* Survol dans le repli : la carte se soulève dans un halo de la couleur de sa rareté (fixe en mouvement réduit). */
.g3[data-mode="repli"] .g3-dessin > .fe-carte { transition: transform .22s cubic-bezier(.2, 1.4, .4, 1), box-shadow .22s ease; }
.g3[data-mode="repli"] .g3-piece:hover .fe-carte, .g3[data-mode="repli"] .g3-piece:focus-visible .fe-carte { transform: translateY(-7px) scale(1.04); box-shadow: 0 0 26px 6px color-mix(in srgb, var(--rc, #e3b84f) 85%, transparent), 0 12px 18px rgba(0, 0, 0, .6); }
.g3[data-mode="repli"] .g3-marque--voile { bottom: 8px; }
.g3[data-mode="repli"] .g3-piece[aria-pressed="true"] .fe-carte { transform: translateY(-5px); }
.g3[data-mode="repli"] .g3-piste { visibility: hidden; }

/* ─── Mise en page des écrans autour de la salle ─── */
.fe-pied-galerie { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; min-height: 44px; }
.fe-pied-galerie .fi-actions { margin: 0; }
.fe-fiche-cadre { min-width: 0; padding: 14px 14px 16px; border-radius: 12px; border: 1px solid var(--fi-or-profond, #a8791f);
  background: radial-gradient(90% 50% at 50% 0, rgba(255, 217, 160, .16), transparent 70%), var(--fi-grain), linear-gradient(180deg, #232d63, #121a40);
  box-shadow: inset 0 0 0 1px rgba(255, 240, 190, .12), 0 6px 14px rgba(0, 0, 0, .45); }
.fe-fiche-cadre--effet { padding: 0; border: 0; background: none; box-shadow: none; }
.fe-fiche-cadre--effet .fe-effet { height: 100%; }
.fe-salle--galerie, .fe-vitrine--effets { align-items: stretch; }
.g3-large { display: none; }
@media (min-width: 700px) { .g3-large { display: inline; } .g3-haut { padding: 12px 16px 6px; } .g3-fleche--g { left: 14px; } .g3-fleche--d { right: 14px; } }
@media (min-width: 1000px) {
  .fe-salle--galerie { grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); }
  .fe-vitrine--effets { grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); }
  .fe-vitrine--effets > .fe-pied-galerie { grid-column: 1 / -1; }
  .fe-fiche-cadre { align-self: stretch; display: grid; align-content: center; }
  .fe-fiche-cadre--effet .fe-effet, .fe-fiche-cadre--effet .fe-effet.possedee { grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); }
}
@media (max-width: 699px) {
  .g3-haut { flex-wrap: wrap; }
  .g3-haut .fe-rail { flex-basis: 100%; }
  .g3-haut .fe-outils { flex: 1 1 0; }
  .g3 .g3-titre { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .g3-haut .fe-recherche { flex: 1 1 auto; }
  .g3 .g3-fleche { width: 44px; height: 44px; margin-top: -22px; font-size: 26px; }
  .g3-cartel { font-size: .62rem; padding: 0 6px 1px; }
  .g3-cartels .g3-marque { font-size: .62rem; padding: 1px 5px; }
  .g3[data-mode="repli"] .g3-pieces { padding-inline: 54px; gap: 24px 16px; }
  .fe-pied-galerie { justify-content: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .g3-toile, .g3 .g3-fleche, .g3[data-mode="repli"] .g3-dessin > .fe-carte { transition: none; }
  .g3-eclair.actif { animation: none; }
  .g3[data-mode="repli"] .g3-piece:hover .fe-carte, .g3[data-mode="repli"] .g3-piece:focus-visible .fe-carte { transform: none; }
  .g3[data-mode="attente"]::after { animation: none; }
}
