/* ══════════════════════════════════════════════════════════
   Inventaires (projet + stock global), grille façon MMORPG.
   Toutes les classes sont préfixées inv- : aucun risque de collision.
   ══════════════════════════════════════════════════════════ */

.inv-ov{ position:fixed; inset:0; z-index:1200; background:rgba(0,0,0,.74); display:flex; align-items:center; justify-content:center; padding:18px; }
.inv-app{ width:min(1180px,100%); height:min(860px,92dvh); background:var(--bg2); border:1px solid var(--border);
          border-radius:var(--r-lg); overflow:hidden; display:grid; grid-template-rows:auto 1fr; box-shadow:0 24px 70px rgba(0,0,0,.55); }

.inv-top{ display:flex; align-items:center; gap:10px; padding:10px 14px; background:var(--bg3); border-bottom:1px solid var(--border); flex-wrap:wrap; }
.inv-top h3{ margin:0; font-size:15px; font-family:var(--font-head); }
.inv-top .inv-spacer{ flex:1; }
/* Outils + fermeture restent groupés : quand la barre passe à la ligne, le ✕ suit ses boutons */
.inv-top-right{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.inv-top{ row-gap:6px; }
.inv-search{ background:var(--bg4); border:1px solid var(--border); color:var(--text); border-radius:8px; padding:6px 10px; font-size:12.5px; font-family:inherit; max-width:220px; }
.inv-x{ background:none; border:none; color:var(--text2); font-size:20px; line-height:1; cursor:pointer; padding:4px 8px; border-radius:8px; }
.inv-x:hover{ background:var(--bg4); color:var(--text); }

/* ── deux panneaux : projet | global ── */
.inv-body{ display:grid; grid-template-columns:1fr 1fr; gap:0; min-height:0; }
.inv-pane{ display:grid; grid-template-rows:auto 1fr auto; min-height:0; padding:10px 12px 12px; }
.inv-pane + .inv-pane{ border-left:1px solid var(--border); }
/* Ouvert depuis le profil : le stock global seul, dans une fenetre plus etroite */
.inv-body.inv-solo{ grid-template-columns:1fr; }
.inv-app.inv-solo-app{ width:min(760px,100%); }
.inv-pane-head{ display:flex; align-items:center; gap:8px; margin-bottom:8px; font-size:13px; flex-wrap:wrap; }
.inv-pane-head b{ font-size:13.5px; }
.inv-pane-head .inv-count{ font-size:11.5px; color:var(--text3); }
.inv-grid{ overflow-y:auto; display:grid; grid-template-columns:repeat(auto-fill, minmax(54px, 1fr)); gap:6px; align-content:start; padding:2px; }
.inv-pane-foot{ font-size:11px; color:var(--text3); margin-top:8px; min-height:16px; }

/* ── une case ── */
.inv-cell{ position:relative; aspect-ratio:1; background:var(--bg3); border:1px solid var(--border); border-radius:8px;
           display:flex; align-items:center; justify-content:center; cursor:default; overflow:hidden; }
.inv-cell.drop{ border-color:var(--accent); background:rgba(79,110,247,.14); }
.inv-cell.has{ cursor:grab; }
.inv-cell.has:active{ cursor:grabbing; }
.inv-cell.sel{ box-shadow:0 0 0 2px var(--accent) inset; }
/* Objet PORTÉ : double liseré doré + pastille, visible quelle que soit la rareté */
.inv-cell.equip{ border-color:#f59e0b !important;
  box-shadow:0 0 0 2px rgba(245,158,11,.55) inset, 0 0 10px rgba(245,158,11,.35); }
.inv-cell.equip.sel{ box-shadow:0 0 0 2px rgba(245,158,11,.55) inset, 0 0 0 2px var(--accent); }
.inv-eq{ position:absolute; left:3px; top:2px; font-size:9.5px; font-weight:800; color:#f59e0b;
         text-shadow:0 1px 3px rgba(0,0,0,.9); pointer-events:none; }
.inv-cell.dim{ opacity:.25; }
.inv-ico{ font-size:24px; line-height:1; pointer-events:none; }
.inv-cell img{ width:82%; height:82%; object-fit:contain; pointer-events:none; }
.inv-qty{ position:absolute; right:3px; bottom:2px; font-size:10.5px; font-weight:800; color:#fff;
          text-shadow:0 1px 3px rgba(0,0,0,.9); pointer-events:none; }
/* Raretés : liseré coloré, comme dans un jeu */
.inv-cell.r-common{ border-color:#5b6472; }
.inv-cell.r-uncommon{ border-color:#22c55e; box-shadow:0 0 8px rgba(34,197,94,.18) inset; }
.inv-cell.r-rare{ border-color:#3b82f6; box-shadow:0 0 8px rgba(59,130,246,.22) inset; }
.inv-cell.r-epic{ border-color:#a855f7; box-shadow:0 0 10px rgba(168,85,247,.26) inset; }
.inv-cell.r-legendary{ border-color:#f59e0b; box-shadow:0 0 12px rgba(245,158,11,.30) inset; }

/* ── fiche de l'objet sélectionné ── */
.inv-detail{ border-top:1px solid var(--border); padding:10px 14px 12px; background:var(--bg3); display:flex; gap:12px; align-items:flex-start; flex-wrap:wrap; }
/* Pastille d'icone, utilisee dans la fiche, le catalogue, les recettes et la liste des membres.
   Regle GLOBALE (pas seulement dans .inv-detail) : sinon l'image garde sa taille naturelle et deborde. */
.inv-d-ico{ width:46px; height:46px; flex:0 0 auto; border-radius:8px; background:var(--bg4);
  display:inline-flex; align-items:center; justify-content:center; font-size:26px; overflow:hidden; }
.inv-d-ico img{ width:100%; height:100%; object-fit:cover; border-radius:8px; display:block; }
.inv-d-main{ flex:1; min-width:180px; }
.inv-d-name{ font-weight:700; font-size:14px; }
.inv-d-meta{ font-size:11.5px; color:var(--text3); margin-top:2px; }
.inv-d-desc{ font-size:12.5px; color:var(--text2); margin-top:5px; white-space:pre-wrap; }
.inv-d-act{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.inv-d-act input[type=number]{ width:86px; }
.r-common{ color:#9aa3b2; } .r-uncommon{ color:#22c55e; } .r-rare{ color:#3b82f6; }
.r-epic{ color:#a855f7; } .r-legendary{ color:#f59e0b; }

/* ── catalogue / donner (gestion) ── */
.inv-cat-row{ display:flex; align-items:center; gap:10px; padding:7px 10px; background:var(--bg3); border:1px solid var(--border); border-radius:var(--r-sm); margin-bottom:6px; }
.inv-cat-row .inv-d-ico{ width:34px; height:34px; font-size:20px; }
.inv-cat-row{ overflow:hidden; }                       /* un nom tres long ne pousse pas les boutons dehors */
.inv-cat-row > div, .inv-cat-row > b{ min-width:0; overflow:hidden; text-overflow:ellipsis; }
.inv-cat-row b{ font-size:13px; }

/* ── téléphone : les deux inventaires l'un sous l'autre ── */
@media (max-width:820px){
  .inv-ov{ padding:0; }
  .inv-app{ width:100%; height:100dvh; border-radius:0; border:none; }
  .inv-body{ grid-template-columns:1fr; overflow-y:auto; }
  .inv-pane + .inv-pane{ border-left:none; border-top:1px solid var(--border); }
  .inv-grid{ grid-template-columns:repeat(auto-fill, minmax(48px, 1fr)); max-height:44dvh; }
  .inv-detail{ position:sticky; bottom:0; }
}

/* ── Atelier de craft : l'objet fabriqué au centre, les ingrédients tout autour ── */
.inv-craft-pane{ grid-template-rows:minmax(0,1fr) auto; min-height:0; }
.inv-craft-board{ position:relative; width:100%; max-width:420px; aspect-ratio:1; margin:0 auto; align-self:center; }
.inv-craft-center{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  width:88px; height:88px; border-radius:14px; background:var(--bg3); border:2px solid var(--border2);
  display:flex; align-items:center; justify-content:center; }
.inv-craft-center img{ width:78%; height:78%; object-fit:contain; }
.inv-craft-cell{ position:absolute; transform:translate(-50%,-50%); width:52px; height:52px; border-radius:9px;
  background:var(--bg3); border:1px solid var(--border); display:flex; align-items:center; justify-content:center; }
.inv-craft-cell img{ width:78%; height:78%; object-fit:contain; }
.inv-craft-cell.manque{ opacity:.45; border-style:dashed; }
.inv-craft-info{ padding-top:10px; }
.inv-craft-empty{ font-size:12.5px; color:var(--text3); text-align:center; padding:30px 10px; }
.inv-craft-list .inv-recipes{ overflow-y:auto; display:flex; flex-direction:column; gap:6px; }
.inv-recipe{ display:flex; align-items:center; gap:10px; width:100%; text-align:left; cursor:pointer;
  background:var(--bg3); border:1px solid var(--border); border-radius:var(--r-sm); padding:7px 10px; color:var(--text); font-family:inherit; }
.inv-recipe:hover{ border-color:var(--border2); }
.inv-recipe.on{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.inv-recipe.lock{ opacity:.55; }
.inv-recipe .inv-d-ico{ width:32px; height:32px; font-size:19px; }

/* ── Cadre d'avatar ── */
.ch-av-wrap{ position:relative; display:inline-block; line-height:0; }
.ch-av-wrap > img.ch-av{ border-radius:50%; object-fit:cover; display:block; }
/* Le cadre est dessiné DERRIÈRE l'avatar : il déborde tout autour, et un cadre dont le centre
   n'est pas transparent ne masque plus la photo. */
/* Sélecteurs volontairement précis : « .avatar img » de app.css impose sinon 100% de largeur. */
.ch-av-frame, .avatar > img.ch-av-frame, .ch-av-wrap > img.ch-av-frame,
.member-avatar > img.ch-av-frame, .profile-avatar > img.ch-av-frame{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  width:152%; height:152%; max-width:none; object-fit:contain; pointer-events:none; z-index:0; border-radius:0; }
.ch-av-wrap > img.ch-av{ position:relative; z-index:1; }
.avatar > img:not(.ch-av-frame){ position:relative; z-index:1; }
/* Communaute et profil : ces pastilles rognent normalement leur contenu (overflow:hidden),
   ce qui couperait le cadre. On ouvre le debordement UNIQUEMENT quand un cadre est porte,
   et on arrondit l'avatar lui-meme puisque le rognage ne le fait plus. */
.member-avatar.has-frame, .profile-avatar.has-frame{ overflow:visible; position:relative; }
.member-avatar.has-frame > img:not(.ch-av-frame),
.profile-avatar.has-frame > img:not(.ch-av-frame){ border-radius:50%; position:relative; z-index:1; }
.member-avatar.has-frame > span, .profile-avatar.has-frame > span{ position:relative; z-index:1; }

/* Ecran large : le plateau se cale sur la HAUTEUR disponible, sinon il pousse
   le bouton « Fabriquer » hors de la fenetre sur un ecran peu haut. */
@media (min-width:821px){
  .inv-craft-board{ width:auto; height:100%; max-width:100%; max-height:420px; }
}
/* Et il se resserre encore quand la fenetre est basse */
@media (min-width:821px) and (max-height:820px){
  .inv-craft-board{ max-height:330px; }
  .inv-craft-center{ width:74px; height:74px; }
  .inv-craft-cell{ width:44px; height:44px; }
}
@media (min-width:821px) and (max-height:680px){
  .inv-craft-board{ max-height:246px; }
  .inv-craft-center{ width:60px; height:60px; }
  .inv-craft-cell{ width:36px; height:36px; }
  .inv-craft-info{ padding-top:6px; }
}
@media (max-width:820px){
  .inv-craft-board{ max-width:300px; }
  .inv-craft-center{ width:66px; height:66px; }
  .inv-craft-cell{ width:42px; height:42px; }
}

/* Animation de fabrication : les ingredients convergent vers la forge,
   elle s'embrase, des etincelles partent, puis l'objet obtenu surgit. */
.inv-craft-board.inv-crafting .inv-craft-cell{
  left:50% !important; top:50% !important;
  transform:translate(-50%,-50%) scale(.34) rotate(200deg); opacity:0;
  transition:left .42s cubic-bezier(.5,-0.25,.4,1.35), top .42s cubic-bezier(.5,-0.25,.4,1.35),
             transform .44s ease-in, opacity .30s ease-in .16s; }
.inv-craft-board.inv-crafting .inv-craft-center{ animation:inv-forge .92s ease-out; }
@keyframes inv-forge{
  0%{   transform:translate(-50%,-50%) scale(1); }
  42%{  transform:translate(-50%,-50%) scale(.9) rotate(-5deg); box-shadow:0 0 0 0 rgba(245,158,11,0); }
  58%{  transform:translate(-50%,-50%) scale(1.24) rotate(4deg); filter:brightness(1.85);
        box-shadow:0 0 30px 12px rgba(245,158,11,.55); border-color:#f59e0b; }
  78%{  transform:translate(-50%,-50%) scale(.97); filter:brightness(1.15);
        box-shadow:0 0 18px 4px rgba(245,158,11,.28); }
  100%{ transform:translate(-50%,-50%) scale(1); filter:none; box-shadow:0 0 0 0 rgba(245,158,11,0); } }
/* onde de choc */
.inv-craft-board.inv-crafting::after{
  content:''; position:absolute; left:50%; top:50%; width:86px; height:86px; border-radius:50%;
  border:2px solid rgba(245,158,11,.85); transform:translate(-50%,-50%) scale(.5); opacity:0;
  animation:inv-ring .62s .44s ease-out; pointer-events:none; }
@keyframes inv-ring{
  0%{   opacity:.95; transform:translate(-50%,-50%) scale(.5); }
  100%{ opacity:0;   transform:translate(-50%,-50%) scale(2.7); } }
/* etincelles */
.inv-craft-fx{ position:absolute; inset:0; pointer-events:none; overflow:visible; }
.inv-craft-fx i{ position:absolute; left:50%; top:50%; width:7px; height:7px; margin:-3.5px 0 0 -3.5px;
  border-radius:50%; opacity:0;
  background:radial-gradient(circle at 50% 50%, #fff 0%, #fde68a 35%, #f59e0b 60%, rgba(245,158,11,0) 72%);
  animation:inv-spark .58s ease-out forwards; }
@keyframes inv-spark{
  0%{   opacity:1; transform:rotate(var(--a)) translateX(6px) scale(1.1); }
  100%{ opacity:0; transform:rotate(var(--a)) translateX(var(--d)) scale(.15); } }
/* l'objet obtenu surgit une fois la grille rechargee */
.inv-craft-center.inv-pop{ animation:inv-pop .58s cubic-bezier(.2,1.45,.4,1); }
@keyframes inv-pop{
  0%{   transform:translate(-50%,-50%) scale(.3);  filter:brightness(2.4); }
  60%{  transform:translate(-50%,-50%) scale(1.16); filter:brightness(1.2); }
  100%{ transform:translate(-50%,-50%) scale(1);   filter:none; } }
@media (prefers-reduced-motion:reduce){
  .inv-craft-board.inv-crafting .inv-craft-cell{ transition:none; }
  .inv-craft-board.inv-crafting .inv-craft-center,
  .inv-craft-board.inv-crafting::after,
  .inv-craft-fx i, .inv-craft-center.inv-pop{ animation:none; } }
