/* Tijgers en geitjes: home tile, menu extras, the field, the meadow and the hints. The menu, HUD
   and turn chips reuse Vier op een rij's classes (games/vier/vier.css), as Dammen does. */

/* ---------- home tile ---------- */
#tile-baghchal .tile-art { display: flex; align-items: center; justify-content: center; }
/* `> svg`, not ` svg`: a filter on the pieces nested in the drawing hung Chrome's first paint of the home screen (PR #95, tests/tile-art-css.test.js) */
#tile-baghchal .tile-art > svg { width: 84px; height: 84px; display: block; filter: drop-shadow(0 3px 0 rgba(43, 35, 112, 0.25)); }

/* ---------- menu: the shell's option cards and segments (css/style.css) ---------- */
.bagh-intro { display: flex; align-items: center; gap: 12px; margin: 4px 4px 4px; color: var(--bz-ink-soft); font-weight: var(--bz-weight-text); }
.bagh-intro p { margin: 0; font-size: var(--bz-text-m); line-height: 1.35; }
.bagh-intro-art { flex: none; width: 64px; height: 64px; }
.bagh-intro-art svg { width: 100%; height: 100%; display: block; }
.bagh-opt .option-art svg.piece { width: 54px; height: 54px; }

/* ---------- HUD ---------- */
#baghchal-undo:disabled { opacity: 0.45; }
#baghchal-undo svg { width: 30px; height: 30px; }

/* ---------- the field ---------- */
#baghchal-stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 6px 6px;
}
#baghchal-stage.side { flex-direction: row; gap: 12px; }
.bagh-board {
  --cell: 56px;
  position: relative;
  flex: none;
  padding: calc(var(--cell) * 0.1);
  border-radius: calc(var(--cell) * 0.28);
  background: #8fcf6f;
  box-shadow: inset 0 -5px 0 rgba(43, 90, 30, 0.22), 0 7px 0 #c9e8b4, 0 14px 30px rgba(60, 110, 40, 0.22);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.bagh-board > svg.bagh-lines { position: absolute; inset: calc(var(--cell) * 0.1); width: calc(var(--cell) * 5); height: calc(var(--cell) * 5); display: block; }
.bagh-grid { position: relative; display: grid; grid-template-columns: repeat(5, var(--cell)); grid-template-rows: repeat(5, var(--cell)); }
.bpt { position: relative; display: block; margin: 0; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; font: inherit; -webkit-tap-highlight-color: transparent; touch-action: none; }
.bpt:disabled { cursor: default; }
.bpt:focus-visible { outline: 4px solid var(--gold); outline-offset: -6px; z-index: 2; }
.bpt > svg.piece { position: absolute; inset: 9%; width: 82%; height: 82%; display: block; pointer-events: none; transition: opacity 0.18s ease, transform 0.15s ease; }
.bpt.last::before { content: ""; position: absolute; inset: 18%; border-radius: 50%; background: rgba(255, 255, 255, 0.45); pointer-events: none; }
.bpt.can > svg.piece { filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)); }

/* the chosen piece */
.bpt.sel::after {
  content: "";
  position: absolute;
  inset: 3%;
  border-radius: 50%;
  border: calc(var(--cell) * 0.07) solid var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
.bpt.sel > svg.piece { transform: translateY(-6%) scale(1.06); }
/* where it can go: a round dot; a free point while placing: a soft one */
.bpt.target::after,
.bpt.place::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40%;
  height: 40%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: calc(var(--cell) * 0.06) solid var(--gold);
  box-shadow: 0 2px 0 rgba(43, 35, 112, 0.25);
  animation: bagh-dot 1s ease-in-out infinite;
  pointer-events: none;
}
.bpt.place::after { width: 30%; height: 30%; background: rgba(255, 255, 255, 0.7); border-color: #fff; border-width: 2px; animation: none; }
.bpt.target.hover::after { width: 54%; height: 54%; }
/* the goat a tiger would jump over */
.bpt.over::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 3px dashed #ff9f43; pointer-events: none; }
.bpt.wiggle > svg.piece { animation: bagh-wiggle 0.4s ease; }
.bagh-fly { position: absolute; pointer-events: none; z-index: 5; }
.bagh-fly > svg { position: absolute; inset: 9%; width: 82%; height: 82%; display: block; filter: drop-shadow(0 6px 4px rgba(43, 35, 112, 0.3)); }
.bagh-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; }
.bagh-ghost > svg { width: 100%; height: 100%; display: block; transform: scale(1.12); filter: drop-shadow(0 8px 6px rgba(43, 35, 112, 0.35)); }

/* ---------- the turn chips and the meadow ---------- */
.bagh-side { gap: 8px; }
#baghchal-stage.side .vier-side { width: 236px; flex: none; }
#baghchal-stage.side .vier-turn { flex-direction: column; align-self: stretch; }
#baghchal-stage.side .bagh-chip { box-sizing: border-box; width: 100%; }
#baghchal-stage.side .bagh-chip.on, #baghchal-stage.side .bagh-chip.winner { transform: none; }
.bagh-chip .piece { width: 44px; height: 44px; flex: none; }
.bagh-chip .count { padding: 0 7px; border-radius: 999px; background: #e7f7d8; color: #3c6e2b; text-align: center; font-size: 0.85rem; white-space: nowrap; }
.bagh-chip.thinking .piece { animation: vier-think 1s ease-in-out infinite; }
.bagh-meadow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 12px;
  border-radius: 999px;
  background: #e7f7d8;
  box-shadow: inset 0 -3px 0 rgba(60, 110, 40, 0.15);
}
.bagh-meadow-head { font-size: 0.85rem; font-weight: 900; color: #3c6e2b; white-space: nowrap; }
.bagh-meadow-row { display: flex; gap: 2px; }
.bagh-spot { width: 40px; height: 40px; display: block; }
.bagh-spot svg { width: 100%; height: 100%; display: block; }
.bagh-spot[data-full="true"] svg { animation: bagh-land 0.5s ease; }
#baghchal-stage.side .bagh-meadow { flex-direction: column; gap: 0; padding: 6px 8px 4px; justify-content: center; border-radius: 22px; }
.ov-art .bagh-ov svg { width: 84px; height: 84px; }
.ov-art .bagh-ov.won svg { width: 104px; height: 104px; }

/* short sideways phones: the HUD becomes a column on the left */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-baghchal { flex-direction: row; }
  .bagh-hud { flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; flex: none; width: 116px; }
  .bagh-hud .hud-mid { flex: 0; min-width: 0; text-align: center; }
  .bagh-hud .hud-level { font-size: 0.8rem; line-height: 1.15; white-space: normal; }
  .bagh-hud .dogu-title { font-size: 1.05rem; line-height: 1.15; white-space: normal; }
  .bagh-hud .btn.icon { width: 54px; height: 54px; }
  #baghchal-stage { padding: 5px 6px; }
  #baghchal-stage.side .vier-side { width: 160px; }
  #baghchal-stage.side .vier-turn { gap: 8px; align-self: stretch; }
  .bagh-chip { gap: 5px; padding: 3px 8px 3px 3px; font-size: 0.85rem; min-width: 0; flex-wrap: wrap; }
  .bagh-chip .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  .bagh-chip .name .robot { display: none; }
  .bagh-chip .piece { width: 34px; height: 34px; }
  .bagh-chip.on, .bagh-chip.winner { transform: none; }
  .bagh-chip.on .arrow { left: 10px; top: -12px; }
  .bagh-meadow { padding: 4px 6px; gap: 2px; }
  .bagh-meadow-head { display: none; }
  .bagh-spot { width: 28px; height: 28px; }
  #baghchal-status { font-size: 0.85rem; }
}
/* phones: both chips side by side */
@media (max-width: 420px) {
  .bagh-chip { gap: 6px; padding: 4px 10px 4px 4px; font-size: 0.95rem; }
  .bagh-chip .piece { width: 38px; height: 38px; }
  .bagh-chip .name .robot { display: none; }
  #baghchal-stage .vier-turn { gap: 10px; }
}
@media (max-width: 360px) {
  .bagh-chip { padding: 4px 8px 4px 4px; font-size: 0.88rem; }
  .bagh-chip .piece { width: 32px; height: 32px; }
  .bagh-chip.on, .bagh-chip.winner { transform: none; }
  #baghchal-stage .vier-turn { gap: 6px; }
  .bagh-spot { width: 30px; height: 30px; }
}
@media (max-height: 600px) {
  .ov-art .bagh-ov svg { width: 60px; height: 60px; }
  .ov-art .bagh-ov.won svg { width: 72px; height: 72px; }
}

@keyframes bagh-dot { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.15); } }
@keyframes bagh-wiggle { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8%); } 75% { transform: translateX(8%); } }
@keyframes bagh-land { 0% { transform: translateY(-30%) scale(0.7); } 60% { transform: translateY(4%) scale(1.05); } 100% { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .bpt.target::after, .bpt.wiggle > svg.piece, .bagh-chip.thinking .piece, .bagh-spot[data-full="true"] svg { animation: none !important; }
}
