/* Industrial Neutral: shared public-site tokens and Bootstrap extensions. */
:root {
    --bs-body-color: #1b1f24;
    --bs-body-color-rgb: 27, 31, 36;
    --bs-body-bg: #ffffff;
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-body-font-size: 1rem;
    --bs-body-line-height: 1.5;
    --bs-secondary-color: #566170;
    --bs-secondary-color-rgb: 86, 97, 112;
    --bs-secondary: #566170;
    --bs-secondary-rgb: 86, 97, 112;
    --bs-primary: #17578a;
    --bs-primary-rgb: 23, 87, 138;
    --bs-link-color: #17578a;
    --bs-link-color-rgb: 23, 87, 138;
    --bs-link-hover-color: #0f4268;
    --bs-link-hover-color-rgb: 15, 66, 104;
    --bs-border-color: #d5dbe1;
    --bs-tertiary-bg: #f4f6f8;
    --bs-tertiary-bg-rgb: 244, 246, 248;
    --bs-border-radius: .25rem;
    --bs-border-radius-sm: .25rem;
    --bs-border-radius-lg: .25rem;
    --bs-border-radius-xl: .25rem;
    --bs-border-radius-xxl: .25rem;
    --bs-box-shadow: none;
    --bs-box-shadow-sm: none;
    --bs-box-shadow-lg: none;
    --bs-box-shadow-inset: none;
    --bld-control-border: #7d8896;
    --bld-focus-color: #17578a;
    --bld-in-stock-fg: #0b5c33;
    --bld-in-stock-bg: #e3f3ea;
    --bld-limited-fg: #6b4200;
    --bld-limited-bg: #fff0cc;
    --bld-out-of-stock-fg: #8f1a1a;
    --bld-out-of-stock-bg: #fbe6e6;
    --bld-preorder-fg: #174a87;
    --bld-preorder-bg: #e5eefb;
    --bld-special-order-fg: #58288a;
    --bld-special-order-bg: #f0e8fa;
    --bld-unknown-fg: #434d59;
    --bld-unknown-bg: #e9edf1;
    --bld-stale-fg: #6b4200;
    --bld-stale-bg: #fff0cc;
}

/* Typography and links. Rem sizes follow the reader's font settings. */
h1, .h1 {
    font-size: 2rem;
    line-height: 2.375rem;
    letter-spacing: -.025em;
}

h2, h2[class], .h2 {
    font-size: 1.25rem;
    line-height: 1.75rem;
}

small, .small, .table, .form-label, .breadcrumb {
    font-size: .875rem;
    line-height: 1.25rem;
}

a {
    text-underline-offset: .1875rem;
}

.link-secondary:hover, .link-secondary:focus {
    color: var(--bs-body-color) !important;
}

/* Controls and opaque keyboard focus, without Bootstrap's focus shadow. */
.form-select, .form-control, .form-check-input,
.form-select:focus, .form-control:focus, .form-check-input:focus {
    border-color: var(--bld-control-border);
}

.form-select, .form-control, .btn, summary, .page-link {
    min-height: 2.75rem;
}

.btn, .page-link {
    align-content: center;
}

summary {
    padding: .625rem 1rem;
    cursor: pointer;
}

.form-check-label {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    cursor: pointer;
}

.form-check-input {
    margin-top: .875rem;
}

.form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-link-hover-color);
    --bs-btn-hover-border-color: var(--bs-link-hover-color);
    --bs-btn-active-bg: var(--bs-link-hover-color);
    --bs-btn-active-border-color: var(--bs-link-hover-color);
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
}

.pagination {
    --bs-pagination-active-bg: var(--bs-primary);
    --bs-pagination-active-border-color: var(--bs-primary);
    flex-wrap: wrap;
    gap: .25rem;
}

.btn:focus, .form-select:focus, .form-control:focus, .form-check-input:focus, .page-link:focus {
    box-shadow: none;
}

a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible,
textarea:focus-visible, summary:focus-visible, .btn:focus-visible, .page-link:focus-visible {
    outline: 2px solid var(--bld-focus-color);
    outline-offset: 2px;
    box-shadow: none;
}

/* Publication states keep their visible labels and permit long text to wrap. */
.availability, .stale-mark {
    display: inline-block;
    max-width: 100%;
    padding: .125rem .375rem;
    border: 1px solid currentColor;
    border-radius: var(--bs-border-radius);
    font-size: .875rem;
    font-weight: 500;
    line-height: 1.25rem;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
}

.availability[data-availability="IN_STOCK"] {
    color: var(--bld-in-stock-fg);
    background-color: var(--bld-in-stock-bg);
}

.availability[data-availability="LIMITED"] {
    color: var(--bld-limited-fg);
    background-color: var(--bld-limited-bg);
}

.availability[data-availability="OUT_OF_STOCK"] {
    color: var(--bld-out-of-stock-fg);
    background-color: var(--bld-out-of-stock-bg);
}

.availability[data-availability="PREORDER"] {
    color: var(--bld-preorder-fg);
    background-color: var(--bld-preorder-bg);
}

.availability[data-availability="SPECIAL_ORDER"] {
    color: var(--bld-special-order-fg);
    background-color: var(--bld-special-order-bg);
}

.availability[data-availability="UNKNOWN"] {
    color: var(--bld-unknown-fg);
    background-color: var(--bld-unknown-bg);
    border-style: dashed;
}

.stale-mark {
    color: var(--bld-stale-fg);
    background-color: var(--bld-stale-bg);
}

/* Price primitives: apply within a single price and its unit. */
.price {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.price-strong {
    font-weight: 700;
}

.price-secondary {
    font-weight: 600;
}

/* Shared shell. Desktop retains Bootstrap's container widths and gutters. */
.site-header .navbar {
    gap: .75rem 1.5rem;
    padding-inline: calc(var(--bs-gutter-x) * .5);
}

/* The wordmark keeps its 502:98 ratio; width/height attributes reserve the space before it loads. */
.site-wordmark {
    display: block;
    width: auto;
    height: 1.5rem;
}

.site-metro {
    flex-wrap: wrap;
    min-width: 0;
    overflow-wrap: anywhere;
}

.skip-link {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1030;
    padding: .625rem 1rem;
    background-color: var(--bs-body-bg);
}

.skip-link:not(:focus) {
    clip-path: inset(50%);
}

@media (max-width: 991.98px) {
    .site-header > .container, #main.container, .site-footer > .container {
        --bs-gutter-x: 3rem;
        max-width: none;
    }
}

@media (max-width: 575.98px) {
    h1, .h1 {
        font-size: 1.625rem;
        line-height: 2rem;
    }

    .site-header > .container, #main.container, .site-footer > .container {
        --bs-gutter-x: 2rem;
    }

    .navbar-brand {
        margin-right: 0;
    }

    .site-wordmark {
        height: 1.25rem;
    }
}

/* Hidden before htmx loads, and with JavaScript disabled. */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator, .htmx-request.htmx-indicator {
    display: inline-block;
}

/* Listing filters remain outside the htmx swap target. */
.listing-filters {
    border: 1px solid var(--bld-control-border);
    border-radius: var(--bs-border-radius);
    background: var(--bs-tertiary-bg);
}

.listing-filters summary {
    font-weight: 600;
}

.listing-filters form {
    padding: 0 1rem 1rem;
}

.listing-filter-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: .75rem;
}

.listing-filter-field {
    min-width: 0;
    overflow-wrap: anywhere;
}

.listing-active-values, .family-section__attributes {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
}

.listing-status:focus {
    outline: 2px solid var(--bld-focus-color);
    outline-offset: 2px;
}

.listing-wrapper.htmx-request :is(.category-listing, .store-listing),
:is(.category-listing, .store-listing)[data-stale] {
    opacity: .55;
}

:is(.category-listing, .store-listing)[data-stale] {
    border-inline-start: .25rem solid var(--bld-stale-fg);
    padding-inline-start: .75rem;
}

/* Family sections use one table and one copy of each item's content at every width. */
.category-intro {
    max-width: 54rem;
    margin-bottom: .75rem;
}

.family-section__header {
    padding: 1rem;
    background: var(--bs-tertiary-bg);
    border-block: 1px solid var(--bs-border-color);
}

.catalog-table :is(th, td) {
    padding: .75rem 1rem;
    overflow-wrap: anywhere;
}

.catalog-table th {
    color: var(--bs-secondary-color);
    font-weight: 500;
}

.catalog-row__product {
    width: 49%;
}

.catalog-row__package, .catalog-row__unit, .catalog-row__source {
    width: 17%;
}

.catalog-row__package, .catalog-row__unit {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.catalog-row__name, .catalog-row__package-price, .catalog-row__unit .price {
    font-size: 1rem;
    line-height: 1.5;
}

.catalog-row__name {
    font-weight: 600;
}

.catalog-row__meta {
    margin-top: .25rem;
}

.catalog-row__thumbnail {
    float: left;
    display: block;
    width: 4rem;
    height: 4rem;
    margin: 0 .75rem .25rem 0;
}

.catalog-row__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.catalog-row__source .stale-mark {
    margin-top: .25rem;
}

@media (max-width: 991.98px) {
    .catalog-table, .catalog-table tbody {
        display: block;
        width: 100%;
    }

    /* Keep the column headers accessible when the rows are re-laid out. */
    .catalog-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .catalog-row {
        display: flex;
        flex-wrap: wrap;
        column-gap: 1rem;
        padding: .75rem 1rem;
        border-bottom: 1px solid var(--bs-border-color);
    }

    .catalog-row td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        background: transparent;
    }

    .catalog-row .catalog-row__product {
        flex-basis: 100%;
        min-width: 0;
    }

    /* The package cell's two children join the row's price and source lines. Explicit cell roles remain. */
    .catalog-row .catalog-row__package {
        display: contents;
    }

    .catalog-row__package-price, .catalog-row .catalog-row__unit {
        flex: 1 1 auto;
        margin-top: .5rem;
    }

    .catalog-row__package-price {
        order: 1;
        text-align: left;
    }

    .catalog-row .catalog-row__unit {
        order: 2;
    }

    /* A line break after the price pair, without a second copy of the store count. */
    .catalog-row::after {
        content: "";
        order: 3;
        flex-basis: 100%;
    }

    .catalog-row__stores {
        order: 4;
        margin-top: .5rem;
        text-align: left;
    }

    .catalog-row .catalog-row__source {
        order: 5;
        display: flex;
        flex: 1 1 auto;
        flex-wrap: wrap;
        align-items: baseline;
        gap: .25rem .5rem;
        margin-top: .5rem;
        min-width: 0;
    }

    .catalog-row__source .stale-mark {
        margin-top: 0;
    }
}

/* Supplier item: identification, offers, photos, details and the two comparison blocks. */
.item-identification h1, .item-identification p {
    overflow-wrap: anywhere;
}

.item-jump-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    margin-top: 1.25rem;
}

.item-jump-links a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
}

.item-offers-table :is(th, td), .comparison-table :is(th, td) {
    padding: .75rem .5rem;
    overflow-wrap: anywhere;
}

.item-offers-table th, .comparison-table th {
    color: var(--bs-secondary-color);
    font-weight: 500;
}

.item-offer__store { width: 11%; }
.item-offer__locality { width: 9%; }
.item-offer__price { width: 8%; }
.item-offer__unit { width: 9%; }
.item-offer__change { width: 18%; }
.item-offer__availability { width: 11%; }
.item-offer__lead { width: 5%; }
.item-offer__updated { width: 15%; }
.item-offer__source { width: 14%; }

.item-offers-history {
    max-width: 56rem;
}

.item-offer__change {
    font-size: .875rem;
    line-height: 1.25rem;
}

.item-offer__change-head {
    font-weight: 600;
}

.item-offer__change-obs {
    white-space: nowrap;
}

.item-offer__change-pair {
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
}

.item-offer__price, .item-offer__unit,
.comparison-row__price, .comparison-row__unit {
    text-align: right;
}

td.item-offer__price, td.item-offer__unit,
.comparison-row__package-price, td.comparison-row__unit {
    font-size: 1rem;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.item-offer__label {
    display: none;
}

.item-offers-disclaimer {
    max-width: 56rem;
}

.item-offers-disclaimer p {
    margin-bottom: 0;
}

.product-gallery {
    padding: 1.25rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.product-gallery__main {
    display: block;
    max-width: 400px;
}

.product-gallery__main img {
    width: 100%;
    height: 280px;
    object-fit: contain;
}

.product-gallery__thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .75rem;
}

.product-gallery__thumbnails a, .product-gallery__thumbnails img {
    display: block;
    width: 80px;
    height: 80px;
}

.product-gallery__thumbnails img {
    object-fit: contain;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.item-details-table {
    max-width: 50rem;
}

/* Label | value rows that reflow with the text size: each row wraps the value under its label once both no longer
   fit side by side (bases in rem, so 200% text stacks them instead of splitting words). The flex rows need the
   explicit table roles of item.html. */
.item-details-table, .item-details-table tbody {
    display: block;
}

.item-details-table tr {
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.5rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.item-details-table :is(th, td) {
    padding: 0;
    border: 0;
    background: transparent;
    min-width: 0;
}

.item-details-table th {
    flex: 1 1 8rem;
    overflow-wrap: break-word;
}

.item-details-table td {
    flex: 999 1 10rem;
    overflow-wrap: anywhere;
}

.comparison-row__product {
    width: 35%;
}

td.comparison-row__product {
    font-weight: 600;
}

/* The "·" between the meta values of a narrow row; the values are separate columns on desktop. */
.comparison-row__sep {
    display: none;
}

@media (max-width: 1199.98px) {
    .item-offers-table, .item-offers-table tbody {
        display: block;
        width: 100%;
    }

    .item-offers-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .item-offer {
        display: flex;
        flex-wrap: wrap;
        column-gap: 1rem;
        padding: 1rem 0;
        border-top: 1px solid var(--bs-border-color);
    }

    .item-offer td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        min-width: 0;
        background: transparent;
    }

    .item-offer .item-offer__store {
        flex: 1 1 60%;
        font-size: 1rem;
        font-weight: 600;
    }

    .item-offer .item-offer__locality {
        flex: 1 1 auto;
        color: var(--bs-secondary-color);
        text-align: right;
    }

    .item-offer::before, .item-offer::after {
        content: "";
        flex-basis: 100%;
    }

    .item-offer::before { order: 1; }
    .item-offer::after { order: 4; }

    .item-offer .item-offer__price {
        order: 2;
        flex: 1 1 auto;
        text-align: left;
        margin-top: .5rem;
    }

    .item-offer .item-offer__unit {
        order: 3;
        flex: 1 1 auto;
        margin-top: .5rem;
    }

    /* Status, lead time, time and source share wrapping lines: one line on tablets, stacked on phones. */
    /* The price change note: its own line right after the price / unit price line. */
    .item-offer .item-offer__change {
        order: 4;
        flex: 1 1 100%;
        margin-top: .25rem;
    }

    /* Preserve the empty table cell for accessibility without an empty visible block. */
    .item-offer .item-offer__change--empty {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        margin: 0;
    }

    .item-offer .item-offer__availability {
        order: 5;
        flex: 0 1 auto;
        margin-top: .5rem;
    }

    .item-offer .item-offer__lead {
        order: 6;
        flex: 0 1 auto;
        margin-top: .5rem;
    }

    /* Preserve the empty table cell for accessibility without an empty visible lead-time block. */
    .item-offer .item-offer__lead--empty {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        margin: 0;
    }

    .item-offer .item-offer__updated {
        order: 7;
        flex: 0 1 auto;
        margin-top: .5rem;
    }

    .item-offer .item-offer__source {
        order: 8;
        flex: 0 1 auto;
        margin-top: .5rem;
    }

    .item-offer__label {
        display: inline;
    }
}

@media (max-width: 991.98px) {
    .comparison-table, .comparison-table tbody {
        display: block;
        width: 100%;
    }

    .comparison-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .comparison-row {
        display: flex;
        flex-wrap: wrap;
        column-gap: .75rem;
        padding: 1rem 0;
        border-top: 1px solid var(--bs-border-color);
    }

    .comparison-row td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        min-width: 0;
        background: transparent;
    }

    .comparison-row .comparison-row__product {
        order: 0;
        flex-basis: 100%;
        font-size: 1rem;
    }

    .comparison-row :is(.comparison-row__chain, .comparison-row__manufacturer, .comparison-row__package) {
        order: 1;
        margin-top: .25rem;
        color: var(--bs-secondary-color);
    }

    .comparison-row__sep {
        display: inline;
        margin: 0 -.375rem 0 .375rem;
    }

    .comparison-row::before {
        content: "";
        order: 2;
        flex-basis: 100%;
    }

    .comparison-row .comparison-row__price {
        display: contents;
    }

    .comparison-row__package-price {
        order: 3;
        flex: 1 1 auto;
        margin-top: .5rem;
        text-align: left;
    }

    .comparison-row .comparison-row__unit {
        order: 4;
        flex: 1 1 auto;
        margin-top: .5rem;
    }

    .comparison-row__stores {
        order: 5;
        flex-basis: 100%;
        margin-top: .5rem;
        text-align: left;
    }
}

@media (max-width: 575.98px) {
    .product-gallery {
        padding: 1rem;
    }

    .product-gallery__main img {
        height: 220px;
    }

    .product-gallery__thumbnails a, .product-gallery__thumbnails img {
        width: 64px;
        height: 64px;
    }
}

/* Store page: compact profile and one offers table, re-laid out as row blocks below 992px. */
.lead {
    max-width: 54rem;
    font-size: 1.125rem;
    font-weight: 400;
}

.store-profile {
    margin-bottom: .5rem;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 2rem;
}

.store-offers-table :is(th, td) {
    padding: .75rem .5rem;
    overflow-wrap: anywhere;
}

.store-offers-table th {
    color: var(--bs-secondary-color);
    font-weight: 500;
}

.store-offer__product { width: 34%; }
.store-offer__package { width: 11%; }
.store-offer__unit { width: 12%; }
.store-offer__availability { width: 15%; }
.store-offer__updated { width: 16%; }
.store-offer__source { width: 12%; }

.store-offer__package, .store-offer__unit {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

td.store-offer__package, td.store-offer__unit {
    font-size: 1rem;
    line-height: 1.5;
}

.store-offer__name {
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 600;
}

.store-offer__meta {
    margin-top: .25rem;
}

.store-offer__label {
    display: none;
}

@media (max-width: 991.98px) {
    .store-offers-table, .store-offers-table tbody {
        display: block;
        width: 100%;
    }

    .store-offers-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .store-offer {
        display: flex;
        flex-wrap: wrap;
        column-gap: 1rem;
        padding: .75rem 0;
        border-top: 1px solid var(--bs-border-color);
    }

    .store-offer td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        min-width: 0;
        background: transparent;
    }

    .store-offer .store-offer__product {
        flex-basis: 100%;
    }

    .store-offer .store-offer__package, .store-offer .store-offer__unit {
        flex: 1 1 auto;
        margin-top: .5rem;
    }

    .store-offer .store-offer__package {
        order: 1;
        text-align: left;
    }

    .store-offer .store-offer__unit {
        order: 2;
    }

    .store-offer::after {
        content: "";
        order: 3;
        flex-basis: 100%;
    }

    .store-offer .store-offer__availability {
        order: 4;
        margin-top: .5rem;
    }

    .store-offer .store-offer__updated {
        order: 5;
        flex: 1 1 auto;
        margin-top: .5rem;
    }

    .store-offer .store-offer__source {
        order: 6;
        flex-basis: 100%;
        margin-top: .5rem;
    }

    .store-offer__label {
        display: inline;
    }
}

/* Reference pages: supplier stores by locality, metro categories and the metro picker. */
.reference-columns {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: 1.25rem 2rem;
}

.reference-columns h3 {
    margin-bottom: .25rem;
}

.reference-list li {
    padding-block: .125rem;
}

.link-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.link-list a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
}

.metro-list li + li {
    border-top: 1px solid var(--bs-border-color);
}

.metro-list a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    font-weight: 600;
}

.metro-list p {
    max-width: 54rem;
    margin-bottom: .75rem;
}
