/**
 * @file
 * The shared weights list (templates/biopama-weights-list.html.twig and
 * biopama-weight-row.html.twig). A criterion is CEAP v1's two lines on the
 * group's background; the group's header mirrors it, so they share columns
 * whatever the texts:
 *
 *   header: edge | switch | chevron | label (count, n off) ... | value | edge
 *   line 1: edge | switch | (i)     | title ...                 | value | edge
 *   line 2: edge | slider ......................................... | edge
 *
 * Hover changes opacity, colour and rotation only, never a size.
 */

.biopama-weights {
  /* Between two columns; wider under a coarse pointer (below). */
  --biopama-weights-gap: 0.5rem;
  /* A criterion's own side padding. */
  --biopama-weights-row-pad: 0.5rem;
  /* The accordion item's edge to the first and the last column: the
     accordion body's px-2 (biopama-accordion-item.html.twig) plus the
     criterion's padding. */
  --biopama-weights-edge: calc(0.5rem + var(--biopama-weights-row-pad));
  /* The value column: fits "100%", and "98%" with the lock icon. */
  --biopama-weights-value: 3.75rem;
}

/* A criterion: no card (no background, border or shadow) and no rules
   between criteria (user, 2026-10-29): spacing separates them. */
.biopama-weight-row {
  padding-left: var(--biopama-weights-row-pad);
  padding-right: var(--biopama-weights-row-pad);
}

/* Gaps here, not in utilities (!important), so the token drives them. */
.biopama-weight-line {
  gap: var(--biopama-weights-gap);
}

.biopama-weight-value-col {
  width: var(--biopama-weights-value);
}

.biopama-weight-value {
  min-width: 2.5rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* The header's first line on the criteria's columns: the switch from the
   edge, the chevron (the button's ::after, moved first) in the information
   buttons' column, the value at the edge. */
.biopama-weights .biopama-accordion-start {
  padding-left: var(--biopama-weights-edge);
  padding-right: var(--biopama-weights-gap);
}

.biopama-weights .accordion-button {
  gap: var(--biopama-weights-gap);
  padding-left: 0;
  padding-right: 0;
}

.biopama-weights .accordion-button::after {
  order: -1;
  width: var(--biopama-icon-btn-size);
  margin-left: 0;
  background-position: center;
}

.biopama-weights .biopama-accordion-actions {
  padding-left: var(--biopama-weights-gap);
  padding-right: var(--biopama-weights-edge);
}

/* The label truncates instead of pushing the value out. */
.biopama-weights-group-name {
  min-width: 0;
}

/* A group's own slider (share scale), the header's second line: full width
   as the criteria's. Hidden while the group is off (the header block is the
   group's row and carries its off state). */
.biopama-weight-group-slider {
  padding: 0 var(--biopama-weights-edge) 0.75rem;
}

.biopama-weights [data-biopama-weight-off] > .biopama-accordion-controls {
  display: none;
}

.biopama-weights-bar {
  gap: var(--biopama-weights-gap);
}

/* Switched off, a criterion or a group: dimmed; the switch keeps its colour
   (it is the way back). A criterion's slider is hidden by the script. A
   lock that cannot be set is not dimmed: grey means off, and its tooltip
   says why. */
.biopama-weights [data-biopama-weight-off] .biopama-weight-dim {
  opacity: 0.55;
}

/* The plus rotates on hover or keyboard focus: a criterion's on the
   criterion, a group's on the header's first line (not on its slider line).
   Hover only where it is real: on touch screens it sticks after a tap. */
.biopama-weight-switch i,
.biopama-weights-group-switch i {
  transition: transform 0.3s ease;
}

.biopama-weight-row:has(:focus-visible) .biopama-weight-switch i.fa-plus,
.biopama-accordion-head:has(> .accordion-header :focus-visible, > .biopama-accordion-start :focus-visible) .biopama-weights-group-switch i.fa-plus {
  transform: rotate(90deg);
}

@media (hover: hover) {
  .biopama-weight-row:hover .biopama-weight-switch i.fa-plus,
  .biopama-accordion-head:has(> .accordion-header:hover, > .biopama-accordion-start:hover) .biopama-weights-group-switch i.fa-plus {
    transform: rotate(90deg);
  }
}

/* Touch: first lines at least 2.75rem tall, and wider gaps so neighbouring
   touch areas (2.75rem around 1.75rem buttons) do not overlap. A pointer
   query, not a width breakpoint. */
@media (any-pointer: coarse) {
  .biopama-weights {
    --biopama-weights-gap: 1rem;
  }

  .biopama-weight-line {
    min-height: 2.75rem;
  }
}
