/* <ch-board>: the live board island (docs/18-web.md §7). The element is a square box whatever
   its content: before script it holds the server's SVG diagram, after it the same squares as
   DOM. Every colour is a token; the board wears the accent for its marks like the app's. */
ch-board { display: block; position: relative; aspect-ratio: 1; width: 100%; user-select: none; -webkit-user-select: none; touch-action: none; border-radius: 4px; overflow: hidden; }
ch-board.cb-live { cursor: pointer; }
ch-board > svg.chessboard { position: absolute; inset: 0; width: 100%; height: 100%; }
.cb-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.cb-sq { background: var(--sq-light); position: relative; }
.cb-sq.dark { background: var(--sq-dark); }
.cb-sq .cb-c { position: absolute; font: 500 9px/1 var(--body); font-variant-numeric: tabular-nums; color: var(--sq-dark); opacity: .9; pointer-events: none; }
.cb-sq.dark .cb-c { color: var(--sq-light); }
.cb-sq .cb-c.r { left: 3px; top: 2px; }
.cb-sq .cb-c.f { right: 3px; bottom: 2px; }
@media (min-width: 560px) { .cb-sq .cb-c { font-size: 11px; } }

/* marks: one layer per kind, every mark a 12.5% box moved by --c/--r */
.cb-mark { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)); pointer-events: none; box-sizing: border-box; }
.cb-mark.last { background: var(--hl); opacity: .55; }
.cb-mark.right { background: var(--win); opacity: .38; }
.cb-mark.wrong { background: var(--loss); opacity: .38; }
.cb-mark.sel { background: color-mix(in srgb, var(--accent) 20%, transparent); border: 3px solid var(--accent); }
.cb-mark.dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 34%; height: 34%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--accent); opacity: .7; }
.cb-mark.take { border-radius: 50%; border: 4px solid var(--accent); opacity: .7; }
.cb-mark.ring { border: 3px solid var(--accent); }

.cb-piece { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)); transition: transform 150ms ease; will-change: transform; pointer-events: none; z-index: 2; }
.cb-piece.drag { transition: none; z-index: 4; }
.cb-piece.no-anim { transition: none; }
.cb-piece svg, .cb-piece use { width: 100%; height: 100%; display: block; }

.cb-arrow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.cb-arrow line { stroke: var(--accent); stroke-opacity: .8; stroke-width: .16; stroke-linecap: round; }
.cb-arrow path { fill: var(--accent); }

/* the promotion picker: four pieces stacked from the destination inward */
.cb-promo { position: absolute; left: 0; top: 0; width: 12.5%; height: 50%; transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)); z-index: 5; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.cb-promo.up { flex-direction: column-reverse; }
.cb-promo button { flex: 1; border: 0; background: transparent; padding: 2%; cursor: pointer; }
.cb-promo button:hover { background: var(--fill); }
.cb-promo svg { width: 100%; height: 100%; display: block; }

/* the pages */
.puzzle { max-width: 560px; }
.puzzle-foot { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; min-height: 40px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.daily { display: grid; grid-template-columns: 160px 1fr; gap: 16px; align-items: center; color: inherit; margin-top: 8px; }
.daily:hover { text-decoration: none; border-color: var(--accent); }
.daily-board { width: 160px; }
@media (max-width: 560px) { .daily { grid-template-columns: 120px 1fr; } .daily-board { width: 120px; } }
.terms li a { display: flex; flex-direction: column; gap: 2px; color: inherit; }
.terms li a:hover { text-decoration: none; }
.terms li a b { color: var(--accent); }
.term { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }
.term.with-board { grid-template-columns: minmax(0, 300px) 1fr; }
.term .board { max-width: 300px; }
.term .prose p + p { margin-top: 12px; }
.term .prose { font-size: 16px; line-height: 1.6; color: var(--ink2); }
@media (max-width: 640px) { .term.with-board { grid-template-columns: 1fr; } .term .board { max-width: 100%; } }

/* <ch-replay>: a walk through positions the server computed */
ch-replay { display: block; }
.rp-controls { display: flex; gap: 6px; margin-top: 10px; }
.rp-controls button { flex: 1; height: 40px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink2); font: 600 16px/1 var(--body); cursor: pointer; }
.rp-controls button:hover { border-color: var(--accent); color: var(--accent); }
.rp-controls button:disabled { opacity: .4; cursor: default; }
.rp-moves { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: max-content 1fr 1fr; gap: 2px 8px; font-family: var(--mono); font-size: 14px; max-height: 320px; overflow-y: auto; }
.rp-moves .n { color: var(--mut2); text-align: right; padding: 3px 0; }
.rp-moves button { text-align: left; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 3px 6px; border-radius: 4px; cursor: pointer; }
.rp-moves button:hover { background: var(--card); }
.rp-moves button.on { background: var(--hl); color: var(--ink); }
.rp-moves .gap { padding: 3px 6px; color: var(--mut2); }

/* check: the king's square glows; a premove waits on the accent tint; the drop target outlines */
.cb-mark.check { background: radial-gradient(circle at center, rgba(200, 60, 40, .95) 0%, rgba(200, 60, 40, .55) 45%, rgba(200, 60, 40, 0) 75%); }
.cb-mark.pre { background: var(--accent); opacity: .35; }
.cb-mark.hover { border: 4px solid var(--accent); opacity: .75; }
.cb-piece.drag { cursor: grabbing; }
ch-board.cb-live .cb-pieces { cursor: grab; }
