/* Rules for the live app only. The mockup never loads this file. */

/* Explorer: board buttons (home, back, next, end, settings) */
.x-nav {
  grid-template-columns: repeat(5, 1fr);
}

/* Explorer: no bar for the line of moves while the board is at the start */
.x-line:not(:has(li)) {
  display: none;
}

/* Explorer: the promotion picker covers the board until a piece is chosen */
.x-promo {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(23, 34, 45, 0.6);
}
.x-promo[hidden] {
  display: none;
}
.x-promo button {
  min-width: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 600 20px/1 var(--ui);
  cursor: pointer;
}
.x-promo button:hover,
.x-promo button:focus-visible {
  border-color: var(--action);
}

/* Explorer: page messages above the panes */
.x-messages {
  margin: 0 0 12px;
}
.x-messages .callout {
  margin: 0 0 6px;
}

/* Explorer: the status row of the moves table holds the state of each numbers cell */
.x-table .x-state-row td {
  padding-top: 4px;
  padding-bottom: 4px;
  border-bottom: 0;
  color: var(--ink-2);
  font: 400 12px/1.3 var(--ui);
  text-align: center;
}
.x-table
  .x-state-row:not(
    :has(.x-cell-text:not(:empty), .x-band-label, [data-x-retry])
  ) {
  display: none;
}
/* With no saved and no other moves the status row stands under Other moves (0), as a
   row of the table */
.x-table tbody + .x-state .x-state-row td {
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.x-band-label {
  display: inline-block;
  font-weight: 500;
}
.x-state-cell .btn {
  margin-left: 6px;
}
.x-table.is-dim tbody:not(.x-state) {
  opacity: 0.45;
}

/* Explorer: table heads and rows */
.x-th-sub,
.x-band-one {
  display: block;
  font: 400 10.5px/1.1 var(--ui);
}
.x-th-band:has(.x-band-one) {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0;
}
.x-play {
  min-height: 28px;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 13px/1 var(--ui);
  white-space: nowrap;
  cursor: pointer;
}
.x-play:hover {
  text-decoration: underline;
}

/* Explorer: the Move column of the moves table is 160px wide, and Lichess and Masters
   share the rest equally. That needs a pane of 544px (160, two numbers cells of 171 and
   the delete column of 42); a narrower pane keeps the table as the other rules make it.
   The scroll box is the container, because the board handle changes the pane and a rule
   on the viewport cannot know it. */
.x-scroll {
  container: xmoves / inline-size;
}
@container xmoves (min-width: 544px) {
  .x-table {
    table-layout: fixed;
  }
  .x-table thead th:first-child {
    width: 160px;
  }
  .x-table thead th:last-child {
    width: 42px;
  }
}

/* Explorer: the collapsed group of removed moves */
.x-removed td {
  padding: 10px 6px 0;
  border-bottom: 0;
}
.x-removed-group > summary {
  padding: 6px 0;
  color: var(--ink-2);
  font: 600 13px/1.3 var(--ui);
}
.x-removed-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.x-removed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid var(--line-soft);
}
.x-removed-act {
  position: relative;
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.x-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}
.x-icon:hover {
  border-color: var(--ink-2);
}
.x-icon.danger {
  color: var(--trim);
}
.x-icon.danger:hover {
  border-color: var(--trim);
  background: var(--trim-bg);
}
.x-icon svg {
  width: 16px;
  height: 16px;
}

/* Explorer: the arrow of the picked saved move stands out */
.x-arrow.picked {
  stroke-width: 0.2;
  opacity: 1;
}

/* Explorer: the message of a Moves list that did not load, above the list */
.x-fail {
  margin: 0 0 8px;
}

/* Explorer: the Stockfish state under its lines (Computing, Stockfish unavailable),
   and the Blunder label after the move of a line, on the same line */
.x-sf-note {
  margin: 6px 0 0;
  color: var(--ink-2);
  font: 400 12px/1.3 var(--ui);
}
.x-sf-note[hidden] {
  display: none;
}
.x-sf-move .x-chip {
  margin-left: 2px;
  padding: 2px 5px;
  font-size: 10.5px;
  vertical-align: 1px;
}

/* Explorer: a move that only turned-off chapters hold says so under the move. The text
   wraps, so the Move column of a phone does not grow. */
.x-turned-off {
  display: block;
  font: 400 11px/1.3 var(--ui);
  color: var(--ink-2);
  white-space: normal;
}
/* Explorer: a move that reaches a course position by another order of moves has a tag
   after the move, the size of the Kept and Cut tags. It goes under them when the Move
   column has no room for it. */
.x-transposed {
  display: inline-block;
  margin-left: 4px;
  padding: 3px 6px;
  border-radius: 9px;
  background: var(--surface);
  font: 600 11px/1 var(--ui);
  color: var(--ink-2);
  white-space: nowrap;
}
.x-table tr.transposed {
  background: var(--min-bg);
}

/* Explorer: an edit that failed shows in the status line under the board, and the
   buttons of an edit are dim while a request is pending */
.x-played.bad {
  color: var(--trim);
}
.x-trash:disabled,
.x-icon:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Explorer: the status line of the text box while the text saves, when it did not
   save (a refusal, the limit) and its Retry button */
.x-saved.saving {
  color: var(--ink-2);
}
.x-saved.bad {
  color: var(--trim);
}
.x-saved button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Explorer: the text of the picked move for a page that cannot edit it keeps its line
   breaks and breaks a word that is too long, so the page does not scroll sideways */
.x-mt-text {
  margin: 0;
  color: var(--ink);
  font: 400 16px/1.6 var(--book);
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* Explorer: the confirm of the Course text link stands in the Notes box, right-aligned
   above the line under the text box (the link is at its right end), as wide as the
   box on a narrow screen. The line is 28 px high, 44 px on a phone. */
.x-note-body {
  position: relative;
}
.x-note-body > .x-confirm {
  top: auto;
  right: 0;
  bottom: 32px;
  width: min(250px, 100%);
}
@media (max-width: 760px) {
  .x-note-body > .x-confirm {
    bottom: 48px;
  }
}

/* Explorer: the panel of the analysis runs is fixed to the window, 16 px above its
   bottom, and lies over the end of the page while a run goes or waits (the Course text
   link of the text box stands there). The page keeps the room of the panel under its
   last card: the 16 px, the head of the panel at 61 px and 12 px of air. The head takes
   two lines when the count of the runs does not fit one (always in the narrow panel of
   a phone; on a screen with a wider font or a long count), so the rule keeps the room
   of two lines at every width. Open, the list of the panel adds its height, 220 px at
   most or 30 % of the window, as the panel sets it. */
body.page-explorer:has(.runs[data-collapsed]:not([hidden])) main {
  padding-bottom: 89px;
}
body.page-explorer:has(.runs:not([data-collapsed], [hidden])) main {
  padding-bottom: calc(89px + min(220px, 30vh));
}

/* Explorer on a phone: the moves table fits its pane. The number columns take the 4px
   padding of the narrow table (the rule of the mockup for them loses to the rule of the
   number columns), the band select is as wide as its longest band, so no band is cut,
   and the numbers go under the bar from 520 px down (the mockup does it at 420 px). The
   tag of a transposed move wraps, as the Kept and Cut tags do, so the Move column can
   narrow. */
@media (max-width: 520px) {
  .x-transposed {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .x-table thead th:nth-child(2),
  .x-table thead th:nth-child(3),
  .x-table td:nth-child(2),
  .x-table td:nth-child(3) {
    padding-left: 4px;
  }
  .x-th-band .x-band {
    max-width: none;
    min-width: max-content;
  }
  .x-stat {
    flex-wrap: wrap;
    gap: 2px;
  }
  .x-stat .x-bar {
    flex-basis: 100%;
  }
  .x-count {
    width: auto;
    text-align: left;
  }
  .x-count .x-n {
    display: inline;
  }
  .x-count .x-share {
    display: inline;
    margin-left: 4px;
  }
  .x-fill {
    display: none;
  }
}
/* The smallest phones: the moves table reaches the sides of its card (the card has 12px
   of padding up to 760 px), and the bar and the delete column get narrower */
@media (max-width: 380px) {
  .x-mid .x-scroll {
    margin-left: -12px;
    margin-right: -12px;
  }
  .x-bar {
    font-size: 10px;
  }
  .x-bar span {
    min-width: 20px;
  }
  .x-table .x-act {
    padding-left: 2px;
    padding-right: 2px;
  }
}

/* The tab row is not printed: the rule of the mockup hides the tabs, and the row and
   its Tabs menu would stay behind */
@media print {
  .tabs-row {
    display: none;
  }
}

/* The Coverage table: the first From is the text 1 as wide as the other From boxes,
   and the slider is a target of 24 px or more */
.cov-targets .cov-fixed {
  display: inline-block;
  min-width: 72px;
  padding: 0 8px;
}
.cov-targets .cov-slider {
  min-height: 24px;
}

/* Admin: the Lichess store panel (Gate 4 spec 3.8.2), from the approved mockup
   docs/mockups/2026-11-26-store-admin (store-panel.css) */
#lichess-store {
  scroll-margin-top: 152px;
}
.store-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.store-head h2 {
  margin: 0;
}
.store-word {
  font-size: 13px;
  padding: 4px 8px;
}
#lichess-store .callout.warn {
  margin-bottom: 12px;
  background: var(--trim-bg);
  border-left-color: var(--trim);
}
#lichess-store .callout.warn strong {
  color: var(--trim);
}
.store-line {
  max-width: 86ch;
  margin-bottom: 12px;
}
.store-facts {
  max-width: 940px;
}
.store-facts th[scope="row"] {
  width: 230px;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
  white-space: normal;
  border-bottom: 1px solid var(--line-soft);
}
.store-facts tr:last-child th {
  border-bottom: 0;
}
.store-facts .bad {
  color: var(--trim);
  font-weight: 500;
}
.store-meter {
  max-width: 320px;
  margin-top: 8px;
}
#store-refill-go,
#store-refill-stop {
  display: flex;
  width: fit-content;
  margin-top: 8px;
}
#lichess-store .actions {
  margin-top: 16px;
}
#store-note {
  margin-top: 12px;
}
#lichess-store > .hint {
  max-width: 100ch;
  margin-top: 8px;
}
.store-rules {
  max-width: 100ch;
  margin: 8px 0 0;
  padding-left: 20px;
}
.store-rules li + li {
  margin-top: 4px;
}
.store-runs-head {
  margin: 24px 0 8px;
}
#lichess-store .scroll-x {
  position: relative;
}
#store-runs {
  min-width: 780px;
}
#store-runs td {
  vertical-align: middle;
}
#store-runs td.cell-end {
  text-align: right;
  white-space: nowrap;
}
#store-runs .skip {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-2);
}
.store-detail > td {
  padding: 12px 16px 16px;
  background: var(--paper);
}
.store-detail .data {
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
}
.store-detail .data + .data {
  margin-top: 12px;
}

@media (max-width: 700px) {
  .store-facts th[scope="row"],
  .store-facts td {
    display: block;
    width: auto;
    padding: 2px 0;
    border: 0;
  }
  .store-facts tr {
    display: block;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .store-facts tr:last-child {
    border-bottom: 0;
  }
}

/* Admin: starting values for new runs */
#defaults-form .start-group + .start-group {
  margin-top: 20px;
}
#defaults-form legend {
  padding: 0;
  margin-bottom: 8px;
}
#defaults-form .start-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 16px;
}
#defaults-form .start-row .field + .field {
  margin-top: 0;
}
#defaults-form .start-row label {
  font-weight: 400;
  color: var(--ink-2);
}
#defaults-form .start-row select,
#defaults-form .start-row input[type="number"] {
  width: 100%;
}
#defaults-form .start-save {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}
#defaults-form .start-save .hint {
  margin: 0;
}
