/* Controls (src/ui/controls.js): buttons, fields, sliders, switches, choices, pickers, rows and groups. */
/* ---- controls ------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r);
  background: var(--raised);
  color: var(--text);
  font-weight: var(--fw-button);
  white-space: nowrap;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 var(--white-12),
    0 1px 1px var(--black-50);
  transition: background-color var(--t-state);
}
.btn:is(:hover, .is-hover):not(:disabled) {
  background: var(--raised-hover);
}
.btn.primary {
  background: var(--accent);
  box-shadow:
    inset 0 1px 0 var(--white-18),
    0 1px 1px var(--black-50);
}
.btn.primary:is(:hover, .is-hover):not(:disabled) {
  background: var(--accent-hover);
}
.btn.danger {
  background: var(--danger);
}
.btn.danger:is(:hover, .is-hover):not(:disabled) {
  background: var(--danger-hover);
}
.btn.wide {
  width: 100%;
  height: 34px;
  justify-content: space-between;
  padding: 0 14px;
  font-size: var(--fs-text);
}
.btn.wide:not(:has(.price)) {
  justify-content: center;
}
.btn.grow {
  flex: 1;
  min-width: 0;
  justify-content: space-between;
}
.btn.grow:not(:has(.price)) {
  justify-content: center;
}
.price {
  font-weight: var(--fw-text);
  font-variant-numeric: tabular-nums;
  opacity: 0.92;
}
.buttons {
  display: flex;
  gap: 8px;
}
.buttons .btn {
  flex: 1;
}
.icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--label);
  cursor: pointer;
}
.icon:is(:hover, .is-hover):not(:disabled) {
  background: var(--flat-hover);
}
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-weight: var(--fw-button);
  cursor: pointer;
}
.link:is(:hover, .is-hover):not(:disabled) {
  text-decoration: underline;
}

select,
input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  border: 1px solid var(--group-border);
  border-radius: var(--r-box);
  background: var(--group);
  color: var(--text);
}
/* The recessed box, one material for every group of rows and every choice (CLAUDE.md: "Every box and field has the
   same background and border"): its border, corners and fill are written here once, and it clips what it holds, so a
   row's hover tint, a chosen row's fill or a progress line follows the rounded corners instead of poking out of them.
   A field (above) is the same box but scrolls its text, so it does not clip. dev/tests/boxes.test.mjs hovers every row
   of every box and checks nothing changes outside its corners. */
.rows,
.options,
.facts,
.fact-box,
.picker,
.refs,
.tile-line {
  border: 1px solid var(--group-border);
  border-radius: var(--r-box);
  background: var(--group);
  overflow: clip;
}
select,
input[type="text"],
input[type="password"] {
  height: 28px;
  padding: 0 8px;
}
textarea {
  padding: 8px 10px;
  line-height: 1.5;
  resize: vertical;
}
select:is(:hover, .is-hover):not(:disabled),
input:is(:hover, .is-hover):not(:disabled),
textarea:is(:hover, .is-hover):not(:disabled) {
  border-color: var(--field-hover);
}
::placeholder {
  color: var(--dim);
}
/* slider (controls.js: Slider): a recessed track with a raised thumb; ticks for steps, their marks under them */
.row.slider {
  --thumb: 14px;
} /* (the track, its ticks and their marks are placed by it) */
.slider-track {
  position: relative;
  height: 18px;
}
/* past the last step that can be taken: the rest of the track, dimmed (the disabled look) */
.slider-rest {
  position: absolute;
  top: 6px;
  right: calc(var(--thumb) / 2);
  height: 6px;
  border: 1px solid var(--group-border);
  border-left: 0;
  border-radius: 0 3px 3px 0;
  background: var(--slider-track);
  opacity: 0.45;
  pointer-events: none;
}
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border: 1px solid var(--group-border);
  border-radius: 3px;
  background: var(--slider-track);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border: 1px solid var(--group-border);
  border-radius: 3px;
  background: var(--slider-track);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  position: relative;
  z-index: 1;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--slider-thumb);
  box-shadow: 0 1px 2px var(--edge);
}
input[type="range"]::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: 0;
  border-radius: 50%;
  background: var(--slider-thumb);
  box-shadow: 0 1px 2px var(--edge);
}
input[type="range"]:is(:hover, .is-hover):not(:disabled)::-webkit-slider-thumb {
  background: var(--slider-thumb-hover);
}
input[type="range"]:is(:hover, .is-hover):not(:disabled)::-moz-range-thumb {
  background: var(--slider-thumb-hover);
}
input[type="range"]:is(:focus-visible, .is-focus) {
  outline: none;
}
input[type="range"]:is(:focus-visible, .is-focus)::-webkit-slider-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="range"]:is(:focus-visible, .is-focus)::-moz-range-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.slider-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.slider-ticks i {
  position: absolute;
  top: 13px;
  width: 1px;
  height: 4px;
  margin-left: -0.5px;
  background: var(--slider-tick);
}
.slider-ticks i.major {
  height: 6px;
  background: var(--slider-major);
}
.slider-ticks i.off {
  background: var(--slider-tick);
  opacity: 0.45;
}
.slider-marks span.off {
  opacity: 0.45;
} /* a step that cannot be taken: the one disabled look */
.slider-marks {
  position: relative;
  height: 14px;
  margin-top: -2px;
  color: var(--label);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-text);
  font-variant-numeric: tabular-nums;
  line-height: 14px;
}
.slider-marks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.slider-marks span.first {
  left: 0;
  transform: none;
}
.slider-marks span.last {
  right: 0;
  transform: none;
}
.slider-detail {
  margin-left: 8px;
  color: var(--dim);
  font-size: var(--fs-text);
  font-weight: var(--fw-text);
}
input[type="radio"] {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: none;
  vertical-align: -2px;
  border: 2px solid var(--raised);
  border-top-color: var(--accent-hover);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* choices: rows in one recessed group; the chosen row is tinted and checked */
.options {
  display: grid;
  grid-template-columns: 28px auto 1fr auto; /* 28: the check (16) and the rows' left padding (12), which a subgrid takes from its edge tracks */
  column-gap: 10px;
}
/* the rows share the columns (subgrid), so labels, factors and values line up across rows */
.option {
  position: relative;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  min-height: 32px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background-color var(--t-state);
}
.option input {
  position: absolute;
  opacity: 0 !important;
  pointer-events: none;
}
.option + .option {
  border-top: 1px solid var(--group-line);
}
/* a fact in a box shaped like the controls around it (a region edit's size): text where a picker's text is */
.fact-box {
  display: flex;
  flex-direction: column;
  gap: 1px;
  opacity: 0.45; /* the disabled look: chosen, not choosable */
  padding: 6px 12px;
}
.fact-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.fact-box .option-detail {
  font-size: var(--fs-text);
} /* a fact in the place of a choice (a region edit's size) */
.option:is(:hover, .is-hover):not(.off):not(.on) {
  background: var(--row-hover);
}
.option.on {
  background: var(--row-on);
}
.option-check {
  width: 16px;
  height: 16px;
  color: var(--white);
  opacity: 0;
}
.option.on .option-check {
  opacity: 1;
}
.option:has(input:is(:focus-visible, .is-focus)) {
  outline: 2px solid var(--accent-hover);
  outline-offset: -2px;
}
.option.off {
  cursor: default;
}
.option.off :is(.option-name, .option-detail, .option-value, .option-hint) {
  color: var(--off-text);
}
.option-name {
  font-weight: var(--fw-text);
  min-width: 46px;
  white-space: nowrap;
}
/* wide: the name over its trait, the value on the right */
.options.wide {
  grid-template-columns: 28px 1fr auto;
}
.options.wide .option {
  min-height: 42px;
  padding-top: 6px;
  padding-bottom: 6px;
}
.option-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.option-main .option-detail {
  font-size: var(--fs-text);
}
.option-detail,
.option-hint {
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.option-hint {
  text-align: right;
}
.option-value {
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-text);
  text-align: right;
}
.option-detail.shrinks,
.option.on .option-detail.shrinks {
  color: var(--danger-text);
} /* a size smaller than what goes in */
.option.on .option-detail {
  color: var(--on-accent-detail);
}

/* picker: the current choice in one recessed row, opens to the full list */
.picker {
  display: grid;
  grid-template-columns: 1fr auto 14px;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px 6px 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-state);
}
.picker:is(:hover, .is-hover):not(:disabled),
.picker.open {
  border-color: var(--field-hover);
}
.picker-chev {
  width: 16px;
  height: 16px;
  color: var(--label);
}
.picker .option-name,
.picker .option-detail {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* compact: a choice in a group's row: its name and the arrows, no box of its own (no box in a box) */
.picker.compact {
  display: inline-flex;
  width: auto;
  max-width: 60%;
  min-height: 0;
  gap: 6px;
  margin-right: -6px;
  padding: 3px 4px 3px 8px;
  overflow: visible; /* no box of its own: its press area (::before) is the whole row, clipped by the row's box */
  border: 0;
  border-radius: var(--r);
  background: none;
}
.picker.compact:is(:hover, .is-hover):not(:disabled),
.picker.compact.open {
  background: var(--flat-hover);
}
.picker.compact .option-name {
  min-width: 0;
}
/* the dropdown's menu: floats over the panel, the current choice checked, the pointer's row highlighted */
.dropdown-menu {
  position: fixed;
  z-index: 60;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--corner);
  border-radius: 9px;
  background: var(--pop);
  box-shadow: var(--shadow-float);
  outline: none;
}
.dd-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--sep);
}
.dd-item {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  column-gap: 10px;
  min-height: 46px;
  padding: 5px 10px 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.dd-item.hi {
  background: var(--accent);
}
.dd-item.hi .option-detail {
  color: var(--on-accent-label);
}
.dd-item .option-check {
  opacity: 0;
}
.dd-item.on .option-check {
  opacity: 1;
}
.dd-item.off {
  cursor: default;
}
.dd-item.off :is(.option-name, .option-detail, .option-value) {
  color: var(--off-text);
}
/* switch: on/off settings in the panel (the view bar keeps plain checkboxes) */
input[type="checkbox"].switch {
  appearance: none;
  position: relative;
  width: 32px;
  height: 18px;
  flex: none;
  margin: 0;
  border: 0;
  border-radius: 9px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background-color var(--t-state);
}
input[type="checkbox"].switch::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 2px var(--black-40);
  transition: transform var(--t-state) var(--ease);
}
input[type="checkbox"].switch:checked {
  background: var(--accent);
}
input[type="checkbox"].switch:checked::after {
  transform: translateX(14px);
}
input[type="checkbox"].switch:disabled {
  cursor: default;
}
.row.toggle {
  gap: 10px;
}

/* settings rows (a toggle or a slider each) in one recessed group */
.rows {
  display: flex;
  flex-direction: column;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 6px 12px;
  cursor: default;
}
label.row {
  cursor: pointer;
}
.row + .row {
  border-top: 1px solid var(--group-line);
}
/* a setting's row: its label as every label (like a section's title or switch), its value as data; a slider over
   steps shows the step it is on as data, its detail as a label */
.row-label {
  flex: 1;
  min-width: 0;
  color: var(--label);
}
.row-note {
  flex: none;
  color: var(--dim);
  white-space: nowrap;
} /* what the setting does now ("Moved 20 px") */
.row.slider.steps .row-label {
  color: var(--text);
  font-size: var(--fs-text);
  font-weight: var(--fw-text);
}
.row-value {
  color: var(--text);
  font-weight: var(--fw-text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.row.check {
  gap: 8px;
}
.sec > .row.check {
  min-height: 0;
  padding: 0;
}
.row.check .row-value {
  margin-left: auto;
}
/* checkbox: a 16 px box, checked = blue with a white tick */
input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  border: 1.5px solid var(--dash);
  border-radius: 4px;
  background: var(--group);
  cursor: pointer;
  transition:
    background-color var(--t-state),
    border-color var(--t-state);
}
input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 14px no-repeat;
}
.row.slider {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 12px 10px;
}
.row-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* the run queue's line when progress cannot be told (queue.js) */
@keyframes sweep {
  from {
    left: -35%;
  }
  to {
    left: 100%;
  }
}

/* Disabled: one look for every control (a fixed step disables its settings: a disabled <fieldset>) */
fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
:is(.btn, .link, .icon, .tb-button, .version-pick, select, textarea, input):disabled {
  opacity: 0.4;
  cursor: default;
}
.row:has(input:disabled) {
  opacity: 0.45;
  cursor: default;
}
.options:not(:has(input:enabled)) {
  opacity: 0.45;
}
