/* Modularity mockups: arrangement only, on Würth UI tokens (bundle.css) and I-Block's page frame (app.css). */

.md-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space);
    align-items: start;
}

/* Side by side only while both tables show every column, their Include ticks above all: below that they stack */
@media (max-width: 1199.98px) {
    .md-split {
        grid-template-columns: minmax(0, 1fr);
    }
}

.md-cut {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.md-swatch {
    display: inline-block;
    flex: none;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: var(--space-tight);
    vertical-align: -1px;
}

.md-code {
    font-weight: 600;
}

.md-plan-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space);
    margin-bottom: var(--space);
}

.md-plan-tools .wh-form-field {
    width: 320px;
    max-width: 100%;
}

.md-plan svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 78vh;
}

.md-plan .arch {
    opacity: 0.35;
}

.md-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space);
    margin: var(--space) 0 0;
    font-size: 14px;
    color: var(--muted);
}

.md-section svg {
    display: block;
    width: auto;
    height: 28px;
}

.md-option-line {
    margin: var(--space-tight) 0 0;
}

/* Round 14 */
.md-search {
    width: 280px;
    max-width: 100%;
}

.md-search > svg {
    flex: none;
    width: 16px;
    height: 16px;
    margin-right: 12px;
    color: var(--muted);
}

.md-file {
    display: flex;
    align-items: center;
    gap: var(--space-tight);
    min-width: 0;
}

.md-file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.md-details-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space);
}

.md-plan-live svg {
    max-height: 60vh;
}

@media (max-width: 991.98px) {
    .md-details-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Round 15: the level picker beside the floor plan slider */
.md-level {
    position: relative;
    width: 280px;
    max-width: 100%;
}

.md-level .wh-menu.md-level-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
}

/* Segmented controls: every option the same width, and a control that spans its row fills it, with no gap at the end */
.wh-segmented {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
}

/* ── The app ── */

/* A press outside an open menu closes it */
.md-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1079;
}

/* The Options step never scrolls: header, steps, option bar and action bar keep their heights, and the viewer takes
   exactly what is left of the window. */
html:has(.md-fill-page),
html:has(.md-fill-page) body {
    height: 100%;
    overflow: hidden;
}

.ib-app:has(> .md-fill-page) {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.ib-app > main.md-fill-page {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    padding-bottom: var(--space);
}

.md-viewer-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
}

/* A row of a table that opens something */
.md-click-row {
    cursor: pointer;
}

/* A check or calculation under way: a slim bar for the whole, over the feed of its steps */
.md-progress {
    height: 4px;
    margin-bottom: var(--space);
    border-radius: 2px;
    background: var(--line);
    overflow: hidden;
}

.md-progress-fill {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--ink);
    transition: width var(--duration-fast) var(--ease);
}

/* Files still to come: muted, below the step under way */
.ib-feed > li.md-feed-waiting {
    color: var(--muted);
}

/* ── Smaller screens ── */

/* A table fills its card: the column without a width takes the room left over. Fixed columns narrow a little on
   smaller screens. Below the fixed columns plus room for the stretching one, a table scrolls sideways in its panel
   rather than crushing that column. A column dragged to a width keeps it (modulariser.js). */
.ib-grid > colgroup > col {
    width: calc(var(--w) * var(--md-col-scale, 1) * 1px);
}

.ib-grid {
    width: 100%;
    min-width: calc((var(--fixed, 0) * var(--md-col-scale, 1) + 200) * 1px);
}

/* A resize line reaches four pixels past its column, into the next one. Where there is nothing to reach into (the
   pinned row action lies over it, or the table ends at its card's or dialog's edge), the line keeps wholly inside its
   own column, so all of it can be grabbed and a dialog has nothing to scroll sideways to while its table fits */
.ib-grid thead th:has(+ .ib-stick-actions) > .ib-col-resize,
.ib-grid thead th:last-child > .ib-col-resize {
    right: 0;
}

.ib-grid thead th:has(+ .ib-stick-actions) > .ib-col-resize::before,
.ib-grid thead th:has(+ .ib-stick-actions) > .ib-col-resize::after,
.ib-grid thead th:last-child > .ib-col-resize::before,
.ib-grid thead th:last-child > .ib-col-resize::after {
    right: 0;
}

/* A table with something pinned at its right (a row action, or a grouped table's Collapse all toggle): the box does
   not fade at its edges; the rows fade just before the pinned column while there is more to scroll. The same edge as
   I-Block's ib-pinned-end, said with an attribute so the scroller's own classes stay as its scrollbars set them. */
.wh-scroll[data-pinned-end] {
    -webkit-mask-image: none;
    mask-image: none;
}

.wh-scroll[data-pinned-end] .ib-stick-actions::before {
    content: "";
    position: absolute;
    top: 0;
    right: 100%;
    bottom: 0;
    width: 32px;
    background-color: inherit;
    -webkit-mask-image: linear-gradient(to right, transparent, #000);
    mask-image: linear-gradient(to right, transparent, #000);
    opacity: 0;
    transition: opacity var(--duration-open) var(--ease);
    pointer-events: none;
}

.wh-scroll[data-pinned-end].is-more-right .ib-stick-actions::before {
    opacity: 1;
}

/* In a dialog the header row stays put while the rows scroll. The row sticks as one, not cell by cell: a cell that
   sticks on its own lies over its neighbour's resize line and halves the line's reach */
.wh-dialog-body.is-flush .ib-grid thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.wh-dialog-body.is-flush .wh-table.ib-grid thead th {
    position: relative;
    top: auto;
    z-index: auto;
}

@media (max-width: 1199.98px) {
    .ib-grid {
        --md-col-scale: 0.85;
    }
}

@media (max-width: 991.98px) {
    .ib-grid {
        --md-col-scale: 0.75;
    }
}

/* Buttons that keep only their icon on a narrow screen (their name stays as the tooltip). On a phone, buttons fill
   their row anyway, so their names come back. */
@media (min-width: 576px) and (max-width: 767.98px) {
    .md-narrow-icon > .wh-btn-label {
        display: none;
    }

    .md-narrow-icon {
        min-width: 0;
        padding-inline: 8px;
    }
}

/* A phone: the option bar's line of text gives way to its buttons */
@media (max-width: 575.98px) {
    .ib-option-tools > .text-small {
        flex-basis: 100%;
    }
}

/* A phone: the header keeps one row (it has no nav links), so the steps band sits right under it */
@media (max-width: 575.98px) {
    :root {
        --wh-header-h: var(--header);
    }
}
