md-list-item {
  display: block;
}

.md-list-item {
  display: flex;
  align-items: center;
  gap: var(--md-spacing-3xs);
  width: 100%;
  border: none;
  border-radius: var(--md-radius-xs);
  background-color: var(--md-background-primary);
  color: var(--md-content-secondary);
  text-align: left;
  cursor: pointer;
}

/* Rows taller than one line keep the leading element on the first line. */
.md-list-item.md-list-item--align-top {
  align-items: flex-start;
}

/* sizes: sm 32px · mn 40px · lg 48px */

.md-list-item.md-list-item--sm,
.md-list-item.md-list-item--mn {
  font-family: var(--md-text-label-lg-font-family);
  font-size: var(--md-text-label-lg-font-size);
  line-height: var(--md-text-label-lg-line-height);
  letter-spacing: var(--md-text-label-lg-letter-spacing);
  font-weight: var(--md-text-label-lg-regular-font-weight);
}

.md-list-item.md-list-item--sm {
  padding: var(--md-spacing-3xs) var(--md-spacing-2xs);
}

.md-list-item.md-list-item--mn {
  padding: var(--md-spacing-2xs);
}

.md-list-item.md-list-item--lg {
  padding: var(--md-spacing-2xs) var(--md-spacing-xs);
  font-family: var(--md-text-body-mn-font-family);
  font-size: var(--md-text-body-mn-font-size);
  line-height: var(--md-text-body-mn-line-height);
  letter-spacing: var(--md-text-body-mn-letter-spacing);
  font-weight: var(--md-text-body-mn-regular-font-weight);
}

/* Row height: only the padding and the text line set it, so a one-line row is 32 / 40 / 48 with or
   without tag. What sits on the line (leading element, tag) takes the line height; the leading element
   may overflow it, centred, but never pushes the row: the Leading and Tag slots of the design. */

/* Leading slot: a 16px column exactly as tall as the first line of text, so icons and checkboxes
   line up with that line and the text of every row starts at the same point. A taller element (the
   24px accent square in mn) overflows it evenly. */
.md-list-item > .md-list-item__leading {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: var(--md-spacing-xs);
  height: calc(var(--md-text-label-lg-font-size) * var(--md-text-label-lg-line-height));
}

.md-list-item.md-list-item--lg > .md-list-item__leading {
  height: calc(var(--md-text-body-mn-font-size) * var(--md-text-body-mn-line-height));
}

/* FMD glyphs are drawn from a 24px svg with a 3px margin, so a 16px font-size fills the 16px icon
   container of the design. */
.md-list-item .md-list-item__icon {
  font-size: var(--md-font-size-4);
  line-height: var(--md-line-height-1);
}

/* icon accent: the icon on a tinted square, 16px in sm and 24px above */

.md-list-item .md-list-item__accent {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--md-spacing-xs);
  height: var(--md-spacing-xs);
  border-radius: var(--md-radius-xs);
  background-color: var(--md-background-tertiary);
  color: var(--md-content-vivid);
}

.md-list-item.md-list-item--sm .md-list-item__accent > .md-list-item__icon {
  font-size: var(--md-font-size-2);
}

.md-list-item.md-list-item--mn .md-list-item__accent,
.md-list-item.md-list-item--lg .md-list-item__accent {
  width: var(--md-spacing-sm);
  height: var(--md-spacing-sm);
}

/* checkbox: drawn here until md-checkbox exists. No touch area of its own, as the whole row is the
   click target. 12px box in sm, 16px in mn and lg. */

.md-list-item .md-list-item__checkbox {
  display: flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  width: var(--md-spacing-2xs);
  height: var(--md-spacing-2xs);
  border: var(--md-border-width-sm) solid var(--md-content-secondary);
  border-radius: var(--md-radius-2xs);
}

.md-list-item.md-list-item--mn .md-list-item__checkbox,
.md-list-item.md-list-item--lg .md-list-item__checkbox {
  width: var(--md-spacing-xs);
  height: var(--md-spacing-xs);
}

.md-list-item.md-list-item--selected .md-list-item__checkbox,
.md-list-item.md-list-item--indeterminate .md-list-item__checkbox {
  border-color: var(--md-content-brand-secondary);
  background-color: var(--md-content-brand-secondary);
  color: var(--md-content-primary-inverse);
}

.md-list-item .md-list-item__check {
  font-size: var(--md-font-size-2);
  line-height: var(--md-line-height-1);
}

/* text */

.md-list-item > .md-list-item__content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--md-spacing-4xs);
  min-width: 0;
}

.md-list-item .md-list-item__text,
.md-list-item .md-list-item__subtitle {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.md-list-item.md-list-item--lines-2 .md-list-item__text,
.md-list-item.md-list-item--lines-3 .md-list-item__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  white-space: normal;
}

.md-list-item.md-list-item--lines-2 .md-list-item__text {
  -webkit-line-clamp: 2;
}

.md-list-item.md-list-item--lines-3 .md-list-item__text {
  -webkit-line-clamp: 3;
}

.md-list-item .md-list-item__subtitle {
  font-family: var(--md-text-label-mn-font-family);
  font-size: var(--md-text-label-mn-font-size);
  line-height: var(--md-text-label-mn-line-height);
  letter-spacing: var(--md-text-label-mn-letter-spacing);
  font-weight: var(--md-text-label-mn-regular-font-weight);
  color: var(--md-content-tertiary);
}

.md-list-item.md-list-item--lg .md-list-item__subtitle {
  font-family: var(--md-text-label-lg-font-family);
  font-size: var(--md-text-label-lg-font-size);
  line-height: var(--md-text-label-lg-line-height);
  letter-spacing: var(--md-text-label-lg-letter-spacing);
  font-weight: var(--md-text-label-lg-regular-font-weight);
}

/* numeric tag: an md-badge (styles/mdds/components.css) whose size and color the controller picks.
   Its height equals the row's text line (xs 16 in sm and mn, sm 24 in lg), so it never pushes the
   row, and the badge itself never shrinks. Only the disabled color depends on the row (below). */

/* variant colors */

.md-list-item.md-list-item--checkbox-info,
.md-list-item.md-list-item--data-list,
.md-list-item.md-list-item--data-info {
  color: var(--md-content-primary);
}

.md-list-item.md-list-item--destructive,
.md-list-item.md-list-item--destructive-info {
  color: var(--md-content-negative);
}

.md-list-item.md-list-item--positive .md-list-item__icon {
  color: var(--md-content-positive);
}

.md-list-item.md-list-item--negative .md-list-item__icon {
  color: var(--md-content-negative);
}

.md-list-item.md-list-item--notice .md-list-item__icon {
  color: var(--md-content-notice);
}

/* states. Same specificity on purpose, so the order decides: selected wins over hover, and
   disabled over both. */

.md-list-item:hover {
  background-color: var(--md-background-hover);
  color: var(--md-content-primary);
}

.md-list-item.md-list-item--destructive:hover,
.md-list-item.md-list-item--destructive-info:hover {
  color: var(--md-content-negative);
}

.md-list-item.md-list-item--selected {
  background-color: var(--md-background-selected);
  color: var(--md-content-primary);
}

/* Multiple selection: the checkbox shows it, so the row keeps its background. */
.md-list-item.md-list-item--selected.md-list-item--checkbox,
.md-list-item.md-list-item--selected.md-list-item--checkbox-info {
  background-color: var(--md-background-primary);
}

.md-list-item.md-list-item--selected.md-list-item--checkbox:hover:not([disabled]),
.md-list-item.md-list-item--selected.md-list-item--checkbox-info:hover:not([disabled]) {
  background-color: var(--md-background-hover);
}

.md-list-item.md-list-item--selected.md-list-item--destructive,
.md-list-item.md-list-item--selected.md-list-item--destructive-info {
  background-color: var(--md-background-negative-subtle);
  color: var(--md-content-negative-bold);
}

.md-list-item.md-list-item--selected.md-list-item--positive {
  background-color: var(--md-background-positive-subtle);
}

.md-list-item.md-list-item--selected.md-list-item--negative {
  background-color: var(--md-background-negative-subtle);
}

.md-list-item.md-list-item--selected.md-list-item--notice {
  background-color: var(--md-background-notice-subtle);
}

/* message: feedback, not an action, so it has no interactive states */
.md-list-item.md-list-item--message {
  background-color: var(--md-background-primary);
  color: var(--md-content-tertiary);
  cursor: default;
}

.md-list-item.md-list-item--message .md-list-item__text {
  white-space: normal;
}

.md-list-item:focus-visible:not([disabled]),
.md-list-item.md-list-item--focused:not([disabled]) {
  outline: var(--md-border-width-sm) solid var(--md-border-focus);
  /* Inside the row, so it is not clipped by the panel: a 1px ring 2px away from the edge. */
  outline-offset: calc(-1 * (var(--md-border-width-sm) + var(--md-border-width-mn)));
}

/* Doubled class to tie with the three-class variant rules above and win by order. */
.md-list-item.md-list-item[disabled] {
  background-color: var(--md-background-disabled);
  color: var(--md-content-disabled);
  cursor: not-allowed;
}

.md-list-item[disabled] .md-list-item__icon,
.md-list-item[disabled] .md-list-item__subtitle,
.md-list-item[disabled] > .md-list-item__tag {
  color: var(--md-content-disabled);
}

.md-list-item[disabled] .md-list-item__checkbox {
  border-color: var(--md-content-disabled);
}

.md-list-item.md-list-item--selected[disabled] .md-list-item__checkbox,
.md-list-item.md-list-item--indeterminate[disabled] .md-list-item__checkbox {
  background-color: var(--md-content-disabled);
}
