/*
 * THE FOLLOW IS THE LAYOUT. A reversed column scrolls from its bottom, so growth paints already
 * pinned with no flash, and scrolling up releases the pin. Short content reads top-down via an auto
 * margin. The root is the frame and the viewport the port, so the jump disc stands still rather
 * than scrolling with the content.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-follow-scroll {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    min-width: 0;
  }

  .lotics-follow-scroll__viewport {
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    justify-content: flex-start;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /*
   * A margin, not `justify-content: flex-end`: end-aligning a reversed column pushes overflow past
   * the start edge, where nothing scrolls. The margin absorbs only free space.
   */
  .lotics-follow-scroll__content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
    min-width: 0;
    margin-block-end: auto;
  }

  /*
   * Always mounted, so the disc keeps its position. `visibility`, since a transparent button is
   * still a tab stop and in the tree.
   */
  .lotics-follow-scroll__jump {
    position: absolute;
    inset-inline: 0;
    bottom: var(--lotics-space-16);
    display: flex;
    flex-direction: row;
    justify-content: center;
    visibility: hidden;
  }

  .lotics-follow-scroll__jump[data-visible] {
    visibility: visible;
  }
}
