/*
 * A LIST-ROW disclosure. The trigger keeps the register's own rhythm — a 44px
 * press target on the row gutter — and its wash BLEEDS outward by a rung, so the
 * title sits on the container's left edge while the highlight still has room.
 *
 * The body is flush with the header BOX rather than with the title text: a
 * marked row's icon gutter pushes its title 28px in, and the panel belongs to
 * the section, not to the heading. An unmarked row draws no gutter, so its name
 * sits on the container's own left edge and the body lines up under it. No
 * tinted well — the chevron and the position already say "inside".
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-accordion {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }

  .lotics-accordion__trigger {
    display: flex;
    flex-direction: row;
    align-items: center;
    /* 12 — a rung and a half, the register's own column gutter. */
    gap: var(--lotics-space-12);
    /* No `width: 100%`: with the bleed's negative margins that resolves to the
       CONTAINER's width and the wash then stops a rung short of each edge.
       Stretching from the root fills the row and the margins widen it. */
    align-self: stretch;
    /* ≥40px press target; the height doubles as the list's row rhythm. */
    min-height: 44px;
    min-width: 0;
    padding-block: var(--lotics-space-12);
    padding-inline: var(--lotics-row-wash-bleed);
    margin-block: 0;
    margin-inline: calc(var(--lotics-row-wash-bleed) * -1);
    /* Half a rung tighter than the control corner — a row nested in a padded
       container reads as its own object when its corners are softer. */
    border: 0 solid transparent;
    border-radius: calc(var(--lotics-radius-control) - var(--lotics-space-2));
    background: transparent;
    background-image: none;
    appearance: none;
    color: var(--lotics-ink-default);
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    font-weight: var(--lotics-weight-regular);
    font-feature-settings: var(--lotics-font-features);
    text-align: start;
    /* The ARROW: a disclosure row is a button wrapped around DATA, and its text
       is selectable. */
    cursor: auto;
    touch-action: manipulation;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  .lotics-accordion__trigger:hover {
    background: var(--lotics-wash-selected);
  }

  .lotics-accordion__trigger:active {
    background: var(--lotics-wash-press);
  }

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

  /* A header-only Accordion: same rhythm, no affordance — so a list can mix
     expandable and static rows without either reading as the other. */
  .lotics-accordion__trigger[data-static] {
    padding-inline: 0;
    margin-inline: 0;
  }

  .lotics-accordion__trigger[data-static]:hover,
  .lotics-accordion__trigger[data-static]:active {
    background: transparent;
  }

  .lotics-accordion__title {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--lotics-space-12);
    flex: 1;
    min-width: 0;
  }

  .lotics-accordion__icon {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }

  .lotics-accordion__label {
    flex: 1;
    min-width: 0;
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    font-weight: var(--lotics-weight-medium);
    font-feature-settings: var(--lotics-font-features);
    color: var(--lotics-ink-default);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    overflow: hidden;
  }

  .lotics-accordion__meta {
    flex-shrink: 1;
    min-width: 0;
    font-family: var(--font-sans);
    font-size: var(--lotics-text-xs);
    line-height: var(--lotics-leading-xs);
    letter-spacing: var(--lotics-tracking-xs);
    font-weight: var(--lotics-weight-regular);
    font-feature-settings: var(--lotics-font-features);
    color: var(--lotics-ink-muted);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    overflow: hidden;
  }

  .lotics-accordion__chevron {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
  }

  .lotics-accordion__trigger[data-panel-open] .lotics-accordion__chevron {
    transform: rotate(180deg);
  }

  .lotics-accordion__panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    /* 10 — the rung and a half the body keeps beneath it before the next row. */
    padding-bottom: var(--lotics-space-10);
    opacity: 1;
    transition: opacity var(--lotics-duration-base) var(--lotics-ease-standard);
  }

  .lotics-accordion__panel[data-starting-style],
  .lotics-accordion__panel[data-ending-style] {
    opacity: 0;
  }
}
