/* Suivi Turbo Attax — dense, lisible, et lisible d'un coup d'œil.
   Pas de framework : la grille fait tout le travail. */

:root {
  --bg: #14161a;
  --bg-alt: #1c1f26;
  --bg-card: #21252d;
  --bg-card-hover: #2a2f39;
  --fg: #e6e8ec;
  --fg-dim: #9aa3b2;
  --fg-faint: #6b7484;
  --line: #2e333d;
  --accent: #4ea3ff;
  --accent-dim: #2b6cb0;
  --have: #3fbf6f;
  --dup: #d99e3a;
  --rare: #b47bf0;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-alt: #fff;
    --bg-card: #fff;
    --bg-card-hover: #eef2f7;
    --fg: #1a1d23;
    --fg-dim: #5a6270;
    --fg-faint: #8b94a3;
    --line: #dde1e8;
    --accent: #1668c4;
    --accent-dim: #a8c8ea;
    --have: #1e8a4c;
    --dup: #b8791a;
    --rare: #7b3fc4;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 64px;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- en-tête ---------- */

header#top {
  display: flex; flex-wrap: wrap; gap: 20px;
  align-items: flex-end; justify-content: space-between;
  padding: 18px 0 12px;
}

h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.meta { margin: 2px 0 0; color: var(--fg-dim); font-size: 12px; }

.progress { min-width: 320px; flex: 1 1 320px; max-width: 560px; }

.bar {
  height: 8px; background: var(--bg-alt);
  border: 1px solid var(--line); border-radius: 99px; overflow: hidden;
}
.fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--have));
  transition: width .18s ease;
}

.nums { margin: 6px 0 2px; font-family: var(--mono); font-size: 14px; }
.nums strong { font-size: 18px; }
.pct { color: var(--fg-dim); margin-left: 4px; }

.legend {
  margin: 0; display: flex; flex-wrap: wrap; gap: 14px;
  color: var(--fg-dim); font-size: 11.5px; font-family: var(--mono);
}
.legend b { color: var(--fg); font-weight: 600; }

/* ---------- barre d'outils ---------- */

nav#bar-tools {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); margin-bottom: 10px;
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
}

.field { display: flex; }
.field input, .field select {
  font: inherit; color: var(--fg); background: var(--bg-alt);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 9px; height: 32px;
}
.field input:focus-visible, .field select:focus-visible,
button:focus-visible, .card:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
#search { width: 340px; max-width: 100%; }

.check {
  display: flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-alt); cursor: pointer; user-select: none;
  font-size: 13px; white-space: nowrap;
}
.check input { margin: 0; accent-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent-dim); color: var(--accent); }

button.ghost {
  font: inherit; color: var(--fg-dim); background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius);
  height: 32px; padding: 0 10px; cursor: pointer; margin-left: auto;
}
button.ghost:hover { color: var(--fg); border-color: var(--fg-faint); }

/* ---------- identité ---------- */

/* Le même aspect que button.ghost, pour le lien de déconnexion. */
.identity { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.identity a.ghost {
  display: inline-flex; align-items: center;
  font: inherit; font-size: 12px; text-decoration: none;
  color: var(--fg-dim); background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius);
  height: 32px; padding: 0 10px;
}
.identity a.ghost:hover { color: var(--fg); border-color: var(--fg-faint); }
.me-pic { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.me-name {
  max-width: 22ch; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 12px; color: var(--fg-dim);
}

/* ---------- page de connexion ---------- */

.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-box {
  width: 100%; max-width: 360px; text-align: center;
  padding: 32px 28px;
  background: var(--bg-card);
  border: 1px solid var(--line); border-radius: 10px;
}
.login-box h1 { margin: 0; font-size: 20px; }
.login-sub { margin: 4px 0 24px; color: var(--fg-faint); font-size: 12px; }
.login-error {
  margin: 0 0 20px; padding: 10px 12px;
  background: color-mix(in srgb, var(--dup) 12%, transparent);
  border: 1px solid var(--dup); border-radius: var(--radius);
  font-size: 12px; color: var(--fg); text-align: left;
}
.login-note { margin: 14px 0 0; color: var(--fg-faint); font-size: 11px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-alt);
  color: var(--fg); font-size: 14px; text-decoration: none;
}
.google-btn:hover { border-color: var(--fg-faint); background: var(--bg-card-hover); }

/* ---------- état ---------- */

.status {
  margin: 0 0 10px; min-height: 16px;
  color: var(--fg-faint); font-size: 11.5px; font-family: var(--mono);
}
.status.error { color: #e2685f; }

.empty { color: var(--fg-dim); padding: 40px 0; text-align: center; }

/* ---------- grille ---------- */

.grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}

.card {
  position: relative;
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 8px 7px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer; min-height: 62px;
  user-select: none;
}
.card:hover { background: var(--bg-card-hover); }
.card.owned { border-left-color: var(--have); }
.card.dup   { border-left-color: var(--dup); }
.card.sel   { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.goal  { border-left-color: color-mix(in srgb, var(--have) 45%, var(--line)); }

.code {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; color: var(--fg-faint);
}
.code .no { color: var(--fg-dim); font-weight: 600; }

.qty {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  color: #0d1a12; background: var(--have);
  border-radius: 99px; padding: 0 6px; min-width: 17px; text-align: center;
}
.qty.dup { background: var(--dup); }

.name {
  font-size: 12.5px; font-weight: 550; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sub {
  font-family: var(--mono); font-size: 9.5px; color: var(--fg-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card.owned .name { color: var(--fg); }

/* pastilles de rareté */
.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.chip {
  font-family: var(--mono); font-size: 9.5px; line-height: 1;
  padding: 2px 4px; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--fg-faint);
}
.chip:hover { border-color: var(--fg-dim); color: var(--fg); }
.chip[data-rarity="base"] { display: none; }
.chip.on { color: #12101a; border-color: transparent; font-weight: 700; }
.chip.on[data-rarity="green"]  { background: #2f9e4f; }
.chip.on[data-rarity="gold"]   { background: #d9a531; }
.chip.on[data-rarity="orange"] { background: #dd8034; }
.chip.on[data-rarity="red"]    { background: #d0453c; }
.chip.on[data-rarity="1of1"]   { background: var(--rare); }

/* visuel facultatif */
.thumb { display: none; }
body.thumbs .card.has-thumb .thumb {
  display: block; width: 100%; height: 92px; object-fit: contain;
  margin: 2px 0 3px; background: var(--bg-alt); border-radius: 3px;
}

/* ---------- aperçu de la carte sélectionnée ---------- */

/* Les visuels disponibles plafonnent à 240 px de haut : ils ne sont
   lisibles qu'agrandis, d'où un panneau plutôt qu'une vignette par
   carte dans la grille. */
#preview {
  position: fixed; right: 16px; bottom: 44px; z-index: 7;
  display: flex; gap: 10px; align-items: flex-start;
  max-width: 340px; padding: 10px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 28px rgb(0 0 0 / .45);
}
#preview[hidden] { display: none; }
#preview-img {
  width: 110px; height: auto; max-height: 160px; object-fit: contain;
  background: var(--bg-alt); border-radius: 4px;
}
#preview-img:not([src]) { display: none; }
#preview .details { min-width: 0; flex: 1; }
.p-code {
  margin: 0 0 3px; display: flex; gap: 8px; align-items: center;
  font-family: var(--mono); font-size: 11px; color: var(--fg-faint);
}
#p-qty { color: var(--have); font-weight: 700; }
.p-name { margin: 0; font-size: 13px; font-weight: 600; }
.p-team { margin: 2px 0 0; font-size: 11.5px; color: var(--fg-dim); }
.p-subset {
  margin: 3px 0 0; font-family: var(--mono); font-size: 10px;
  color: var(--fg-faint);
}

@media (max-width: 720px) { #preview { display: none !important; } }

/* ---------- pied ---------- */

footer#keys {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 7px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  color: var(--fg-faint); font-size: 11px;
}
kbd {
  font-family: var(--mono); font-size: 10px;
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 3px; padding: 0 4px; background: var(--bg-alt); color: var(--fg-dim);
}
.mouse { margin-left: auto; }

@media (max-width: 720px) {
  #search { width: 100%; }
  footer#keys { font-size: 10px; gap: 9px; }
  .mouse { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
