/* ═══════════════════════════════════════════
   Typefoundry Font Sampler — Front-end CSS
═══════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

.tfs-sampler {
    display: flex;
    flex-direction: column;
    width: 100%;
    font-family: inherit;
    border: 1px solid currentColor;
}

/* ════════════════════════════════════════════
   CONTROLS BAR — DESKTOP
   All cells share equal width (flex: 1).
   Sliders fill the remaining space inside
   their cell after label + value are placed.
════════════════════════════════════════════ */
.tfs-controls {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    border-bottom: 1px solid currentColor;
    overflow-x: auto;
}

/* Every control cell grows equally */
.tfs-control {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    min-height: 48px;
    border-right: 1px solid currentColor;
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

.tfs-control:last-child {
    border-right: none;
}

/* Label e.g. "Size" */
.tfs-control-label {
    font-size: 13px;
    flex-shrink: 0;
}

/* Numeric readout e.g. "96 px" */
.tfs-value {
    font-size: 13px;
    min-width: 46px;
    text-align: right;
    flex-shrink: 0;
}

/* ── Sliders fill remaining cell space ── */
.tfs-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 0;
    min-width: 0;
    height: 1px;
    background: currentColor;
    border-radius: 0;
    outline: none;
    cursor: pointer;
}

.tfs-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: currentColor;
    cursor: pointer;
}

.tfs-slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: none;
    border-radius: 50%;
    background: currentColor;
    cursor: pointer;
}

/* ── Dropdowns fill their cell ── */
.tfs-sample-select,
.tfs-font-select {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    font-size: 13px;
    color: inherit;
    cursor: pointer;
    outline: none;
    padding: 0 22px 0 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23000'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 9px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Invert arrow on dark backgrounds */
.tfs-sampler.tfs-dark .tfs-sample-select,
.tfs-sampler.tfs-dark .tfs-font-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23fff'/%3E%3C/svg%3E");
}

.tfs-font-label {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ════════════════════════════════
   PREVIEW AREA
════════════════════════════════ */
.tfs-preview-wrap {
    padding: 48px 36px;
    overflow: hidden;
}

.tfs-preview {
    outline: none;
    min-height: 1.1em;
    word-break: break-word;
    cursor: text;
}

.tfs-preview:focus { outline: none; }

/* ════════════════════════════════════════════
   MOBILE (≤640px) — stacked controls
   label ─────────── value
   ●━━━━━━━━━━━━━━━━ (full-width slider)
   Dropdowns: full-width rows
════════════════════════════════════════════ */
@media (max-width: 640px) {

    .tfs-sampler {
        border: none;
        border-top: 1px solid currentColor;
    }

    .tfs-controls {
        flex-direction: column;
        flex-wrap: nowrap;
        overflow-x: visible;
        border-bottom: none;
    }

    .tfs-control {
        flex: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid currentColor;
        min-height: unset;
        white-space: normal;
        overflow: visible;
    }

    .tfs-control:last-child {
        border-bottom: 1px solid currentColor;
    }

    /* Slider rows: grid layout */
    .tfs-control-size,
    .tfs-control-lh,
    .tfs-control-ls {
        display: grid;
        grid-template-areas:
            "lbl val"
            "sl  sl";
        grid-template-columns: 1fr auto;
        padding: 14px 18px 16px;
    }

    .tfs-control-size   .tfs-control-label,
    .tfs-control-lh     .tfs-control-label,
    .tfs-control-ls     .tfs-control-label {
        grid-area: lbl;
        font-size: 14px;
        align-self: center;
    }

    .tfs-control-size   .tfs-value,
    .tfs-control-lh     .tfs-value,
    .tfs-control-ls     .tfs-value {
        grid-area: val;
        font-size: 14px;
        min-width: unset;
        text-align: right;
        align-self: center;
    }

    .tfs-control-size   .tfs-slider,
    .tfs-control-lh     .tfs-slider,
    .tfs-control-ls     .tfs-slider {
        grid-area: sl;
        flex: none;
        width: 100%;
        margin-top: 12px;
    }

    /* Dropdown rows */
    .tfs-control-sample,
    .tfs-control-font,
    .tfs-control-font-label {
        flex-direction: row;
        align-items: center;
        padding: 15px 18px;
    }

    .tfs-sample-select,
    .tfs-font-select {
        width: 100%;
        max-width: 100%;
        font-size: 14px;
        padding-right: 28px;
    }

    .tfs-preview-wrap {
        padding: 28px 18px;
    }
}
