/*
 * The trade calculators (lane L4, family 'trade-calc', site/pages/free-tools/trade-calc.php), after ft-base.css and
 * ft-calc.css: the repeating rows of inputs and the answers in words. Tokens only; 44 px targets.
 *
 *   .ft-rows > .ft-rows__title, fieldset.ft-row (.ft-row__legend, .ft-row__remove, .ft-row__fields), .ft-rows__add
 *   .ft-out__row--text   an answer in words ("6 AWG copper"), allowed to wrap; so are the worked example's cells
 */
/* one column on a phone that a long select option (a box's name and volume) cannot widen */
@media (max-width: 959px) {
    .ft-calc[data-ft-trade] {
        grid-template-columns: minmax(0, 1fr);
    }
}

.ft-calc[data-ft-trade] .select {
    width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
}

.ft-rows {
    display: grid;
    gap: var(--sp-3);
}

.ft-rows__title {
    margin: 0;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--c-ink);
}

.ft-row {
    display: grid;
    gap: var(--sp-2);
    min-width: 0;
    margin: 0;
    padding: var(--sp-3);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    background: var(--c-surface-2);
}

.ft-row[hidden] {
    display: none;
}

.ft-row__legend {
    padding: 0 var(--sp-1);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--c-text-2);
}

.ft-row__remove {
    order: 2;
    justify-self: end;
    min-height: 44px;
}

.ft-row__fields {
    display: grid;
    gap: var(--sp-3);
}

/* a phone: a row of three (insulation, size, how many) puts the last two side by side, so more rows stay in view */
@media (max-width: 639px) {
    .ft-row__fields:has(> .ft-field:nth-child(3)) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }

    .ft-row__fields:has(> .ft-field:nth-child(3)) > .ft-field:first-child {
        grid-column: 1 / -1;
    }
}

@media (min-width: 640px) {
    .ft-row__fields {
        grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
        align-items: start;
    }
}

.ft-rows__add {
    justify-self: start;
    min-height: 44px;
}

.ft-rows__add[hidden],
.ft-row__remove[hidden] {
    display: none;
}

.ft-out__row[hidden] {
    display: none;
}

.ft-out__row--text {
    flex-wrap: wrap;
}

/* a short answer stays on its label's line ("3/4 in. EMT"); a long one wraps under it */
.ft-out__row--text dd {
    flex: 1 1 auto;
    min-width: 0;
    white-space: pre-line;
    overflow-wrap: break-word;
    text-align: right;
}

/* the worked example prints lists, one item a line (ft-base.css wraps the words) */
.ft-data td {
    white-space: pre-line;
}

@media print {
    .ft-rows__add,
    .ft-row__remove {
        display: none;
    }
}
