/*
 * THE LIST ROW'S OWN BOX; the row is `row.css`'s. Here: the bleed, corner, press states and UA
 * face. The wash sits on the wrapper but answers the region's hover, so the row lights as one
 * without lighting for a slot control.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  /* One gap, the lead's, so the slot sits as far from the row as its parts do. */
  .lotics-list-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--lotics-lead-gap);
    flex-shrink: 0;
    min-width: 0;
    position: relative;
    padding-inline: var(--lotics-space-8);
    margin-inline: calc(var(--lotics-space-8) * -1);
    /* §5 rule 1: an `option` row is the `<button>`. */
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    color: var(--lotics-ink-default);
    text-align: start;
    /* A row is read, not pressed. */
    border-radius: var(--lotics-radius-control);
    background-color: transparent;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  /* Sized to content and wholly the target, so it needs no inner press region. */
  .lotics-list-item[data-variant="option"] {
    box-sizing: border-box;
    width: 100%;
    padding-block: var(--lotics-space-8);
    margin-inline: 0;
    border: 0 solid transparent;
    background-color: transparent;
    --lotics-icon-color: currentColor;
    appearance: none;
    cursor: pointer;
    user-select: none;
  }

  .lotics-list-item[data-variant="option"]:focus-visible {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }

  .lotics-list-item[data-variant="option"][data-disabled] {
    opacity: var(--lotics-disabled-opacity);
    cursor: default;
  }

  .lotics-list-item[data-variant="option"][data-pressable]:not([data-disabled]):not([data-selected]):hover {
    background-color: var(--lotics-wash-hover);
  }

  .lotics-list-item[data-variant="option"][data-pressable]:not([data-disabled]):active {
    background-color: var(--lotics-wash-press);
  }

  /* The overline names the title, so they sit closer than title and description. */
  .lotics-list-item__overline {
    margin-bottom: var(--lotics-space-2);
    max-width: 100%;
  }

  /* Takes the slack so the row presses everywhere it is about. */
  .lotics-list-item__press {
    align-self: stretch;
    flex: 1;
    min-width: 0;
    /* Bleeds through the inset so the row presses to its edges. */
    margin-block: calc(var(--lotics-row-inset) * -1);
    border: 0 solid var(--border);
    border-radius: 0;
    background-color: transparent;
    /* §5 rule 1. */
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    color: var(--lotics-ink-default);
    padding-block: var(--lotics-row-inset);
    padding-inline: 0;
    appearance: none;
    /* A settings row is a surface, not a verb. */
    cursor: auto;
    text-align: start;
    user-select: none;
  }

  .lotics-list-item__press:focus-visible {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }

  /*
   * Hover once painted the selected grey, erasing which row was open. `PressableRow`'s ladder:
   * hover lighter than selection and excluded from it; press outranks both.
   */
  .lotics-list-item:not([data-variant="option"]):not([data-selected]):has(.lotics-list-item__press:not([data-disabled]):hover) {
    background-color: var(--lotics-wash-hover);
  }

  .lotics-list-item[data-selected] {
    background-color: var(--lotics-wash-selected);
  }

  /* The roving highlight takes the transient rung so a selected row keeps its ground. */
  .lotics-list-item[data-focused] {
    background-color: var(--lotics-wash-hover);
  }

  .lotics-list-item:not([data-selected]):has(.lotics-list-item__press:not([data-disabled]):active),
  .lotics-list-item[data-selected]:has(.lotics-list-item__press:not([data-disabled]):active) {
    background-color: var(--lotics-wash-press);
  }
}
