/* =====================================================================
   SHOP.CSS — Vue Boutique (décor de place de marché + catégories à
   gauche + objets à droite + cadeau quotidien + fenêtres d'achat)

   Structure HTML (dans index.html) :
     <section id="shop-view" class="game-view shop-view">
       .shop-bg / .shop-shade / .shop-particles   -> décor
       .shop-cats                                 -> catégories (gauche)
       .shop-main > .shop-gift + .shop-head + .shop-grid -> droite
     </section>
   Le contenu (boutons, cartes, fenêtres) est généré par js/shop.js.
   Dimensions pensées pour le cadre fixe 1600x900 (voir scale.js).
   ===================================================================== */

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

/* Image de fond de la place de marché (recadrée en "cover", centrée) */
.shop-bg {
  position: absolute; inset: 0;
  background: url('../assets/images/bg-shop.webp') center 40% / cover no-repeat;
}
/* Voile sombre : assombrit la gauche (catégories) et le bas (barre) pour la lisibilité */
.shop-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(6,4,14,.62) 0%, rgba(6,4,14,.26) 20%, rgba(6,4,14,.08) 60%, rgba(6,4,14,.18) 100%),
    linear-gradient(0deg, rgba(6,4,14,.75) 0%, transparent 22%);
}
/* Conteneur des particules dorées (style .scene-particle défini dans scene-fx.css) */
.shop-particles { z-index: 1; }

/* ---------- 2. CATÉGORIES (gauche) ---------- */
.shop-cats {
  position: absolute; left: 40px; top: 150px; z-index: 5;
  display: flex; flex-direction: column; gap: 14px;
}
.shop-cat {
  position: relative; width: 104px; height: 90px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(12, 9, 22, .86);
  border: 1px solid rgba(216, 168, 62, .5);
  /* coins coupés, comme le menu latéral du lobby */
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.shop-cat::before { /* liseré intérieur fin */
  content: ""; position: absolute; inset: 3px; pointer-events: none;
  border: 1px solid rgba(216, 168, 62, .18);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}
.shop-cat-icon { width: 34px; height: 34px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
.shop-cat-label { font: 700 11px "Cinzel", serif; color: var(--cream); letter-spacing: .2px; }
@media (hover: hover) {
  /* Souris uniquement : au doigt il n'y a pas de survol, l'effet resterait "collé" après un appui */
  .shop-cat:hover { transform: translateX(5px); border-color: var(--gold-light); background: rgba(30,20,48,.95); }
}
/* Catégorie sélectionnée : allumée, décalée, avec une petite gemme à droite */
.shop-cat.is-active {
  transform: translateX(8px); border-color: var(--gold-light);
  background: linear-gradient(160deg, rgba(64,34,110,.95), rgba(20,12,40,.95));
  box-shadow: 0 0 18px rgba(216,168,62,.45), inset 0 0 14px rgba(156,90,197,.35);
}
.shop-cat.is-active .shop-cat-label { color: var(--gold-light); }
.shop-cat:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }

/* Contours sombres des icônes SVG (même règle que .side-icon .ol) */
.shop-view .ol, .shop-modal .ol { stroke: var(--void, #090811); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }

/* ---------- 3. ZONE DROITE ---------- */
.shop-main {
  position: absolute; left: 176px; right: 40px; top: 146px; bottom: 152px; z-index: 5;
  display: flex; flex-direction: column; gap: 12px;
}

/* --- 3a. Bandeau "Bonus de la semaine" (ex "Cadeau du jour", passé en hebdomadaire) --- */
.shop-gift {
  flex: none; height: 72px; display: flex; align-items: center; gap: 16px; padding: 0 20px 0 18px;
  background: linear-gradient(90deg, rgba(74,38,120,.9), rgba(20,12,40,.88) 55%, rgba(12,9,22,.88));
  border: 1px solid rgba(216,168,62,.6);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  box-shadow: 0 10px 22px rgba(0,0,0,.4);
}
.shop-gift-art {
  flex: none; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a2a72, #180f3c 60%, #0a0620);
  box-shadow: 0 0 0 2px var(--gold-light), 0 0 0 4px rgba(9,8,17,.9), 0 0 14px 2px rgba(216,168,62,.4);
}
.shop-gift-art svg { width: 30px; height: 30px; }
.shop-gift-text { flex: 1; min-width: 0; }
.shop-gift-text small { display: block; font: 700 10px "Montserrat"; letter-spacing: 1.5px; color: var(--gold-light); }
.shop-gift-text strong { display: block; font: 700 18px "Cinzel", serif; color: var(--cream); margin: 2px 0; }
.shop-gift-text span { font-size: 12px; color: var(--muted); }
.shop-gift-reward { display: flex; align-items: center; gap: 6px; font: 800 20px "Cinzel", serif; color: var(--gold-light); }
.shop-gift-reward svg { width: 34px; height: 34px; }
.shop-gift.is-ready { animation: shop-gift-pulse 2.2s ease-in-out infinite; }
.shop-gift.is-claimed { filter: saturate(.55) brightness(.9); }
@keyframes shop-gift-pulse {
  0%, 100% { box-shadow: 0 10px 22px rgba(0,0,0,.4), 0 0 8px rgba(216,168,62,.25); }
  50%      { box-shadow: 0 10px 22px rgba(0,0,0,.4), 0 0 26px rgba(255,225,138,.6); }
}

/* --- 3b. Titre de la catégorie --- */
.shop-head { flex: none; display: flex; align-items: baseline; gap: 12px; padding-left: 4px; }
.shop-head h2 { margin: 0; font: 800 22px "Cinzel", serif; color: var(--gold-light); text-shadow: 0 2px 8px rgba(0,0,0,.8); letter-spacing: 1px; }
.shop-head span { font-size: 12px; color: var(--muted); text-shadow: 0 1px 4px #000; }

/* --- 3c. Grille d'objets (4 colonnes, défile si jamais il y en a trop) --- */
.shop-grid {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 192px; gap: 12px; align-content: start;
  overflow-y: auto; padding: 2px 6px 6px 2px;
  scrollbar-width: thin; scrollbar-color: rgba(216,168,62,.5) transparent;
}

/* ---------- 4. CARTE D'OBJET ---------- */
.shop-card {
  /* couleur selon la rareté (voir data-rarity plus bas) */
  --accent: #9fb0d0; --glow: rgba(159,176,208,.3);
  position: relative; display: flex; flex-direction: column; gap: 7px; padding: 10px 14px 10px 18px;
  background: linear-gradient(160deg, rgba(26,16,46,.86), rgba(10,7,18,.88));
  border: 1px solid rgba(216,168,62,.3);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  box-shadow: 0 10px 22px rgba(0,0,0,.4);
  transition: transform .2s ease, border-color .2s ease;
}
.shop-card[data-rarity="rare"]      { --accent: #6d97ff; --glow: rgba(109,151,255,.35); }
.shop-card[data-rarity="epic"]      { --accent: #b678ff; --glow: rgba(182,120,255,.4); }
.shop-card[data-rarity="legendary"] { --accent: #ffd76a; --glow: rgba(255,215,106,.45); }
.shop-card::before { /* liseré coloré à gauche = rareté */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--accent), transparent 130%); box-shadow: 0 0 10px var(--glow);
}
.shop-card::after { /* lueur diffuse en haut à droite */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 160px 70px at 100% -10%, var(--glow), transparent 70%);
}
@media (hover: hover) {
  /* Souris uniquement : au doigt il n'y a pas de survol, l'effet resterait "collé" après un appui */
  .shop-card:hover { transform: translateY(-4px); border-color: var(--accent); }
}

.shop-card-top { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.shop-medal { /* médaillon rond de l'icône */
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a2a72, #180f3c 60%, #0a0620);
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(9,8,17,.9), 0 0 10px 1px var(--glow);
}
.shop-medal svg { width: 24px; height: 24px; }
.shop-card h3 { flex: 1; margin: 0; font: 700 14px/1.2 "Cinzel", serif; color: var(--cream); }
.shop-price { /* pastille de prix */
  flex: none; display: flex; align-items: center; gap: 4px; padding: 3px 9px 3px 5px; border-radius: 12px;
  font: 800 12px "Montserrat"; color: #fff; background: linear-gradient(180deg, #a86bff, #6a35b8);
  border: 1px solid rgba(255,225,138,.6); box-shadow: 0 0 8px rgba(156,90,197,.6);
}
.shop-price svg { width: 16px; height: 16px; }
.shop-card p { flex: 1; margin: 0; font-size: 11px; line-height: 1.4; color: var(--muted); position: relative; z-index: 1; }
.shop-card-foot {
  display: flex; align-items: center; justify-content: space-between; padding-top: 7px;
  border-top: 1px solid rgba(216,168,62,.2); position: relative; z-index: 1;
}
.shop-tag { padding: 2px 9px; border-radius: 10px; font: 700 10px "Montserrat"; color: var(--accent); border: 1px solid var(--accent); background: rgba(0,0,0,.3); }
.shop-cd { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.shop-cd svg { width: 12px; height: 12px; }

/* ---------- 5. BOUTONS DORÉS (Acheter / Réclamer / Confirmer) ---------- */
.shop-btn {
  position: relative; z-index: 1; height: 36px; padding: 0 18px;
  font: 800 13px "Cinzel", serif; letter-spacing: .5px; color: #2a1a04; cursor: pointer;
  background: linear-gradient(180deg, #fff1b8, #f5cf4c 45%, #d8a83e);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  box-shadow: 0 0 12px rgba(216,168,62,.4); transition: filter .15s ease, transform .15s ease;
}
@media (hover: hover) {
  /* Souris uniquement : au doigt il n'y a pas de survol, l'effet resterait "collé" après un appui */
  .shop-btn:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
}
.shop-btn:active:not(:disabled) { transform: scale(.96); }
.shop-btn:disabled { cursor: default; filter: grayscale(.9) brightness(.55); box-shadow: none; }
.shop-btn--ghost { /* bouton secondaire (Annuler) */
  color: var(--cream); background: linear-gradient(180deg, rgba(60,40,100,.9), rgba(24,15,44,.95));
  box-shadow: inset 0 0 0 1px rgba(216,168,62,.5);
}
.shop-card .shop-btn { width: 100%; height: 32px; }

/* ---------- 6. FENÊTRES (confirmation d'achat + résultat) ---------- */
.shop-modal { position: absolute; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; }
.shop-modal[hidden] { display: none; }
.shop-modal-backdrop { position: absolute; inset: 0; background: rgba(5,4,10,.78); backdrop-filter: blur(3px); animation: shop-fade .2s ease; }
.shop-modal-panel {
  position: relative; width: 440px; padding: 24px 26px 22px;
  background: linear-gradient(160deg, rgba(34,20,62,.98), rgba(10,8,20,.98));
  border: 1.5px solid var(--gold);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
  box-shadow: 0 0 30px rgba(216,168,62,.3);
  animation: shop-pop .28s cubic-bezier(.2,.9,.3,1.2);
}
.shop-modal-panel.is-shake { animation: shop-shake .4s ease; }
.shop-modal-head { display: flex; align-items: center; gap: 14px; }
.shop-modal-head .shop-medal { width: 56px; height: 56px; }
.shop-modal-head .shop-medal svg { width: 32px; height: 32px; }
.shop-modal-head small { font: 700 10px "Montserrat"; letter-spacing: 1.5px; color: var(--gold-light); text-transform: uppercase; }
.shop-modal-head h3 { margin: 2px 0 0; font: 700 20px "Cinzel", serif; color: var(--cream); }
.shop-modal-desc { margin: 14px 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.shop-qty { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 6px 0 14px; }
.shop-qty button { width: 38px; height: 38px; font: 800 20px "Cinzel"; color: var(--gold-light); background: rgba(60,40,100,.8); border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--gold); transition: transform .12s; }
.shop-qty button:active { transform: scale(.88); }
.shop-qty output { min-width: 54px; text-align: center; font: 800 26px "Cinzel", serif; color: #fff; }
.shop-sum { padding: 10px 14px; margin-bottom: 18px; background: rgba(0,0,0,.35); border: 1px solid rgba(216,168,62,.25); }
.shop-sum div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12.5px; color: var(--muted); }
.shop-sum div b { color: var(--cream); font-weight: 700; }
.shop-sum .is-total b { color: var(--gold-light); font-size: 15px; }
.shop-sum .is-bad b { color: #ff7a8a; }
.shop-modal-actions { display: flex; gap: 12px; }
.shop-modal-actions .shop-btn { flex: 1; }

/* Popup de résultat (succès / erreur) */
.shop-result { text-align: center; padding: 6px 0 0; }
.shop-result-icon { width: 76px; height: 76px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #3a2a72, #180f3c 65%); }
.shop-result-icon svg { width: 38px; height: 38px; }
.shop-result.is-success .shop-result-icon { color: #7dffb0; box-shadow: 0 0 0 3px #7dffb0, 0 0 22px rgba(125,255,176,.55); }
.shop-result.is-error   .shop-result-icon { color: #ff7a8a; box-shadow: 0 0 0 3px #ff7a8a, 0 0 22px rgba(255,122,138,.55); }
.shop-result h3 { margin: 0 0 6px; font: 700 21px "Cinzel", serif; color: var(--cream); }
.shop-result p { margin: 0 0 18px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.shop-result .shop-btn { min-width: 150px; }

/* ---------- 7. ANIMATIONS D'ENTRÉE (uniquement pendant la transition, classe .is-entering) ---------- */
.shop-view.is-entering .shop-bg { animation: shop-bg-in 1.1s cubic-bezier(.22,.61,.36,1) both; }
.shop-view.is-entering .shop-cat { animation: shop-slide-in .5s cubic-bezier(.22,.61,.36,1) both; animation-delay: calc(var(--i) * 70ms + 250ms); }
.shop-view.is-entering .shop-gift { animation: shop-rise .5s ease both; animation-delay: 300ms; }
.shop-view.is-entering .shop-head { animation: shop-rise .5s ease both; animation-delay: 380ms; }
/* Les cartes se rejouent aussi à chaque changement de catégorie (via --base) */
.shop-card { animation: shop-rise .45s ease both; animation-delay: calc(var(--i) * 55ms); }
.shop-view.is-entering .shop-card { animation-delay: calc(var(--i) * 60ms + 450ms); }

@keyframes shop-bg-in    { from { transform: scale(1.08); } to { transform: scale(1); } }
@keyframes shop-slide-in { from { opacity: 0; transform: translateX(-34px); } to { opacity: 1; transform: none; } }
@keyframes shop-rise     { from { opacity: 0; transform: translateY(22px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes shop-fade     { from { opacity: 0; } to { opacity: 1; } }
@keyframes shop-pop      { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: scale(1); } }
@keyframes shop-shake    { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }

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

/* ---------- 8. TRANSITION ENTRE LES VUES (fondu enchaîné, piloté par main.js) ----------
   La nouvelle vue (.is-entering) apparaît par-dessus l'ancienne (.is-leaving) avec un
   léger flou lumineux, puis l'ancienne est retirée. Valable pour toutes les vues. */
.game-view.is-leaving  { z-index: 1; }
.game-view.is-entering { z-index: 2; animation: view-fade-in .65s cubic-bezier(.22,.61,.36,1) both; }
/* Éclat doré qui traverse l'écran pendant le fondu */
.game-views::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(255,225,138,.16), rgba(156,90,197,.10) 45%, transparent 75%);
}
.game-views:has(.is-entering)::after { animation: view-flash .65s ease-out; }
@keyframes view-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes view-flash   { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .game-view.is-entering, .game-views::after { animation: none !important; } }
