/* Dopamine Boosters — ornate vintage-pharma card stylesheet.
   Hand-drawn SVG details, filigree corners, wax-seal cost, shield stats,
   pharmaceutical registry strip. */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;900&family=Grenze+Gotisch:wght@500;700;800&family=Spectral:ital,wght@0,500;0,600;1,500&family=Bebas+Neue&display=swap');

:root {
  --card-width: 380px;
  --card-radius: 14px;
  --card-pad: 4px;

  /* Per-card faction colors — set in each card's :root override */
  --accent-gold: #d4af37;            /* metalwork: corners, filigree, stripe, footer text */
  --wax-color: #5a1218;              /* wax seal + stats shield */
  --wax-color-light: #a82d3a;
  --wax-color-bright: #c63a48;
  --wax-highlight: #e57580;
  --art-bg-from: #1a3a5a;             /* background fallback under art */
  --art-bg-to: #0a0810;
  --rarity-color: #a82d3a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Spectral', Georgia, serif;
  background: #0c0c0e;
  color: #ddd;
  padding: 2rem;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

.card-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem;
}

/* === FRAMELESS ORNATE CARD === */
.tcg-card {
  width: var(--card-width);
  aspect-ratio: 5 / 7;
  background: #000;
  border-radius: var(--card-radius);
  padding: var(--card-pad);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(212, 175, 55, 0.15);
  font-family: 'Cormorant Garamond', Georgia, serif;
}

.tcg-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(ellipse at 30% 25%,
    var(--art-bg-from) 0%, var(--art-bg-to) 70%, #040810 100%);
}

/* Full-bleed art window */
.tcg-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(212, 175, 55, 0.18);
  font-family: 'Special Elite', monospace;
  font-size: 10px;
  letter-spacing: 3px;
  text-align: center;
}

.tcg-art.has-art {
  color: transparent;
}

.tcg-art.has-art .art-placeholder { display: none; }

/* Grain + foxing removed — keep the art clean and vibrant */
.tcg-noise, .tcg-foxing { display: none; }

/* === Thin gothic frame === */
.tcg-frame {
  position: absolute;
  inset: 9px;
  border: 1.5px solid var(--accent-gold);
  border-radius: 9px;
  z-index: 6;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 2.5px rgba(0, 0, 0, 0.55),
    inset 0 0 0 3.5px rgba(212, 175, 55, 0.40),
    0 0 6px rgba(0, 0, 0, 0.4);
}
.tcg-fcorner {
  position: absolute;
  width: 26px;
  height: 26px;
  z-index: 7;
}
.tcg-fcorner.tl { top: 5px; left: 5px; }
.tcg-fcorner.tr { top: 5px; right: 5px; transform: scaleX(-1); }
.tcg-fcorner.bl { bottom: 5px; left: 5px; transform: scaleY(-1); }
.tcg-fcorner.br { bottom: 5px; right: 5px; transform: scale(-1); }

/* === Top overlay === */
.tcg-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 14px 26px 16px;
  /* light scrim — just enough for the strip/title, art stays bright */
  background: linear-gradient(180deg, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.28) 50%, rgba(0,0,0,0) 100%);
  z-index: 3;
}

.tcg-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 11px;
  color: var(--accent-gold);
  letter-spacing: 2.5px;
  padding: 0 38px 6px;          /* clear the top corners */
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  margin-bottom: 10px;
  text-shadow: 0 0 4px #000, 0 0 6px rgba(0,0,0,0.85), 0 1px 1px #000;
}
.tcg-strip .clan {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 20px;
  letter-spacing: 2px;
  text-shadow: 0 0 4px #000, 0 0 6px rgba(0,0,0,0.8), 0 1px 2px #000;
}
.tcg-strip .clan-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
}
.tcg-strip .clan-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}
.tcg-strip .cnum {
  font-size: 9px;
  letter-spacing: 1.5px;
  opacity: 0.85;
  white-space: nowrap;
}
.tcg-strip .dash {
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(90deg,
    var(--accent-gold) 0 4px, transparent 4px 8px);
  margin: 0 10px;
  opacity: .6;
}

/* Name row — full width (no cost medallion in The Pull) */
.tcg-namerow {
  margin-bottom: 2px;
}

.tcg-name {
  width: 100%;
}
.tcg-name h1 { white-space: nowrap; }
.tcg-name.small h1, .tcg-name.tiny h1 { white-space: normal; }

.tcg-name h1 {
  font-family: 'Grenze Gotisch', serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: 0.6px;
  color: #f6e2a0;
  /* raised emboss (light top edge + dark bottom edge) + dark halo so it reads on bright art */
  text-shadow:
    0 -1px 0 rgba(255, 246, 214, 0.6),
    0 1px 0 #3a2a08,
    0 0 5px #000,
    0 0 9px rgba(0, 0, 0, 0.85),
    0 2px 3px rgba(0, 0, 0, 0.95);
}

.tcg-name.small h1 { font-size: 23px; }
.tcg-name.tiny h1  { font-size: 18px; }

.tcg-name h1::first-letter {
  font-size: 1.25em;
  color: #ffe9a8;
}

/* Filigree under name */
.tcg-flourish {
  display: flex;
  justify-content: center;
  margin: 3px 0 1px;
  color: var(--accent-gold);
}

.tcg-subline {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 12px;
  color: rgba(212, 175, 55, 0.85);
  text-align: center;
  letter-spacing: 1.4px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* === Rotated rarity stamp === */
.tcg-stamp {
  position: absolute;
  top: 132px;
  right: 14px;
  width: 70px;
  height: 70px;
  z-index: 5;
  transform: rotate(-12deg);
  opacity: 0.86;
  color: var(--rarity-color);
}
.tcg-stamp svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tcg-stamp .text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  text-align: center;
  line-height: 1;
}
.tcg-stamp .text .r1 { font-size: 14px; letter-spacing: 1.6px; }
.tcg-stamp .text .r2 { font-size: 6.5px; letter-spacing: 1.4px; margin-top: 2px; opacity: .85; }

/* Faction sigil — small in upper corner of art */
.tcg-sigil {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  z-index: 4;
  color: var(--accent-gold);
  opacity: .85;
}
.tcg-sigil svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7)); }

/* === Bottom panel === */
.tcg-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: none;               /* no bottom scrim — text reads on the art via its own halos */
  padding: 30px 24px 12px 24px;   /* symmetric; clears the gold frame (inset 9px) on both sides */
  z-index: 3;
}
.tcg-bottom.has-stats { padding-left: 100px; }

/* Rendered stats shield bottom-left */
.tcg-stats {
  position: absolute;
  bottom: 14px;
  left: 10px;
  width: 84px;
  height: 96px;
  z-index: 5;
}
.tcg-stats .orn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.85));
}
.tcg-stats .pt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* sit in the shield's recessed center (slightly above the point) */
  padding-bottom: 14px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 22px;
  color: #f5e9c8;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
}

.tcg-effect {
  font-family: 'Spectral', Georgia, serif;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.1px;
  color: #fff;
  /* dark halo so text stays legible on bright art (no panel behind) */
  text-shadow: 0 0 4px #000, 0 0 7px rgba(0,0,0,0.9), 0 1px 2px #000, 0 2px 4px rgba(0,0,0,0.85);
}

.tcg-divider {
  display: flex;
  justify-content: center;
  margin: 8px 0 6px;
  color: var(--accent-gold);
  opacity: .65;
}

.tcg-flavor {
  font-family: 'Spectral', Georgia, serif;
  font-style: italic;
  font-size: 13px;
  color: #f3e6c8;
  line-height: 1.4;
  text-shadow: 0 0 4px #000, 0 0 7px rgba(0,0,0,0.85), 0 1px 2px #000;
  letter-spacing: 0.2px;
}

.tcg-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 55px;              /* lock footer height (QR 48 + padding/border) so COMMON + number sit at the SAME height on every card */
  font-family: ui-monospace, 'SF Mono', 'Roboto Mono', monospace;
  font-size: 8px;
  color: rgba(212, 175, 55, 0.55);
  letter-spacing: 1px;
  margin-top: 10px;
  padding: 6px 16px 0;            /* +24px from .tcg-bottom = ~40px net; clears the bottom corners */
  border-top: 1px dashed rgba(212, 175, 55, 0.25);
}
.foot-info { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.tcg-footer .rar {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 1.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-shadow: 0 0 4px #000, 0 0 7px rgba(0,0,0,0.9), 0 1px 2px #000;
}
.tcg-footer .setcode {
  font-size: 10px;
  letter-spacing: 0.8px;
  color: rgba(231, 217, 184, 0.95);
  text-shadow: 0 0 4px #000, 0 0 6px rgba(0,0,0,0.9), 0 1px 2px #000;
}
.tcg-footer .setmark {
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* === GALLERY === */
.gallery-header {
  max-width: 1500px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
}
.gallery-header h1 {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: #f5e9c8;
  letter-spacing: 1px;
}
.gallery-header p {
  color: #888;
  font-family: ui-monospace, 'SF Mono', 'Roboto Mono', monospace;
  font-size: 12px;
  letter-spacing: 1px;
}

.gallery {
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  /* fixed column = scaled card width (380 * 0.658 = 250) so every thumbnail is identical */
  grid-template-columns: repeat(auto-fill, 250px);
  justify-content: center;
  gap: 26px 20px;
  padding: 0 1rem;
}

/* Each grid cell is a viewport that holds a pixel-identical, uniformly-scaled standalone card.
   Because the card renders at its true 380px then scales as one piece, text wrapping and icon
   sizes match the standalone view exactly. */
.gallery-card {
  display: block;
  width: 250px;
  height: 362px;            /* 350 scaled card + 12px clearance so the bottom frame/corners aren't clipped flush */
  overflow: hidden;
  transition: transform .15s ease;
}
.gallery-card:hover { transform: translateY(-6px); }
.gallery-card .tcg-card {
  width: 380px;             /* true standalone width */
  transform: scale(0.6579); /* 250 / 380 */
  transform-origin: top left;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
}

/* ===== FOIL / EMBOSS ENGINE — rarity-gated premium effect, pointer-reactive ===== */
.gallery-card.tilt {
  transform: perspective(900px) rotateY(var(--rx, 0deg)) rotateX(var(--ry, 0deg)) translateY(-6px) scale(1.03);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.65);
  z-index: 5;
}
.tcg-foil {
  position: absolute; inset: 0; z-index: 9; pointer-events: none; border-radius: 10px; opacity: 0;
  -webkit-mask-image: var(--fmask); mask-image: var(--fmask);
  -webkit-mask-size: cover; mask-size: cover; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  background:
    repeating-linear-gradient(110deg,
      rgba(255,255,255,0) 0%, rgba(255,0,170,.42) 9%, rgba(0,210,255,.42) 18%,
      rgba(110,255,120,.42) 27%, rgba(255,225,0,.42) 36%, rgba(255,255,255,0) 46%),
    radial-gradient(circle at var(--px,50%) var(--py,50%), rgba(255,255,255,.55), rgba(255,255,255,0) 42%);
  background-size: 280% 280%, 100% 100%;
  background-position: var(--fx, 50%) var(--fy, 50%), center;
  mix-blend-mode: color-dodge; filter: saturate(1.6) brightness(1.05);
  transition: opacity .2s ease;
}
.tcg-foil::after {
  content: ''; position: absolute; inset: 0; border-radius: 10px; mix-blend-mode: overlay; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.95) .7px, transparent 1.3px);
  background-size: 6px 6px; background-position: var(--fx, 50%) var(--fy, 50%);
}
.tilt .tcg-card[data-rarity="Uncommon"]  .tcg-foil,
.tcg-card.foil-on[data-rarity="Uncommon"]  .tcg-foil { opacity: .30; }
.tilt .tcg-card[data-rarity="Rare"]      .tcg-foil,
.tcg-card.foil-on[data-rarity="Rare"]      .tcg-foil { opacity: .55; }
.tilt .tcg-card[data-rarity="Mythic"]    .tcg-foil,
.tcg-card.foil-on[data-rarity="Mythic"]    .tcg-foil { opacity: .72; }
.tilt .tcg-card[data-rarity="Legendary"] .tcg-foil,
.tcg-card.foil-on[data-rarity="Legendary"] .tcg-foil { opacity: .80; }
/* webapp / single-card: tilt the card itself toward the pointer */
.tcg-card.foil-on { transform: perspective(900px) rotateY(var(--rx,0deg)) rotateX(var(--ry,0deg)); transition: transform .1s ease; }
/* 3D EMBOSS — COLOURED topographical relief baked from the art's own pixels; sits just
   above the art (below text/frame) and blends NORMAL, so it reads as the image embossed, not a grey ghost */
.tcg-emboss {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: 10px;
  background: var(--emb) center / cover no-repeat;
  mix-blend-mode: normal; opacity: 1;
}
/* moving specular gleam — the embossed "best things" catch the light as you tilt (every rarity) */
.tcg-spec {
  position: absolute; inset: 0; z-index: 8; pointer-events: none; border-radius: 10px; opacity: 0;
  background: radial-gradient(circle at var(--px,50%) var(--py,50%), rgba(255,255,255,.95), rgba(255,255,255,0) 38%);
  -webkit-mask-image: var(--fmask); mask-image: var(--fmask);
  -webkit-mask-size: cover; mask-size: cover; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  mix-blend-mode: color-dodge; transition: opacity .2s ease;
}
.tilt .tcg-spec, .tcg-card.foil-on .tcg-spec { opacity: .5; }

/* ===== 3D EMBOSS viewer (backstage single-card page) ===== */
.cardtabs{display:flex;gap:6px;justify-content:center;margin:16px auto 6px;padding:4px;width:max-content;
  border:1px solid rgba(212,175,55,.28);border-radius:999px;background:rgba(0,0,0,.35);}
.cardtab{appearance:none;border:0;cursor:pointer;font-family:'Bebas Neue',sans-serif;letter-spacing:2px;font-size:14px;
  padding:7px 18px;border-radius:999px;color:rgba(231,217,184,.75);background:transparent;transition:.18s;}
.cardtab:hover{color:#f3e6c4;}
.cardtab.on{color:#1a1206;background:linear-gradient(180deg,#f4d781,#d9ab43);}
.view-3d[hidden]{display:none;}
.emboss3d-wrap{position:relative;width:min(94vw,460px);height:620px;margin:8px auto 0;border-radius:16px;
  background:radial-gradient(120% 90% at 50% 18%,rgba(60,42,90,.5),rgba(8,6,14,.9));
  border:1px solid rgba(212,175,55,.22);overflow:hidden;}
#emboss3d{width:100%;height:100%;display:block;cursor:grab;}
#emboss3d:active{cursor:grabbing;}
.emboss3d-loading{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  font-family:'Bebas Neue',sans-serif;letter-spacing:3px;color:rgba(231,217,184,.7);font-size:16px;}
.emboss3d-toggle{position:absolute;top:12px;left:12px;display:flex;align-items:center;gap:7px;cursor:pointer;
  font-family:'JetBrains Mono',monospace;font-size:11px;letter-spacing:1px;color:rgba(231,217,184,.9);text-transform:uppercase;
  background:rgba(0,0,0,.55);padding:6px 10px;border-radius:8px;border:1px solid rgba(212,175,55,.25);user-select:none;}
.emboss3d-toggle input{accent-color:#d9ab43;width:14px;height:14px;cursor:pointer;}
.emboss3d-hint{position:absolute;left:0;right:0;bottom:10px;text-align:center;pointer-events:none;
  font-family:'JetBrains Mono',monospace;font-size:10px;letter-spacing:2px;color:rgba(231,217,184,.5);text-transform:uppercase;}

/* Prev / All / Next on the single-card page */
.card-nav { max-width: 420px; margin: 1.4rem auto 0; display: flex; gap: 10px; }
.cardnav-btn {
  flex: 1; text-align: center; text-decoration: none; border-radius: 8px; padding: 12px 8px;
  background: linear-gradient(#f3d98a, #cda644); color: #1a1206;
  font-family: 'Bebas Neue', sans-serif; letter-spacing: 2px; font-size: 15px; transition: filter .12s ease;
}
.cardnav-btn:hover { filter: brightness(1.08); }
.cardnav-btn.mid { flex: 1.3; background: #2a2233; color: #e7d9c4; border: 1px solid #4a3e54; }

.faction-filter {
  max-width: 1500px;
  margin: 0 auto 1.5rem;
  display: flex;
  gap: 8px;
  padding: 0 1rem;
  flex-wrap: wrap;
}
.faction-filter button {
  background: transparent;
  color: #ddd;
  border: 1px solid #444;
  padding: 6px 14px;
  border-radius: 16px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
}
.faction-filter button:hover { background: #2a2a2a; }
.faction-filter button.active {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
}

@media print {
  body { background: white; padding: 0; }
  .gallery-header, .faction-filter, .gallery-card:hover { display: none; }
  .tcg-card { width: 63mm; page-break-after: always; box-shadow: none; }
}
