@import url('tokens.css');

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night-900);
  color: var(--paper-2);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
a { color: var(--gold-400); text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- Shell ---------- */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--header-h) 1fr var(--tabbar-h);
  grid-template-areas: "top" "main" "tabs";
  background:
    radial-gradient(circle at 50% 30%, rgba(38, 45, 82, .55), transparent 65%),
    var(--night-900);
}
.top {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--night-line);
  background: rgba(11, 13, 24, .8);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 24px; color: var(--paper-2); }
.brand img { width: 28px; height: 28px; }
.page-title { display: none; font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.balance {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 13px;
  background: rgba(20, 24, 43, .7);
  box-shadow: inset 0 0 0 1px var(--night-line-2);
  padding: 6px 12px; border-radius: var(--radius-pill);
}
.balance .coin { width: 17px; height: 17px; background: url(../assets/wc-piece-gold.svg) center/contain no-repeat; }
.balance.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.12); box-shadow: inset 0 0 0 1px var(--gold-400), 0 0 14px rgba(226, 190, 106, .5); } }

main { grid-area: main; min-height: 0; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; display: none; }
.view.active { display: flex; }
.view-scroll { overflow-y: auto; }

/* ---------- Navigation ---------- */
.side { display: none; }
.tabbar {
  grid-area: tabs;
  display: flex; justify-content: space-around; align-items: stretch;
  border-top: 1px solid var(--night-line);
  background: rgba(11, 13, 24, .92);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font-size: 11px; letter-spacing: .02em;
  min-width: 44px; min-height: 44px;
}
.nav-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item[aria-current="page"] { color: var(--gold-400); }
.nav-item:focus-visible { outline: 2px solid var(--gold-400); outline-offset: -3px; border-radius: 10px; }

.more-sheet {
  position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 50;
  display: none; flex-direction: column; gap: 4px; padding: 10px 12px;
  background: var(--night-800); border-top: 1px solid var(--night-line-2);
  border-radius: 18px 18px 0 0; box-shadow: 0 -20px 40px rgba(0, 0, 0, .5);
}
.more-sheet.open { display: flex; }
.more-sheet .nav-item { flex-direction: row; justify-content: flex-start; gap: 14px; padding: 12px 14px; font-size: 16px; border-radius: 12px; }
.more-sheet .nav-item[aria-current="page"] { background: rgba(226, 190, 106, .08); }

/* ---------- Pages à venir ---------- */
.soon {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  text-align: center; padding: 24px;
}
.soon .piece { width: 72px; height: 72px; background: url(../assets/wc-piece-violet.svg) center/contain no-repeat; opacity: .9; }
.soon h2 { margin: 0; font-family: var(--font-display); font-size: 36px; font-weight: 600; }
.soon p { margin: 0; color: var(--muted); max-width: 32ch; }
.soon .tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; color: var(--gold-400); box-shadow: inset 0 0 0 1px var(--gold-500); padding: 4px 10px; border-radius: var(--radius-pill); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px); transform: translate(-50%, 20px);
  background: var(--night-800); color: var(--paper-2);
  box-shadow: inset 0 0 0 1px var(--wine), 0 10px 30px rgba(0, 0, 0, .5);
  padding: 10px 18px; border-radius: var(--radius-pill); font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Desktop : barre latérale ---------- */
@media (min-width: 860px) {
  .app {
    grid-template-columns: var(--side-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas: "side top" "side main";
  }
  .tabbar, .more-sheet { display: none !important; }
  .side {
    grid-area: side; display: flex; flex-direction: column; gap: 4px;
    padding: 18px 12px; background: var(--night-800); border-right: 1px solid var(--night-line);
  }
  .side .brand { padding: 4px 10px 18px; }
  .side .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; padding: 11px 12px; font-size: 16px; border-radius: 12px; }
  .side .nav-item:hover { background: rgba(255, 255, 255, .04); color: var(--paper-2); }
  .side .nav-item[aria-current="page"] { background: rgba(226, 190, 106, .1); box-shadow: inset 3px 0 0 var(--gold-400); }
  .top .brand { display: none; }
  .page-title { display: block; }
}

/* ---------- Gain de wikipuzzle (portefeuille) ---------- */
.gain-ring { position: fixed; z-index: 200; width: 28px; height: 28px; border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 2px var(--gold-400), 0 0 14px rgba(226, 190, 106, .8); }
.gain-float { position: fixed; z-index: 201; pointer-events: none; font-family: var(--font-mono); font-size: 16px; font-weight: 500; color: var(--gold-300); text-shadow: 0 0 10px rgba(226, 190, 106, .9), 0 1px 0 rgba(0, 0, 0, .6); }
.coin-fly { position: fixed; z-index: 190; pointer-events: none; filter: drop-shadow(0 0 8px var(--glow, rgba(255, 214, 120, .9))); }
.coin-fly .coin-body {
  position: absolute; inset: 0;
  -webkit-mask: url(../assets/wc-piece-gold.svg) center / contain no-repeat; mask: url(../assets/wc-piece-gold.svg) center / contain no-repeat;
}
.coin-spark { position: fixed; z-index: 189; width: 6px; height: 6px; border-radius: 50%; pointer-events: none; background: #FFE6A3; box-shadow: 0 0 6px 2px rgba(226, 190, 106, .8); }

/* ---------- En-tête : collection + solde ---------- */
.hud { display: flex; align-items: center; gap: 8px; }
.collection-btn {
  display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 13px; color: var(--paper-2);
  background: rgba(20, 24, 43, .7); box-shadow: inset 0 0 0 1px var(--night-line-2); padding: 6px 12px 6px 10px; border-radius: var(--radius-pill);
  transition: box-shadow .2s, background .2s;
}
.collection-btn:hover { box-shadow: inset 0 0 0 1px var(--gold-500); background: rgba(26, 31, 56, .9); }
.collection-btn:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }
.collection-btn .coll-ico { width: 18px; height: 18px; fill: none; stroke: var(--gold-400); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.collection-btn.bump { animation: bump .5s ease; }
