/*
 * 64 around a tight pair of 40 and an `md` (28px) leading mark — 12 a side,
 * which is what lets a settings list of identity rows read as a list rather than
 * a table. A title-only row keeps one 20px line centred in the same box, so the
 * two shapes share a beat. `min-height`, not `height`: a `description` node the
 * caller supplies (a chip row, two stacked facts) is taller than a line of text,
 * and a fixed height clips it.
 *
 * The wash sits on the WRAPPER but answers the REGION's hover and press: the
 * region alone would light up to the edge of the `right` slot and stop, which
 * reads as two rows, and the wrapper alone would light up when the pointer is on
 * a control that is not part of the row's press target.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-list-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--lotics-space-8);
    flex-shrink: 0;
    min-width: 0;
    position: relative;
    min-height: 64px;
    padding-inline: var(--lotics-space-8);
    margin-inline: calc(var(--lotics-space-8) * -1);
    /* §5 rule 1: an `option` row IS the `<button>`, and a raw string in `left`
       would otherwise render in the UA's own 13.33px button face. The
       `settings` row's press region states the same for the same reason. */
    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;
    /* One rung softer than the control corner — a row is a surface you read, not
       a control you press. */
    border-radius: var(--lotics-radius-control);
    background-color: transparent;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  /*
   * THE OPTION ROW sizes to its CONTENT — a title over a description is two
   * rungs of type, not a 64px band — and takes the whole row as its target,
   * which is what lets it carry no inner press region.
   */
  .lotics-list-item[data-variant="option"] {
    box-sizing: border-box;
    width: 100%;
    min-height: 0;
    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);
  }

  /* NO GAP. Each tight line box already contributes 3px above and below its
     glyphs, so the pair reads at 6px — a gap here is a third source of space
     between two lines meant to read as one object. */
  .lotics-list-item__content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
  }

  /* Half a rung: the overline NAMES the title under it, so the two are one
     label, and the pair sits closer than the title/description pair does. */
  .lotics-list-item__overline {
    margin-bottom: var(--lotics-space-2);
    max-width: 100%;
  }

  .lotics-list-item__title,
  .lotics-list-item__description {
    max-width: 100%;
  }

  /* Takes the slack, so the press target reaches the slot and the row presses
     everywhere the row is ABOUT. */
  .lotics-list-item__press {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-self: stretch;
    gap: var(--lotics-space-8);
    flex: 1;
    min-width: 0;
    border: 0 solid var(--border);
    border-radius: 0;
    background-color: transparent;
    /* §5 rule 1. `left` is any node, and a raw string in it would otherwise
       render in the UA's own 13.33px button face. */
    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: 0;
    appearance: none;
    /* The ARROW: a settings row is a surface with text in it, not a verb. */
    cursor: auto;
    text-align: start;
  }

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

  /*
   * SELECTION AND HOVER MUST NOT PAINT THE SAME GREY. They did — both the
   * selected wash — so on a navigation pane, pointing at any row made it
   * indistinguishable from the row currently OPEN: the persistent state erased
   * by the transient one, exactly while the reader was choosing between them.
   * Every probe reads a RESTING screen, which is why it survived — at rest the
   * selected row is the only grey one and looks perfect.
   *
   * The ladder is `PressableRow`'s, verbatim: one neutral step apart, hover
   * LIGHTER than selection. A second answer here would give one question two
   * selection languages on surfaces the same reader crosses.
   *
   * Hover excludes a selected row rather than losing to it on order, because the
   * `:has()` carries the weight of what it matches — and the press rule is
   * written in both halves so it out-specifies selection and outlasts hover on
   * source order. A press outranks everything, selected or not.
   */
  .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);
  }

  /* WHERE THE KEYBOARD IS, which is not where the value is: the roving
     highlight takes the transient rung so a selected row keeps its own ground
     while the arrows travel over it. */
  .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);
  }
}
