/* Select All — nested checklists. Every row is a <label> (the whole row is the tap target), the piece is its
   checkbox, and the goal column is a second, read-only box per row. Connector lines are CSS borders.
   PERF: no opacity / filter / transform on any box (see toys.js). Tints come from accent-color and --a. */

.toy.select-all .sa-board {
  --row: 28px;
  --box: 18px;
  --indent: 22px;
  --goal: 44px;
  --wire: color-mix(in srgb, var(--ink) 28%, var(--card));
  position: relative;
  width: min(100%, 430px);
  padding: 10px 6px 8px 10px;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.2;
}

@media (pointer: coarse) {
  .toy.select-all .sa-board {
    --row: 36px;
    --box: 22px;
    --indent: 22px;
    --goal: 46px;
    font-size: 15px;
  }
}

/* "goal" sits in the top border over its column, like a fieldset legend */
.toy.select-all .sa-cap {
  position: absolute;
  top: -8px;
  right: 6px;
  width: var(--goal);
  font-size: 11px;
  font-weight: 900;
  line-height: 14px;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--card);
}

.toy.select-all .sa-row {
  position: relative;
  display: flex;
  height: var(--row);
  border-radius: 6px;
}

.toy.select-all .sa-hit {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.toy.select-all .sa-row[data-lock] .sa-hit {
  cursor: default;
}

/* connector lines: each segment is one indent wide; the line runs under the parent's box centre */
.toy.select-all .sa-lines {
  display: flex;
  flex: none;
  align-self: stretch;
}

.toy.select-all .sa-lines i {
  position: relative;
  flex: none;
  width: var(--indent);
}

.toy.select-all .sa-v::before,
.toy.select-all .sa-t::before,
.toy.select-all .sa-l::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--box) / 2 - 1px);
  border-left: 2px solid var(--wire);
}

.toy.select-all .sa-l::before {
  bottom: calc(50% - 1px);
}

.toy.select-all .sa-t::after,
.toy.select-all .sa-l::after {
  content: "";
  position: absolute;
  top: calc(50% - 1px);
  left: calc(var(--box) / 2 - 1px);
  right: 2px;
  border-top: 2px solid var(--wire);
}

.toy.select-all .sa-box {
  flex: none;
  width: var(--box);
  height: var(--box);
  margin: 0 8px 0 0;
  accent-color: var(--a, var(--ink));
  cursor: pointer;
}

.toy.select-all .sa-box:disabled {
  cursor: default;
}

/* half = the tick colour mixed toward the card, as on the screens */
.toy.select-all .sa-box:indeterminate,
.toy.select-all .sa-goal input:indeterminate {
  accent-color: color-mix(in srgb, var(--a, var(--ink)) 70%, var(--card));
}

.toy.select-all .sa-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toy.select-all .sa-row[data-kind="folder"] .sa-name,
.toy.select-all .sa-row[data-kind="flip"] .sa-name {
  font-weight: 800;
}

.toy.select-all .sa-row[data-lock] .sa-name {
  color: var(--ink-2);
}

.toy.select-all .sa-tag {
  flex: none;
  margin-left: 7px;
  padding: 1px 4px;
  font-size: 10px;
  font-weight: 900;
  line-height: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}

/* mixed toward ink: darker on light cards, lighter on dark ones */
.toy.select-all .t-purple {
  color: color-mix(in srgb, var(--purple) 80%, var(--ink));
}
.toy.select-all .t-blue {
  color: color-mix(in srgb, var(--blue) 80%, var(--ink));
}
.toy.select-all .t-lock {
  color: var(--ink-3);
}

/* the goal column: read-only boxes behind a dashed rule */
.toy.select-all .sa-goal {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--goal);
  margin-left: 6px;
  border-left: 2px dashed color-mix(in srgb, var(--ink) 16%, var(--card));
}

.toy.select-all .sa-goal input {
  width: calc(var(--box) - 2px);
  height: calc(var(--box) - 2px);
  margin: 0;
  pointer-events: none;
  accent-color: var(--a, var(--ink));
}

/* rows that don't match their goal yet */
.toy.select-all .sa-row[data-off] {
  background: color-mix(in srgb, var(--gold) 17%, var(--card));
}

/* hovering or focusing a linked item rings its twin too */
.toy.select-all .sa-row[data-twin] {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--blue) 45%, var(--card));
}

/* solved: the board goes green */
.toy.select-all .sa-board.won .sa-box,
.toy.select-all .sa-board.won .sa-goal input {
  --a: var(--green);
}

/* HUD */
.toy.select-all .sa-hud {
  margin-bottom: -2px;
}

/* level strip: one checkbox per level in two rows, ticked = cleared, gold = par. It spans the board's width,
   so its first and last columns line up with the panel's edges. */
.toy.select-all .sa-levels {
  display: grid;
  grid-template-columns: repeat(var(--cols, 14), 18px);
  gap: 7px 2px; /* the column gap is only a floor: space-between spreads the columns to the board's edges */
  justify-content: space-between;
  width: min(100%, 430px);
  padding: 2px 0;
}

.toy.select-all .sa-levels input {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.toy.select-all .sa-levels input.sa-gold {
  accent-color: var(--gold);
}

.toy.select-all .sa-levels input[data-on] {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.toy.select-all .sa-levels input:disabled {
  cursor: default;
}

@media (pointer: coarse) {
  .toy.select-all .sa-levels {
    grid-template-columns: repeat(var(--cols, 14), 20px);
    row-gap: 8px;
  }
  .toy.select-all .sa-levels input {
    width: 20px;
    height: 20px;
  }
}

/* the narrowest phones (320px): smaller level boxes so the two rows still fit */
@media (max-width: 359px) {
  .toy.select-all .sa-levels {
    grid-template-columns: repeat(var(--cols, 14), 17px);
  }
  .toy.select-all .sa-levels input {
    width: 17px;
    height: 17px;
  }
}
