@import url('./tokens.css');
@import url('./card.css');
@import url('./opening.css');
@import url('./views.css');

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-block: calc(var(--header-h) + 8px) var(--page-bottom); }
html:has(.modal-back, .zoom-art, .spotlight) { overflow: hidden; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg-0);
  -webkit-font-smoothing: antialiased; overflow-x: hidden; overflow-x: clip; line-height: 1.45; overflow-wrap: anywhere;
}
body::before { /* fond : nébuleuse + grille */
  content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(124, 140, 255, .18), transparent 60%),
    radial-gradient(900px 600px at 110% 10%, rgba(255, 95, 210, .10), transparent 60%),
    radial-gradient(1000px 800px at 50% 120%, rgba(57, 225, 255, .10), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .35;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(ellipse at 50% 30%, #000 10%, transparent 70%);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

/* ===== Navigation ===== */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--header-h); display: flex; align-items: center; gap: clamp(8px, 2vw, 16px);
  padding: var(--safe-top) max(var(--page-gutter), var(--safe-right)) 0 max(var(--page-gutter), var(--safe-left));
  background: rgba(6, 8, 18, .9); backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: .22em; font-size: 15px; white-space: nowrap; }
.brand__mark { width: 30px; height: 30px; flex: none; filter: drop-shadow(0 0 10px rgba(124, 140, 255, .7)); }
.brand span b { color: var(--accent-2); font-weight: 800; }
.nav__links { display: flex; gap: 4px; white-space: nowrap; }
.nav__link {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 14px;
  border-radius: 999px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 1rem;
  transition: color .2s, background .2s;
}
.nav__link:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.nav__link.is-active { color: var(--text); background: rgba(124, 140, 255, .16); box-shadow: inset 0 0 0 1px rgba(124, 140, 255, .35); }
.nav__link .dot { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.nav__right { margin-left: auto; display: flex; min-width: 0; align-items: center; gap: var(--s-3); }
.bits {
  display: inline-flex; min-width: 0; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border-radius: 999px; font-family: var(--font-num); font-weight: 700;
  background: linear-gradient(180deg, rgba(255, 182, 39, .16), rgba(255, 182, 39, .06)); border: 1px solid rgba(255, 182, 39, .35);
  color: #ffe2a3; text-decoration: none; transition: transform .2s var(--ease-back);
}
.bits b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bits.bump { animation: bump .45s var(--ease-back); }
@keyframes bump { 40% { transform: scale(1.14); box-shadow: 0 0 24px rgba(255, 182, 39, .6); } }
.coin { width: 22px; height: 22px; flex: none; }
.charges-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; color: var(--text-2); border: 1px solid var(--line-2); text-decoration: none; }
.charges-pill b { color: var(--text); }
.charges-pill.ready { color: #c9ffe9; border-color: rgba(46, 229, 157, .5); box-shadow: 0 0 16px rgba(46, 229, 157, .25); }
.quests-pill {
  display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 999px;
  color: #d3dcff; background: rgba(124, 140, 255, .13); border: 1px solid rgba(124, 140, 255, .36);
  transition: color .2s, background .2s, box-shadow .2s;
}
.quests-pill:is(:hover, [aria-current="page"]) { color: var(--text); background: rgba(124, 140, 255, .27); box-shadow: 0 0 16px rgba(124, 140, 255, .25); }
.quests-pill[aria-current="page"] { border-color: var(--accent); }
.avatar { --av: var(--accent); width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--av);
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--av) 70%, #fff), var(--av) 45%, color-mix(in srgb, var(--av) 40%, #000));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .12), 0 0 18px color-mix(in srgb, var(--av) 50%, transparent); border: 0; cursor: pointer; padding: 0; }
.avatar svg { width: 64%; height: 64%; }
.avatar--lg { width: 84px; height: 84px; }
.nav .avatar, .nav .bits { min-height: 44px; }
.nav .avatar { width: 44px; }
.menu { position: fixed; right: max(var(--page-gutter), var(--safe-right)); top: var(--header-h); width: 20rem; max-width: calc(100% - var(--safe-left) - var(--safe-right) - 24px); max-height: calc(var(--viewport-h) - var(--header-h) - var(--page-bottom)); overflow: auto; overscroll-behavior: contain; padding: 8px; border-radius: var(--r-md); background: rgba(14, 19, 40, .96); border: 1px solid var(--line-2); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); z-index: 60; }
.menu a, .menu button { display: flex; width: 100%; min-height: 44px; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; text-decoration: none; background: none; border: 0; cursor: pointer; color: var(--text-2); text-align: left; }
.menu svg { flex: none; }
.menu a:hover, .menu button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.toggle { margin-left: auto; width: 38px; height: 22px; border-radius: 99px; background: var(--bg-3); position: relative; transition: background .2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform .25s var(--ease-back), background .2s; }
[aria-checked="true"] .toggle { background: rgba(124, 140, 255, .5); }
[aria-checked="true"] .toggle::after { transform: translateX(16px); background: #fff; }

.tabbar { display: none; }
@media (max-width: 1120px) {
  :root { --nav-h: 104px; }
  .nav { display: grid; grid-template: "brand account" 52px "links links" minmax(0, 1fr) / auto minmax(0, 1fr); row-gap: 0; }
  .brand { grid-area: brand; justify-self: start; }
  .nav__right { grid-area: account; }
  .nav__links { grid-area: links; justify-content: center; padding-bottom: 4px; }
  .nav__link { padding-inline: 10px; }
}
@media (max-width: 560px), (max-width: 980px) and (pointer: coarse) {
  :root { --nav-h: 56px; --tabbar-h: calc(61px + var(--safe-bottom)); }
  .nav { display: flex; }
  .nav__links, .charges-pill { display: none; }
  .menu { width: 270px; right: max(12px, var(--safe-right)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    padding: 6px max(6px, var(--safe-right)) calc(6px + var(--safe-bottom)) max(6px, var(--safe-left)); background: rgba(6, 8, 18, .94); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; font-size: clamp(10px, 3vw, 12px); line-height: 1.2; text-align: center; color: var(--text-2); text-decoration: none; border-radius: 12px; position: relative; min-height: 48px; justify-content: center; }
  .tabbar a.is-active { color: var(--text); background: rgba(124, 140, 255, .14); }
  .tabbar a.tab--main { color: #fff; }
  .tabbar a.tab--main svg { filter: drop-shadow(0 0 8px var(--accent-2)); }
  .tabbar svg { width: 22px; height: 22px; }
  @media (max-height: 480px) and (min-width: 500px) {
    :root { --nav-h: 52px; --tabbar-h: calc(53px + var(--safe-bottom)); }
    .tabbar { padding-block: 4px calc(4px + var(--safe-bottom)); }
    .tabbar a { min-height: 44px; flex-direction: row; gap: 4px; }
    .tabbar svg { width: 18px; height: 18px; flex: none; }
  }
}
@media (max-width: 420px) {
  .nav__right { gap: 8px; }
  .brand { gap: 6px; font-size: 13px; letter-spacing: .14em; }
  .bits { padding: 6px 8px; }
}
@media (max-width: 360px) {
  .nav, .nav__right { gap: 6px; }
  .brand { font-size: 12px; letter-spacing: .11em; }
  .brand__mark { width: 26px; height: 26px; }
  .bits { gap: 5px; padding-inline: 6px; }
}
/* ===== Layout & primitives ===== */
main { max-width: 1280px; margin: 0 auto; padding: var(--page-top) max(var(--page-gutter), var(--safe-right)) max(var(--s-6), var(--page-bottom)) max(var(--page-gutter), var(--safe-left)); min-height: calc(var(--viewport-h) - var(--header-h)); }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head > *, .row > *, .grid > * { min-width: 0; max-width: 100%; }
.eyebrow { font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--accent-2); font-weight: 700; }
h1, h2, h3 { margin: 0; line-height: 1.1; letter-spacing: .01em; }
h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; }
h2 { font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--text-2); } .dim { color: var(--text-3); }
.glass { background: var(--glass); border: 1px solid var(--glass-brd); border-radius: var(--r-lg); backdrop-filter: blur(14px); }
.panel { padding: clamp(14px, 3vw, 24px); }
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  --b: var(--accent); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px;
  border-radius: 14px; border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .05); color: var(--text); font-weight: 700; letter-spacing: .02em;
  max-width: 100%; cursor: pointer; text-align: center; text-decoration: none; transition: transform .15s var(--ease-out), background .2s, box-shadow .2s, border-color .2s; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn svg, .chip svg { flex: none; }
.btn:hover { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .22); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn--primary {
  border: 0; color: #050714; background: linear-gradient(135deg, #8ff0ff, var(--accent-2) 40%, var(--accent)); box-shadow: 0 8px 30px rgba(57, 225, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.btn--primary:hover { background: linear-gradient(135deg, #b5f6ff, #6fe9ff 40%, #98a5ff); box-shadow: 0 10px 40px rgba(57, 225, 255, .45); }
.btn--gold { border: 0; color: #2a1600; background: linear-gradient(135deg, #fff1c1, var(--gold) 45%, #ff8a00); box-shadow: 0 8px 30px rgba(255, 182, 39, .35), inset 0 1px 0 rgba(255, 255, 255, .7); }
.btn--gold:hover { background: linear-gradient(135deg, #fff7db, #ffd06a 45%, #ff9a19); }
.btn--danger { border-color: rgba(255, 93, 115, .4); color: #ffc2cb; }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn--xl { min-height: 64px; padding: 16px 36px; font-size: 19px; border-radius: 20px; letter-spacing: .06em; text-transform: uppercase; }
.btn--icon { width: 44px; padding: 0; }
.btn .kbd { flex: none; white-space: nowrap; font-size: 11px; opacity: .6; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .03); color: var(--text-2); font-size: 13px; cursor: pointer; min-height: 34px; transition: all .15s; }
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); }
.chip[aria-pressed="true"] { color: var(--text); background: rgba(var(--rgb, 124, 140, 255), .18); border-color: rgba(var(--rgb, 124, 140, 255), .6); box-shadow: 0 0 14px rgba(var(--rgb, 124, 140, 255), .25); }
.input, select.input { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(4, 6, 16, .6); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 140, 255, .2); }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
@media (max-width: 640px), (pointer: coarse) {
  .input { font-size: max(16px, 1rem); }
  .btn--sm, .chip { min-height: 44px; }
}
@media (max-width: 560px), (max-width: 980px) and (pointer: coarse) {
  .btn--xl { min-height: 48px; padding: 10px 16px; font-size: 1rem; }
}
@media (pointer: coarse) { .btn .kbd { display: none; } }
button, .gv-card[role="button"], .tabbar a { touch-action: manipulation; }

.progress { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 12px rgba(57, 225, 255, .5); transition: width .8s var(--ease-out); }
.progress--gold > i { background: linear-gradient(90deg, #ff8a00, var(--gold), #fff1c1); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.badge--new { background: linear-gradient(135deg, #8ff0ff, var(--accent-2)); color: #031018; box-shadow: 0 0 14px rgba(57, 225, 255, .6); }
.badge--dup { background: rgba(255, 255, 255, .1); color: var(--text-2); border: 1px solid var(--line-2); }

/* ===== Toasts & modales ===== */
.toasts { position: fixed; z-index: 200; right: max(12px, var(--safe-right)); bottom: var(--page-bottom); display: grid; gap: 8px; width: 380px; max-width: calc(100% - max(12px, var(--safe-left)) - max(12px, var(--safe-right))); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 14px; background: rgba(14, 19, 40, .96); border: 1px solid var(--line-2); box-shadow: 0 16px 40px rgba(0, 0, 0, .45); display: flex; gap: 10px; align-items: start; animation: toastIn .35s var(--ease-back); }
.toast--ok { border-color: rgba(46, 229, 157, .45); } .toast--err { border-color: rgba(255, 93, 115, .5); } .toast--gold { border-color: rgba(255, 182, 39, .6); box-shadow: 0 0 30px rgba(255, 182, 39, .25); }
.toast.out { animation: toastOut .25s forwards; }
@keyframes toastIn { from { transform: translateY(16px) scale(.96); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }
.modal-back {
  position: fixed; inset: 0; z-index: 120; background: rgba(2, 3, 8, .72); backdrop-filter: blur(8px); display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; animation: fade .25s; overflow: hidden;
  padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-bottom)) max(12px, var(--safe-left));
}
.modal { width: min(960px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; animation: modalIn .4s var(--ease-out); }
.modal__close { flex: none; align-self: flex-end; margin: 6px 6px 0; }
.modal__content { min-height: 0; overflow: auto; overscroll-behavior: contain; }
@keyframes fade { from { opacity: 0; } }
@keyframes modalIn { from { transform: translateY(20px) scale(.97); opacity: 0; } }

/* ===== États ===== */
.state { display: grid; place-items: center; text-align: center; gap: 12px; padding: var(--s-8) var(--s-4); color: var(--text-2); }
.state svg { width: 64px; height: 64px; opacity: .7; }
.skeleton { background: linear-gradient(90deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .09), rgba(255, 255, 255, .04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--accent-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view-enter { animation: viewIn .45s var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } }

/* ===== Mode animations réduites ===== */
html.reduced *, html.reduced *::before, html.reduced *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 80ms !important; }
@media (prefers-reduced-motion: reduce) { html:not(.motion-ok) *, html:not(.motion-ok) *::before, html:not(.motion-ok) *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 80ms !important; } }
