/* UR20 field I/O configuration tool: first-use rules, `ur20-` prefixed until a second selector shares them. */

/* Part colours sampled from the artwork, not brand values. */
:root {
    --ur20-part-grey: #58585A;
    /* The u-remote orange, sampled the same way. */
    --ur20-part-orange: #F26522;
    /* Rack background, on screen and on the printed sheet. */
    --ur20-rack-bg: #EEF3F8;
}

/* The rack in one scrolling row at real part widths (50 px per 11.5 mm); "-img" widths are for uncropped art. */
.ur20-rack {
    --ur20-img-h: 540px;
    --ur20-mod-w: 50px;
    --ur20-mod-img: 80px;
    --ur20-coup-w: 220px;
    --ur20-coup-img: 250px;
    /* End bracket 8 mm; the right end is 11.5 mm, one module wide. */
    --ur20-brk-w: 35px;
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    /* The sides leave room for the end columns' overlays. */
    padding: 16px 36px;
    background: var(--ur20-rack-bg);
    border: 1px solid var(--bs-gray-300);
    border-radius: 6px;
}

/* A fixed-width column with nothing reserved: the parts touch. */
.ur20-slot {
    position: relative;
    flex: 0 0 auto;
    cursor: pointer;
    width: var(--ur20-mod-w);
}

/* The selection ring, drawn over the column so it costs no layout. */
.ur20-slot::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    pointer-events: none;
}

/* Clips uncropped art's fingers; on the art, not the slot, so the overlay is not clipped. */
.ur20-slot-art {
    overflow: hidden;
    width: 100%;
}

.ur20-slot img {
    display: block;
    width: var(--ur20-mod-w);
    height: var(--ur20-img-h);
}

/* Set when the cropped art 404s: the original, oversize, fingers clipped. */
.ur20-slot img.ur20-art-uncropped {
    width: var(--ur20-mod-img);
}

.ur20-slot.ur20-coupler {
    width: var(--ur20-coup-w);
}

.ur20-slot.ur20-coupler img {
    width: var(--ur20-coup-w);
}

.ur20-slot.ur20-coupler img.ur20-art-uncropped {
    width: var(--ur20-coup-img);
}

/* Keyboard focus only (not a mouse click): the same blue as a selected column, outside it. */
.ur20-slot:focus-visible {
    outline: 2px solid var(--adc-blue);
    outline-offset: 2px;
}

/* The one highlighted column; a coloured border means selected and nothing else. */
.ur20-slot.focused {
    background: #fff;
}

.ur20-slot.focused::after {
    border-color: var(--adc-blue);
}

/* Three lines at 50 px, breaking on the part numbers' hyphens. */
.ur20-slot-label {
    font-size: 12px;
    text-align: center;
    overflow-wrap: break-word;
    line-height: 1.15;
}

/* A gutter between neighbouring labels. */
.ur20-slot .ur20-slot-label {
    padding-inline: 2px;
}

/* Where a power feed is required but not yet placed, red like the over-budget readout. */
.ur20-gap {
    flex: 0 0 auto;
    align-self: stretch;
    width: 5px;
    background: repeating-linear-gradient(
        180deg, var(--bs-danger) 0 6px, transparent 6px 12px);
}

/* The drop list, below the rack so its horizontal scroll cannot clip it. */
.ur20-slot-picker {
    /* Holds the caret; ur20Rack slides the panel with `left`, never a margin. */
    position: relative;
    background: #fff;
    /* Same blue as the focused column, so panel and column read as one. */
    border: 2px solid var(--adc-blue);
    border-radius: 6px;
    /* A readable measure; the panel slides under the open column. */
    max-width: 760px;
}

/* The active-module limit notice; italic sets it apart from the bold optgroup labels. */
.ur20-slot-picker option.ur20-limit-notice {
    font-weight: 700;
    font-style: italic;
}

/* Points the panel at the column it is acting on. */
.ur20-caret {
    position: absolute;
    top: -14px;
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 14px solid var(--adc-blue);
    transform: translateX(-50%);
}

/* The selected module's front view below the rack. */
.ur20-focus-img {
    height: 120px;
    width: auto;
}

.ur20-load-input {
    max-width: 12rem;
}

.ur20-factor-input {
    max-width: 8rem;
}

/* Action overlay, hover only; every action is also in the drop list. */
.ur20-overlay {
    position: absolute;
    z-index: 20;
    /* On the artwork, where the rack's scroll cannot clip it. */
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
}

/* The coupler's overlay sits at its right edge, where a new module would land. */
.ur20-slot.ur20-coupler .ur20-overlay {
    left: auto;
    right: 4px;
    transform: none;
}

.ur20-oo:first-child {
    border-radius: 10px 0 0 10px;
}

.ur20-oo:last-child {
    border-radius: 0 10px 10px 0;
}

.ur20-oo {
    border: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
    padding: 4px 8px;
    line-height: 1;
    color: #fff;
    cursor: pointer;
}

.ur20-oo-add {
    background: var(--adc-green);
}

.ur20-oo-edit {
    background: var(--adc-blue);
}

.ur20-oo-remove {
    background: var(--bs-danger);
}

.ur20-oo:hover {
    filter: brightness(1.15);
}

/* The station's two ends: not slots, so no overlay and no label. */
.ur20-end {
    flex: 0 0 auto;
}

.ur20-end img {
    display: block;
    height: var(--ur20-img-h);
}

.ur20-end-left img {
    width: var(--ur20-brk-w);
}

.ur20-end-right img {
    width: var(--ur20-mod-w);
}

/* The Add button past the end of the station. */
.ur20-add-end {
    flex: 0 0 auto;
    align-self: center;
    margin-left: 24px;
}

/* Totals strip under the rack; each entry stacks label over value. */
.ur20-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin: 0;
    padding: 8px 12px;
    background: var(--bs-gray-100);
    border: 1px solid var(--bs-gray-300);
    border-radius: 5px;
}

.ur20-summary li {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

/* Small label, so the value is what the eye lands on. */
.ur20-summary-label {
    font-size: 12px;
    color: var(--bs-gray-600);
}

/* Mounting schematic; the caption sits outside the SVG and stays upright when it turns. */
.ur20-mount-schematic {
    flex: 0 0 auto;
    /* Sized to the wider caption, kept on one line. */
    width: 148px;
}

/* Centres the drawing in the caption-width box. */
.ur20-mount-schematic svg {
    display: block;
    margin-inline: auto;
}

.ur20-mount-schematic figcaption {
    line-height: 1.2;
    white-space: nowrap;
}

.ur20-mount-parts {
    /* view-box makes transform-origin's px user units. */
    transform-box: view-box;
    transform-origin: 60px 60px;
    transition: transform .35s ease;
}

.ur20-mount-schematic.is-vertical .ur20-mount-parts {
    transform: rotate(-90deg);
}

@media (prefers-reduced-motion: reduce) {
    .ur20-mount-parts {
        transition: none;
    }
}

.ur20-ms-rail {
    fill: var(--bs-gray-400);
}

/* The coupler carries the brand blue. */
.ur20-ms-coupler {
    fill: var(--adc-blue);
}

.ur20-ms-module {
    fill: var(--ur20-part-grey);
}

.ur20-ms-endplate {
    fill: var(--bs-gray-700);
}

/* The orange tops, drawn over the body. */
.ur20-ms-top {
    fill: var(--ur20-part-orange);
}

/* The current-path bar: one equal-width section per stretch of rail between power feeds. */
.ur20-sections {
    display: flex;
    /* Not `stretch`: the feed ticks stand proud of the bar and have to keep their own height. */
    align-items: center;
}

.ur20-section {
    position: relative;
    height: 18px;
    background: var(--bs-gray-300);
    overflow: hidden;
}

.ur20-sections .ur20-section:first-child {
    border-radius: 4px 0 0 4px;
}

.ur20-sections .ur20-section:last-child {
    border-radius: 0 4px 4px 0;
}

/* A size container, so the figure is placed by the fill's drawn width; above the shared block. */
.ur20-section-fill {
    position: relative;
    z-index: 1;
    height: 18px;
    container-type: inline-size;
}

/* Shared coupler use in a path's first section, after its own fill; amber when the feed is on the other path. */
.ur20-section-shared {
    position: absolute;
    top: 0;
    height: 18px;
    background: repeating-linear-gradient(135deg, var(--bs-gray-500) 0 4px,
        var(--bs-gray-400) 4px 8px);
}

.ur20-section-shared-over {
    background: repeating-linear-gradient(135deg, var(--bs-warning) 0 4px,
        var(--bs-gray-400) 4px 8px);
}

/* The feed tick, proud of the bar; negative margins keep the count row aligned. */
.ur20-section-tick {
    flex: 0 0 3px;
    margin: 0 -1.5px;
    align-self: center;
    height: 26px;
    background: var(--bs-gray-900);
    /* Over the fills it divides, not under them. */
    position: relative;
    z-index: 1;
}

/* The section's running total, from the left, white inside the fill. */
.ur20-section-amps {
    position: absolute;
    top: 0;
    left: 6px;
    line-height: 18px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

/* A fill too short for the figure puts it just past the tip; 60px fits "10.00 A". */
@container (max-width: 60px) {
    .ur20-section-amps {
        left: 100%;
        margin-left: 6px;
        font-weight: 400;
        color: inherit;
    }
}

.ur20-section-count {
    color: var(--bs-gray-600);
    text-align: center;
    padding-top: 2px;
}

/* The printed sheet, hidden on screen; print.css reveals it. */
.ur20-print-sheet {
    display: none;
}
