/* css/card.css — LE composant carte (V13.17, refonte : remplace ~350 règles qui étaient dispersées dans six feuilles).

   Trois tailles, une seule règle de mise en page :
     .card-sm  petite  : main de combat. Image, nom, valeurs. Jamais de description.
     .card-md  moyenne : inventaire (deck), Codex, Sanctuaire, marchand. Même contenu, en plus grand.
     .card-lg  large   : fiche de détail (appui long ou clic droit). Le texte de règle est sous la carte (.card-detail-desc).
   Une carte « .with-desc » (récompense, marchand, PNJ : on choisit, donc on lit) ajoute la description sous le nom et
   prend la largeur --card-pick.

   Tout est proportionnel à la largeur de la carte (--w) : police, badges, image. La largeur vient de la taille
   (--dw) ou du contexte (--cw : fitHand() pour la main, .drop-hand). La hauteur est toujours largeur × --ratio :
   deux cartes de la même taille ont la même hauteur, quel que soit leur nombre d'effets (la main, qui peut contenir plus
   de pastilles que le rapport ne prévoit, pose --ch : la hauteur de sa carte la plus chargée, pour toutes). */

:root {
  --card-sm: 100px;
  --card-md: clamp(104px, calc((100vw - 64px) / 3), 132px);
  --card-pick: var(--card-md);
  --card-lg: min(46vw, 180px);
}
@media (min-width: 1024px) and (orientation: landscape), (min-width: 1200px) {
  :root { --card-sm: clamp(112px, 8.6vw, 160px); --card-md: clamp(104px, 8.4vw, 160px); --card-pick: clamp(140px, 11vw, 200px); }
}

/* ================================================================ La carte */
.card {
  --c: var(--atk);
  --w: var(--cw, var(--dw, var(--card-md)));
  position: relative; display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; padding: 0; text-align: left;
  width: var(--w); height: var(--ch, calc(var(--w) * var(--ratio, 1.5))); font-size: calc(var(--w) * .105);
  border-radius: 14px; border: 2px solid color-mix(in srgb, var(--c) 75%, #000);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, var(--panel)) 0%, var(--panel) 65%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), 0 6px 14px rgba(0, 0, 0, .35);
  cursor: default; transition: transform .14s ease-out, box-shadow .14s, opacity .2s, filter .2s;
}
.card.defense { --c: var(--def); }
.card.status { --c: var(--sta); }
.card.clickable { cursor: pointer; }
.card::before { content: ""; position: absolute; inset: 3px; border-radius: 11px; border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); pointer-events: none; }
.card-sm { --dw: var(--card-sm); --ratio: 1.35; }
.card-md { --dw: var(--card-md); --ratio: 1.6; }
.card-lg { --dw: var(--card-lg); --ratio: 1.55; }
.card.with-desc { --dw: var(--card-pick); --ratio: 1.7; } /* T758 : 1,95 laissait un grand vide entre la description et les valeurs (marchand, récompense, PNJ) ; 1,7 tient aussi pour trois rangées d effets */

/* Poids (pastille or) et rang, en surimpression sur les coins de l'image. */
.card-top { position: absolute; inset: 0 0 auto; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: .4em .45em 0; pointer-events: none; }
.card-weight { min-width: 1.7em; height: 1.7em; display: grid; place-items: center; border-radius: 99px; background: var(--gold); color: var(--ink-dark); font-size: max(11px, .85em); font-weight: 800; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.card-key { font-size: max(11px, .8em); font-weight: 800; line-height: 1.3; padding: .1em .5em; border-radius: 99px; color: #fff; background: rgba(0, 0, 0, .4); }
.card-key-plus { color: var(--gold); }
.card-tech { position: absolute; top: 2.6em; right: .45em; z-index: 2; width: 1.9em; height: 1.9em; display: grid; place-items: center; border-radius: 99px; background: color-mix(in srgb, var(--gold) 30%, var(--panel)); border: 1px solid var(--gold); }
.card-tech img.pxi { width: 1.1em; height: 1.1em; }
.card-hotkey { position: absolute; left: .5em; bottom: .5em; z-index: 2; font-size: max(11px, .8em); font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .9), 0 0 4px rgba(0, 0, 0, .7); opacity: .65; pointer-events: none; }

/* Image : la vignette de 32 × 24 px, agrandie par multiples entiers quand le navigateur sait arrondir. */
.card-art { position: relative; flex: none; width: 62%; aspect-ratio: 4 / 3; margin: .6em auto .2em; border-radius: 4px; overflow: hidden; background: #140e16; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 60%, transparent); }
.card-art img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
@supports (width: round(nearest, 1px, 1px)) {
  .card-art { width: max(32px, min(round(nearest, 62%, 32px), round(down, calc(100% - 4px), 32px))); }
}
.card-icon { flex: none; display: grid; place-items: center; width: 2.6em; height: 2.6em; margin: .6em auto .2em; border-radius: 50%; line-height: 1;
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--c) 55%, #000) 0%, rgba(0, 0, 0, .45) 72%); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 65%, transparent), 0 2px 0 rgba(0, 0, 0, .35); }
.card-icon img.pxi { width: 1.7em; height: 1.7em; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .6)); }

.card-name { flex: none; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; min-height: 2.24em; padding: 0 .35em;
  font-size: max(11px, .92em); font-weight: 800; line-height: 1.12; text-align: center; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.card-desc { flex: 0 1 auto; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; margin: .1em 0 .3em; padding: 0 .6em;
  font-size: max(11px, .8em); line-height: 1.25; text-align: center; color: var(--muted); }
.card-flag { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: .25em; text-align: center; font-size: max(11px, .7em); font-weight: 800; letter-spacing: .06em; color: #fff; background: rgba(0, 0, 0, .72); }

/* Valeurs (dégâts, garde, effets) : toutes les pastilles s'écoulent dans un seul bloc, en bas, centrées, sur autant de
   lignes que nécessaire (deux ou trois par ligne selon la largeur) — la hauteur de la carte ne dépend donc pas du nombre d'effets. */
.card-fx { flex: none; margin-top: auto; display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-end; align-items: center; gap: .2em; padding: .2em .3em .5em; }
.card .fx-row { display: contents; }
.card .fx { min-width: 0; max-width: 100%; box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .02em .3em; font-size: max(11px, .95em); font-weight: 650; line-height: 1.35; }
.card .fx img.pxi { width: 1.1em; height: 1.1em; margin-right: 1px; vertical-align: -.2em; }
.card .fx-bonus { margin-left: 2px; padding: 0 3px; }
.card .fx-full { display: none; }
.card .fx-abbr { display: inline; }

/* ================================================================ Contextes */
/* Main de combat : des rangées de petites cartes, aucune ne recouvre une autre (fitHand() pose --cw). */
.hand { --cw: var(--card-sm); display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 6px; padding: 10px 4px; }
.hand .card { z-index: 2; }
.hand > .hand-br { flex: 0 0 100%; height: 0; }
/* Dans la main, les valeurs suivent le nom (elles ne sont pas collées au bas de la carte) : une carte couverte par la suivante
   perd du vide, pas de la lecture. Le contenu de la carte ne change jamais de place. */
.hand .card .card-fx { margin-top: .3em; }
.hand.overlap-x { column-gap: 0; }
.hand .card.ov { margin-left: calc(var(--ox, 0px) * -1); }
.hand .card.row-next { margin-top: calc(var(--oy, 0px) * -1); }
/* Main très fournie (fitHand pose .dense) : plus de place pour les cartes en retirant l'image, nom et valeurs restent. */
.hand.dense .card { --ratio: 1.2; }
.hand.dense .card-art, .hand.dense .card-icon { display: none; }
.hand.dense .card-name { margin-top: 2.3em; }
/* Deck, Codex, choix d'une carte du deck : grille de cartes moyennes. */
.deck-grid, .card-grid { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, var(--card-md)); justify-content: center; align-items: start; gap: 10px; padding: 6px 2px 10px; }
.drop-hand { display: flex; }
/* Récompense, marchand : les cartes avec description se rangent côte à côte. */
.choices .card, .shop-cards .card { margin: 0; }

/* ================================================================ États */
.card.dim { opacity: .45; filter: grayscale(.6); }
html:not(.dark) .card.dim { opacity: .6; filter: saturate(.4); }
.card.locked { pointer-events: none; }
.card.shake { animation: shake .3s ease-in-out; }
.card.gold { border-color: var(--gold); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 45%, transparent), 0 0 0 1px color-mix(in srgb, var(--gold) 55%, transparent), 0 6px 16px rgba(0, 0, 0, .35); }
.card.gold::before { border-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.card.gold .card-top { background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 32%, transparent), transparent); }
.card.gold::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; mix-blend-mode: screen;
  background: linear-gradient(115deg, transparent 38%, color-mix(in srgb, var(--gold) 38%, transparent) 50%, transparent 62%) -160% 0 / 250% 100% no-repeat; animation: gold-glint 5.5s ease-in-out infinite; }
html:not(.dark) .card.gold::after { mix-blend-mode: normal; opacity: .6; }
/* « Teintes et cadres » (cosmétique du Sanctuaire). */
html[data-ctint] .card:not(.gold)::before { border: 2px solid color-mix(in srgb, var(--ct) 85%, transparent); }
html[data-ctint] .card:not(.gold) { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, var(--panel)) 0%, color-mix(in srgb, var(--ct) 18%, var(--panel)) 72%); }

/* Souris : la carte cliquable se lève. */
@media (hover: hover) and (pointer: fine) {
  .card.clickable:hover { transform: translateY(-6px); z-index: 5; box-shadow: 0 12px 24px rgba(0, 0, 0, .5); }
}
/* Sélectionnée dans la main : assombrie, liseré ambré (le voile, pas un filtre, pour que le liseré reste ambré). */
.card.selected { transform: translateY(-4px); box-shadow: 0 0 0 2px #E2A93B, 0 0 10px rgba(226, 169, 59, .35), inset 0 0 0 999px rgba(8, 7, 10, .5); }
.card.selected > * { filter: brightness(.5) saturate(.55); }
@media (hover: hover) and (pointer: fine) { .card.selected:hover > * { filter: brightness(.8) saturate(.85); } }
/* Choisie dans une liste (deck, récompense) ; « doom » : la carte qu'on va perdre. */
.card.chosen { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--gold), 0 14px 26px rgba(0, 0, 0, .5); }
.card.chosen.doom { box-shadow: 0 0 0 3px var(--danger), 0 0 14px color-mix(in srgb, var(--danger) 45%, transparent), 0 14px 26px rgba(0, 0, 0, .5); }
.deck-grid .card.chosen.doom::after, .drop-hand .card.chosen.doom::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.2em; font-weight: 800; color: var(--danger); text-shadow: 0 2px 0 rgba(0, 0, 0, .6); pointer-events: none; }
/* Main de combat : cartes que le budget ne permet plus de poser, main verrouillée pendant la révélation. */
.hand .card.unplayable:not(.selected) { opacity: .45; filter: grayscale(.8); box-shadow: none; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) { .hand .card.unplayable:not(.selected):hover { transform: none; } }
.hand.locked .card { opacity: .4; filter: saturate(.5); pointer-events: none; transition: opacity .25s, filter .25s; }
.hand.ff-hint .card:not(.unplayable) { box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 80%, transparent), 0 0 16px color-mix(in srgb, var(--gold) 45%, transparent); animation: ffHalo 1.6s ease-in-out infinite; }
/* Charge pleine : le deck en cartes à retirer (C4). */
.drop-hand .card { transition: transform .14s ease-out, opacity .2s, filter .2s; }
.drop-hand .card.chosen.doom { transform: translateY(-10px); }
.drop-hand.done .card:not(.chosen) { opacity: .4; filter: saturate(.5) brightness(.8); }
@media (hover: hover) and (pointer: fine) { .drop-hand.done .card:not(.chosen):hover { opacity: .75; filter: none; } }
/* Échange (récompense avec charge pleine) : carte à rendre, cartes qui ne peuvent pas l'être. */
.swap-grid .card.chosen.doom { transform: translateY(-6px); z-index: 2; box-shadow: 0 0 0 3px var(--danger), 0 0 18px color-mix(in srgb, var(--danger) 50%, transparent), 0 10px 22px rgba(0, 0, 0, .45); }
.swap-grid .card .card-flag { left: 50%; right: auto; bottom: auto; top: 29%; transform: translate(-50%, -50%); padding: .3em .8em; border-radius: 99px; background: var(--danger); color: #fff;
  font-family: var(--font-ui); font-size: max(13px, .72em); letter-spacing: .04em; text-transform: uppercase; box-shadow: 0 2px 0 rgba(0, 0, 0, .45), 0 0 0 2px rgba(255, 255, 255, .85); white-space: nowrap; }
.swap-grid .card.ineligible { z-index: 0; transform: scale(.94); filter: grayscale(.9) brightness(.7); cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) { .swap-grid .card.ineligible:hover { filter: grayscale(.6) brightness(.85); } }
/* Entrée d'écran : les cartes se retournent. */
.enter .app-main .card { animation: cardFlipIn .28s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(var(--in, 0) * 35ms); }

@media (prefers-reduced-motion: reduce) {
  .card, .drop-hand .card { transition: none; }
  .card.gold::after { animation: none; background: none; }
  .hand.ff-hint .card:not(.unplayable) { animation: none; }
}
