/* ========================================================================
   PokePack - feuille de style unique, pensee mobile d'abord.
   ======================================================================== */

:root {
  --bg: #0d0718;
  --bg-2: #150d26;
  --surface: #1b1230;
  --surface-2: #241836;
  --surface-3: #2e2046;
  --line: #342548;
  --text: #f2eefa;
  --muted: #a99fc4;
  --dim: #7d7398;

  --accent: #b06cff;
  --accent-2: #7d4dff;
  --gold: #ffc43a;
  --green: #4ade80;
  --red: #ff6b6b;

  --t1: #9aa6b2;
  --t2: #4ec9a7;
  --t3: #4aa3ff;
  --t4: #b06cff;
  --t5: #ffc43a;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(1000px 520px at 50% -10%, #2a1650 0%, transparent 62%),
    radial-gradient(760px 420px at 100% 100%, #1a1140 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100svh;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

/* ------------------------------------------------------------ structure -- */

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--nav-h) + var(--safe-b) + 24px);
  min-height: 100svh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 12px;
  margin: 0 0 14px;
  background: linear-gradient(to bottom, var(--bg) 62%, transparent);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.02em; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }

.wallet {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wallet b { color: var(--gold); font-size: 15px; }

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(16, 10, 30, .93);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--dim);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  transition: color .15s;
}
.nav a.on { color: var(--accent); }
.nav a svg { width: 22px; height: 22px; }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 24px 0 12px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.card-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--green); }
.down { color: var(--red); }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* --------------------------------------------------------------- boutons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 650;
  transition: transform .08s, filter .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(125, 77, 255, .35);
}
.btn.gold {
  background: linear-gradient(135deg, #ffd56b, #e8a21a);
  border-color: transparent;
  color: #2a1a00;
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 107, .35); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 13px; border-radius: 10px; font-size: 13px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.chip.on { background: rgba(176, 108, 255, .2); border-color: var(--accent); color: #e4d4ff; }

.chiprow { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chiprow::-webkit-scrollbar { display: none; }

/* ------------------------------------------------------------ formulaire -- */

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.error {
  background: rgba(255, 107, 107, .12);
  border: 1px solid rgba(255, 107, 107, .35);
  color: #ffc9c9;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ------------------------------------------------------------- extension -- */

.blockname {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 18px 0 8px;
}

.setscroll { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.setscroll::-webkit-scrollbar { display: none; }

.settile {
  flex: 0 0 142px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 11px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  transition: border-color .15s, transform .08s;
}
.settile:active { transform: scale(.98); }
.settile.on { border-color: var(--accent); background: linear-gradient(180deg, rgba(176, 108, 255, .14), var(--surface)); }
.settile .logo { height: 42px; display: grid; place-items: center; }
.settile .logo img { max-height: 42px; width: auto; object-fit: contain; }
.settile .nm { font-size: 12.5px; font-weight: 700; line-height: 1.25; }
.settile .meta { font-size: 11px; color: var(--dim); }

.bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

/* ---------------------------------------------------------------- pochette */

.packs { display: grid; gap: 12px; }

.packcard {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  overflow: hidden;
  text-align: left;
  width: 100%;
}
.packcard.premium { border-color: rgba(255, 196, 58, .4); }
.packcard.premium::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 196, 58, .13) 50%, transparent 65%);
  animation: sweep 3.6s linear infinite;
  pointer-events: none;
}
@keyframes sweep { from { transform: translateX(-60%); } to { transform: translateX(60%); } }

.packmini {
  flex: 0 0 56px;
  height: 78px;
  border-radius: 8px;
  background: linear-gradient(160deg, #3a2170, #1d1140 60%, #120a24);
  border: 1px solid rgba(255, 255, 255, .13);
  display: grid;
  place-items: center;
  padding: 5px;
}
.packmini img { max-width: 100%; max-height: 100%; object-fit: contain; }
.packcard.premium .packmini { background: linear-gradient(160deg, #6b4a12, #2c1d06 60%, #150e02); }

.packname { display: block; font-weight: 750; font-size: 15px; }
.packblurb { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.packprice { margin-left: auto; font-weight: 800; color: var(--gold); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- les cartes -- */

.cardgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
@media (min-width: 520px) { .cardgrid { grid-template-columns: repeat(4, 1fr); } }

.ct { position: relative; border-radius: 9px; overflow: hidden; background: var(--surface-2); aspect-ratio: 245 / 342; }
.ct img { width: 100%; height: 100%; object-fit: cover; }
.ct.missing img { filter: grayscale(1) brightness(.26) contrast(.85); }
.ct .qty {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0, 0, 0, .78);
  border-radius: 6px; padding: 1px 6px;
  font-size: 10.5px; font-weight: 800;
}
.ct .gradebadge {
  position: absolute; left: 4px; bottom: 4px;
  background: rgba(0, 0, 0, .82);
  border-radius: 5px; padding: 1px 5px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .02em;
}
.ct .lock {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 22px; color: rgba(255, 255, 255, .22);
}

/* Effets de variante -------------------------------------------------- */

.shine { position: relative; }
.shine::before {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: screen;
}
.shine::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 3;
  border-radius: inherit;
}

/* Reverse : la zone autour de l'illustration brille */
.v-reverse::before {
  background: linear-gradient(118deg, transparent 38%, rgba(160, 220, 255, .5) 50%, transparent 62%);
  animation: glide 3.4s ease-in-out infinite;
}
.v-reverse::after { box-shadow: inset 0 0 0 2px rgba(127, 212, 255, .55); }

/* Holo : l'illustration brille */
.v-holo::before {
  background:
    linear-gradient(118deg, transparent 32%, rgba(255, 255, 255, .55) 48%, transparent 60%),
    linear-gradient(60deg, rgba(0, 200, 255, .3), rgba(255, 0, 200, .22), rgba(255, 220, 0, .3));
  animation: glide 2.9s ease-in-out infinite;
}
.v-holo::after { box-shadow: inset 0 0 0 2px rgba(89, 176, 255, .6); }

/* Reverse Poke Ball : motifs de Poke Ball dans la brillance */
.v-reverse_pokeball::before {
  background:
    radial-gradient(circle at 20% 25%, rgba(255, 106, 106, .55) 0 7%, transparent 8%),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, .5) 0 6%, transparent 7%),
    radial-gradient(circle at 38% 82%, rgba(255, 106, 106, .45) 0 5%, transparent 6%),
    linear-gradient(118deg, transparent 38%, rgba(255, 255, 255, .45) 50%, transparent 62%);
  animation: glide 3.1s ease-in-out infinite;
}
.v-reverse_pokeball::after { box-shadow: inset 0 0 0 2px rgba(255, 106, 106, .7); }

/* Reverse Master Ball : la piece rare */
.v-reverse_masterball::before {
  background:
    radial-gradient(circle at 25% 30%, rgba(197, 107, 255, .7) 0 8%, transparent 9%),
    radial-gradient(circle at 72% 68%, rgba(255, 255, 255, .6) 0 6%, transparent 7%),
    radial-gradient(circle at 48% 12%, rgba(197, 107, 255, .55) 0 5%, transparent 6%),
    linear-gradient(118deg, transparent 34%, rgba(236, 200, 255, .6) 50%, transparent 64%);
  animation: glide 2.4s ease-in-out infinite;
}
.v-reverse_masterball::after { box-shadow: inset 0 0 0 2.5px rgba(197, 107, 255, .9); }

.v-full_art::after { box-shadow: inset 0 0 0 2.5px rgba(176, 108, 255, .85), 0 0 18px rgba(176, 108, 255, .3); }
.v-alt_art::after { box-shadow: inset 0 0 0 2.5px rgba(255, 122, 209, .85), 0 0 18px rgba(255, 122, 209, .3); }
.v-promo::after { box-shadow: inset 0 0 0 2px rgba(143, 217, 143, .7); }

.v-rainbow::before {
  background: linear-gradient(118deg,
    rgba(255, 0, 120, .3), rgba(255, 200, 0, .3), rgba(0, 230, 160, .3),
    rgba(0, 170, 255, .3), rgba(190, 0, 255, .3));
  animation: glide 4s ease-in-out infinite;
}
.v-rainbow::after { box-shadow: inset 0 0 0 2.5px rgba(94, 242, 208, .85), 0 0 20px rgba(94, 242, 208, .3); }

.v-gold::before {
  background: linear-gradient(118deg, transparent 32%, rgba(255, 226, 140, .65) 50%, transparent 66%);
  animation: glide 2.6s ease-in-out infinite;
}
.v-gold::after { box-shadow: inset 0 0 0 3px rgba(255, 196, 58, .9), 0 0 22px rgba(255, 196, 58, .35); }

@keyframes glide {
  0%, 100% { transform: translateX(-28%) rotate(0deg); opacity: .75; }
  50% { transform: translateX(28%) rotate(0deg); opacity: 1; }
}

/* --------------------------------------------------------- ouverture live -- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(800px 600px at 50% 40%, #241046, #090512 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
  overflow: hidden;
}
.overlay[hidden] { display: none; }

.rip {
  width: min(66vw, 240px);
  aspect-ratio: 63 / 88;
  border-radius: 14px;
  background: linear-gradient(160deg, #46259b, #2a1360 55%, #160b30);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), inset 0 0 50px rgba(255, 255, 255, .06);
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  animation: breathe 2.4s ease-in-out infinite;
}
.rip.premium { background: linear-gradient(160deg, #7a560f, #3c2906 55%, #1b1203); }
.rip img { max-width: 86%; max-height: 60%; object-fit: contain; }
.rip::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .22) 50%, transparent 62%);
  animation: sweep 2.6s linear infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50% { transform: scale(1.035) rotate(1deg); }
}
.rip.tearing { animation: tear .55s cubic-bezier(.3, -0.4, .5, 1.5) forwards; }
@keyframes tear {
  0% { transform: scale(1); }
  35% { transform: scale(1.1) rotate(-3deg); }
  100% { transform: scale(1.5) rotate(6deg); opacity: 0; }
}

.tapHint { margin-top: 22px; color: var(--muted); font-size: 14px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

.stage { position: relative; width: min(74vw, 300px); aspect-ratio: 245 / 342; perspective: 1400px; }

.flip { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, .8, .3, 1); }
.flip.revealed { transform: rotateY(180deg); }
.flip > div {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 13px;
  overflow: hidden;
}
.flip .back {
  background:
    radial-gradient(circle at 50% 42%, #5a3bb8 0 22%, #2f1d73 23% 34%, #241058 35%),
    linear-gradient(160deg, #3b2585, #1d1046);
  border: 3px solid #140a2e;
  display: grid;
  place-items: center;
}
.flip .back::after {
  content: '';
  width: 34%; aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(#ee3a48 0 48%, #140a2e 48% 56%, #f2f3f7 56%);
  box-shadow: 0 0 0 3px #140a2e, 0 0 26px rgba(176, 108, 255, .5);
}
.flip .front { transform: rotateY(180deg); background: #120a24; }
.flip .front img { width: 100%; height: 100%; object-fit: cover; }

.burst {
  position: absolute; inset: -40%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}
.burst.go { animation: burst .85s ease-out forwards; }
@keyframes burst {
  0% { opacity: .85; transform: scale(.3); }
  100% { opacity: 0; transform: scale(1.5); }
}

.revealinfo { margin-top: 18px; text-align: center; min-height: 92px; }
.revealinfo .nm { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.revealinfo .val { font-size: 22px; font-weight: 850; color: var(--gold); font-variant-numeric: tabular-nums; }
.revealinfo .badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 7px; }

.counter {
  position: absolute;
  top: calc(var(--safe-t) + 14px);
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.newtag {
  background: linear-gradient(135deg, #4ade80, #16a34a);
  color: #04240f;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: .04em;
}

.summary { width: 100%; max-width: 440px; }
.summary .grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 14px 0; }
.summary .grid .ct { border-radius: 6px; }

/* ------------------------------------------------------------ feuille bas -- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(5, 2, 12, .72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet .panel {
  width: 100%;
  max-width: 680px;
  max-height: 88svh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(var(--safe-b) + 22px);
  animation: slideup .26s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slideup { from { transform: translateY(16%); opacity: .5; } to { transform: none; opacity: 1; } }
.grabber { width: 38px; height: 4px; border-radius: 4px; background: var(--surface-3); margin: 0 auto 14px; }

.copyrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------ graphiques -- */

.spark { width: 100%; height: 44px; display: block; }
.sparkbig { width: 100%; height: 132px; display: block; }

.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 13px; }
.stat .k { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }

.listrow {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  width: 100%;
  text-align: left;
  background: none;
  border-left: 0; border-right: 0; border-bottom: 0;
}
.listrow:first-of-type { border-top: 0; }
.listrow .thumb { flex: 0 0 38px; height: 53px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.listrow .thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ----------------------------------------------------------------- toasts -- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}
.toast {
  background: rgba(36, 24, 54, .97);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastin .22s ease-out;
}
.toast.ok { border-color: rgba(74, 222, 128, .45); }
.toast.err { border-color: rgba(255, 107, 107, .5); }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- divers -- */

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-3) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty { text-align: center; padding: 44px 18px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .08s !important; }
}
