/* MagicAIl Table — styles: Commander: command zones and life pop-up, face-down cards.
   The styles are split into files in their old order (build 71, before: one style.css); index.html loads them in
   this order, so later rules still win over earlier ones. */

/* ---------- Commander: the command zones and the life pop-up ---------- */

/* In the middle of the left column: Claude's commander under Claude's box, yours above your box — face to face. */
.command-zone {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.command-zone[hidden] { display: none; }

.cmd-slot {
  --card-w: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cmd-slot:hover { border-color: var(--gold); }
.cmd-slot:focus { outline: none; }
.cmd-slot:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* Yours mirrored: the two commanders look at each other. */
.cmd-human { flex-direction: row-reverse; text-align: right; }

/* The commander of the player whose turn it is lights up like their box. */
.cmd-slot { transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s; }
.cmd-slot.active-turn {
  border-color: #6fd08f;
  background-color: #1f2d25;
  box-shadow: 0 0 0 1px rgba(111, 208, 143, 0.35), 0 0 16px rgba(111, 208, 143, 0.18);
}

.cmd-card { position: relative; flex: none; transition: opacity 0.2s, filter 0.2s; }

/* Commander games: the piles in the boxes a bit smaller, so both command zones fit in between. */
.commander-game .zone-piles .pile { --card-w: 70px; }
.commander-game .zone-piles.with-exile .pile { --card-w: 52px; }
/* Not in the command zone (on the battlefield, on the stack …): only a shadow of it stays here. */
.cmd-card.out { opacity: 0.35; filter: grayscale(0.7); }

.cmd-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
  line-height: 1.2;
}

.cmd-who {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* Up to two lines, then "…". */
.cmd-name {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* Commander tax for the next cast: a round tile like a generic mana symbol, half over the card's lower edge. */
.cmd-tax {
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #cbc5bd;
  color: #15130f;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.life-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: fade-in 0.15s ease-out;
}

.life-menu[hidden] { display: none; }

.life-menu-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.life-menu-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 34px 34px 5.5ch 34px 34px;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.life-menu-row[hidden] { display: none; }
.life-menu-row b { text-align: center; font-size: 17px; white-space: nowrap; }
.life-menu-row b.lethal { color: var(--red); }
.life-menu .count-btn { width: 34px; height: 28px; font-size: 13px; border-radius: 8px; }

/* Wide window: the command zone takes the free height of the left column. With enough room each commander shows
   big — "Sir Mulligan's commander" on top, the whole card as large as it fits in the middle, the name below; the two
   share the height. With little room the compact boxes stay (the card small at the side). */
@media (min-width: 1101px) {
  .command-zone:not([hidden]) {
    flex: 1 1 0;
    min-height: 136px;
    justify-content: center;
    container: cmdzone / size;
  }
  @container cmdzone (min-height: 420px) {
    .cmd-slot,
    .cmd-human {
      --card-w: max(60px, min(100cqw - 40px, (50cqh - 112px) * 63 / 88));
      flex: 1 1 0;
      min-height: 0;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      gap: 8px;
      padding: 10px 12px 12px;
      text-align: center;
    }
    .cmd-info { display: contents; }
    .cmd-who { order: 0; }
    .cmd-card { order: 1; }
    .cmd-name { order: 2; font-size: 17px; }
  }
}

/* One column (narrow screens): Claude's commander right under Claude's box, yours right above your box. */
@media (max-width: 1100px) {
  .command-zone { display: contents; }
  .cmd-claude { grid-area: zcmdc; }
  .cmd-human { grid-area: zcmdp; }
}

/* ---------- Face-down cards (Morph, Manifest, Disguise, Foretell) ---------- */

.face-down-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 63 / 88;
}

.face-down-card .card-back { width: 100%; }

.fd-label,
.fd-pt {
  position: absolute;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(13, 19, 16, 0.88);
  color: var(--gold);
  font-weight: 700;
  font-size: clamp(8px, calc(var(--card-w) * 0.09), 13px);
  line-height: 1.4;
  white-space: nowrap;
}

.fd-label { top: 7%; left: 50%; transform: translateX(-50%); text-transform: uppercase; letter-spacing: 0.06em; }
.fd-pt { right: 7%; bottom: 5%; color: var(--text); }

/* The server's build number at the bottom of the page. */
.build-tag { display: block; margin-top: 4px; font-size: 10px; letter-spacing: 0.04em; opacity: 0.55; }
.build-tag:empty { display: none; }

/* The commanders on the table: a crown. */
.badge-commander { background: var(--gold); color: #1a1408; font-size: 12px; line-height: 1.2; padding: 0 5px; text-transform: none; }

@media (max-width: 1100px) {
  .table-layout.side-collapsed.commander-game { grid-template-areas: "turn" "zclaude" "zcmdc" "main" "zcmdp" "zplayer"; }
}

/* A Saga's chapter (lore counters) as on the card: "I/III". */
.counter-saga { font-family: var(--font-display); letter-spacing: 0.04em; }

/* Claude's side mirrored: the lands line up along Claude's edge (top), the cards sit at the bottom of their boxes,
   right at the middle of the table — facing the player's creatures. */
#bf-lands { align-items: flex-start; }
#bf-permanents,
#bf-other { align-content: flex-end; }

/* Both creature areas share the free height half and half: each side starts from its fixed part (lands, padding,
   title — js/table.js sets it as flex-basis, see balanceSides) and both grow by the same amount. A side whose cards need
   more takes it from the other, never below what the other's cards need (min-height: auto). The combat arena takes
   its room from both. */
.claude-side { flex: 1 1 0; }
.claude-row { flex: 1 1 auto; }
.player-side { flex: 1 1 0; display: flex; flex-direction: column; }
.player-row { flex: 1 1 auto; flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
.player-row > .perm-row { flex: 1 1 auto; }
.player-row > .land-stacks { flex: 0 0 auto; }
