/* CardQuest — enhanced visuals: portraits, animations, mana crystals, shop, foil */

/* ===== Hero portraits with blood-fill HP ===== */
.hero-portrait {
  width: 70px;
  height: 100px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  position: relative;
}
.hero-portrait .portrait-svg { width: 100%; height: 100%; display: block; }
.hero-portrait.targetable {
  outline: 3px solid #ffd070;
  border-radius: 8px;
  animation: targetPulse 1s infinite;
  cursor: pointer;
}
@keyframes targetPulse {
  0%, 100% { filter: drop-shadow(0 0 6px #ffd070); }
  50%      { filter: drop-shadow(0 0 14px #ff5a3a); }
}
.hero-portrait.damaged {
  animation: heroShake 0.4s;
}
@keyframes heroShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(2deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.blood-fill { transition: y 0.6s cubic-bezier(0.23,1,0.32,1), height 0.6s cubic-bezier(0.23,1,0.32,1); }

.opp-row, .you-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
}
.hero-meta {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; min-width: 0;
}
.hero-name { font-weight: 700; color: var(--gold); font-size: 14px; }
.hp-text { font-size: 14px; color: #ffb0b0; }
.deck-pill { font-size: 12px; opacity: 0.85; }

/* ===== Mana crystals ===== */
.mana-row { display: flex; gap: 2px; flex-wrap: wrap; max-width: 220px; }
.crystal {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1;
  border-radius: 4px;
  transition: all 0.3s;
}
.crystal.full {
  background: radial-gradient(circle, #7dcfff 0%, #3aa8ff 70%, #063a6a 100%);
  box-shadow: 0 0 6px #3aa8ff, inset 0 1px 2px rgba(255,255,255,0.6);
  filter: drop-shadow(0 0 2px #7dcfff);
}
.crystal.empty {
  background: rgba(58, 168, 255, 0.15);
  border: 1px solid rgba(58, 168, 255, 0.4);
  opacity: 0.5;
}
.crystal.slot {
  width: 14px; height: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: 3px;
}

/* ===== Card animations ===== */
.hand-card {
  transition: transform 0.25s cubic-bezier(0.23,1,0.32,1), box-shadow 0.25s;
  animation: cardDealIn 0.4s backwards;
}
@keyframes cardDealIn {
  from { transform: translateY(40px) scale(0.8); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.hand-card.playable:hover, .hand-card.playable:active {
  transform: translateY(-12px) scale(1.06);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6), 0 0 14px var(--gold);
  z-index: 10;
}
.hand-card.played {
  animation: cardPlay 0.5s forwards;
}
@keyframes cardPlay {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  60%  { transform: translateY(-80px) scale(1.4); opacity: 1; box-shadow: 0 0 30px var(--gold); }
  100% { transform: translateY(-160px) scale(0.4); opacity: 0; }
}

.board-card {
  animation: boardSummon 0.45s backwards;
  transition: transform 0.2s, box-shadow 0.25s;
}
@keyframes boardSummon {
  0%   { transform: scale(0.3) translateY(-30px); opacity: 0; }
  60%  { transform: scale(1.15) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.board-card.attacking-up {
  animation: attackUp 0.5s;
  z-index: 50;
}
@keyframes attackUp {
  0%,100% { transform: translateY(0); }
  40%     { transform: translateY(-40px) scale(1.15); filter: brightness(1.3) drop-shadow(0 0 12px var(--gold)); }
  60%     { transform: translateY(-30px) scale(1.1); }
}
.board-card.attacking-down {
  animation: attackDown 0.5s;
  z-index: 50;
}
@keyframes attackDown {
  0%,100% { transform: translateY(0); }
  40%     { transform: translateY(40px) scale(1.15); filter: brightness(1.3) drop-shadow(0 0 12px #ff5a3a); }
  60%     { transform: translateY(30px) scale(1.1); }
}
.board-card.dying {
  animation: cardDeath 0.6s forwards;
  pointer-events: none;
}
@keyframes cardDeath {
  0%   { transform: scale(1) rotate(0); opacity: 1; }
  40%  { transform: scale(1.15) rotate(0); filter: brightness(2); }
  100% { transform: scale(0.2) rotate(45deg); opacity: 0; filter: brightness(0.3); }
}
.board-card.damaged {
  animation: cardDamage 0.4s;
}
@keyframes cardDamage {
  0%,100% { transform: translateX(0); filter: brightness(1); }
  20% { transform: translateX(-4px); filter: brightness(1.5) drop-shadow(0 0 10px #ff3030); }
  40% { transform: translateX(4px); filter: brightness(1.5); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

/* Selected attacker */
.board-card.selected {
  outline: 3px solid #ffd070;
  box-shadow: 0 0 18px #ffd070;
  transform: translateY(-6px);
}
.board-card.ready::after {
  content: '⚔';
  position: absolute; top: -8px; right: -6px;
  background: #ffd070; color: #1a1f3a;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  box-shadow: 0 0 8px #ffd070;
  animation: readyPulse 1.2s infinite;
}
@keyframes readyPulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.2); }
}
.board-card { position: relative; }

/* Holographic foil for rare/epic */
.rarity-rare, .rarity-epic { position: relative; overflow: hidden; }
.rarity-rare::before, .rarity-epic::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.4) 45%, rgba(180,255,255,0.5) 50%, rgba(255,200,255,0.4) 55%, transparent 70%);
  background-size: 200% 200%;
  animation: foilShine 3.5s infinite;
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 5;
}
@keyframes foilShine {
  0%   { background-position: -100% -100%; }
  100% { background-position: 200% 200%; }
}
.rarity-epic { box-shadow: 0 0 16px var(--epic), inset 0 0 8px rgba(196,124,255,0.4); }
.rarity-rare { box-shadow: 0 0 12px var(--rare), inset 0 0 6px rgba(78,168,255,0.3); }

/* ===== Opponent hand of card backs ===== */
.opp-hand {
  display: flex; gap: -10px; align-items: center;
  margin-left: auto;
}
.opp-hand .card-back {
  width: 32px; height: 44px;
  margin-left: -10px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6));
  transform: rotate(0deg);
  transition: transform 0.3s;
}
.opp-hand .card-back svg { width: 100%; height: 100%; display: block; }
.opp-hand .card-back:nth-child(odd) { transform: rotate(-3deg); }
.opp-hand .card-back:nth-child(even) { transform: rotate(3deg); }

/* ===== Floating damage numbers ===== */
.floating-damage-layer {
  position: absolute; inset: 0; pointer-events: none; z-index: 100;
}
.float-num {
  position: absolute;
  font-size: 32px; font-weight: 900;
  color: #fff;
  text-shadow: 0 0 6px #000, 0 2px 4px rgba(0,0,0,0.8);
  animation: floatNum 1.2s forwards;
}
.float-num.damage { color: #ff3a3a; text-shadow: 0 0 8px #fff, 0 2px 4px #500; }
.float-num.heal   { color: #4ec870; text-shadow: 0 0 8px #fff, 0 2px 4px #050; }
@keyframes floatNum {
  0%   { transform: translate(-50%, 0) scale(0.5); opacity: 0; }
  20%  { transform: translate(-50%, -10px) scale(1.4); opacity: 1; }
  100% { transform: translate(-50%, -80px) scale(1); opacity: 0; }
}

/* ===== Shop ===== */
.shop-intro {
  text-align: center; opacity: 0.85; margin: 0 12px 12px;
  color: var(--paper);
}
.shop-filters {
  display: flex; gap: 6px; padding: 0 12px 8px;
  flex-wrap: wrap; justify-content: center;
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; padding: 12px;
  overflow-y: auto;
  height: calc(100% - 140px);
}
.shop-card {
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 8px;
  display: flex; flex-direction: column; align-items: stretch;
  position: relative; overflow: hidden;
}
.shop-card .shop-art {
  width: 100%; height: 110px;
  border-radius: 8px; overflow: hidden;
  background: #000; margin-bottom: 6px;
}
.shop-card .shop-art svg { width: 100%; height: 100%; display: block; }
.shop-card .shop-name { font-weight: 700; font-size: 13px; text-align: center; color: var(--paper); }
.shop-card .shop-mini { font-size: 11px; text-align: center; opacity: 0.85; margin: 2px 0 6px; }
.shop-card .buy-btn {
  background: var(--gold); color: var(--ink);
  border: none; padding: 6px; border-radius: 6px;
  font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.4);
}
.shop-card .buy-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.shop-card .buy-btn:active { transform: translateY(2px); box-shadow: 0 0 0 rgba(0,0,0,0.4); }
.shop-card.purchased {
  animation: purchaseFlash 0.6s;
}
@keyframes purchaseFlash {
  0%,100% { background: rgba(0,0,0,0.4); }
  50%     { background: rgba(244,196,48,0.7); }
}

/* Card-tile art uses the new richer SVG aspect */
.card-tile, .card-tile.small, .hand-card, .board-card, .reveal-card {
  position: relative;
}
.hand-card .hc-art, .board-card .bc-art, .card-tile .ct-art, .reveal-card .rc-art {
  width: 100%; aspect-ratio: 5 / 4; overflow: hidden; border-radius: 6px; background: #000;
}
.hand-card .hc-art svg, .board-card .bc-art svg, .card-tile .ct-art svg, .reveal-card .rc-art svg {
  width: 100%; height: 100%; display: block;
}

/* Pack reveal — flip animation */
.reveal-card {
  animation: revealFlip 0.8s backwards;
  transform-style: preserve-3d;
}
@keyframes revealFlip {
  0%   { transform: rotateY(180deg) scale(0.5); opacity: 0; }
  60%  { transform: rotateY(0) scale(1.15); opacity: 1; }
  100% { transform: rotateY(0) scale(1); opacity: 1; }
}

/* ===== Battle log polish ===== */
.battle-log div {
  animation: logIn 0.3s;
}
@keyframes logIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Make end-turn button glow on your turn */
.end-turn-btn:not(:disabled) {
  animation: endTurnGlow 2s infinite;
}
@keyframes endTurnGlow {
  0%,100% { box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 0 8px rgba(244,196,48,0.4); }
  50%     { box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 0 16px rgba(244,196,48,0.8); }
}

/* Choice button feedback */
.choice-btn.right { background: #4ec870; color: #fff; animation: rightFlash 0.6s; }
.choice-btn.wrong { background: #ff5a3a; color: #fff; animation: wrongShake 0.4s; }
@keyframes rightFlash {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.15); box-shadow: 0 0 16px #4ec870; }
}
@keyframes wrongShake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Element-glow border on creature board cards */
.board-card.element-fire    { box-shadow: 0 0 8px rgba(255,90,58,0.7); }
.board-card.element-water   { box-shadow: 0 0 8px rgba(58,168,255,0.7); }
.board-card.element-earth   { box-shadow: 0 0 8px rgba(110,200,78,0.7); }
.board-card.element-air     { box-shadow: 0 0 8px rgba(200,192,255,0.7); }
.board-card.element-spirit  { box-shadow: 0 0 8px rgba(255,224,112,0.7); }

/* Hand row scrollable on small screens */
.hand-row { overflow-x: auto; padding: 8px; scroll-snap-type: x mandatory; }
.hand-row .hand-card { scroll-snap-align: center; flex-shrink: 0; }

/* Ensure overall layout still fits on phones */
.battle-board { display: flex; flex-direction: column; gap: 4px; padding: 4px; height: calc(100% - 160px); }
.player-area { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.middle-band { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; background: rgba(0,0,0,0.3); border-radius: 6px; }
.turn-indicator { font-weight: 700; color: var(--gold); }
.board-row { display: flex; gap: 6px; padding: 6px; min-height: 90px; overflow-x: auto; }
.board-empty { opacity: 0.5; padding: 20px; text-align: center; flex: 1; }

.battle-log {
  height: 80px; overflow-y: auto;
  background: rgba(0,0,0,0.5);
  border-top: 1px solid var(--gold);
  font-size: 12px; padding: 6px 10px; line-height: 1.4;
}
