/* picker.css -- the two-level catalogue grid.
 *
 * THE TILE IS AN OUTCOME, NOT A NUMBER. The grid is two equal columns of
 * whatever the panel leaves, exactly as the frame's catalogue grid is: the
 * design says 185, which is 429 less its padding, the scrollbar gutter and the
 * gap, halved. Writing 185 here would be a third copy of a number that is
 * already derived twice, and the first time the panel width moved they would
 * disagree with nothing to notice.
 *
 * EVERY LENGTH HERE READS THE FRAME'S CUSTOM PROPERTIES. A custom property
 * flows down and never sideways -- the frame owns the geometry, and a second
 * declaration in this file to fix a scoping problem is how one number becomes
 * two that agree today and not next month.
 */

#cs-picker {
    display: flex;
    flex-direction: column;
    gap: var(--cs-grid-gap);
    min-height: 0;
    /* stable, so the gutter is reserved whether or not this level scrolls --
       otherwise the grid rewraps the moment a category is long enough to
       overflow, and the tiles change size on a scroll. */
    scrollbar-gutter: stable;
    overflow-y: auto;
}

.cs-picker-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
}

.cs-picker-title {
    /* A LONGHAND, NOT THE font SHORTHAND. The shorthand takes `inherit` as a
       family and then never parses at all -- one of the recorded ways a
       declaration can be present, correct and inert. */
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    color: var(--cs-ink);
    /* A flex item will not shrink below its min-content size, and neither a
       max-width nor an ellipsis on a child changes that. */
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-picker-back {
    flex: 0 0 auto;
    appearance: none;
    border: 1px solid var(--cs-line);
    background: var(--cs-white);
    color: var(--cs-ink);
    border-radius: var(--cs-r-well);
    padding: 4px 10px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.cs-picker-back:hover { background: var(--cs-track); }

.cs-picker-msg {
    margin: 0;
    padding: 18px 0;
    color: var(--cs-muted);
    font-size: 13px;
}

.cs-grid {
    display: grid;
    /* TWO EQUAL COLUMNS OF WHAT IS LEFT. minmax(0, 1fr) rather than 1fr: a bare
       1fr floors at min-content, so one wide tile pushes the grid past its
       container instead of shrinking. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--cs-grid-gap);
    align-content: start;
}

.cs-cat,
.cs-tile {
    appearance: none;
    border: 1px solid var(--cs-line);
    background: var(--cs-white);
    border-radius: var(--cs-r-card);
    padding: 0;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
}

.cs-cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font: inherit;
    font-size: 13px;
    text-align: left;
    color: var(--cs-ink);
}

.cs-cat-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-cat-count {
    flex: 0 0 auto;
    color: var(--cs-muted);
    font-variant-numeric: tabular-nums;
}

.cs-tile {
    /* The well. Square, so a grid of mixed shapes does not jump line to line --
       the art inside is contained rather than cropped. */
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cs-blueprint);
    padding: 7px;
}

.cs-tile-img {
    max-width: 100%;
    max-height: 100%;
    /* contain, never cover: a customer choosing art has to see all of it. */
    object-fit: contain;
    display: block;
}

.cs-cat:hover,
.cs-tile:hover { border-color: var(--cs-accent); }

.cs-cat:focus-visible,
.cs-tile:focus-visible,
.cs-picker-back:focus-visible {
    outline: 2px solid var(--cs-accent);
    outline-offset: 2px;
}

/* THE PRESS THAT IS STILL WORKING.
 *
 * A first press of a file also makes the server build its preview -- 2,143ms
 * measured live -- and for that whole time the page said nothing, so the honest
 * reading was that the press had missed and a customer pressing again got two
 * identical layers. picker.js refuses the repeat; this is the half a customer
 * can see.
 *
 * SPECIFICITY, STATED HONESTLY: .cs-tile[aria-busy="true"] is (0,2,0) and so is
 * .cs-tile:hover, so those two are an equal-specificity tie decided by source
 * order -- which this rule wins only by sitting below. That is fine here and
 * nowhere near as fine as it sounds, so it is written down: the two agree on
 * border-color anyway, and opacity and cursor are declared by nobody else. If
 * a hover rule ever grows an opacity, this becomes the tie that loses.
 *
 * NO !important: nothing here is arguing with another stylesheet, because
 * engine/ owns every stylesheet that applies to it.
 *
 * The border colour is the accent so a busy tile reads as CHOSEN rather than
 * broken -- it is about to become a layer, not failing to. */
.cs-tile[aria-busy="true"] {
    border-color: var(--cs-accent);
    opacity: 0.55;
    cursor: progress;
}

/* ════════════════════════════════════════════════════════════════════
   THE INSPECTOR — the panel when something is selected
   ════════════════════════════════════════════════════════════════════
   It lives here rather than in a file of its own because it is the panel's
   OTHER state: the two are exclusive and reading them side by side is how you
   see that they are. Neither declares geometry — the panel's width and padding
   are the frame's, and a custom property flows down and never sideways. */

#cs-inspector { display: block; }

.cs-insp-head {
    padding: 0 0 12px;
    border-bottom: 1px solid var(--cs-hairline);
}

.cs-insp-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: var(--cs-ink);
    /* A catalogue file name can be long and the panel is 429px. It wraps rather
       than being cut: a truncated name is a name the customer cannot check. */
    overflow-wrap: anywhere;
}

.cs-insp-kind {
    margin: 2px 0 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--cs-muted);
}

/* Two columns of label and value. The value column is where the numbers go, so
   it gets tabular figures — a size that jumps by a pixel of width as it counts
   through 9 to 10 reads as the panel twitching during a resize. */
.cs-insp-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 14px 0 0;
    font-size: 12px;
}

.cs-insp-facts dt { color: var(--cs-muted); font-weight: 600; }

.cs-insp-facts dd {
    margin: 0;
    color: var(--cs-ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cs-insp-acts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 20px 0 0;
}

.cs-act {
    padding: 8px 14px;
    border: 1px solid var(--cs-hairline);
    border-radius: 8px;
    background: var(--cs-white);
    color: var(--cs-ink);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.cs-act:hover:not(:disabled) { border-color: var(--cs-accent); color: var(--cs-accent); }

/* IT MUST LOOK DISABLED, not merely stop working. Straighten is disabled when
   the layer is already straight, so it can never report success for doing
   nothing — a control that fires on correct behaviour is worse than none. */
.cs-act:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Remove is the one destructive control on the surface, so it says so in
   colour rather than sitting identical to Straighten. */
.cs-act[data-cs-act="delete"]:hover:not(:disabled) {
    border-color: var(--cs-danger);
    color: var(--cs-danger);
}
