/* ===========================================================================
   TCG Vault — COMPONENTS (réutilisables, pilotés par les tokens)
   =========================================================================== */

/* ---- Boutons icône ---- */
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--c-ink-2);
  border: 1px solid var(--c-line); background: var(--c-surface);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.icon-btn:active { background: var(--c-bg-2); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---- Marque ---- */
.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.brand__mark {
  width: 40px; height: 40px; border-radius: var(--r-md); flex: none;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700;
  font-size: var(--fs-14); letter-spacing: .06em;
  color: var(--c-ink); background: var(--c-surface); border: 1.5px solid var(--c-ink);
}
.brand__name { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-18); letter-spacing: .02em; line-height: 1; text-transform: uppercase; }
.brand__name small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--c-ink-3); margin-top: 3px; }

/* ---- Chips (filtres) & onglets ---- */
.chip {
  height: 38px; padding: 0 var(--sp-4); border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-13); font-weight: 600; color: var(--c-ink-2);
  background: var(--c-surface); border: 1px solid var(--c-line);
  white-space: nowrap; transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.chip:active { background: var(--c-bg-2); }
.chip svg { width: 16px; height: 16px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, var(--c-ink-3)); }
.chip__count { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--c-ink-3); }

.chip.is-active {
  color: var(--c-on-ink); background: var(--c-ink-active); border-color: var(--c-ink-active);
}
.chip.is-active .chip__count { color: rgba(246,242,232,.7); }
.chip.is-active .dot { box-shadow: 0 0 0 2px rgba(246,242,232,.25); }

.chip--badge {
  height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-12);
  background: var(--c-brand-soft); border-color: transparent; color: var(--c-brand);
}

/* ---- KPI (stats) ---- */
.kpi {
  min-width: 104px; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--c-surface); border: 1px solid var(--c-line); box-shadow: var(--shadow-inset);
}
.kpi__val { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-22); line-height: 1; letter-spacing: .01em; }
.kpi__val.mono { font-family: var(--font-mono); font-size: var(--fs-18); }
.kpi__lbl { margin-top: var(--sp-1); }
.kpi--accent .kpi__val { color: var(--c-value); }

/* ---- Carte (cadre « Polaroid » + filet de statut) ---- */
.card {
  position: relative; text-align: left; width: 100%;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-left: 3px solid var(--accent, var(--c-line-2));
  border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.card:active { transform: translateY(1px); box-shadow: var(--shadow-1); }

.card__art {
  position: relative; aspect-ratio: 3 / 3.4; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 18%, color-mix(in srgb, var(--accent) 22%, var(--c-surface)) 0%, var(--c-surface) 70%);
  display: grid; place-items: center;
}
.card__art::after { /* guilloché léger dans l'artwork */
  content: ""; position: absolute; inset: 0; opacity: .5;
  background:
    repeating-linear-gradient(45deg,  rgba(124,100,60,.06) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-45deg, rgba(124,100,60,.06) 0 1px, transparent 1px 6px);
}
.card__glyph {
  position: relative; font-family: var(--font-display); font-weight: 700;
  font-size: var(--fs-28); letter-spacing: .04em; color: color-mix(in srgb, var(--accent) 70%, var(--c-ink));
  opacity: .85;
}
/* Image officielle de la carte (recouvre le glyphe ; retirée par onerror si échec) */
.card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 18%; z-index: 1; }
.detail__art .card__img { object-position: center 14%; }
.card__idx {
  position: absolute; top: var(--sp-2); right: var(--sp-2); z-index: 2;
  font-family: var(--font-mono); font-size: var(--fs-11); color: var(--c-ink-3);
}

/* Badge de rareté */
.badge {
  position: absolute; top: var(--sp-2); left: var(--sp-2); z-index: 2;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 3px 7px; border-radius: 5px;
  color: var(--c-surface-2); background: var(--rarity, var(--c-ink-3));
}
.card--common  { --rarity: var(--rarity-common); }
.card--rare    { --rarity: var(--accent); }
.card--premium { --rarity: var(--rarity-premium); }

/* Foil discret (premium uniquement) */
.card__foil { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: .14;
  background: linear-gradient(115deg, transparent 30%, var(--foil-2) 45%, var(--foil-3) 52%, transparent 66%);
  background-size: 250% 250%; transition: opacity var(--dur-3) var(--ease);
}
.card--premium:hover .card__foil, .card--premium:active .card__foil { opacity: .42; }

/* Bandeau-légende */
.card__cap { padding: var(--sp-3) var(--sp-3) var(--sp-3); background: var(--c-surface-2); border-top: 1px solid var(--c-line); }
.card__name { font-size: var(--fs-16); font-weight: 600; text-transform: uppercase; letter-spacing: .01em;
  color: var(--c-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__meta { font-size: var(--fs-12); color: var(--c-ink-3); margin-top: 2px; }
.card__valrow { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-2); }
.card__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-16);
  font-weight: 700; color: var(--accent, var(--c-ink)); }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-2);
  padding-top: var(--sp-2); border-top: 1px dashed var(--c-line); }
.card__cert { font-family: var(--font-mono); font-size: 10px; color: var(--c-ink-3); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__date { font-family: var(--font-mono); font-size: 10px; color: var(--c-ink-3); }
.card__qty { font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 700; color: var(--c-ink-2);
  background: var(--c-bg-2); border-radius: var(--r-pill); padding: 1px 8px; }

/* ---- FAB / bouton + (cercle noir + liseré pointillé) ---- */
.fab {
  position: relative; width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
  background: var(--c-fab); box-shadow: 0 6px 16px rgba(0,0,0,.32);
  transform: translateY(-10px);
}
.fab::after { content: ""; position: absolute; inset: 5px; border: 1.5px dashed rgba(255,255,255,.55); border-radius: 50%; }
.fab svg { width: 22px; height: 22px; }

/* ---- Bouton Filtres pleine largeur (noir) ---- */
.filters-btn {
  width: 100%; height: 48px; margin-bottom: var(--sp-4); border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  background: var(--c-ink-active); color: var(--c-on-ink);
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-14);
  text-transform: uppercase; letter-spacing: .06em;
}
.filters-btn:active { transform: translateY(1px); }
.filters-btn svg { width: 18px; height: 18px; }
.filters-btn__count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-ink);
  font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 700;
}

/* ---- Sceau « registre » filigrane sur l'artwork ---- */
.card__seal {
  position: absolute; right: 8px; bottom: 8px; z-index: 1; width: 38px; height: 38px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 50%;
  pointer-events: none;
}
.card__seal::after {
  content: ""; position: absolute; inset: 5px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

/* ---- Bottom-sheet (filtres, détail) ---- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: rgba(28,26,23,.42); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: var(--app-max);
  background: var(--c-surface); border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-2); padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + var(--safe-bottom));
  max-height: 86vh; overflow-y: auto; animation: sheet-up var(--dur-3) var(--ease);
}
.sheet__grab { width: 40px; height: 4px; border-radius: 4px; background: var(--c-line-2); margin: 0 auto var(--sp-4); }
.sheet__title { font-size: var(--fs-18); margin-bottom: var(--sp-3); }
.sheet__group { padding: var(--sp-3) 0; border-top: 1px solid var(--c-line); }
.sheet__chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.sheet__actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-4); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---- Boutons texte ---- */
.btn { height: 48px; border-radius: var(--r-md); padding: 0 var(--sp-5); font-weight: 700; font-size: var(--fs-14);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.btn--primary { background: var(--c-ink-active); color: var(--c-on-ink); flex: 1; }
.btn--ghost { background: var(--c-surface); border: 1px solid var(--c-line); color: var(--c-ink-2); flex: 1; }

/* ---- Barre de recherche (en-tête déployé) ---- */
.searchbar { display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  height: 44px; padding: 0 var(--sp-3); border-radius: var(--r-md);
  background: var(--c-surface); border: 1px solid var(--c-line-2); }
.searchbar svg { width: 18px; height: 18px; color: var(--c-ink-3); flex: none; }
.searchbar input { flex: 1; border: none; background: none; outline: none; font-size: 16px; }
.searchbar input::placeholder { color: var(--c-ink-3); }
