/* card fonts (from cardconjurer.app): Beleren for title/type/P-T,
   MPlantin for rules text, Gotham Medium for the footer.
   Colors live in card-theme.css. */
@font-face { font-family: "Beleren"; font-weight: 700;
  src: url("fonts/beleren-b.ttf") format("truetype"); }
@font-face { font-family: "MPlantin"; font-style: normal;
  src: url("fonts/mplantin.ttf") format("truetype"); }
@font-face { font-family: "MPlantin"; font-style: italic;
  src: url("fonts/mplantin-i.ttf") format("truetype"); }
@font-face { font-family: "Gotham Medium";
  src: url("fonts/gotham-medium.ttf") format("truetype"); }
:root {
  --font-title: "Beleren", "Segoe UI", system-ui, sans-serif;
  --font-rules: "MPlantin", "Palatino Linotype", Georgia, serif;
  --font-foot: "Gotham Medium", "Segoe UI", system-ui, sans-serif;
  --footer-h: 20px;
}


/* ---------- card shell ---------- */
.mtg-card {
  position: relative; display: flex; flex-direction: column;
  width: 240px; height: 335px; padding: 8px; border-radius: 12px;
  background: var(--card-black); color: var(--card-ink);
  font-family: var(--font-rules); cursor: pointer; user-select: none;
  box-shadow: 0 2px 8px var(--card-shadow); transition: transform .08s;
}
.mtg-card:hover { transform: translateY(-3px); }
.mtg-card.selected { outline: 3px solid var(--link); }
.mtg-card.dirty { outline: 3px solid var(--dirty-outline); }
.mtg-card.dirty::after {
  content: "●"; position: absolute; top: 3px; right: 7px; z-index: 3;
  color: var(--dirty-dot); font-size: 13px;
  text-shadow: 0 0 3px var(--dirty-dot-shadow);
}

/* frame body color per card kind */
.mtg-card.c-w .card-inner { --inner-bg: var(--frame-w); }
.mtg-card.c-u .card-inner { --inner-bg: var(--frame-u); }
.mtg-card.c-b .card-inner { --inner-bg: var(--frame-b); }
.mtg-card.c-r .card-inner { --inner-bg: var(--frame-r); }
.mtg-card.c-g .card-inner { --inner-bg: var(--frame-g); }
.mtg-card.c-gold .card-inner { --inner-bg: var(--frame-gold); }
.mtg-card.c-colorless .card-inner { --inner-bg: var(--frame-colorless); }
.mtg-card.c-land .card-inner { --inner-bg: var(--frame-land); }
.mtg-card.c-u, .mtg-card.c-b, .mtg-card.c-r, .mtg-card.c-g,
.mtg-card.c-hydark { color: var(--card-ink-light); }

/* colored body (curved at the bottom) sits above the black footer strip */
.card-inner {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; flex: 1;
  background: var(--card-black); border-radius: 8px 8px 0 0;
}
.card-inner::before {
  content: ""; position: absolute; z-index: -1; inset: 0 0 var(--footer-h) 0;
  background: var(--inner-bg, none); border-radius: 8px 8px 28px 28px;
}

/* ---------- pinlined boxes ---------- */
/* --box-bg / --text-bg are the fill, --pin the (solid or gradient) border */
.card-bar, .card-typeline, .card-pt, .card-art, .card-text {
  border: 2px solid transparent; color: var(--box-ink);
  background: var(--box-bg, linear-gradient(var(--box-fill), var(--box-fill))) padding-box,
              var(--pin, var(--pin-default)) border-box;
}
.card-bar, .card-typeline {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 6px; border-radius: 10px;
  font-family: var(--font-title); font-weight: 700;
  font-size: 13px; 
}
.card-bar { margin: 3px 2px 0; }
.card-typeline { margin: 0 2px; }
.card-name, .card-type { flex: 1; min-width: 0; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; }
.card-cost { flex-shrink: 0; margin-left: 6px; white-space: nowrap; }
.card-bar .mana { filter: drop-shadow(-1px 1px 0 var(--mana-shadow)); }

.card-art {
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  height: 155px; margin: -1px 7px; border-radius: 2px;
  font-size: 34px; color: var(--art-glyph);
  background: linear-gradient(145deg, var(--art-fill-top), var(--art-fill-bottom)) padding-box,
              var(--pin, var(--pin-default)) border-box;
}
.art-glyph { display: block; width: 96px; height: 96px;
  background: var(--art-glyph);
  -webkit-mask: url(img/type-icons/planeswalker.svg) center / contain no-repeat;
  mask: url(img/type-icons/planeswalker.svg) center / contain no-repeat; }
.art-glyph.t-creature { --icon: url(img/type-icons/creature.svg); }
.art-glyph.t-planeswalker { --icon: url(img/type-icons/planeswalker.svg); }
.art-glyph.t-battle { --icon: url(img/type-icons/battle.svg); }
.art-glyph.t-land { --icon: url(img/type-icons/land.svg); }
.art-glyph.t-artifact { --icon: url(img/type-icons/artifact.svg); }
.art-glyph.t-enchantment { --icon: url(img/type-icons/enchantment.svg); }
.art-glyph.t-instant { --icon: url(img/type-icons/instant.svg); }
.art-glyph.t-sorcery { --icon: url(img/type-icons/sorcery.svg); }
.art-glyph[class*="t-"] {
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat; }
.card-art-img { display: block; width: 100%; height: 100%; object-fit: cover; }

.card-typeline .rarity-dot { margin-right: 0; flex-shrink: 0; }
.rarity-sym { height: 14px; max-width: 24px; object-fit: contain;
  flex-shrink: 0; margin-left: 4px; }
.cp-type .rarity-sym { height: 22px; max-width: 36px; }

/* ---------- rules text ---------- */
.card-text {
  display: flex; flex-direction: column; justify-content: center;
  flex: 1; margin: -1px 7px 0; padding: 3px 0; border-radius: 2px;
  overflow: hidden; white-space: pre-wrap; font-size: 12px; line-height: 1.1;
  background: var(--text-bg, linear-gradient(var(--text-fill), var(--text-fill))) padding-box,
              var(--pin, var(--pin-default)) border-box;
}
.card-rules { flex: 1; min-height: 0; display: flex; flex-direction: column;
  justify-content: center; }
/* planeswalkers with >3 rules lines: steal ~25% of the text box's height
   from the art box so the extra rows fit */
.mtg-card.pw-tall .card-art { height: 132px; }
/* planeswalkers: let loyalty badges overhang the box's left edge */
.card-text.pw { overflow: visible; min-height: 0; padding: 0; }
/* planeswalkers: rules fills the whole box in the light-band tint so the
   empty space above/below doesn't read as extra stripes */
.card-text.pw .card-rules { background: rgba(255, 255, 255, .45); }
.card-flavor { margin-top: 2px; padding: 0 3px; font-style: italic; }
.card-line { padding: 0px 3px; }
.card-line + .card-line { margin-top: 4px; }
.card-line.bullet { display: flex; gap: .45em; }
.card-line.bullet .bul { flex-shrink: 0; }
.card-line.bullet > span:last-child { min-width: 0; }
.card-line.pw-row { padding: 2px 3px; flex: 1;
  background: rgba(0, 0, 0, .09); }
.card-line.pw-row + .card-line.pw-row { margin-top: 0; }
.card-line.pw-row.stripe { background: rgba(255, 255, 255, .45); }
.card-line.loyalty-ab { display: flex; gap: .35em; align-items: center; }
/* loyalty badge: gray rim is the outer clip shape peeking past the inner one */
.card-line.loyalty-ab .lcost { flex-shrink: 0; min-width: 2.1em; font-weight: bold;
  font-family: var(--font-title); font-size: 10px; text-align: center;
  padding: 1.5px; background: #b9b9b9; margin-left: -8px; }
.card-line.loyalty-ab .lcost-in { display: block; background: #000;
  color: #fff; padding: 3px 5px; }
/* loyalty badge shapes, as close to the printed faceted gems/shields as
   clip-path polygons allow — edit the coords here, rim + fill share them */
:root {
  --loy-up: polygon(50% 0%, 100% 20%, 100% 100%, 50% 90%, 0% 100%, 0% 20%);
  --loy-down: polygon(50% 10%, 100% 0%, 100% 80%, 50% 100%, 0% 80%, 0% 0%);
  --loy-zero: polygon(50% 0%, 100% 20%, 100% 80%, 50% 100%, 0% 80%, 0% 20%);
  --loy-start: polygon(90% 50%, 85% 80%, 50% 100%, 15% 80%, 10% 50%, 0% 20%, 35% 0%, 43% 12%, 50% 15%, 57% 12%, 65% 0%, 100% 20%);
}
.lcost.lup, .lcost.lup .lcost-in { clip-path: var(--loy-up); }
.lcost.ldown, .lcost.ldown .lcost-in { clip-path: var(--loy-down); }
.lcost.lzero, .lcost.lzero .lcost-in { clip-path: var(--loy-zero); }
.card-line.loyalty-ab > span:last-child { min-width: 0; }
.card-divider { flex-shrink: 0; height: 1px; margin: 4px 6%;
  background: var(--divider); }

.card-pt {
  position: absolute; right: 4px; bottom: 10px; z-index: 2;
  padding: 0 8px; border-radius: 8px;
  font-family: var(--font-title); font-weight: 700; font-size: 13px;
}
/* planeswalkers: footer box becomes a starting-loyalty shield —
   gray rim from the outer clip peeking past the inner one */
.mtg-card.pw .card-pt { border: 0; border-radius: 0; padding: 1.5px;
  display: flex; background: #b9b9b9; clip-path: var(--loy-start);
  width: 2.5em; height: 1.5em;
}
.mtg-card.pw .card-pt .pt-in { display: flex; flex: 1;
  align-items: center; justify-content: center; padding-top: 3px;
  background: #000; color: #fff; clip-path: var(--loy-start); }

/* ---------- footer ---------- */
.card-footer {
  position: relative; box-sizing: border-box; flex-shrink: 0;
  display: flex; justify-content: flex-start; align-items: center; gap: 4px;
  height: var(--footer-h); padding: 2px 8px 0;
  background: var(--footer-bg); color: var(--footer-ink);
  font-size: 7px; font-family: var(--font-foot);
}
.card-footer.has-pt .card-artist { max-width: 58%; }
.card-ids { display: flex; flex-direction: column; flex-shrink: 0; }
.card-artist { min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.card-brush {
  display: inline-block; width: 10px; height: 6px; margin-right: 2px;
  vertical-align: -1px; background: currentColor;
  -webkit-mask: url("img/artistbrush.svg") center / contain no-repeat;
  mask: url("img/artistbrush.svg") center / contain no-repeat;
}

/* ---------- rarity ---------- */
.rarity-dot { display: inline-block; width: 10px; height: 10px;
  margin-right: 3px; border-radius: 50%; vertical-align: -1px; }
.rarity-common { background: var(--rarity-common); }
/* metallic gradients, like printed set symbols */
.rarity-uncommon { background: linear-gradient(140deg, #dbe4ec, var(--rarity-uncommon) 45%, #54697e); }
.rarity-rare { background: linear-gradient(140deg, #f4dc8e, var(--rarity-rare) 50%, #7c5f22); }
.rarity-mythic { background: linear-gradient(140deg, #f6a05a, var(--rarity-mythic) 50%, #82290e); }

/* ---------- final rendered image replaces the CSS frame ---------- */
.mtg-card.final { padding: 0; background: transparent; height: auto;
  aspect-ratio: 2010 / 2814; overflow: hidden; border-radius: 12px; }
.mtg-card.final.selected, .mtg-card.final.dirty { outline-offset: 2px; }
.card-final { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; }
/* 2187x2975 renders include print bleed: crop to the 2010x2814 card */
.card-final.bleed { inset: auto; object-fit: fill; width: 108.806%;
  height: 105.721%; left: -4.403%; top: -2.861%; }

/* ---------- mana symbols ---------- */
.mana { width: 13px; height: 13px; margin-left: 2px; vertical-align: -3px; }
.mana.inline { width: 10px; height: 10px; margin: 0 1px; vertical-align: -2px; }
.mana.hybrid { width: 15px; height: 15px; vertical-align: -4px; }
.mana.inline.hybrid { width: 12px; height: 12px; vertical-align: -3px; }
.cp-rules .mana.inline { width: 16px; height: 16px; vertical-align: -3px; }
/* fallback pips for symbols with no image */
.pip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 2px; border-radius: 50%;
  border: 1px solid var(--pip-border); color: var(--pip-ink);
  font-size: 10px; font-weight: 700; vertical-align: -3px;
}
.pip.w { background: var(--frame-w); color: var(--pip-w-ink); }
.pip.u { background: var(--frame-u); }
.pip.b { background: var(--frame-b); }
.pip.r { background: var(--frame-r); }
.pip.g { background: var(--frame-g); }
.pip.c, .pip.n, .pip.x { background: var(--pip-colorless); color: var(--pip-colorless-ink); }
.pip.s { background: var(--pip-snow); color: var(--pip-snow-ink); }
/* hybrid split pip — two letters on a diagonal two-color background */
.pip.hy { font-size: 7px; letter-spacing: -.5px; gap: 1px; }

/* ---------- unfilled skeleton slot ---------- */
.mtg-card.ghost {
  justify-content: center; align-items: center; text-align: center;
  background: transparent; border: 2px dashed var(--input-border); color: var(--muted);
}
.mtg-card.ghost .gcode { font-size: 15px; font-weight: 700; }
.mtg-card.ghost .grole { font-size: 11.5px; padding: 6px 14px; }
.mtg-card.ghost:hover { border-color: var(--link); color: var(--soft); }
