/* ANCIENT cards: weathered gold-and-sandstone look with drifting dust motes.
   js/ui.js adds class "ancient", an .ancient-dust layer and the ANCIENT tag.
   Also styles the Pack Crafting panel (Crafting tab). */

/* Same design as a regular card (rarity-coloured frame, dark body, original art), just old:
   a slightly dulled frame, a faded body, and an aging layer (.ancient-dust) with scratches,
   stains, chipped corners and worn edges. Gold is only a thin accent. */
.card.ancient .card-front {
  background:
    radial-gradient(circle at 50% 0%, rgba(235, 215, 170, 0.08), transparent 60%) padding-box,
    linear-gradient(#211c3b, #16122c) padding-box,
    linear-gradient(145deg, color-mix(in srgb, var(--rc) 82%, #b8a07a), color-mix(in srgb, var(--rc) 30%, #000)) border-box;
  animation: ancient-glow 5s ease-in-out infinite alternate;
}
@keyframes ancient-glow {
  from { box-shadow: 0 0 4px 0 rgba(214, 178, 100, 0.12), 0 12px 26px rgba(0, 0, 0, 0.45); }
  to   { box-shadow: 0 0 9px 1px rgba(214, 178, 100, 0.26), 0 12px 26px rgba(0, 0, 0, 0.45); }
}
.card.ancient .card-art { box-shadow: inset 0 0 0 2px rgba(227, 193, 90, 0.4), inset 0 -18px 30px rgba(0, 0, 0, 0.25); }
.card.ancient .card-odds { color: #e6cf94; }

/* aging layer: static wear. It sits inside the frame, so the rarity colour and badges stay clear. */
.ancient-dust {
  position: absolute; inset: 0; z-index: 2; border-radius: 11px; pointer-events: none;
  background:
    /* chipped corners */
    radial-gradient(circle at 0 0, rgba(0, 0, 0, 0.55) 0 7px, transparent 8px),
    radial-gradient(circle at 100% 0, rgba(0, 0, 0, 0.5) 0 5px, transparent 6px),
    radial-gradient(circle at 0 100%, rgba(0, 0, 0, 0.5) 0 6px, transparent 7px),
    radial-gradient(circle at 100% 100%, rgba(0, 0, 0, 0.55) 0 8px, transparent 9px),
    /* stains */
    radial-gradient(ellipse at 10% 90%, rgba(150, 110, 55, 0.26), transparent 45%),
    radial-gradient(ellipse at 92% 8%, rgba(150, 110, 55, 0.2), transparent 40%),
    radial-gradient(ellipse at 70% 55%, rgba(120, 90, 50, 0.1), transparent 35%),
    /* scratches */
    repeating-linear-gradient(112deg, transparent 0 26px, rgba(255, 245, 220, 0.1) 26px 27px, transparent 27px 71px),
    repeating-linear-gradient(67deg, transparent 0 41px, rgba(255, 245, 220, 0.07) 41px 42px, transparent 42px 97px),
    linear-gradient(80deg, transparent 38%, rgba(255, 245, 220, 0.14) 38.5%, transparent 39.5%) 0 0 / 60% 30% no-repeat,
    linear-gradient(-20deg, transparent 52%, rgba(255, 245, 220, 0.12) 52.5%, transparent 53.5%) 100% 90% / 45% 25% no-repeat,
    /* faded wash */
    linear-gradient(rgba(214, 196, 160, 0.07), rgba(214, 196, 160, 0.07));
  box-shadow: inset 0 0 0 1px rgba(255, 235, 190, 0.16), inset 0 0 16px 2px rgba(110, 78, 30, 0.38);
}
/* a few drifting dust motes on top */
.ancient-dust::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background:
    radial-gradient(circle at 20% 80%, rgba(255, 236, 170, 0.3) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(255, 236, 170, 0.25) 0 2px, transparent 3px),
    radial-gradient(circle at 45% 30%, rgba(255, 236, 170, 0.28) 0 1.5px, transparent 3px),
    radial-gradient(circle at 85% 20%, rgba(255, 236, 170, 0.22) 0 2px, transparent 3px);
  animation: ancient-drift 5s ease-in-out infinite alternate;
}
@keyframes ancient-drift { from { transform: translateY(3px); opacity: 0.35; } to { transform: translateY(-4px); opacity: 0.7; } }

.tag-ancient { top: 6px; right: 6px; background: linear-gradient(90deg, #7a5a22, #f3d98a); color: #2e1d08; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); }
.flash.flash-ancient { background: radial-gradient(circle at 50% 45%, #fff 0, rgba(243, 205, 120, 0.6) 25%, transparent 72%); }
.coll-bar.ancient-mode .progress-fill { background: linear-gradient(90deg, #7a5a22, #f3d98a); }
.coll-bar.ancient-mode .coll-text b { color: #f3d98a; }
.sell-row.is-ancient { background: rgba(200, 150, 60, 0.18); }

/* ---------- Pack Crafting panel ---------- */
.craft-tabs { margin-bottom: 1rem; }
.craft-recipe { display: flex; gap: 1rem; align-items: stretch; margin-top: 1rem; padding: 0.9rem; border-radius: 14px; background: rgba(0, 0, 0, 0.22); }
.craft-recipe.ready { box-shadow: 0 0 0 2px rgba(243, 217, 138, 0.55); }
.craft-pack-swatch {
  /* same 220:310 proportions as the real pack; crimped foil edges like the shelf packs */
  position: relative; flex: 0 0 150px; width: 150px; aspect-ratio: 220 / 310; align-self: center;
  display: grid; place-items: center; padding: 0 0.5rem; text-align: center; border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
  clip-path: polygon(0 8px, 5% 0, 10% 8px, 15% 0, 20% 8px, 25% 0, 30% 8px, 35% 0, 40% 8px, 45% 0, 50% 8px, 55% 0, 60% 8px, 65% 0, 70% 8px, 75% 0, 80% 8px, 85% 0, 90% 8px, 95% 0, 100% 8px, 100% calc(100% - 8px), 95% 100%, 90% calc(100% - 8px), 85% 100%, 80% calc(100% - 8px), 75% 100%, 70% calc(100% - 8px), 65% 100%, 60% calc(100% - 8px), 55% 100%, 50% calc(100% - 8px), 45% 100%, 40% calc(100% - 8px), 35% 100%, 30% calc(100% - 8px), 25% 100%, 20% calc(100% - 8px), 15% 100%, 10% calc(100% - 8px), 5% 100%, 0 calc(100% - 8px));
}
.craft-pack-name { font: 400 1.35rem/1.1 var(--font-display); color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
@media (max-width: 520px) { .craft-pack-swatch { flex-basis: 110px; width: 110px; } .craft-pack-name { font-size: 1rem; } }
.craft-recipe-info { flex: 1; min-width: 0; }
.craft-recipe-info h3 { margin: 0 0 0.2rem; font: 400 1.5rem var(--font-display); }
.craft-costs { list-style: none; margin: 0.6rem 0; padding: 0; display: grid; gap: 0.3rem; }
.craft-costs li { display: flex; justify-content: space-between; gap: 1rem; font-weight: 800; }
.craft-costs li.ok b { color: #7be39a; }
.craft-costs li.short b { color: #ff8a80; }

@media (prefers-reduced-motion: reduce) {
  .card.ancient .card-front, .ancient-dust::after { animation: none; }
}
