/* SpacerSelect FormElement — visual radio tiles for Bootstrap spacer values. */

.t3bs-spacer-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
}

.t3bs-spacer-select__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.t3bs-spacer-select__tile {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 88px;
    padding: 10px 12px 8px;
    border: 1px solid var(--typo3-component-border-color, #ced4da);
    border-radius: 4px;
    background: var(--typo3-component-bg, #fff);
    color: var(--typo3-component-color, #495057);
    cursor: pointer;
    user-select: none;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
    margin-bottom: 0;
}

.t3bs-spacer-select__tile:hover {
    border-color: var(--typo3-component-primary-color, #0078e6);
    background: var(--typo3-component-hover-bg, #f5f9fd);
}

.t3bs-spacer-select__input:checked + .t3bs-spacer-select__tile {
    border-color: var(--typo3-component-primary-color, #0078e6);
    background: var(--typo3-component-primary-bg-subtle, #e7f1ff);
    box-shadow: inset 0 0 0 1px var(--typo3-component-primary-color, #0078e6);
}

.t3bs-spacer-select__input:focus-visible + .t3bs-spacer-select__tile {
    outline: 2px solid var(--typo3-component-focus-color, #0078e6);
    outline-offset: 2px;
}

.t3bs-spacer-select__input:disabled + .t3bs-spacer-select__tile {
    opacity: .55;
    cursor: not-allowed;
}

.t3bs-spacer-select__preview-track {
    display: flex;
    width: 100%;
    height: 10px;
    background: var(--typo3-component-border-color, #e9ecef);
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
    /* Default (horizontal): bar grows from the left edge. */
    justify-content: flex-start;
    align-items: stretch;
}

.t3bs-spacer-select__preview-bar {
    display: block;
    height: 100%;
    width: var(--spacer-pct, 0%);
    background: var(--typo3-component-primary-color, #0078e6);
    border-radius: 2px;
    min-width: 2px;
    transition: width .15s ease, height .15s ease;
}

/* --- Directional variants ---------------------------------------------- */
/* The bar's growth direction matches the padding direction (analogous to
   top → grows upward). For start (left) it grows leftward, so the bar is
   anchored on the right edge. For end (right) it grows rightward from the
   left edge — the same as the default horizontal rendering. */
.t3bs-spacer-select[data-direction="start"] .t3bs-spacer-select__preview-track {
    justify-content: flex-end;
}
.t3bs-spacer-select[data-direction="end"] .t3bs-spacer-select__preview-track {
    justify-content: flex-start;
}

/* Vertical (top/bottom): tall narrow track, bar grows from one edge. */
.t3bs-spacer-select[data-direction="top"] .t3bs-spacer-select__preview-track,
.t3bs-spacer-select[data-direction="bottom"] .t3bs-spacer-select__preview-track {
    width: 12px;
    height: 36px;
    margin-left: auto;
    margin-right: auto;
}

.t3bs-spacer-select[data-direction="top"] .t3bs-spacer-select__preview-track {
    align-items: flex-end; /* bar anchored to bottom, grows upward */
}

.t3bs-spacer-select[data-direction="bottom"] .t3bs-spacer-select__preview-track {
    align-items: flex-start; /* bar anchored to top, grows downward */
}

.t3bs-spacer-select[data-direction="top"] .t3bs-spacer-select__preview-bar,
.t3bs-spacer-select[data-direction="bottom"] .t3bs-spacer-select__preview-bar {
    width: 100%;
    height: var(--spacer-pct, 0%);
    min-width: 0;
    min-height: 2px;
}

.t3bs-spacer-select__label {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
}

.t3bs-spacer-select__value {
    font-size: 11px;
    color: var(--typo3-component-secondary-color, #6c757d);
    line-height: 1.2;
}

.t3bs-spacer-select__hint {
    margin-top: 2px;
    font-size: 11px;
    font-style: italic;
    color: var(--typo3-component-secondary-color, #6c757d);
}

/* "Standard" tile — represents the active TypoScript default. */
.t3bs-spacer-select__tile--default {
    border-style: dashed;
    background: var(--typo3-component-bg-subtle, #f8f9fa);
}

.t3bs-spacer-select__input:checked + .t3bs-spacer-select__tile--default {
    border-style: solid;
    background: var(--typo3-component-primary-bg-subtle, #e7f1ff);
}

.t3bs-spacer-select__preview-bar--default {
    background: var(--typo3-component-secondary-color, #6c757d);
}

.t3bs-spacer-select__input:checked + .t3bs-spacer-select__tile--default
    .t3bs-spacer-select__preview-bar--default {
    background: var(--typo3-component-primary-color, #0078e6);
}
