/* MagicAIl Table — styles: later details of the table: the player's zones, folding column, turn light, icons, tokens.
   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. */

/* ---------- The player's zones: same look as Claude's ---------- */

.zones-player { position: relative; }

.hand.clickable { cursor: pointer; border-radius: 10px; }
.hand.clickable:hover,
#p-pile-library:hover .pile-stack { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--card-r); }
#p-pile-library { cursor: pointer; }

.card-total {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.card-total.wrong { color: var(--red); font-weight: 700; }

.count-menu {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 6px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  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;
}

.count-menu-row {
  display: grid;
  grid-template-columns: 1fr auto 3ch auto;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.count-menu-row b { text-align: center; font-size: 17px; }
.count-menu .count-btn { width: 28px; height: 28px; font-size: 15px; }
.count-menu-close { align-self: flex-end; font-size: 13px; }

/* ---------- Right column folds away: the "i" in the turn bar ---------- */

.info-toggle {
  margin-left: auto;
  align-self: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1.5px solid var(--muted);
  background: transparent;
  color: var(--muted);
  font: italic 700 16px Georgia, serif;
  line-height: 1;
  cursor: pointer;
}

.info-toggle:hover { color: var(--text); border-color: var(--gold); }
.info-toggle.active { color: #1a1408; background: var(--gold); border-color: var(--gold); }

.table-layout.side-collapsed {
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-areas:
    "turn  turn"
    "zones main";
}

.table-layout.side-collapsed .side-panel { display: none; }

@media (max-width: 1100px) {
  .table-layout.side-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "turn" "zclaude" "main" "zplayer";
  }
}

/* ---------- Whose turn: the active player's zones light up ---------- */

.zones { transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s; }

.zones.active-turn {
  border-color: #6fd08f;
  background-color: #1f2d25;
  background-image: radial-gradient(ellipse at 50% 30%, rgba(111, 208, 143, 0.14), transparent 75%);
  box-shadow: 0 0 0 1px rgba(111, 208, 143, 0.35), 0 0 22px rgba(111, 208, 143, 0.18);
}

/* ---------- Claude takes a webcam photo: short flash ---------- */

.webcam-frame.snap { animation: snap-flash 0.6s ease-out; }

@keyframes snap-flash {
  0% { box-shadow: 0 0 0 3px #fff, 0 0 30px rgba(255, 255, 255, 0.9); filter: brightness(1.8); }
  100% { box-shadow: none; filter: none; }
}

/* ---------- Ability icons (Mana font) ---------- */

.ability.has-icon { min-width: 24px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.ability.has-icon .ms { font-size: 14px; line-height: 1; }
.card.big .ability.has-icon { min-width: 34px; height: 30px; }
.card.big .ability.has-icon .ms { font-size: 20px; }

/* Attacking: a red round icon instead of the word. */
.badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.badge-icon .ms { font-size: 13px; line-height: 1; }
.badge-icon.badge-attack { background: var(--red); color: #fff; }
.card.big .badge-icon { width: 34px; height: 34px; }
.card.big .badge-icon .ms { font-size: 18px; }

/* ---------- Land types: piles side by side, "2/3 Mountain" below ---------- */

.land-type-name { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.land-type-name b { color: var(--text); font-size: 13px; }
.land-type-name .ms-cost { font-size: 12px; margin: 0; }
.land-type.single .slot { --under: 0; }
.land-pile { padding-bottom: 0; }
#bf-lands { gap: 16px 22px; align-items: flex-end; }

/* ---------- The player's cards: side by side, not stacked ---------- */

.player-row { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.p-row {
  --card-w: clamp(84px, min(6.6vw, 11.5vh), 140px);
  flex: 1 1 220px;
  min-height: calc(var(--card-w) * 1.4 + 12px);
  gap: 12px;
}
.land-stacks { flex: 1 1 100%; }

/* ---------- Both sides: creatures box left, other cards box right ---------- */

/* Two boxes side by side, always the same height. Cards start at the top. */
.perm-row {
  display: flex;
  gap: 14px 22px;
  align-items: stretch;
}

.player-row > .perm-row { flex: 1 1 100%; }
.perm-row > .bf-row { align-content: flex-start; }
.perm-row > .bf-row:first-child { flex: 1 1 260px; min-width: 0; }

/* The other cards (artifacts, enchantments, Treasures …): as many rows as the creatures box has, top to bottom,
   then the next column (--rows: no script sets it any more since build 67, so it is 1). Only as wide as needed — gone while empty. */
.perm-row > .other-row {
  flex: 0 0 auto;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--rows, 1), max-content);
  grid-auto-columns: max-content;
  align-content: start;
  align-items: start;
}

.perm-row > .other-row:empty { display: none; }

/* ---------- Player markers: Monarch, Initiative … ---------- */

.markers { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.markers:empty { display: none; }

.marker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
}

/* ---------- Claude's library, when shown ---------- */

#pile-library.revealed .pile-stack { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--card-r); }
#pile-library.revealed .pile-label::after { content: " · shown"; color: var(--gold); }

/* ---------- Copy the log ---------- */

.log-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.log-head h3 { margin: 0; }

/* ---------- Double-sided cards: turn over in the big view ---------- */

.flip-btn {
  display: block;
  margin: 8px auto 0;
  padding: 7px 18px;
  border-radius: 999px;
  border: 1px solid #8ccaff;
  background: #2f7fd0;
  color: #fff;
  font: 600 14px var(--font-body);
  cursor: pointer;
}

.flip-btn:hover { background: #3d93ea; }
.flip-btn:focus-visible { outline: 2px solid #cfe8ff; outline-offset: 3px; }

/* Phone: the other cards box goes below the creatures, full width. */
@media (max-width: 620px) {
  .perm-row { flex-wrap: wrap; }
  .perm-row > .other-row { display: flex; flex: 1 1 100%; }
}

/* ---------- Token piles ---------- */

/* Same tokens on one pile: the layers behind (like the land piles) and "×5" on the card. */
.token-pile .pile-layer { left: calc(var(--k) * 3px); }
.slot.tapped.token-pile .pile-layer { left: calc((var(--card-w) * 88 / 63 - var(--card-w)) / 2 + var(--k) * 3px); }
.token-pile { margin-top: 9px; }

/* Top right corner: the power/toughness bottom right stays visible (tokens have no mana cost up there). */
.pile-count-badge {
  position: absolute;
  right: 4%;
  top: 3%;
  z-index: 3;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(13, 19, 16, 0.9);
  border: 1px solid var(--gold);
  color: var(--gold);
  font: 700 13px var(--font-body);
}

/* Treasures at the end of the lands: a little apart, with a thin line. */
.token-lands {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-left: 10px;
  padding-left: 18px;
  border-left: 1px dashed var(--border);
}
/* Tapped pile: the card lies sideways, the number stays readable. */
.slot.tapped .pile-count-badge { transform: rotate(-90deg); }
