/* ============================================================================
   library.css — the module library across the top of the plan builder: every
   module as an icon button in its role's colour (a tinted Ant button),
   grouped by category under the category's name. Press a tile to preview it,
   double-click to add it, or drag it onto the canvas. The bar scrolls sideways
   when it runs out of room.
   ============================================================================ */

.library {
    display: flex;
    align-items: flex-end;
    gap: var(--space-24);
    flex-shrink: 0;
    padding: var(--space-8) var(--space-16) var(--space-12);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--color-fill) transparent;
    background: var(--color-bg-container);
    border-bottom: var(--line-width) solid var(--color-border-secondary);
}

.lib-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: none;
}
/* Its type is the .eyebrow's (style.css). */
.lib-group-name {
    padding-left: 1px;
    color: var(--color-text-tertiary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-strong);
    line-height: var(--line-height-sm);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}
.lib-group-items { display: flex; gap: 6px; }

/* A tile: a 32px button tinted in its role's colour, edged a step stronger. */
.lib-tile {
    display: grid;
    place-items: center;
    width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    border: 0;
    border-radius: var(--border-radius);
    background: transparent;
    cursor: grab;
}
.lib-tile .role-tile {
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
    background: color-mix(in srgb, var(--tile) 10%, var(--color-bg-container));
    box-shadow: inset 0 0 0 var(--line-width) color-mix(in srgb, var(--tile) 30%, var(--color-bg-container));
    transition: background-color var(--motion-duration-mid), box-shadow var(--motion-duration-mid);
}
.lib-tile .role-tile .icon { width: 18px; height: 18px; }
.lib-tile:hover .role-tile {
    background: color-mix(in srgb, var(--tile) 18%, var(--color-bg-container));
    box-shadow: inset 0 0 0 var(--line-width) color-mix(in srgb, var(--tile) 60%, var(--color-bg-container));
}
.lib-tile:active { cursor: grabbing; }
.lib-tile:active .role-tile { background: color-mix(in srgb, var(--tile) 26%, var(--color-bg-container)); }
/* The module previewed in the inspector. */
.lib-tile[aria-pressed="true"] .role-tile {
    box-shadow: inset 0 0 0 var(--line-width) var(--tile), 0 0 0 2px color-mix(in srgb, var(--tile) 22%, transparent);
}
.lib-tile:focus-visible { outline: 4px solid var(--color-primary-border); outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
    .lib-tile .role-tile { transition: none; }
}
