/* Backgammon (js/games/backgammon.js). Kit styles: css/game.css.
 * The board is puzzle art with its own colours: a walnut frame, linen field, terracotta and
 * sage points, ivory checkers for you and graphite for the computer. Highlights on the board
 * use a fixed indigo (the light-theme accent), since the board is light in both themes. */

.bg-room {
  --bg-frame: #3A2C24; --bg-frame-ink: #D9CBB4; --bg-field: #E4D9C2; --bg-tray: #2E231D;
  --bg-pa: #C46A4E; --bg-pb: #6E9A8E;
  --bg-light: #FAF6EC; --bg-light-edge: #8C8270; --bg-light-ring: #E6DDCB;
  --bg-dark: #2A2A31; --bg-dark-edge: #8A8A94; --bg-dark-ring: #3C3C45;
  --bg-mark: #4A4ED4;
  position: absolute; inset: 0; overflow: hidden; background: var(--surface-100);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
:root[data-theme="light"] .bg-room { --bg-frame: #6B4E3B; --bg-frame-ink: #F3E9D8; --bg-field: #F3EBDB; --bg-tray: #5A4131; }

.bg-board { position: absolute; z-index: 0; }
.bg-svg { display: block; overflow: visible; font-family: var(--font-sans); }
.bg-board.bg-nope { animation: bg-nope .32s ease; }
@keyframes bg-nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.bg-frame { fill: var(--bg-frame); }
.bg-field { fill: var(--bg-field); }
.bg-trayrect { fill: var(--bg-tray); }
.bg-trayrect.is-dest { fill: var(--bg-mark); fill-opacity: .55; }
.bg-trayrect.is-hint { fill: var(--bg-mark); fill-opacity: .4; }
.bg-pt { transition: fill-opacity .15s ease; }
.bg-pa { fill: var(--bg-pa); }
.bg-pb { fill: var(--bg-pb); }
.bg-pt.is-dest { fill: var(--bg-mark); fill-opacity: .5; }
.bg-pt.is-hint { fill: var(--bg-mark); fill-opacity: .7; animation: bg-pulse 1.1s ease-in-out 3; }
@keyframes bg-pulse { 50% { fill-opacity: .35; } }
.bg-num { fill: var(--bg-frame-ink); font-size: max(12px, calc(var(--bg-u, 40px) * .34)); font-weight: 500; font-variant-numeric: tabular-nums; pointer-events: none; }

/* checkers */
.bg-ck { pointer-events: none; transition: translate .26s cubic-bezier(.2, .8, .3, 1); }
.bg-ck0 .bg-ck-body { fill: var(--bg-light); stroke: var(--bg-light-edge); stroke-width: 1.5; }
.bg-ck0 .bg-ck-ring { fill: none; stroke: var(--bg-light-ring); stroke-width: 1.5; }
.bg-ck1 .bg-ck-body { fill: var(--bg-dark); stroke: var(--bg-dark-edge); stroke-width: 1.5; }
.bg-ck1 .bg-ck-ring { fill: none; stroke: var(--bg-dark-ring); stroke-width: 1.5; }
.bg-ck.can-move .bg-ck-body { stroke: var(--bg-mark); stroke-width: 3; }
.bg-ck.is-picked .bg-ck-body { stroke: var(--bg-mark); stroke-width: 4.5; filter: drop-shadow(0 0 6px rgba(74, 78, 212, .7)); }
.bg-ck.is-hintck .bg-ck-body { stroke: var(--bg-mark); stroke-width: 4; }
.bg-ck.was-moved .bg-ck-body { stroke: #F2C879; stroke-width: 3; }
.bg-count { font-weight: 600; font-size: calc(var(--bg-u, 40px) * .42); pointer-events: none; }
.bg-count0 { fill: #1B1B22; }
.bg-count1 { fill: #F2EEE6; }
.bg-ghost { fill: rgba(255, 255, 255, .55); stroke: var(--bg-mark); stroke-width: 3; stroke-dasharray: 6 4; pointer-events: none; }

/* borne off */
.bg-slab0 { fill: var(--bg-light); stroke: var(--bg-light-edge); stroke-width: 1; }
.bg-slab1 { fill: var(--bg-dark); stroke: var(--bg-dark-edge); stroke-width: 1; }

/* dice */
.bg-die rect { stroke-width: 1.5; }
.bg-die0 rect { fill: #FFFDF7; stroke: var(--bg-light-edge); }
.bg-die0 circle { fill: #1B1B22; }
.bg-die1 rect { fill: var(--bg-dark); stroke: var(--bg-dark-edge); }
.bg-die1 circle { fill: #F2EEE6; }
.bg-die { transition: opacity .2s ease; }
.bg-die.is-used { opacity: .35; }
.bg-die-wait { fill: none; stroke: #8C8270; stroke-width: 2; stroke-dasharray: 6 5; opacity: .7; }

/* tap areas sit on top of everything */
.bg-hit { fill: transparent; cursor: pointer; }
/* keyboard: the focused point, bar or tray gets the site's focus ring as an outline of its column */
.bg-hit:focus { outline: none; }
.bg-hit:focus-visible { stroke: var(--focus-ring); stroke-width: 3.5; stroke-dasharray: 7 4; fill: color-mix(in srgb, var(--focus-ring) 10%, transparent); }

/* the drag: a checker following the finger or mouse */
.bg-drag { position: absolute; left: 0; top: 0; z-index: 5; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, var(--bg-light) 0 38%, var(--bg-light-ring) 39% 43%, var(--bg-light) 44%);
  box-shadow: 0 0 0 1.5px var(--bg-light-edge), 0 0 0 4px var(--bg-mark), 0 10px 24px rgba(0, 0, 0, .4); }

/* the controls under the board: what's happening, and one big button */
.bg-ctrl { position: absolute; z-index: 2; display: flex; align-items: center; gap: var(--space-4); box-sizing: border-box; padding: 0 2px; }
.bg-ctrl-text { flex: 1; min-width: 0; }
.bg-status { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.25; color: var(--ink); }
.bg-sub { margin: .15rem 0 0; font-size: .85rem; line-height: 1.3; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.bg-main { flex: none; min-width: 8.5rem; min-height: var(--control-lg); font-size: 1.05rem; }
.bg-main[hidden] { display: none; }
.bg-main .icon { width: 1.1rem; height: 1.1rem; }
.bg-done .bg-ctrl { opacity: .5; }

/* between the games of a match */
.bg-between { font-size: 1.05rem; margin: 0 0 var(--space-4); }
.bg-between-score { display: flex; gap: var(--space-6); font-size: 1.1rem; margin: 0 0 var(--space-3); }
.bg-between-score b { font-size: 1.6rem; margin-left: .35rem; font-variant-numeric: tabular-nums; }
.bg-confirm { display: flex; gap: var(--space-3); flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  .bg-ck, .bg-die, .bg-pt { transition: none; }
  .bg-pt.is-hint { animation: none; }
  .bg-board.bg-nope { animation: none; }
}
