/* Grid palette, symbols and key (E006, E013). */

.grid-palette-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--kp-space-2); }
.grid-palette-list { display: flex; flex-wrap: wrap; gap: var(--kp-space-2); margin: 0; padding: 0; list-style: none; }
.grid-palette-list > li { display: flex; flex-direction: column; align-items: center; gap: var(--kp-space-1); width: 3.5rem; }
.grid-swatch, .grid-swatch-add { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; min-height: 0; padding: 0; border: 1px solid var(--kp-control-border); border-radius: var(--kp-radius-sm); }
.grid-swatch[aria-pressed="true"] { outline: 2px solid var(--kp-text); outline-offset: 2px; }
.grid-swatch .kp-icon { width: 1.25rem; height: 1.25rem; }
.grid-swatch.removed { opacity: 0.5; border-style: dashed; }
.grid-swatch-add { background: transparent; border: 2px dashed var(--kp-control-border); color: var(--kp-text-muted); }
.grid-swatch-add:hover { color: var(--kp-text); border-color: var(--kp-text); }
.grid-swatch-name { max-width: 100%; font-size: var(--kp-text-xs); color: var(--kp-text-muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-stitch-list { display: flex; flex-wrap: wrap; gap: var(--kp-space-2); margin: 0; padding: 0; list-style: none; }
.grid-stitch { position: relative; display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; min-height: 0; padding: var(--kp-space-1); }
.grid-stitch-check { position: absolute; inset-block-start: -0.375rem; inset-inline-end: -0.375rem; display: inline-grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; background: var(--kp-primary); color: var(--kp-on-primary); }
.grid-stitch-check .kp-icon { width: 0.75rem; height: 0.75rem; }
.grid-symbol { display: block; width: 1.5rem; height: 1.5rem; flex: none; }
.grid-layer { margin: 0 0 var(--kp-space-1); }
.grid-legend-list { display: flex; flex-direction: column; gap: var(--kp-space-1); margin: 0; padding: 0; list-style: none; }
.grid-legend-list li, .grid-legend-list a { display: flex; align-items: center; gap: var(--kp-space-2); min-height: 2rem; }
.grid-legend-empty { margin: 0; }
.grid-color-sheet .kp-button-row { margin-block-start: var(--kp-space-2); }

@media (pointer: coarse) {
  .grid-swatch, .grid-swatch-add, .grid-stitch { width: 2.75rem; height: 2.75rem; }
}

.grid-tray-strip .grid-palette-list > li { width: auto; }
.grid-tray-strip .grid-swatch-name { display: none; }
.grid-tray-strip :is(.grid-palette-row, .grid-palette-list, .grid-stitch-list) { flex-wrap: nowrap; }
.grid-tray-strip { overflow: hidden; }
.grid-tray-strip .grid-layer { flex: none; margin: 0; }
.grid-tray-strip .kp-segmented-option { padding: 0 var(--kp-space-3); font-size: var(--kp-text-sm); }
.grid-tray-strip :is(kp-grid-palette, kp-grid-stitches) { display: block; flex: 1 1 0; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding-block: var(--kp-space-2); margin-block: calc(-1 * var(--kp-space-2)); padding-inline: var(--kp-space-1) var(--kp-space-4); -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--kp-space-4)), transparent); mask-image: linear-gradient(to right, #000 calc(100% - var(--kp-space-4)), transparent); }
/* The fade sits at the inline end, which is the left in right-to-left text. */
.grid-tray-strip :is(kp-grid-palette, kp-grid-stitches):dir(rtl) { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - var(--kp-space-4)), transparent); mask-image: linear-gradient(to left, #000 calc(100% - var(--kp-space-4)), transparent); }
.grid-tray-strip :is(kp-grid-palette, kp-grid-stitches)::-webkit-scrollbar { display: none; }
.grid-tray-strip .grid-palette-row { width: max-content; }
.grid-editor[data-layer="stitch"] .grid-tray-strip kp-grid-palette,
.grid-editor[data-layer="color"] .grid-tray-strip kp-grid-stitches { display: none; }

.grid-legend > h2 { margin: 0 0 var(--kp-space-1); font-size: var(--kp-text-sm); font-weight: 600; color: var(--kp-text-muted); }
