/* css/train.css - Repertoire trainer (on top of prepare.css: .exgrid board layout, and repertoire.css) */
.pl { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
#chPick { max-width: 260px; }
.fromform { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.fromform .pl { flex: 1 1 220px; }
#fromText { flex: 1; min-width: 0; font-size: 13px; padding: 5px 9px; }
#fromError:empty { display: none; }
#fromError { flex-basis: 100%; margin: 0; }
/* choosing the start position on the board */
.trmsg.setup { border-left-color: #7ee2a8; }
.smoves { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.smove { border: 1px solid var(--border); background: transparent; color: #e6edf3; border-radius: 999px; padding: 2px 11px; font: 600 13px 'Poppins', sans-serif; cursor: pointer; }
.smove:hover { border-color: var(--gold); color: #ffd60a; }
.smove.main { border-color: var(--gold); }
.sacts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#trBoard { width: var(--exb); }
.trright { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.trmsg { min-height: 52px; border: 1px solid var(--border); border-left: 4px solid var(--gold); border-radius: 10px; padding: 10px 12px; font-size: 14.5px; line-height: 1.6; }
.trmsg b { color: #f0d9a8; }
.trmsg .ok, .trstats .ok { color: #4ade80; font-weight: 600; }
.trmsg .bad, .trstats .bad { color: #f87171; font-weight: 600; }
.trmsg .new { font-size: 11.5px; font-weight: 600; color: #111; background: var(--gold); border-radius: 999px; padding: 1px 9px; margin-right: 4px; }
.trnote { font-size: 13px; color: #cfd6df; font-style: italic; border-left: 3px solid var(--border); padding: 2px 0 2px 10px; }
/* a long comment: 4 lines, "more" shows the rest (train.js showNote) */
.trnote.long:not(.open) .tx { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.trnote .more { background: none; border: 0; padding: 2px 0 0; color: var(--gold); font: inherit; font-style: normal; font-size: 12.5px; cursor: pointer; }
.trnote .more:hover { text-decoration: underline; }
.trline { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; min-height: 1em; }
.tracts { display: flex; gap: 8px; flex-wrap: wrap; }
.tracts:not(:has(button:not([hidden]))) { display: none; }
.trstats { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; }
.trstats b { color: #e6edf3; font-size: 15px; }
.trstats .sess { flex-basis: 100%; }
.trset { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.svst { font-size: 12.5px; color: var(--muted); }
.svst.dirty { color: #fbbf24; font-weight: 600; }
.svst.ok { color: #4ade80; }
.trhow summary { cursor: pointer; font-size: 13px; color: var(--gold); }
.trhow p { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 6px 0 0; }
/* the move to play (a new move, or after a miss) and the last move */
#trBoard .sq-last { box-shadow: inset 0 0 0 100px rgba(255, 214, 10, .28); }
#trBoard .sq-hint { box-shadow: inset 0 0 0 100px rgba(74, 222, 128, .45); }   /* after .sq-last: the hint wins */
#trBoard.viewing { opacity: .8; }   /* ◀ looking back at an earlier move */
@media (max-width: 900px) { #trBoard { width: 100%; } }
/* phones: the training screen stays put (train.js focusMode). Once you chose what to train, the card fills the screen
   (the site header slides away): ☰ choice + side tabs, the message, the board, the comment, the buttons; only the card scrolls. */
.trback, #trGo { display: none; }
@media (max-width: 900px), (max-height: 500px) and (pointer: coarse) {   /* = PHONE in train.js: also a phone held sideways */
  #trGo { display: block; flex-basis: 100%; margin-top: 4px; }
  body.trfocus { overflow: hidden; }
  body.trfocus footer { display: none; }
  body.trfocus #header { transform: translateY(-110%); }   /* the site header slides away: its room goes to the board */
  body.trfocus #trCard { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 900; margin: 0;
    border-radius: 0; border-width: 1px 0 0; padding: calc(8px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-content: start;
    --trb: max(240px, min(calc(100vw - 24px), calc(100dvh - 320px))); }
  body.trfocus .trback { display: flex; align-items: center; gap: 6px; min-width: 0; background: transparent; border: 1px solid var(--border);
    border-radius: 999px; color: var(--gold); font: 600 13px 'Poppins', sans-serif; padding: 5px 12px; cursor: pointer; text-align: left; }
  body.trfocus #trBackTxt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  body.trfocus #trCard .tabs { margin: 0; gap: 6px; }
  body.trfocus #trCard .tab { padding: 5px 12px; font-size: 13px; }
  body.trfocus .exgrid { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
  body.trfocus .trright { display: contents; }
  body.trfocus .trmsg { order: 1; min-height: 0; height: 66px; overflow-y: auto; padding: 7px 10px; font-size: 13.5px; line-height: 1.45; }
  body.trfocus .trmsg.setup { height: auto; max-height: 34vh; }
  body.trfocus .exboardwrap { order: 2; width: var(--trb); max-width: none; margin: 0 auto; }
  body.trfocus #trBoard { width: 100%; touch-action: none; }
  body.trfocus .exboardwrap > .exnav { margin: 6px 0 0 50%; transform: translateX(-50%); width: calc(100vw - 24px); max-width: none; gap: 4px; }
  body.trfocus .exnav .btn { padding: 5px 12px; font-size: 15px; white-space: nowrap; min-width: 44px; }
  body.trfocus .trnote { order: 3; max-height: 5.2em; overflow-y: auto; }
  body.trfocus .tracts { order: 4; justify-content: center; }
  body.trfocus .trmiss { order: 4; }
  body.trfocus .trline { order: 5; }
  body.trfocus .trstats { order: 6; }
  body.trfocus .trweak { order: 6; }
  body.trfocus .trset { order: 7; }
  body.trfocus .trhow { order: 8; }
}
/* phones: the counter next to ☰ (what is left today, this session's ✓ ✗) */
.trcount { display: none; }
@media (max-width: 900px), (max-height: 500px) and (pointer: coarse) {   /* = PHONE in train.js: also a phone held sideways */
  body.trfocus #trCard { grid-template-columns: minmax(0, 1fr) auto; }
  body.trfocus .trback { grid-column: 1 / -1; }
  body.trfocus .trcount { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
  body.trfocus .trcount b { color: #e6edf3; }
  body.trfocus .trcount .ok { color: #4ade80; font-weight: 600; }
  body.trfocus .trcount .bad { color: #f87171; font-weight: 600; }
}
/* right / wrong: the square flashes */
#trBoard .sq-ok { animation: trok .9s ease-out; }
#trBoard .sq-bad { animation: trbad .9s ease-out; }
@keyframes trok { 0%, 35% { box-shadow: inset 0 0 0 100px rgba(74, 222, 128, .75); } 100% { box-shadow: inset 0 0 0 100px rgba(74, 222, 128, 0); } }
@keyframes trbad { 0%, 35% { box-shadow: inset 0 0 0 100px rgba(248, 113, 113, .8); } 100% { box-shadow: inset 0 0 0 100px rgba(248, 113, 113, 0); } }
/* a phone held sideways: the board on the left as high as the screen, the rest on the right */
@media (orientation: landscape) and (max-height: 500px) {
  body.trfocus #trCard { grid-template-columns: var(--trb) minmax(0, 1fr) auto; column-gap: 14px;
    padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    --trb: max(200px, min(calc(100dvh - 76px), 55vw)); }
  body.trfocus .exgrid { display: contents; }
  body.trfocus .exboardwrap { grid-column: 1; grid-row: 1 / 13; align-self: start; position: sticky; top: 0; margin: 0; }
  body.trfocus .exboardwrap > .exnav { width: auto; margin: 6px 0 0; transform: none; }
  body.trfocus .trback { grid-column: 2 / 4; grid-row: 1; }
  body.trfocus .trcount { grid-column: 2; grid-row: 2; }
  body.trfocus #trCard .tabs { grid-column: 3; grid-row: 2; }
  body.trfocus .trmsg { grid-column: 2 / 4; grid-row: 3; }
  body.trfocus .trnote { grid-column: 2 / 4; grid-row: 4; }
  body.trfocus .tracts { grid-column: 2 / 4; grid-row: 5; justify-content: flex-start; }
  body.trfocus .trmiss { grid-column: 2 / 4; grid-row: 6; }
  body.trfocus .trline { grid-column: 2 / 4; grid-row: 7; }
  body.trfocus .trstats { grid-column: 2 / 4; grid-row: 8; }
  body.trfocus .trweak { grid-column: 2 / 4; grid-row: 9; }
  body.trfocus .trgaps { grid-row: 10; }
  body.trfocus .trset { grid-column: 2 / 4; grid-row: 11; }
  body.trfocus .trhow { grid-column: 2 / 4; grid-row: 12; }
}
/* a line is done: tap the board for the next one (train.js tapNext) */
#trBoard { position: relative; }
#trBoard.tapnext { cursor: pointer; }
#trBoard.tapnext::after { content: attr(data-tap); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5;
  pointer-events: none; white-space: nowrap; background: rgba(13, 17, 23, .85); color: #ffd60a; border: 1px solid var(--gold);
  border-radius: 999px; padding: 8px 16px; font: 600 14px 'Poppins', sans-serif; box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  animation: trtap .4s ease-out .3s both; }
@keyframes trtap { from { opacity: 0; transform: translate(-50%, -40%); } to { opacity: 1; transform: translate(-50%, -50%); } }
/* today's mistakes (train.js showMisses) */
.trmiss { border: 1px solid var(--border); border-left: 4px solid #f87171; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.trmiss ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.trmiss li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.trmiss .mline { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; flex: 1 1 100%; }
.trmiss .bad { color: #f87171; font-weight: 600; }
.trmiss b { color: #f0d9a8; }
.trmiss .btn { margin-left: auto; }
/* add to home screen (train.js installUI) */
.trinstall { font-size: 12.5px; color: var(--muted); }
.trinstall:empty { display: none; }
.trinstall b { color: #e6edf3; }
/* the week ahead (train.js weekAhead): quiet small bars under the stats */
.trstats .fc { flex-basis: 100%; display: flex; gap: 6px; align-items: flex-end; margin-top: 2px; }
.fc > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.fc i { display: block; width: 100%; max-width: 26px; background: rgba(197, 157, 95, .45); border-radius: 3px 3px 0 0; }
.fc > div:first-child i { background: var(--gold); }
.fc .fcn { font-size: 10.5px; color: var(--muted); min-height: 1em; }
.fc .fcd { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
/* your weakest spots (train.js showWeak): closed until you open it */
.trweak summary { cursor: pointer; font-size: 13px; color: #f87171; }
.trweak ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.trweak li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.trweak .mline { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; flex: 1 1 100%; }
.trweak .bad { color: #f87171; font-weight: 600; }
.trweak b { color: #f0d9a8; }
.trweak .btn { margin-left: auto; }
/* 🎮 from my games (train.js startGames) and the gaps it finds; 🎯 against an opponent */
.gmrow { font-size: 13px; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fromform.gm > :not(.gmrow):not(#fromError) { display: none; }
.oppnote { margin: 10px 0 0 !important; }
.trgaps summary { color: var(--gold); }
.trgaps small { color: var(--muted); }
/* where the lines start: right of the side tabs (train.js); the typed field is not shown */
#trCard .tabs { flex-wrap: wrap; align-items: center; }
#trCard .tabs .fromform { margin: 0 0 0 auto; }
#trCard .tabs .fromform .pl, #trCard .tabs .fromform > button[type="submit"] { display: none; }
#fromClear { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#trCard .tabs .oppnote { flex-basis: 100%; margin: 4px 0 0 !important; }
body.trfocus #trCard .tabs .fromform { display: none; }
/* laptop / desktop: the rows above the board are gone (title line one row, start buttons on the tabs row), so the board
   gets that height; the buttons under it stay on one line; the week bars stay compact */
body[data-page="train"] .exgrid { --exb: clamp(320px, calc(100vh - var(--hdr, 84px) - 160px), 860px); }
.trright > .tabs { margin: 0; }
#trCard .exnav .btn { white-space: nowrap; }
.trstats .fc { max-width: 460px; }
/* a file with one side only: no White / Black tabs (train.js build) */
#trCard .tabs.oneside > [data-side] { display: none; }
/* 🔬 analysing a position (js/modules/anaboard.js, on the trainer and My puzzles): quick buttons, the moves played, the
   live engine (live-engine.css) */
.anapanel { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.anapanel > * { min-width: 0; }
.anapanel .live-engine { margin-top: 0; }
.anabar { display: flex; flex-wrap: wrap; gap: 6px; }
.anabar:empty { display: none; }
/* not the site's yellow hover (buttons.css): it hides the red / green move, and a phone keeps it after the tap */
.anabar .btn:hover { background: linear-gradient(#232b36, #181e27); transform: none; }
.anabar .btn.cur { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.anabar .btn.bad b { color: #f87171; }
.anabar .btn.good b { color: #4ade80; }
.analine .later { opacity: .45; }
/* phones: the engine under the board; the message and the comment make room for it */
@media (max-width: 900px), (max-height: 500px) and (pointer: coarse) {   /* = PHONE in train.js / puzzles.js */
  body.trfocus .anapanel { order: 3; }
  body.trfocus.analysing .trmsg, body.trfocus.analysing .trnote { display: none; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.trfocus .anapanel { grid-column: 2 / 4; grid-row: 3; }
}
