/**
 * table.css — the UVS play mat
 * ─────────────────────────────────────────────────────
 * Styles every class/ID that uvs/game-engine.js's render functions
 * generate. This file's structure mirrors that file's render
 * functions on purpose — see the section comments.
 *
 * Kept separate from the site-wide style.css (unlike the emulator/
 * builder pages) because this is a genuinely different visual
 * register: real card frames and TCG-board layout, not terminal
 * prose. It still uses the same design tokens (--p, --bg, etc. from
 * style.css's :root) so it reads as part of the same site.
 */

#uvs-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: var(--border);
  background: var(--bg-s);
  padding: 14px;
  margin-top: 14px;
}

/* ── PLAYER ZONES ── */
.player-zone {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.p2-zone { opacity: .92; } /* opponent zone reads very slightly recessed */

.player-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.p1-zone .player-header { order: 3; } /* your header sits below your board */

.player-character {
  width: 56px; height: 56px;
  border: var(--border);
  background: var(--bg);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.ch-art { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.ch-initial { font-size: 1.6rem; font-weight: bold; color: #fff; text-shadow: 0 0 6px rgba(0,0,0,.6); }
.ch-name {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: .5rem; text-align: center; background: rgba(0,0,0,.7);
  color: var(--p-hot); padding: 1px 0;
}

.player-vitals { flex: 1; }
.player-label { font-size: .65rem; letter-spacing: .12em; color: var(--p-dim); }
.life-row { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.life-number {
  font-size: 1.3rem; font-weight: bold; color: var(--p-hot); text-shadow: var(--gs);
  min-width: 2.2ch;
  transition: color .15s;
}
.life-number[data-low="true"]  { color: var(--amber); }
.life-number[data-crit="true"] { color: var(--red); }
.life-number.hit { animation: uvs-hit-flash .5s ease-out; }
@keyframes uvs-hit-flash {
  0%   { transform: scale(1.4); color: var(--red); }
  100% { transform: scale(1); }
}
.life-bar-track {
  flex: 1; height: 6px; background: var(--bg); border: 1px solid var(--p-dim);
  max-width: 160px;
}
.life-bar-fill {
  height: 100%; background: var(--p); box-shadow: var(--gs);
  width: 100%; transition: width .3s ease-out;
}
.deck-count { font-size: .65rem; color: var(--p-dim); }

/* ── FIELD ZONE (played foundations) ── */
.field-zone {
  min-height: 64px;
  display: flex; flex-wrap: wrap; gap: 6px;
  border: 1px dashed var(--p-dim);
  padding: 6px;
  align-items: flex-start;
}
.empty-field, .empty-hand {
  color: var(--p-dim); font-size: .7rem; font-style: italic;
  align-self: center; margin: auto;
}

.field-card {
  border: var(--border);
  background: var(--bg);
  padding: 5px 8px;
  font-size: .68rem;
  min-width: 90px;
}
.field-card.committed { opacity: .5; border-style: dashed; }
.field-card.ready { border-color: var(--p); }
.field-card-name { color: var(--p-hot); font-weight: bold; margin-bottom: 2px; }
.field-card-stats { color: var(--p-mid); }
.field-card-state { color: var(--p-dim); font-size: .6rem; margin-top: 2px; }

/* ── HAND ZONE ── */
.hand-zone {
  min-height: 190px;
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: flex-start;
  padding: 4px;
}

/* ── CARDS (the main visual fix) ── */
.hand-card {
  width: 130px; height: 180px;
  cursor: default;
  transition: transform .12s ease-out;
  flex-shrink: 0;
}
.hand-card.playable { cursor: pointer; }
.hand-card.playable:hover { transform: translateY(-8px); }

.hand-card.face-down {
  background: repeating-linear-gradient(135deg, var(--bg-h), var(--bg-h) 6px, var(--bg) 6px, var(--bg) 12px);
  border: var(--border);
}

.card-inner {
  width: 100%; height: 100%;
  border: 1px solid var(--p-dim);
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.hand-card.playable .card-inner { border-color: var(--p); box-shadow: var(--gs); }

.card-art {
  height: 60px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.card-type-icon { font-size: 1.4rem; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }

.card-body {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 5px 6px;
  gap: 3px;
  overflow: hidden;
}
.card-name {
  font-size: .68rem; font-weight: bold; color: var(--p-hot);
  line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-type-label {
  font-size: .55rem; letter-spacing: .08em; color: var(--p-dim); text-transform: uppercase;
}
.card-stats { display: flex; gap: 6px; flex-wrap: wrap; font-size: .6rem; }
.card-stats .stat { color: var(--p-mid); }
.card-text {
  font-size: .56rem; color: var(--p-dim); line-height: 1.3;
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  margin-top: auto;
}

/* Type-based accent (border-left stripe reads fast at a glance) */
.hand-card.attack     .card-inner { border-left: 3px solid #e53935; }
.hand-card.foundation .card-inner { border-left: 3px solid #43a047; }
.hand-card.action     .card-inner { border-left: 3px solid #fbc02d; }
.hand-card.character  .card-inner { border-left: 3px solid #8e24aa; }

/* ── TABLE CENTER: phase tracker / turn bar / action button ── */
.table-center {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--p-dim);
  border-bottom: 1px solid var(--p-dim);
}
.phase-tracker { display: flex; gap: 4px; }
.phase-pip {
  font-size: .62rem; padding: 3px 10px; border: 1px solid var(--p-dim); color: var(--p-dim);
  letter-spacing: .08em;
}
.phase-pip.active { border-color: var(--p); color: var(--p-hot); box-shadow: var(--gs); }
.phase-pip.done { color: var(--p-mid); border-color: var(--p-mid); }

.active-player-bar { font-size: .78rem; color: var(--p-hot); text-shadow: var(--gs); }

.action-btn {
  background: none; border: var(--border); color: var(--p);
  font-family: var(--mono); font-size: .8rem; padding: 8px 18px; cursor: pointer;
}
.action-btn:hover { border-color: var(--p); box-shadow: var(--gs); }
.action-btn.end-turn { color: var(--amber); border-color: var(--amber); }
.action-btn.waiting { opacity: .5; cursor: default; }
.action-btn.play-again { color: var(--p-hot); border-color: var(--p); }

/* ── COMBAT LOG ── */
.log-panel { max-height: 160px; overflow-y: auto; font-size: .72rem; }
.log-line { padding: 2px 0; color: var(--p-mid); border-bottom: 1px solid rgba(65,255,133,.08); }

/* ── TOOLTIP (self-created by game-engine.js) ── */
#card-tooltip {
  position: fixed;
  display: none;
  width: 220px;
  border: var(--border);
  background: var(--bg-h);
  padding: 8px 10px;
  font-size: .68rem;
  z-index: 500;
  opacity: 0;
  transition: opacity .12s;
  pointer-events: none;
  box-shadow: var(--gm);
}
#card-tooltip.visible { opacity: 1; }
.tip-name { color: var(--p-hot); font-weight: bold; margin-bottom: 2px; }
.tip-type { color: var(--p-dim); font-size: .6rem; text-transform: uppercase; margin-bottom: 6px; }
.tip-stats { display: flex; gap: 8px; flex-wrap: wrap; color: var(--p-mid); margin-bottom: 6px; }
.tip-text { color: var(--p-mid); line-height: 1.4; }
.tip-cost { color: var(--amber); font-size: .62rem; margin-top: 6px; }

/* ── ATTACK FLASH (self-created) ── */
.attack-flash {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%);
  font-size: 2.5rem; font-weight: bold; color: var(--red);
  text-shadow: 0 0 20px rgba(255,64,64,.8);
  z-index: 600;
  animation: uvs-attack-pop .7s ease-out forwards;
  pointer-events: none;
}
@keyframes uvs-attack-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ── GAME OVER BANNER (self-created) ── */
#gameover-banner {
  display: none;
  position: fixed; inset: 0; z-index: 700;
  background: rgba(0,0,0,.85);
  align-items: center; justify-content: center;
}
.go-inner { text-align: center; border: var(--border); background: var(--bg-s); padding: 30px 50px; box-shadow: var(--gm); }
.go-title { font-size: 1.8rem; color: var(--p-hot); text-shadow: var(--gs); margin-bottom: 6px; }
.go-sub { color: var(--p-mid); margin-bottom: 16px; }

/* ── FLASH MESSAGE (self-created) ── */
#flash-msg {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg-h); border: var(--border); padding: 8px 18px;
  font-size: .8rem; color: var(--p-hot);
  z-index: 550;
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
#flash-msg.visible { opacity: 1; }

/* ── RESPONSIVE ── */
@media (max-width: 720px) {
  .hand-card { width: 100px; height: 150px; }
  .card-art { height: 44px; }
  .player-character { width: 44px; height: 44px; }
  .table-center { flex-direction: column; gap: 8px; }
}
