/*
 * What the order portals need beyond Bootstrap, served at /assets/clientwms.css and loaded after it. The pages are Bootstrap
 * markup; a site's colors are Bootstrap variables set in its _theme.html.twig (see the package's own), loaded after this file.
 * Here are only the parts Bootstrap has no component for: the facet buttons, the product tiles and their banners, the folds.
 */
:root { --accent: var(--bs-primary); --accent-text: #fff; --blur-opacity: .2; --blur-offset: .2em; --blur-distance: .4em; }

/* the left menu: one static width, at every window size (no breakpoints, it never hides or stacks); the content beside it scrolls sideways if it must */
.sidebar { width: 240px; min-width: 240px; }
.content { min-width: 0; }
/* the page's cards, one under another with a gap between them */
main.content { display: flex; flex-direction: column; gap: 1rem; }

/* a select smaller than Bootstrap's small one (the products-per-page box) */
.form-select-ss {
    padding-top: .125rem;
    padding-bottom: .125rem;
    padding-left: .375rem;
    border-radius: var(--bs-border-radius-sm);
    padding-right: .25rem;
    font-size: 1em;
}

/* a select smaller than Bootstrap's small one, in a heading or a row of fields (with form-select-sm, which keeps the room for its arrow) */
.form-select-smaller {
  padding-top: .125rem;
  padding-bottom: .125rem;
  padding-left: .5rem;
  font-size: .75rem;
  border-radius: var(--bs-border-radius-sm);
}

/* a checkbox that marks something for removal: red when it is checked, and its focus ring */
.form-check-input-danger:checked {
  background-color: var(--bs-danger);
  border-color: var(--bs-danger);
}
.form-check-input-danger:focus {
  border-color: var(--bs-danger);
  box-shadow: 0 0 0 .25rem rgba(var(--bs-danger-rgb), .25);
}

/* paragraphs have no bottom margin (Bootstrap's reboot gives them 1rem); a space between things is an mb-* class or a gap */
p { margin-bottom: 0; }

/* a card body is a column of its children with a gap between them, in place of a margin on each */
.card-body { display: flex; flex-direction: column; gap: 1rem; }

/* the last thing in a card body has no bottom margin, or the card ends in a gap (!important: Bootstrap's mb-* utilities are) */
.card-body > :last-child { margin-bottom: 0 !important; }

/* a ship method row: the label stretches over the whole row, so a click anywhere on it picks the radio */
.method-row { cursor: pointer; }

/* tables: small capitals for the headings */
.table > thead > tr > th { font-size: .75rem; text-transform: uppercase; color: var(--bs-secondary-color); white-space: nowrap; }
/* a dark header keeps the table's own light text: the muted color above is for a light one */
.table > thead.table-dark > tr > th { color: var(--bs-table-color); }

/* a link that opens in a new tab ends in the external-link icon (the legacy portals' own), in the link's color */
a[target="_blank"]::after {
    content: ""; display: inline-block; width: .7em; height: .7em; margin-left: .25rem; background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='black' stroke-width='1.2'%3E%3Cpath d='M4 1.5H1.5v7h7V6M6 1h3v3M9 1L4.5 5.5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='black' stroke-width='1.2'%3E%3Cpath d='M4 1.5H1.5v7h7V6M6 1h3v3M9 1L4.5 5.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* order and item statuses */
.status-shipped { color: #1a7f37; }
.status-cancelled { color: #444; }
.status-backorder { color: #8a1f17; }
.status-open { color: var(--accent); }
.expiry-expired { color: #8a1f17; text-decoration: line-through; }
.expiry-very-soon { color: #8a1f17; }
.expiry-soon { color: #9a6700; }
.cutoff-warning { color: #8a1f17; }
.field-error { color: #8a1f17; }

/* an order with a note in the admin's print list: the legacy light blue, the same on every site (not the site's primary color) */
.order-note { font-weight: bold; color: rgb(117, 197, 240); }
.order-ecommerce { font-weight: bold; color: rgb(255, 170, 85); }
/* an order that ships from a non-standard location (HDB): the legacy red */
.order-ships-from { font-weight: bold; color: #f05; }

/* a facet option has two buttons, + (only these) and - (not these): a faint grey symbol when off, filled when on */
.tri { display: inline-flex; justify-content: center; align-items: center; width: 1rem; height: 1rem; padding-bottom: 2px; border: 1px solid var(--bs-border-color); border-radius: 3px; background: var(--bs-body-bg); color: #c5c9cf; font-size: .85rem; font-weight: 700; line-height: 1; text-decoration: none; }
.tri:hover { border-color: var(--bs-secondary-color); color: var(--bs-secondary-color); }
.state-plus .tri-plus { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.state-minus .tri-minus { border-color: #8a1f17; background: #8a1f17; color: #fff; }

/* label/value tables (replace dl/dt/dd) */
.table.table-kv th { width: 1%; padding-right: 1rem; white-space: nowrap; font-weight: 400; color: var(--bs-secondary-color); }
.table.table-kv td { overflow-wrap: anywhere; }
/* tables that stand one under the other (an order's sections, the receipt, the review) share one label width, so their values line up */
.table.table-kv.table-kv--aligned th { width: 12rem; white-space: normal; }
@media (max-width: 575.98px) { .table.table-kv.table-kv--aligned th { width: 35%; } }

/* two label/value tables side by side (the order information of the receipt, the checkout review and the order page); one under the other on a phone */
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
@media (max-width: 767.98px) { .two-columns { grid-template-columns: 1fr; } }

/* folds (native details, no script): a carrier's methods, a destination's carriers */
details.carrier { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); margin-bottom: .5rem; overflow: clip; }
details.carrier > summary { cursor: pointer; padding: .4rem .75rem; background: var(--bs-tertiary-bg); font-weight: 600; }
details.carrier[open] > summary { border-bottom: 1px solid var(--bs-border-color); }
details.carrier .table-responsive, details.carrier table { margin: 0; }
/* separate borders: collapsed ones round differently per fold at a fractional zoom (the line under the header showed on some folds only) */
details.carrier table { border-collapse: separate; border-spacing: 0; }
details.carrier td label { margin: 0; }
details.carrier td:first-child, details.carrier th:first-child { min-width: 4rem; text-align: center; }
details.carrier th:nth-child(2), details.carrier th:nth-child(3) { width: 50%; }
/* an open fold ends at its own border: the last row has no bottom border of its own, and the last fold has no margin below it */
details.carrier tbody tr:last-child > * { border-bottom-width: 0; }
details.carrier:last-child { margin-bottom: 0; }
details.ship-destination > summary { cursor: pointer; }
details.ship-destination > summary .fw-bold { display: inline; }
fieldset.destination { border: 0; padding: 0; }

/* product list */
.pages a, .pages b { padding: .1rem .45rem; border-radius: var(--bs-border-radius); text-decoration: none; }
.pages b { background: var(--accent); color: var(--accent-text); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.tile { position: relative; display: flex; flex-direction: column; gap: .5rem; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: var(--bs-body-bg); padding: .5rem; text-align: center; }
.tile > a { display: block; position: relative; aspect-ratio: 1; }
.tile img { width: 100%; height: 100%; object-fit: contain; }
.tile div.title { font-weight: bold; font-size: .95rem; }
.tile p { margin: 0; font-size: .85rem; }
/* the bottom of a tile (its add-to-cart form and order unit, or the several-options note) sits at the foot, level across the row of tiles */
.tile .tile-foot { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: end; gap: .5rem; }
.in-cart { color: #fff; background: #1a7f37; font-weight: 700; font-size: 1rem; border-radius: var(--bs-border-radius); padding: .5rem .75rem; }

/*
 * tile banners: the text of each is its title (::after), so a site restyles them wholesale in its own stylesheet.
 * Both carry .text-shadow, which builds a soft glow (--blur-shadow) from the --blur-* values on the element itself, so one
 * banner can set its own; the shadow has to be built on the element that uses it, not on :root, or those overrides are lost.
 */
.text-shadow {
    --blur-color: rgba(255, 255, 255, var(--blur-opacity));
    --blur-shadow:
        0 var(--blur-offset) var(--blur-distance) var(--blur-color),
        0 calc(-1 * var(--blur-offset)) var(--blur-distance) var(--blur-color),
        var(--blur-offset) 0 var(--blur-distance) var(--blur-color),
        calc(-1 * var(--blur-offset)) 0 var(--blur-distance) var(--blur-color);
    text-shadow: var(--blur-shadow); /* inherited, so the ::after text of a banner gets it too */
}
.tile-banner, .stock-banner { color: var(--accent-text); font-size: .75rem; pointer-events: none; }
.tile-banner::after, .stock-banner::after { content: attr(title); }

/*
 * A small badge in the tile's corner. A site makes it a ribbon by setting these on .tile-banner and moving ::after:
 * --banner-width, --banner-inset (how far the corner sits in from the tile's top and left), the paddings and --banner-height.
 */
.tile-banner {
    --banner-padding-x: .4rem;
    --banner-padding-y: .1rem;
    --banner-height: calc(1.5em + 2 * var(--banner-padding-y));
    --banner-inset: .5rem;
    --banner-width: auto;
    position: absolute; z-index: 10;
    top: var(--banner-inset); left: var(--banner-inset);
    display: block;
    width: var(--banner-width); height: var(--banner-height);
    padding: var(--banner-padding-y) var(--banner-padding-x);
    border-radius: .25rem;
    background: var(--accent);
    line-height: 1.5; /* so a line is the 1.5em of --banner-height */
    font-weight: normal; text-align: center; text-transform: uppercase; letter-spacing: 1px;
}

/* a band across the bottom of the image link, which is relative */
.stock-banner { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(138, 31, 23, .85); }
.stock-banner::after { display: block; padding: .25rem 0; font-weight: bold; text-align: center; text-transform: uppercase; letter-spacing: 1px; }
/* nothing on hand: still orderable, but marked */
.tile.out-of-stock { background: #fafafa; border-color: #e3b5b0; }
.tile.out-of-stock > a img { opacity: .45; filter: grayscale(1); }

/* product pictures */
.pictures { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.pictures .preview img { max-width: 480px; width: 100%; border: 1px solid var(--bs-border-color); }
.pictures .thumbs { display: flex; gap: .75rem; flex-wrap: wrap; }
.pictures figure { margin: 0; text-align: center; font-size: .8rem; }
.pictures figure img { width: 90px; height: 90px; object-fit: contain; border: 1px solid var(--bs-border-color); }
.submit-order { text-align: center; margin: 1.5rem 0; }
/* a wide report scrolls inside its own box, so its horizontal scrollbar is on screen (not at the bottom of a long page), and its heading stays in view */
.table-scroll { max-height: calc(100vh - 13rem); overflow: auto; }
.table-scroll > .table > thead th { position: sticky; top: 0; z-index: 1; background: var(--bs-body-bg); box-shadow: inset 0 -1px 0 var(--bs-border-color); }
/* the lines of a bundle (an Explode import mapping made them from one imported line): a row group with a border on the edit and close pages,
   a left border on the order page, which has no row groups; each has a label row above it */
.table tbody.bundle { border: 2px solid var(--bs-secondary-color); }
.table tr.bundle-head > td { background: var(--bs-tertiary-bg); font-size: .8rem; padding-top: .25rem; padding-bottom: .25rem; }
.table tr.bundle-line > td:first-child { border-left: 3px solid var(--bs-secondary-color); }

/* a card collapsed to its header (the body has d-none) has no border under the header */
.card-header:has(+ .d-none) { border-bottom: 0; }
