/* Parent Search / Sort chip styling shared byte-for-byte by make2 and tapx2.
   Load after the product base stylesheet. Existing glyph DOM names remain a
   compatibility contract until the shared renderer lands in Phase 5. */

#search-glyphs,
#sort-glyphs {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    /* Center the chips in the row so they line up with the adjacent recents
	   dropdown instead of sitting at the top. */
    align-items: center;
}

#search-glyphs {
    /* 	min-height: 1rem; */
    padding-left: calc(1rem);
}

#sort-glyphs {
    justify-content: end;
    padding-right: 1rem;
}

/* Chip label and value layout. Removal buttons are deliberately absent: their box, text and
   font belong to `.glyph button.glyph-btn:not(.sort_up_down)` in app_base.css, and the
   direction toggle's belong to #sort-glyphs .sort_up_down below. One owner each. */
.glyph-label,
.glyph-text {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Shared by search and sort glyph chips: one compact height (matching
   .global-search-control) keeps both rows aligned with their adjacent Edit/recents
   dropdowns and stops the taller macOS menulist-button select from inflating the
   row. Only column count and color differ — see the per-area rules below. */
.glyph {
    display: grid;
    box-sizing: border-box;
    width: fit-content;
    height: calc(var(--glyph_height) + (var(--txt_margin) * 2) - 2px);
    align-items: center;
    border: var(--txt_margin) solid transparent;
}

#search-glyphs .glyph {
    grid-template-columns: repeat(4, auto);
    background-color: var(--pale_tan);
    border-color: var(--pale_tan);
}

.glyph[data-hide='true'] {
    display: none;
}

/* Direction toggles only. The chip removal buttons also carry .glyph-btn, but their box, border,
   background, margins, hover and focus belong to `.glyph button.glyph-btn:not(.sort_up_down)` in
   app_base.css; restating any of that here would give one value two owners.
   The toggle's own box is #sort-glyphs .sort_up_down below; this rule only squares off the 8px
   radius the product `.glyphs-wrapper button` rule would otherwise give it. */
button.glyph-btn.sort_up_down {
    border-radius: 0;
}

button.glyph-btn.sort_up_down:hover {
    filter: invert(100%);
}

/* not editable ==> should not have white background */
.glyph-text {
    background-color: var(--paler_tan);
    color: var(--deep_blue);
}

.glyph-label,
.glyph-text {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

#search-glyphs .glyph[data-search-kind='multi-field'] .glyph-label {
    font-style: italic;
    font-weight: 700;
}

/* needs a bigger delta vs button */
.glyph-select,
select.glyph-select,
select.small {
    font-size: 12px;
}

.glyph-select {
    margin-right: 0.25rem;
}

.glyphs-wrapper {
    display: grid;
    /* 	grid-template-columns: 1fr 1fr; */
    grid-template-columns: minmax(min-content, max-content) minmax(min-content, max-content);
    grid-auto-flow: column;
    justify-content: space-between;
}

.glyphs-wrapper {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Search and sort rows are identical in structure and height, so they share one
   alignment: each is a grid whose two cells (chips + dropdown group) center on a
   common vertical line. Only the column track and margins differ, below. */
#search-glyphs-wrapper,
#sort-glyphs-wrapper {
    display: grid;
    align-items: center;
}

#search-glyphs-wrapper {
    grid-template-columns: auto 1fr;
    margin-left: 1rem;
}

#sort-glyphs-wrapper {
    grid-template-columns: auto max-content;
    margin-left: 1rem;
    margin-right: 1rem;
}

/* The Edit-button + recents-dropdown group on each row: center them together as
   a unit so the group lines up with the chips in the adjacent cell (and with
   each other, replacing the old per-dropdown nudge). */
#search-glyphs-wrapper > div:first-child,
#edit-sort-wrapper,
.parent-layout-controls,
.parent-toolbar .parent-layout-controls {
    display: flex;
    gap: 0.25rem;
}

#search-glyphs-wrapper > div:first-child,
#edit-sort-wrapper,
.parent-layout-controls,
.parent-toolbar {
    align-items: center;
}

#edit-sort-wrapper {
    padding-right: 0.25rem;
    /* padding-left: 0.25rem; */
}

/* Sort direction toggle inside a parent Sort chip. Button and mark are one box: both are
   --icon_size, so there is no ring of button showing around the glyph and only one number
   describes the affordance. The mark's own geometry belongs to app_base.css. */
#sort-glyphs .sort_up_down {
    align-items: center;
    align-self: center;
    color: var(--button_color);
    display: inline-flex;
    justify-content: center;
    line-height: 1;
    width: var(--icon_size);
    height: var(--icon_size);
}

#sort-glyphs button.sort_up_down {
    border: 0;
    padding: 0;
}

/* Sort-chip children other than the removal button: transparent so the operator dropdown is not
   tinted, plus the standard chip spacing. The removal button supplies its own background and
   margins from app_base.css; the direction toggle stays in, hence the second selector. */
div.sort-glyph > *:not(.glyph-btn),
div.sort-glyph > .sort_up_down {
    background-color: transparent;
    margin: var(--btn_margin);
}

#sort-glyphs .glyph {
    grid-template-columns: repeat(3, auto);
    background-color: var(--pale_green);
    border-color: var(--pale_green);
}

/* Parent Recent + Named controls are intentionally narrow. Positive parent
   scoping keeps this contract out of ordinary and Export dialogs.
   .parent-toolbar is the shared host class both products stamp on their toolbar — make2's
   #header-btn-container, tapx2's .navbar. It replaced those two product selectors: an id cannot
   port, and tapx2's zone class only ever matched tapx2. */
.glyphs-wrapper .parent-set-dropdown,
.glyphs-wrapper #recent-searches,
.glyphs-wrapper #recent-sorts,
.glyphs-wrapper #recent-layouts,
.parent-toolbar .parent-set-dropdown,
.parent-toolbar #recent-searches,
.parent-toolbar #recent-sorts,
.parent-toolbar #recent-layouts {
    box-sizing: border-box;
    flex: 0 0 30px;
    margin-left: 0.25rem;
    margin-right: 0.25rem;
    max-width: 30px;
    min-width: 30px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 30px;
}

/* Edit Search / Sort / Layout buttons: complete shared visual contract. Only
   the two colors differ, set per button via the custom properties below. */
.glyphs-wrapper .edit-btn,
.parent-toolbar .edit-btn,
#export-dialog .dialog-toolbar .edit-btn {
    --button_text_color: white;
    align-items: center;
    background: var(--edit-btn-color);
    border: 2px solid var(--edit-btn-color);
    border-radius: 8px;
    box-sizing: border-box;
    color: var(--button_text_color);
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    height: 24px;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    transition: transform 0.2s ease;
    width: 5.5rem;
}

.glyphs-wrapper .edit-btn:hover,
.parent-toolbar .edit-btn:hover,
#export-dialog .dialog-toolbar .edit-btn:hover {
    background: var(--edit-btn-hover-color);
    border-color: var(--edit-btn-hover-color);
    color: black;
}

#edit-search {
    --edit-btn-color: var(--deep_brown);
    --edit-btn-hover-color: var(--mid_brown);
}

#edit-sort {
    --edit-btn-color: var(--deep_green);
    --edit-btn-hover-color: var(--mid_green);
}

#edit-layout {
    --edit-btn-color: var(--royal_purple);
    --edit-btn-hover-color: var(--light_royal_purple);
}
