/*
 * A canvas under a transparent scroll layer: the layer is sized to the SHEET so
 * the browser owns the scrollbars and the momentum, and the canvas is sized to
 * the VIEWPORT and redrawn per frame. Both sizes are data the component
 * measures, so both arrive as properties this sheet reads.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

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

  /* Loading and refusal both stand in the middle of the frame the sheet would
     have filled, so nothing moves when the bytes arrive. */
  .lotics-spreadsheet-view__message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    gap: var(--lotics-space-12);
    padding: var(--lotics-space-48);
  }

  .lotics-spreadsheet-view__viewport {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  .lotics-spreadsheet-view__canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--lotics-spreadsheet-width);
    height: var(--lotics-spreadsheet-height);
  }

  .lotics-spreadsheet-view__scroller {
    position: absolute;
    inset: 0;
    overflow: auto;
  }

  .lotics-spreadsheet-view__sheet {
    width: var(--lotics-spreadsheet-width);
    height: var(--lotics-spreadsheet-height);
  }

  .lotics-spreadsheet-view__tabs {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-shrink: 0;
    min-width: 0;
    overflow-x: auto;
    border-top: 1px solid var(--border);
    background-color: var(--muted);
  }

  /* A sheet tab is a FILE tab: square, edge to edge, divided by a hairline —
     the strip a spreadsheet has had for thirty years, and not the kit's page
     tab bar, which is a different question about a different surface. */
  .lotics-spreadsheet-view__tab {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    margin: 0;
    padding-block: var(--lotics-space-8);
    padding-inline: var(--lotics-space-12);
    border: 0 solid var(--border);
    border-right: 1px solid var(--border);
    border-radius: 0;
    background-color: transparent;
    background-image: none;
    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);
    color: var(--lotics-ink-muted);
    white-space: nowrap;
    appearance: none;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  /* The selected sheet is the one lifted out of the strip's ground. */
  .lotics-spreadsheet-view__tab[data-selected] {
    background-color: var(--card);
    color: var(--lotics-ink-default);
  }

  .lotics-spreadsheet-view__tab:hover {
    background-image: linear-gradient(
      0deg,
      var(--lotics-wash-selected),
      var(--lotics-wash-selected)
    );
  }

  .lotics-spreadsheet-view__tab:focus-visible {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: calc(var(--lotics-ring-width) * -1);
  }
}
