/* Chess Opening Trainer's own look, after the shell every tool shares (../shell/shell.css: the brand, the name card,
   the score, the list down the left, the settings and their "i", the windows, the phone layout, and the wide middle
   column every trainer has). What is here is the board in that column, this run's moves and the mistakes on the left,
   and the phone layout's differences (the board takes the screen; the score and the left column wait in Settings). */
:root {
  --warn: #f0cf6a;
  /* the board */
  --sq-light: #d5dde2;
  --sq-dark: #7e98a8;
  --sq-last: rgba(111, 208, 232, 0.5);
  --sq-sel: rgba(240, 207, 106, 0.6);
}

select { touch-action: manipulation; }
/* the board sizes itself from the room its column leaves (cq units) */
.centre > .stage { display: grid; place-items: center; container-type: size; }

/* the engine thinking: a small turning ring in the name card's corner */
.prompt.is-busy::before { content: ""; position: absolute; top: 9px; inset-inline-start: 12px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--scan); border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ptip p { margin: 0; }

/* the two lines after a stop: what was played and what was better, move by move */
.lines { display: grid; gap: 5px; margin-top: 6px; justify-items: center; }
.lrow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center; }
.lrow .lab { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; margin-inline-end: 4px; }
.lrow.bad .lab { color: var(--bad); } .lrow.good .lab { color: var(--ok); }
.chipmove {
  font: inherit; font-family: var(--f-mono); font-size: 12.5px; font-weight: 500; color: var(--fg); cursor: pointer;
  background: var(--bg-lift); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px;
}
/* moves and scores keep their own order on a page laid out right to left ("1.e4", "+0.3") */
.chipmove, .lrow .lab:last-child { unicode-bidi: isolate; direction: ltr; }
.chipmove:hover { border-color: var(--scan); }
.chipmove[aria-pressed="true"] { border-color: var(--scan); background: #13232c; color: var(--scan); }
.lrow.bad .chipmove:first-of-type { border-color: rgba(255, 122, 107, 0.6); }
.lrow.good .chipmove:first-of-type { border-color: rgba(95, 211, 154, 0.6); }

/* the board is the same in every language, a1 bottom left for White, also on a page laid out right to left */
.table { display: flex; gap: 8px; align-items: stretch; direction: ltr; }
.evalbar {
  width: 10px; border-radius: 5px; overflow: hidden; background: #2a3138; border: 1px solid var(--line-strong);
  display: flex; flex-direction: column; justify-content: flex-end; visibility: hidden;
}
.evalbar.is-on { visibility: visible; }
.evalbar i { display: block; background: var(--sq-light); height: 50%; transition: height .3s ease; }
.evalbar.flip { justify-content: flex-start; }
.board {
  --size: min(calc(100cqw - 18px), 100cqh);
  width: var(--size); height: var(--size); position: relative; flex: none;
  border-radius: 6px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none;
  box-shadow: 0 0 0 1px var(--line-strong), 0 14px 34px rgba(0, 0, 0, 0.45);
  background: var(--sq-dark);
}
.board .squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; background: var(--sq-dark); }
.sq.l { background: var(--sq-light); }
.sq.last::before, .sq.sel::before, .sq.chk::before { content: ""; position: absolute; inset: 0; }
.sq.last::before { background: var(--sq-last); }
.sq.sel::before { background: var(--sq-sel); }
.sq.chk::before { background: radial-gradient(circle, rgba(255, 70, 50, 0.9) 0%, rgba(255, 70, 50, 0.45) 45%, transparent 72%); }
.sq.dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 28%; height: 28%; margin: -14% 0 0 -14%; border-radius: 50%; background: rgba(10, 15, 20, 0.28); }
.sq.dot.cap::after { width: 86%; height: 86%; margin: -43% 0 0 -43%; background: none; box-sizing: border-box; border: calc(var(--size) / 110) solid rgba(10, 15, 20, 0.28); }
.sq .co { position: absolute; font-family: var(--f-mono); font-weight: 600; font-size: clamp(8px, calc(var(--size) / 52), 12px); color: var(--sq-light); line-height: 1; pointer-events: none; }
.sq.l .co { color: #5f7a8a; }
.sq .co.f { right: 3px; bottom: 2px; }
.sq .co.r { left: 3px; top: 2px; }
.board .pieces { position: absolute; inset: 0; pointer-events: none; }
.pc { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; background-size: 100% 100%; background-repeat: no-repeat; will-change: transform; }
.pc.move { transition: transform .16s ease-out; }
.pc.drag { z-index: 5; transition: none; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.4)); }
.board svg.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board.can-move { cursor: pointer; }
.promo { position: absolute; inset: 0; background: rgba(6, 10, 14, 0.55); display: grid; place-items: center; z-index: 8; }
.promo div { display: flex; gap: 6px; background: var(--bg-lift); border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px; }
.promo button { width: calc(var(--size) / 7); height: calc(var(--size) / 7); border: 1px solid var(--line); border-radius: 8px; background: var(--sq-light); cursor: pointer; position: relative; padding: 0; }
.promo button .pc { position: static; width: 100%; height: 100%; display: block; }
.promo button:hover { border-color: var(--scan); box-shadow: 0 0 0 2px var(--scan); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: 100%; }
.actions:empty { display: none; }
.act {
  font: inherit; font-weight: 700; font-stretch: 105%; font-size: 15px; color: var(--fg); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 9px; padding: 11px 16px; min-width: 92px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.act kbd { font-family: var(--f-mono); font-weight: 500; font-size: 10.5px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; }
.act:hover:not(:disabled) { border-color: var(--scan); }
.act:disabled { opacity: .32; cursor: default; }
.act.primary { background: var(--bone); color: #1b1610; border-color: var(--bone); }
.act.primary kbd { color: #5d5345; border-color: #a99c84; }

/* the left column: two cards, this run's moves and the mistakes waiting to be fixed (not a list to pick from, so
   their buttons are the settings' buttons) */
.leftcol .rail { padding: 12px; gap: 8px; min-height: 0; }
.leftcol .rail-title { margin: 0; }
.rail .btn { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--fg); background: var(--bg-lift); border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 10px; }
.rail .btn:hover { border-color: var(--scan); background: var(--bg-lift); }
.rail .btn:disabled { opacity: .45; }
.opening { font-weight: 650; font-size: 13.5px; line-height: 1.35; color: var(--bone); text-wrap: balance; }
.opening small { display: block; font-family: var(--f-mono); font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 2px; }
.movelist { direction: ltr; display: grid; grid-template-columns: auto 1fr 1fr; gap: 2px 10px; font-family: var(--f-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.movelist .n { color: var(--muted); text-align: end; }
.movelist .m { color: var(--fg); }
.movelist .m.setup { color: var(--muted); }
.movelist .m.slip { color: var(--warn); }
.movelist .m.bad { color: var(--bad); text-decoration: line-through; }
.movelist:empty::after { content: "No moves yet"; grid-column: 1 / -1; color: var(--muted); font-family: var(--f-display); font-size: 12.5px; }
.rail p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.rail p b { color: var(--fg); font-weight: 600; }

.pick { font: inherit; font-weight: 600; font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; width: 100%; }

#phoneStats { display: none; }

/* ---------- phones / narrow ---------- */
@media (max-width: 900px) {
  /* the board takes the screen: the score and the left column wait in Settings (#phoneStats) */
  .ui.wide { grid-template-rows: auto minmax(0, 1fr); padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); }
  .ui.wide > .stats, .ui.wide > .leftcol { display: none; }
  .centre { grid-row: 2; overflow-y: auto; scrollbar-width: none; }
  .centre::-webkit-scrollbar { display: none; }
  .ptip { line-height: 1.45; }
  /* the board keeps its full width: when the explanation is long, the column scrolls instead */
  .centre > .stage { flex: none; width: 100%; aspect-ratio: 1; max-height: 60vh; }
  .board { --size: min(100cqw, 100cqh); }
  .evalbar { display: none; }
  .centre > .dock { margin-top: auto; }
  .act { flex: 1 1 28%; min-width: 0; padding: 13px 8px; font-size: 15px; }
  .act kbd { display: none; }
  #phoneStats { display: block; }
}
