/* =====================================================================
   INVENTORY.CSS — Vue Inventaire (intérieur d'un coffre en cuir)

   Structure HTML (dans index.html) :
     <section id="inventory-view" class="game-view inventory-view">
       .inv-bg / .inv-glow / .inv-shade / .inv-particles   -> décor
       .inv-detail                                         -> détail de l'objet (panneau de gauche, sur le cuir)
       .inv-main > .inv-tabs + .inv-grid + .inv-foot       -> catégories, emplacements, compteur (à droite)
     </section>
   Le contenu (onglets, emplacements, détail) est généré par js/inventory.js.
   Les fenêtres (utiliser un objet) réutilisent les styles .shop-modal de shop.css.

   Repères sur l'image de fond (1600x900 dans le jeu) :
     - le cuir sombre occupe x 60 -> 515, la sangle verticale x 520 -> 585
     - la partie violette (avec le rai de lumière) occupe x 590 -> 1545
   ===================================================================== */

/* ---------- 1. DÉCOR ---------- */
.inventory-view { overflow: hidden; }

.inv-bg {
  position: absolute; inset: 0;
  background: url('../assets/images/bg-inventory.webp') center / cover no-repeat;
}
/* Rai de lumière de la fenêtre : "respire" doucement pour rendre le décor vivant */
.inv-glow {
  position: absolute; left: 1010px; top: 90px; width: 560px; height: 460px; pointer-events: none;
  background: radial-gradient(ellipse at 62% 45%, rgba(200,160,255,.42), rgba(140,90,220,.16) 50%, transparent 72%);
  mix-blend-mode: screen; animation: inv-breathe 6s ease-in-out infinite;
}
@keyframes inv-breathe { 0%, 100% { opacity: .45; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.05); } }
/* Voile : assombrit le bas (barre de navigation) et le haut (header) pour la lisibilité */
.inv-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(0deg, rgba(6,4,14,.7) 0%, transparent 20%),
    linear-gradient(180deg, rgba(6,4,14,.4) 0%, transparent 16%);
}
.inv-particles { z-index: 1; }

/* Contours sombres des icônes SVG */
.inventory-view .ol, .inv-modal .ol {
  stroke: var(--void, #090811); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round;
}

/* ---------- 2. PANNEAU DE DÉTAIL (à gauche, sur le cuir) ---------- */
.inv-detail {
  position: absolute; left: 74px; top: 150px; width: 424px; height: 600px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.inv-detail-label {
  align-self: stretch; display: flex; align-items: center; gap: 10px;
  font: 700 12px "Montserrat"; letter-spacing: 3px; color: var(--gold-light);
}
.inv-detail-label::before, .inv-detail-label::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(216,168,62,.7)); }
.inv-detail-label::after { transform: scaleX(-1); }

/* Médaillon de l'objet sélectionné */
.inv-medal {
  /* --accent / --glow viennent de data-rarity posé sur .inv-detail (voir plus bas) */
  position: relative; flex: none; width: 150px; height: 150px; margin-top: 6px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a2a72, #180f3c 62%, #0a0620);
  box-shadow: 0 0 0 3px var(--accent, #9fb0d0), 0 0 0 7px rgba(9,8,17,.92), 0 0 30px 6px var(--glow, rgba(159,176,208,.35));
  animation: inv-medal-pop .5s cubic-bezier(.2,.9,.3,1.25) both;
}
.inv-medal::after { /* halo qui pulse */
  content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 2px solid var(--accent, #9fb0d0); opacity: 0;
  animation: inv-halo 2.6s ease-out infinite;
}
.inv-medal svg { width: 84px; height: 84px; filter: drop-shadow(0 3px 4px rgba(0,0,0,.6)); animation: inv-float 3.4s ease-in-out infinite; }
@keyframes inv-medal-pop { from { opacity: 0; transform: scale(.6) rotate(-12deg); } to { opacity: 1; transform: none; } }
@keyframes inv-halo { 0% { opacity: .7; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.22); } }
@keyframes inv-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
/* Couleurs selon la rareté (data-rarity="common|rare|epic|legendary") */
.inventory-view [data-rarity="common"]    { --accent: #9fb0d0; --glow: rgba(159,176,208,.35); }
.inventory-view [data-rarity="rare"]      { --accent: #6d97ff; --glow: rgba(109,151,255,.4); }
.inventory-view [data-rarity="epic"]      { --accent: #b678ff; --glow: rgba(182,120,255,.45); }
.inventory-view [data-rarity="legendary"] { --accent: #ffd76a; --glow: rgba(255,215,106,.5); }

.inv-name { margin: 8px 0 0; font: 800 26px "Cinzel", serif; color: var(--cream); text-shadow: 0 2px 10px rgba(0,0,0,.8); animation: inv-fade .4s ease both; }
.inv-chips { display: flex; gap: 8px; justify-content: center; }
.inv-chip { padding: 3px 12px; border-radius: 12px; font: 700 12px "Montserrat"; border: 1px solid var(--accent, var(--gold)); color: var(--accent, var(--gold-light)); background: rgba(0,0,0,.4); }
.inv-chip--cat { --accent: var(--gold-light); }
.inv-desc { margin: 4px 6px 0; min-height: 60px; font-size: 13px; line-height: 1.55; color: #cdc3e6; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.inv-info { align-self: stretch; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.inv-info div { padding: 8px 4px; background: rgba(6,4,16,.55); border: 1px solid rgba(216,168,62,.3); clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px); }
.inv-info small { display: block; font: 700 12px "Montserrat"; letter-spacing: 1.5px; color: var(--muted); }
.inv-info b { display: block; margin-top: 3px; font: 700 14px "Cinzel", serif; color: var(--cream); }
.inv-use { align-self: stretch; height: 46px; margin-top: auto; font-size: 16px; }
.inv-empty-detail { margin: auto 0; padding: 30px 26px; color: var(--muted); font-size: 13px; line-height: 1.6; border: 1.5px dashed rgba(216,168,62,.4); }
.inv-empty-detail b { display: block; margin-bottom: 8px; font: 700 18px "Cinzel", serif; color: var(--gold-light); }
@keyframes inv-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 3. ZONE DE DROITE : onglets + emplacements + compteur ---------- */
.inv-main { position: absolute; left: 612px; right: 62px; top: 148px; z-index: 5; display: flex; flex-direction: column; gap: 14px; }

/* --- Onglets de catégories --- */
.inv-tabs { display: flex; gap: 8px; }
.inv-tab {
  position: relative; flex: 1; height: 46px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 8px;
  font: 700 12px "Cinzel", serif; color: var(--cream); white-space: nowrap;
  background: rgba(10,7,22,.82); border: 1px solid rgba(216,168,62,.45);
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%, 0 9px);
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.inv-tab svg { width: 20px; height: 20px; flex: none; }
.inv-tab i { min-width: 20px; padding: 1px 6px; border-radius: 9px; font: 800 12px "Montserrat"; font-style: normal; color: #fff; background: rgba(120,70,190,.9); }
@media (hover: hover) {
  /* Souris uniquement : au doigt il n'y a pas de survol, l'effet resterait "collé" après un appui */
  .inv-tab:hover { transform: translateY(-2px); border-color: var(--gold-light); }
}
.inv-tab.is-active { color: var(--gold-light); border-color: var(--gold-light); background: linear-gradient(180deg, rgba(88,48,150,.95), rgba(28,16,52,.95)); box-shadow: 0 0 16px rgba(216,168,62,.4), inset 0 0 12px rgba(156,90,197,.35); }
.inv-tab.is-active::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: 0; height: 3px; background: var(--gold-light); box-shadow: 0 0 8px var(--gold-light); }
.inv-tab:focus-visible, .inv-slot:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

/* --- Grille d'emplacements (8 colonnes) --- */
.inv-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; align-content: start;
  position: relative; max-height: 480px; overflow-y: auto; padding: 4px 6px 6px 2px;
  scrollbar-width: thin; scrollbar-color: rgba(216,168,62,.5) transparent;
}
.inv-slot {
  --accent: #9fb0d0; --glow: rgba(159,176,208,.3);
  position: relative; aspect-ratio: 1; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 30%, rgba(52,32,96,.9), rgba(12,8,26,.92) 75%);
  border: 1.5px solid var(--accent);
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px);
  box-shadow: inset 0 0 16px var(--glow);
  animation: inv-slot-in .4s cubic-bezier(.2,.9,.3,1.2) both; animation-delay: calc(var(--i) * 28ms);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.inv-slot svg { width: 56%; height: 56%; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); transition: transform .2s ease; }
@media (hover: hover) {
  /* Souris uniquement : au doigt il n'y a pas de survol, l'effet resterait "collé" après un appui */
  .inv-slot:hover { transform: translateY(-4px); filter: brightness(1.2); }
}
@media (hover: hover) {
  /* Souris uniquement : au doigt il n'y a pas de survol, l'effet resterait "collé" après un appui */
  .inv-slot:hover svg { transform: scale(1.12) rotate(-4deg); }
}
.inv-qty { position: absolute; right: 5px; bottom: 4px; padding: 0 6px; border-radius: 8px; font: 800 12px "Montserrat"; color: #2a1a04; background: linear-gradient(180deg, #fff1b8, #d8a83e); box-shadow: 0 1px 3px rgba(0,0,0,.6); }
/* Emplacement sélectionné : cadre doré qui pulse */
.inv-slot.is-selected { border-color: var(--gold-light); box-shadow: inset 0 0 18px var(--glow), 0 0 0 2px rgba(255,225,138,.8), 0 0 20px rgba(255,225,138,.55); animation: inv-slot-in .4s cubic-bezier(.2,.9,.3,1.2) both, inv-pulse 1.8s ease-in-out .5s infinite; animation-delay: calc(var(--i) * 28ms), 0s; }
@keyframes inv-pulse { 0%, 100% { box-shadow: inset 0 0 18px var(--glow), 0 0 0 2px rgba(255,225,138,.6), 0 0 12px rgba(255,225,138,.35); } 50% { box-shadow: inset 0 0 18px var(--glow), 0 0 0 2px rgba(255,225,138,.95), 0 0 26px rgba(255,225,138,.7); } }
/* Emplacement vide : creux discret */
.inv-slot.is-empty { border-color: rgba(216,168,62,.16); background: rgba(6,4,16,.4); box-shadow: inset 0 0 14px rgba(0,0,0,.6); animation-name: inv-slot-in-soft; }
@media (hover: hover) {
  /* Souris uniquement : au doigt il n'y a pas de survol, l'effet resterait "collé" après un appui */
  .inv-slot.is-empty:hover { transform: none; filter: none; }
}
@keyframes inv-slot-in      { from { opacity: 0; transform: scale(.6) translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes inv-slot-in-soft { from { opacity: 0; } to { opacity: 1; } }
/* Grille sans animation d'entrée (mise à jour après l'utilisation d'un objet) */
.inv-grid.is-static .inv-slot { animation: none; }
.inv-grid.is-static .inv-slot.is-selected { animation: inv-pulse 1.8s ease-in-out infinite; }
/* Éclat sur l'emplacement qui vient d'être utilisé */
.inv-slot.is-burst::after { content: ""; position: absolute; inset: 0; border: 3px solid var(--gold-light); border-radius: 50%; animation: inv-burst .6s ease-out forwards; pointer-events: none; }
@keyframes inv-burst { from { opacity: 1; transform: scale(.5); } to { opacity: 0; transform: scale(1.9); } }

/* Inventaire vide : message posé sur la grille */
.inv-grid-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; text-align: center; padding: 18px 26px; background: rgba(8,5,18,.9); border: 1px solid rgba(216,168,62,.5); font-size: 13px; color: var(--muted); }
.inv-grid-msg b { display: block; margin-bottom: 6px; font: 700 17px "Cinzel", serif; color: var(--gold-light); }

/* --- Compteur --- */
.inv-foot { display: flex; justify-content: space-between; padding: 0 6px; font: 600 12px "Montserrat"; color: #cdc3e6; text-shadow: 0 1px 4px #000; }
.inv-foot b { color: var(--gold-light); }

/* ---------- 4. FENÊTRE "UTILISER" (styles .shop-modal en plus) ---------- */
.inv-field { display: block; margin: 0 0 14px; }
.inv-field span { display: block; margin-bottom: 6px; font: 700 12px "Montserrat"; letter-spacing: 1.5px; color: var(--gold-light); }
.inv-field input {
  width: 100%; height: 40px; padding: 0 14px; font: 600 14px "Montserrat"; color: var(--cream);
  background: rgba(0,0,0,.45); border: 1px solid rgba(216,168,62,.5); outline: none; transition: border-color .15s, box-shadow .15s;
}
.inv-field input:focus { border-color: var(--gold-light); box-shadow: 0 0 10px rgba(216,168,62,.4); }
.inv-field small { display: block; margin-top: 5px; min-height: 14px; font-size: 12px; color: #ff7a8a; }

/* ---------- 5. ANIMATIONS D'ENTRÉE (pendant la transition, classe .is-entering) ---------- */
.inventory-view.is-entering .inv-bg { animation: shop-bg-in 1.1s cubic-bezier(.22,.61,.36,1) both; }
.inventory-view.is-entering .inv-detail { animation: shop-slide-in .55s cubic-bezier(.22,.61,.36,1) 200ms both; }
.inventory-view.is-entering .inv-tab { animation: inv-drop .45s cubic-bezier(.22,.61,.36,1) both; animation-delay: calc(var(--i) * 60ms + 250ms); }
.inventory-view.is-entering .inv-foot { animation: shop-rise .5s ease 600ms both; }
.inventory-view.is-entering .inv-slot { animation-delay: calc(var(--i) * 28ms + 450ms); }
@keyframes inv-drop { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .inventory-view *, .inv-modal * { animation: none !important; transition: none !important; }
}
