/* ==========================================================================
   CardPreview: a Fracctal TCG card drawn from card data with the game's own
   frame sprites (assets/ui/frames/, exported from the Unity project's
   Sprites/FracctalCardFrames, gold "_G" variants). Stats and text are live
   HTML on top of the frame, never baked into an image.

   Size: set --card-w on .ft-card or any parent (default 260px). Everything
   inside is in em or %, so the card scales as a whole and never reflows.
   Team: data-el="fire|water|plant|rock|ice|shadow|electric|psychic".

   Geometry comes from the 1024 x 1437 frame sprite: art window x 128-899,
   y 205-976; attack shape centred at (13.9%, 90.5%), health at (86.1%, 90.4%).
   ========================================================================== */

[data-el="plant"]    { --el: var(--el-plant);    --on-el: var(--ink); }
[data-el="rock"]     { --el: var(--el-rock);     --on-el: var(--ink); }
[data-el="water"]    { --el: var(--el-water);    --on-el: var(--ink); }
[data-el="fire"]     { --el: var(--el-fire);     --on-el: var(--ink); }
[data-el="ice"]      { --el: var(--el-ice);      --on-el: var(--ink); }
[data-el="shadow"]   { --el: var(--el-shadow);   --on-el: #ffffff; }
[data-el="electric"] { --el: var(--el-electric); --on-el: var(--ink); }
[data-el="psychic"]  { --el: var(--el-psychic);  --on-el: #ffffff; }

.ft-card {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  display: block;
  width: var(--card-w, 260px);
  aspect-ratio: 1024 / 1437;
  font-size: calc(var(--card-w, 260px) / 16.25); /* 1em = 16px at 260px wide */
  color: #ffffff;
  text-align: center;
  /* the game's Outer_Edge colour shows in the frame's rounded corners */
  background: #1e2128;
  border-radius: 4.5% / 3.2%;
  /* the dark outer edge the game draws around the gold frame */
  box-shadow: 0 0 0 0.3em #1e2128, 0 0.9em 1.6em rgba(0, 10, 30, 0.45);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

/* Prismatic cards get the rainbow rim the game draws around them */
.ft-card[data-rarity="prismatic"]::before,
.ft-card[data-rarity="full_prismatic"]::before {
  content: "";
  position: absolute;
  inset: -3.6% -5%;
  z-index: -1;
  border-radius: 7% / 5%;
  background: conic-gradient(from 200deg, #ff4fd8, #ffcf3f, #4dff8a, #3fd2ff, #8a5bff, #ff4fd8);
  box-shadow: inset 0 0 0 0.18em rgba(20, 22, 28, 0.55), 0 0 1.2em rgba(255, 120, 230, 0.4);
}

.ft-card__art {
  position: absolute;
  /* bleeds a little under the frame so no edge shows through */
  left: 11%;
  top: 13%;
  width: 78%;
  height: 56.5%;
  overflow: hidden;
  background: linear-gradient(160deg, var(--sky-400), var(--sky-700));
}

.ft-card__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ft-card__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

/* Shared lettering: the game's display face with a dark outline */
.ft-card__name,
.ft-card__num,
.ft-card__ability,
.ft-card__type,
.ft-card__evo-label {
  position: absolute;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0.02em;
  line-height: 1.05;
  text-transform: uppercase;
  color: #ffffff;
  paint-order: stroke fill;
  -webkit-text-stroke: 0.12em #1b1d24;
  text-shadow: 0 0.06em 0 #1b1d24;
}

.ft-card__name {
  left: 20%;
  right: 20%;
  top: 8.7%;
  transform: translateY(-50%);
  font-size: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.ft-card__name--long { font-size: 0.95em; }

/* Mana: the hex gem overlapping the top-left corner */
.ft-card__mana {
  position: absolute;
  left: -1.6%;
  top: -1.2%;
  width: 23%;
  aspect-ratio: 128 / 136;
  filter: drop-shadow(0 0.1em 0.12em rgba(0, 0, 0, 0.45));
}

.ft-card__mana img {
  display: block;
  width: 100%;
  height: 100%;
}

.ft-card__mana .ft-card__num {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 0.06em;
  font-size: 1.8em;
}

/* "Evolves to" badge: small art thumb at the top right of the art window */
.ft-card__evo {
  position: absolute;
  right: 13.4%;
  top: 15.6%;
  width: 14.5%;
}

.ft-card__evo-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 22%;
  overflow: hidden;
  background: var(--sky-700);
  box-shadow: 0 0 0 0.12em #bfe6ff, 0 0 0 0.22em #1b1d24;
}

.ft-card__evo-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ft-card__evo-label {
  position: static;
  display: block;
  margin-top: 0.3em;
  margin-left: -25%;
  margin-right: -25%;
  font-size: 0.48em;
  line-height: 1.1;
  -webkit-text-stroke-width: 0.18em;
}

/* Ability text, on the frame's team panel */
.ft-card__text {
  position: absolute;
  left: 10.5%;
  right: 10.5%;
  top: 70.4%;
  height: 13.2%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ft-card__ability {
  position: static;
  display: block;
  font-size: 0.74em;
  line-height: 1.12;
  -webkit-text-stroke-width: 0.16em;
}

.ft-card__text--long .ft-card__ability { font-size: 0.62em; }

.ft-card__ability strong { font-weight: inherit; }

/* Attack and health numbers, on the frame's built-in shapes */
.ft-card__atk,
.ft-card__hp {
  position: absolute;
  top: 90.4%;
  width: 14%;
  transform: translate(-50%, -50%);
}

.ft-card__atk { left: 13.9%; }
.ft-card__hp { left: 86.1%; }

.ft-card__atk .ft-card__num,
.ft-card__hp .ft-card__num {
  position: static;
  display: block;
  font-size: 1.4em;
}

.ft-card__type {
  left: 30%;
  right: 30%;
  top: 92.6%;
  transform: translateY(-50%);
  font-size: 0.52em;
  -webkit-text-stroke-width: 0.18em;
}

a.ft-card:hover,
button.ft-card:hover {
  transform: translateY(-4px);
}

/* Element chip (team pill) */
.ft-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 30px;
  padding: 0 var(--space-3) 0 var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--el, var(--steel-400));
  color: var(--on-el, var(--ink));
  font: 700 13px/16px var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px var(--stone-800);
}

.ft-chip img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
  .ft-card { transition: none; }
  a.ft-card:hover,
  button.ft-card:hover { transform: none; }
}
