/* Vier op een rij: home tile, menu, HUD, board and turn chips. Shared look lives in css/style.css. */

/* ---------- home tile: a little board with a slanting row ---------- */
#tile-vier .tile-art { display: flex; align-items: center; justify-content: center; }
.mini-vier-tile {
  width: 90px;
  height: 70px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 4px;
  border-radius: 14px;
  background: #7b6cf0;
  box-shadow: inset 0 -3px 0 rgba(43, 35, 112, 0.25);
}
.mini-vier-tile span { border-radius: 50%; background: #f4f0ff; display: block; }
.mini-vier-tile svg { width: 100%; height: 100%; display: block; }

/* ---------- menu: the shell's option cards and segments (css/style.css) ---------- */
.option-art .mini-vier { width: 56px; height: auto; }

/* tokens per player: tap to change */
.vier-tokens { display: flex; gap: 12px; justify-content: center; }
.vier-token-pick {
  font: inherit;
  position: relative;
  flex: 0 1 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 10px;
  border: 0;
  border-radius: var(--bz-radius-l);
  background: var(--bz-surface);
  box-shadow: 0 3px 0 var(--bz-brand-edge), var(--bz-shadow-s);
  color: var(--bz-ink);
  font-weight: var(--bz-weight-brand);
  cursor: pointer;
  touch-action: manipulation;
}
.vier-token-pick:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 3px; }
.vier-token-pick .token { width: 70px; height: 70px; }
.vier-token-pick .who { display: inline-flex; align-items: center; gap: 4px; }
.vier-token-pick .swap { position: absolute; top: 6px; right: 10px; font-size: 1.2rem; color: var(--bz-group-ink); }
.robot.tiny { width: 22px; height: 22px; }

/* ---------- HUD ---------- */
#vier-undo.off { visibility: hidden; } /* two players: no undo, but the title stays centred */
#vier-undo:disabled { opacity: 0.45; }
#vier-undo svg { width: 30px; height: 30px; }

/* ---------- board ---------- */
#vier-stage {
  flex: 1;
  min-height: 0;
  min-width: 0; /* sideways 360-dp phones: let the stage shrink next to the HUD column */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 4px 12px 14px;
}
#vier-stage.side { flex-direction: row; }
.vier-board {
  --cols: 7;
  --rows: 6;
  --cell: 48px;
  --frame: #6f5fe6;
  position: relative;
  flex: none;
  padding: calc(var(--cell) * 0.18);
  border-radius: calc(var(--cell) * 0.42);
  background: var(--frame);
  box-shadow: inset 0 -6px 0 rgba(43, 35, 112, 0.25), 0 8px 0 #c9c1ff, 0 14px 30px rgba(59, 47, 168, 0.22);
  touch-action: manipulation;
}
.vier-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
}
.vhole {
  position: relative;
  margin: calc(var(--cell) * 0.06);
  border-radius: 50%;
  background: #f4f0ff;
  box-shadow: inset 0 calc(var(--cell) * 0.07) 0 rgba(43, 35, 112, 0.18);
}
.vhole > svg.token, .vfall > svg.token { position: absolute; inset: -4%; width: 108%; height: 108%; display: block; }
.vfall { position: absolute; pointer-events: none; z-index: 2; }

/* the columns: tall invisible buttons over the board, so a tap anywhere in a column counts */
.vier-cols {
  position: absolute;
  inset: calc(var(--cell) * 0.18);
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
}
.vcol {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: calc(var(--cell) * 0.4);
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.vcol:active:not(:disabled), .vcol:focus-visible { background: rgba(255, 255, 255, 0.22); }
.vcol:focus-visible { outline: 4px solid var(--gold); outline-offset: -2px; }
.vcol:disabled { cursor: default; }
.vcol.wiggle { animation: vier-wiggle 0.4s ease; }

/* four (or three) in a row: a gold ring, and every token in the row hops */
.vhole.win::after {
  content: "";
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  border: calc(var(--cell) * 0.08) solid var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 197, 49, 0.35);
  animation: vier-pulse 0.9s ease-in-out infinite;
  pointer-events: none;
}
.vier-board.won .vhole.win > svg.token { animation: vier-hop 0.6s ease calc(var(--i) * 70ms) 3; }

/* ---------- whose turn ---------- */
.vier-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#vier-stage.side .vier-side { width: 200px; }
.vier-turn { display: flex; gap: 14px; justify-content: center; }
#vier-stage.side .vier-turn { flex-direction: column; }
.vier-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  border: 3px solid transparent;
  background: rgba(255, 255, 255, 0.7);
  color: var(--bz-ink-quiet);
  font-weight: 900;
  transition: transform 0.15s ease;
}
/* whose turn it is not: the token fades, the name stays readable (inactive text in --bz-ink-quiet,
   4.5:1 or more; a faded name failed axe's contrast check, tests/smoke.py a11y) */
.vier-chip .token { width: 44px; height: 44px; flex: none; opacity: 0.6; transition: opacity 0.15s ease; }
.vier-chip.on .token, .vier-chip.winner .token { opacity: 1; }
.vier-chip:not(.on):not(.winner) .name svg { opacity: 0.6; }
.vier-chip .name { display: inline-flex; align-items: center; gap: 4px; }
.vier-chip.on, .vier-chip.winner { background: #fff; color: var(--primary-dark); border-color: var(--gold); transform: scale(1.08); box-shadow: 0 4px 0 #f0d98a; }
.vier-chip.on .arrow {
  position: absolute;
  left: 22px;
  top: -16px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 12px solid var(--accent);
  animation: vier-bob 0.8s ease-in-out infinite;
}
.vier-chip.thinking .token { animation: vier-think 1s ease-in-out infinite; }
.vier-status { margin: 0; min-height: 1.4em; font-weight: 800; color: var(--primary-dark); text-align: center; }

/* the end card shows the winning token */
.vier-ov { display: inline-flex; gap: 8px; }
.ov-art .vier-ov svg { width: 84px; height: 84px; }
.ov-art .vier-ov.won svg { width: 104px; height: 104px; animation: vier-hop 0.6s ease 0.1s 2; }

/* short sideways phones: the HUD becomes a column on the left, the turn chips beside the board */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-vier { flex-direction: row; }
  .vier-hud { flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; }
  .vier-hud .hud-mid { flex: 0; }
  .vier-hud .btn.icon { width: 54px; height: 54px; }
}
/* narrow phones: the computer's levels and the tokens stay on one row, the turn chips fit */
@media (max-width: 360px) {
  #vier-menu .seg-card { font-size: 0.82rem; }
  .vier-token-pick .token { width: 58px; height: 58px; }
  .vier-turn { gap: 8px; flex-wrap: wrap; }
  .vier-chip { gap: 6px; padding: 4px 10px 4px 4px; font-size: 0.92rem; }
  .vier-chip .token { width: 36px; height: 36px; }
  .vier-chip.on, .vier-chip.winner { transform: none; }
  .vier-chip.on .arrow { left: 14px; top: -14px; }
}
/* short screens: a smaller token on the end card, so its buttons stay on screen */
@media (max-height: 600px) {
  .ov-art .vier-ov svg { width: 60px; height: 60px; }
  .ov-art .vier-ov.won svg { width: 72px; height: 72px; }
}

@keyframes vier-hop { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-16%) scale(1.06); } 70% { transform: translateY(2%) scale(0.98, 1.02); } }
@keyframes vier-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes vier-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
@keyframes vier-think { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes vier-wiggle { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

@media (prefers-reduced-motion: reduce) {
  .vier-board.won .vhole.win > svg.token, .vhole.win::after, .ov-art .vier-ov.won svg, .vier-chip.on .arrow, .vier-chip.thinking .token, .vcol.wiggle { animation: none !important; }
}

/* Samen op twee telefoons (spike, only with ?test&coop): the panes of Voortgang overzetten, under
   their own name (its smoke test looks for its own .transfer-pane) */
.coop-pane { width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.coop-pane[hidden] { display: none; }
.coop-pane .btn { min-height: 56px; padding: 0 20px; font-size: 1.05rem; font-weight: 800; }
@media (orientation: landscape) and (max-height: 500px) {
  .coop-pane:not([hidden]) {
    max-width: 760px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    align-content: start;
    column-gap: 18px;
    row-gap: 6px;
    text-align: left;
  }
  .coop-pane > .transfer-qr, .coop-pane > .transfer-cam { grid-row: 1 / span 6; align-self: start; }
  .coop-pane > :not(.transfer-qr):not(.transfer-cam) { grid-column: 2; }
  .coop-pane .btn { min-height: 46px; }
}
.transfer-qr[hidden] { display: none; }
.coop-msg.ok { color: var(--bz-ink); font-size: 1.4rem; font-weight: 900; }
.coop-diag { margin: 4px 0 0; font: 600 0.8rem/1.3 ui-monospace, monospace; color: var(--bz-ink-quiet); text-align: center; }
.coop-diag[hidden] { display: none; }
#coop-pick .btn.big { width: min(100%, 360px); }
