/* Unit card: a cream specimen plate. Portrait + name/stats + the ability
   sentence as three chips (Trigger | Target | Effect). Container queries
   let the same card work in the shop, the formation, and a phone battle. */
.card {
  container-type: inline-size;
  position: relative;
  background:
    var(--grain),
    linear-gradient(180deg, rgba(255,255,255,.35), transparent 40%),
    var(--paper);
  color: var(--ink);
  border-radius: var(--r);
  border: 1px solid var(--paper-edge);
  box-shadow: var(--plate), var(--shadow);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation; /* keep the page scrollable; touch drags arm on hold (interact.js) */
  transition: transform .18s, box-shadow .18s, opacity .3s, filter .3s;
}
.card-inner { display: flex; gap: 10px; padding: 10px; align-items: stretch; }
.card.mirrored .card-inner { flex-direction: row-reverse; }
.card-portrait {
  position: relative; flex: 0 0 auto; width: clamp(56px, 26cqi, 104px); aspect-ratio: 1;
  border-radius: 3px; overflow: hidden; background: #efe3cc;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.card-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; mix-blend-mode: multiply; }
.card.mirrored .card-portrait img { transform: scaleX(-1); }
.tier {
  position: absolute; left: 4px; top: 4px; font: 12px/1 var(--display); color: var(--ink-soft);
  background: rgba(243,234,216,.85); border-radius: 4px; padding: 2px 4px;
}
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.card-head { display: flex; align-items: baseline; gap: 6px; }
.card.mirrored .card-head { flex-direction: row-reverse; }
.card .name { font: 20px/1 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.speed {
  font: 700 10px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 5px; border-radius: 4px; margin-left: auto;
}
.card.mirrored .speed { margin-left: 0; margin-right: auto; }
.speed.fast { background: #2a2118; color: #f3d38a; }
.speed.slow { background: var(--paper-2); color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--paper-edge); }

.stats { display: flex; gap: 6px; flex-wrap: wrap; }
.card.mirrored .stats { flex-direction: row-reverse; }
.stat {
  display: inline-flex; align-items: center; gap: 3px;
  font: 700 15px/1 var(--ui); padding: 3px 6px 3px 4px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.stat svg { width: 14px; height: 14px; }
.stat.atk { background: #efd3c9; color: #7a2d20; }
.stat.hp { background: #dfe7cf; color: #3d5a24; }
.stat.shield { background: #dde3ea; color: #34506e; }
.stat.hp.hurt { background: #f0c9bd; color: #7a2d20; }
.stat.up { animation: stat-up .5s; }
.stat.down { animation: stat-down .5s; }
@keyframes stat-up { 40% { transform: scale(1.25); box-shadow: 0 0 0 3px rgba(127,174,106,.6); } }
@keyframes stat-down { 40% { transform: scale(1.25); box-shadow: 0 0 0 3px rgba(192,83,63,.6); } }

.sentence { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: auto; }
.card.mirrored .sentence { justify-content: flex-end; }
.chip {
  font: 600 12.5px/1.1 var(--ui);
  padding: 5px 7px; border-radius: 6px; white-space: nowrap;
  touch-action: manipulation; cursor: grab; position: relative;
  transition: transform .12s, box-shadow .12s, background .2s;
}
.chip.trigger { background: var(--trigger-bg); color: #6d4610; box-shadow: inset 0 0 0 1px var(--trigger); }
.chip.target { background: var(--target-bg); color: #24534b; box-shadow: inset 0 0 0 1px var(--target); }
.chip.effect { background: var(--effect-bg); color: #6f2619; box-shadow: inset 0 0 0 1px var(--effect); }
.chip.pending::after {
  content: ''; position: absolute; inset: -3px; border-radius: 8px;
  border: 1.5px dashed currentColor; opacity: .7; pointer-events: none;
}
.chip.fired { animation: chip-fire .7s; }
@keyframes chip-fire { 30% { transform: scale(1.12); box-shadow: 0 0 0 3px var(--focus); } }
.card:not(.interactive) .chip { cursor: default; }

/* interaction states */
.card.interactive { cursor: grab; }
.card.selected { box-shadow: var(--plate), 0 0 0 3px var(--focus), 0 10px 22px rgba(0,0,0,.45); transform: translateY(-2px); }
.chip.selected { box-shadow: 0 0 0 3px var(--focus); transform: translateY(-1px); }
.chip.drop-ok { outline: 2px dashed var(--focus); outline-offset: 2px; }
.chip.drop-hover { transform: scale(1.1); box-shadow: 0 0 0 3px var(--focus); }
.card.dragging-source, .chip.dragging-source { opacity: .35; }
.card.lifted, .chip.lifted { transform: scale(1.04); box-shadow: 0 0 0 3px var(--focus), 0 12px 24px rgba(0,0,0,.45); }

.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none;
  transform-origin: 0 0; opacity: .92; filter: drop-shadow(0 10px 18px rgba(0,0,0,.5));
}

/* compact: phones and narrow battle columns */
@container (max-width: 250px) {
  .card-inner { gap: 6px; padding: 8px; }
  .card .name { font-size: 16px; }
  .stat { font-size: 13px; padding: 2px 5px 2px 3px; }
  .stat svg { width: 12px; height: 12px; }
  .chip { font-size: 11px; padding: 4px 5px; }
}
@container (max-width: 190px) {
  .card-inner, .card.mirrored .card-inner { flex-direction: column; }
  .card-portrait { width: 100%; aspect-ratio: 16 / 9; }
  .card-portrait img { object-fit: contain; }
  .card.mirrored .card-head, .card.mirrored .stats { flex-direction: row; }
  .card.mirrored .speed { margin-left: auto; margin-right: 0; }
  .card.mirrored .sentence { justify-content: flex-start; }
}

/* dead in battle */
.card.dead { filter: grayscale(1) brightness(.6); opacity: .35; transform: scale(.96); }
