/* A card as the game draws it, shared by the game page and the deck editor study. */
:root {
  --gold: #d9b56a; --text: #efe6d2; --target: #f2c14e;
  /* Retail CardSharedGraphics.SubtypeColorStyles.MainColor (rounded 8-bit RGB). */
  --strength: #f22a0e; --intelligence: #0084ff; --willpower: #ffc000; --agility: #00b450;
  --endurance: #9750e7; --neutral: #f0ece6; --dual: #6d5432;
  --serif: Georgia, 'Times New Roman', serif;
  --orb: var(--art-orb, radial-gradient(circle at 40% 35%, #8cc4ff, #123c8a));
}

/* Header and type above the portrait; sword/shield beside it; rules over full art.
   --height keeps portrait ornaments fixed when a long rules box grows the card. */
.card { --frame: var(--neutral); --card-aura: none; --card-border: 0.3em; --height: calc(var(--card-w) / 0.68 - var(--card-w) * 0.6 / 16);
  position: relative; flex: none; width: var(--card-w); aspect-ratio: 0.68; padding: 0; overflow: visible;
  border: var(--card-border) solid var(--frame); border-radius: 0.2em; background: #17130f; color: var(--text); font: calc(var(--card-w) / 16) / normal system-ui, sans-serif; text-align: center;
  box-shadow: 0 0.25rem 0.6rem #000b; cursor: default; user-select: none; transition: transform 0.15s ease, box-shadow 0.15s ease; }
:is(.card, .card-half).strength { --frame: var(--strength); } :is(.card, .card-half).intelligence { --frame: var(--intelligence); } :is(.card, .card-half).willpower { --frame: var(--willpower); }
:is(.card, .card-half).agility { --frame: var(--agility); } :is(.card, .card-half).endurance { --frame: var(--endurance); } :is(.card, .card-half).dual { --frame: var(--dual); }
/* Multicolour: the frame and name banner blend the colours in retail order. */
.card.dual { border-color: transparent; background: linear-gradient(#17130f, #17130f) padding-box, linear-gradient(135deg, var(--frame-blend)) border-box; }
:is(.card, .card-half).dual .name { background: linear-gradient(#0009, #000d), linear-gradient(90deg, var(--frame-blend)); }
/* Preserve the border's spacing, but paint retail's textured rim and inward wash.
   The archive supplies the original mask/material; letters and ornaments stay above it. */
.card.retail-framed { border-color: transparent; background: linear-gradient(#17130f, #17130f) padding-box; }
/* Match the browser's whole-CSS-pixel border width, not the unrounded em value. */
.card .retail-frame { position: absolute; inset: calc(-1 * round(down, var(--card-border), 1px)); z-index: 1;
  border-radius: inherit; pointer-events: none; }
.card .retail-frame[data-layer="wash"] {
  background: linear-gradient(90deg, var(--frame-blend, var(--frame), var(--frame)));
  mask: var(--retail-texture) center / 100% 100% no-repeat;
}
.card .retail-frame[data-layer="rim"] { background: var(--retail-texture) center / 100% 100% no-repeat; }
.card.retail-framed :is(.text, .keywords) { position: relative; z-index: 2; }
.card:disabled { opacity: 1; }
/* Full artwork beneath the header and rules; keep the portrait anchored at the top. */
.card .art { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.card .art.blank { background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--frame) 80%, white), #120f0c); }
.card .name { position: absolute; top: 0; left: 0; right: 0; z-index: 2; height: calc(var(--height) * 0.09);
  display: block; align-content: center; padding: 0 0.3em 0 1.7em; border-bottom: 1px solid var(--gold);
  background: linear-gradient(color-mix(in srgb, var(--frame) 30%, black), #060b08);
  font: bold 1.15em/1.1 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 1px #000; }
/* One rules layout for printed and live cards: longer text covers more artwork. */
.card .box { position: absolute; right: 0; bottom: 0; left: 0; min-height: 23%; max-height: 86%; overflow: auto;
  display: flex; flex-direction: column; justify-content: center; gap: 0.25em; font-size: clamp(12px, 1em, 16px);
  padding: 0.8em 0.7em max(0.8em, var(--card-footer, 0px)); background: linear-gradient(#0b090700, #0b0907c4 25%, #0b0907e6);
  text-shadow: 0 1px 2px #000, 0 0 0.4em #000; }
.card .kind { position: absolute; top: calc(var(--height) * 0.09); left: 50%; z-index: 2; transform: translate(-50%, -50%);
  max-width: 65%; padding: 0.1em 0.8em; isolation: isolate; background: var(--gold); color: #d6c9ad;
  font: 0.65em/1.15 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  clip-path: polygon(6% 0, 94% 0, 100% 50%, 94% 100%, 6% 100%, 0 50%); }
.card .kind::before { content: ''; position: absolute; inset: 1px; z-index: -1; background: #22231d; clip-path: inherit; }
.card .keywords { color: var(--target); font-weight: bold; }
.card .text { display: block; flex-shrink: 0; overflow: hidden; white-space: pre-line; line-height: 1.2; }
.card .cost, .card .attack, .card .health { position: absolute; z-index: 2; display: grid; place-items: center; font: bold 2.25em/1 Arial, sans-serif; }
.card .cost { top: calc(var(--height) * -0.035); left: var(--cost-left, -10%); width: 23%; aspect-ratio: 1; border: 0.04em solid #d6d4a5; border-radius: 50%;
  background: var(--card-orb, var(--orb)) center / contain no-repeat; background-color: #1e9fd6; background-blend-mode: luminosity;
  color: #050b10; text-shadow: none;
  box-shadow: 0 0 0 0.025em #111713, 0 0 0 0.055em #ada779, inset 0 0 0 0.025em #07131c; }
.card .attack, .card .health { width: 27%; isolation: isolate; color: #efe6d2; text-shadow: 0 1px 1px #000; }
/* Glyph centers inside the original mesh: sword y=.529; shield y=.465.
   Both counters center on the same line, 59% down the normal card face. */
.card .attack { top: calc(var(--height) * 0.59 - var(--card-w) * 0.62 * 0.529); left: -13.5%; height: calc(var(--card-w) * 0.62); padding-top: calc(var(--card-w) * 0.036); }
.card .health { top: calc(var(--height) * 0.59 - var(--card-w) * 0.38 * 0.465); right: -13.5%; height: calc(var(--card-w) * 0.38); padding-bottom: calc(var(--card-w) * 0.0266); }
.card :is(.attack, .health)::before, .card :is(.attack, .health)::after { content: ''; position: absolute; inset: 0; z-index: -1; }
.card :is(.attack, .health)::before { background: #171813; }
.card .attack::before { clip-path: polygon(46% 1%, 54% 1%, 57% 3%, 59% 6%, 56% 9%, 56% 17%, 65% 18%, 72% 16%, 78% 16%, 82% 20%, 78% 23%, 72% 23%, 65% 21%, 56% 21%, 56% 27%, 99% 53%, 60% 75%, 56% 87%, 50% 99%, 44% 87%, 40% 75%, 1% 53%, 44% 27%, 44% 21%, 35% 21%, 28% 23%, 22% 23%, 18% 20%, 22% 16%, 28% 16%, 35% 18%, 44% 17%, 44% 9%, 41% 6%, 43% 3%); }
.card .health::before { clip-path: polygon(17% 2%, 83% 2%, 88% 10%, 99% 14%, 99% 61%, 83% 80%, 50% 98%, 17% 80%, 1% 61%, 1% 14%, 12% 10%); }
.card .attack::after { background: var(--card-attack) center / 100% 100% no-repeat; }
.card .health::after { background: var(--card-health) center / 100% 100% no-repeat; }
.card .health.damaged { color: #ffb3ad; }
/* Long rules grow downward without moving the portrait, header or counters. */
.card.tall { display: flex; flex-direction: column; min-height: calc(var(--card-w) / 0.68); aspect-ratio: auto; }
.card.tall .box { position: relative; top: auto; flex: auto; margin-top: calc(var(--height) * 0.77); }
.card .text .dim { color: #808080; }
.card .text .text-icon { height: 1.15em; width: auto; vertical-align: -0.2em; }

/* Double cards stack two cropped portraits at the size of a single card. */
.card.split-card { border: 0; background: none; }
.card-half { position: absolute; inset: 0 0 47.5%; border: var(--card-border) solid var(--frame);
  border-radius: inherit; background: #17130f; }
.card-half + .card-half { inset: 52.5% 0 0; z-index: 1; }
.card-half.retail-framed { border-color: transparent; }
.card-half .art { top: calc(var(--height) * 0.09); height: calc(100% - var(--height) * 0.09);
  object-position: 50% 18%; border-radius: 0 0 0.15em 0.15em; }
.card-half .name { padding-inline: 1.2em; }
.card-half .half-attribute { position: absolute; z-index: 1; top: calc(var(--height) * 0.09);
  left: calc(var(--cost-left, -10%) + 6.5%); width: 10%; background: #171813;
  border: 1px solid #ada779; border-radius: 0 0 50% 50%; padding: 0.07em; }
.card .split-gem { position: absolute; z-index: 3; bottom: 0; left: 50%; width: 14%; height: 5%;
  transform: translate(-50%, 50%); pointer-events: none; }

.card-inspection { position: fixed; pointer-events: none; padding: calc(var(--card-w) * 0.07) calc(var(--card-w) * 0.14); }
.card-inspection:not([hidden]) { display: flex; }
