/*
 * SCM Admin UI Kit — Public storefront (merchandise)
 *
 * The customer-facing product grid and product page.
 *
 * WHY THIS FILE EXISTS
 *
 * ProductGrid.razor and ProductDetail.razor shipped with sixteen-odd semantic class
 * names — product-grid, product-card, product-card-media — and no stylesheet behind
 * any of them. The browser fell back to defaults: product names rendered as bare
 * headings with default margins, images at intrinsic size, and no grid at all. On an
 * admin panel that is embarrassing; on the shop it is what every customer sees.
 *
 * Tokens, not literals, so the shop follows a venue's theme like everything else.
 * The public site loads this file DIRECTLY (see WebsiteDisplayResources) rather than
 * through SCMUIKit.css's @import chain, because the entry point's imports are
 * unversioned and go stale in browser caches.
 */

/* ── Category rail ──────────────────────────────────────────────────────── */

.product-category-rail {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    /* Momentum scrolling on touch, and no scrollbar chrome eating the row on desktop. */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: 0 0 auto;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--simx-border-default, #dee2e6);
    border-radius: 999px;
    background: var(--simx-bg-surface, #fff);
    color: var(--simx-text-primary, #212529);
    font-size: 0.9375rem;
    line-height: 1.2;
    cursor: pointer;
    /* Chips are anchors (crawlable category links), so suppress the link underline. */
    text-decoration: none;
    transition: background-color var(--simx-duration-fast, 120ms) ease,
                border-color var(--simx-duration-fast, 120ms) ease;
}

.category-chip:hover,
.category-chip:focus {
    text-decoration: none;
    color: var(--simx-text-primary, #212529);
}

.category-chip.active:hover,
.category-chip.active:focus {
    color: var(--simx-text-on-accent, #fff);
}

.category-chip:hover {
    background: var(--simx-bg-hover, #f1f3f5);
}

.category-chip.active {
    background: var(--simx-accent, #2f6fed);
    border-color: var(--simx-accent, #2f6fed);
    color: var(--simx-text-on-accent, #fff);
}

.category-count {
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: var(--simx-bg-sunken, #f8f9fa);
    color: var(--simx-text-tertiary, #6c757d);
    font-size: 0.75rem;
}

.category-chip.active .category-count {
    /* Reads against the accent fill without hard-coding a second colour. */
    background: rgba(255, 255, 255, 0.25);
    color: inherit;
}

/* ── Toolbar: search and sort ───────────────────────────────────────────── */

.product-browse-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

/* The icon sits INSIDE the field rather than above it, which is what the unstyled
   version was doing and why the magnifier floated alone on its own line. */
.product-search {
    position: relative;
    flex: 1 1 260px;
    min-width: 0;
}

.product-search .bi-search {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    transform: translateY(-50%);
    color: var(--simx-text-tertiary, #6c757d);
    pointer-events: none;
}

.product-search .form-control {
    padding-left: 2.25rem;
}

.product-sort {
    flex: 0 0 auto;
    margin-bottom: 0;
}

/* ── The grid ───────────────────────────────────────────────────────────── */

.product-grid {
    display: grid;
    /* auto-fill with a floor rather than fixed columns: the shop has to look right
       from a phone to a shop-window display without a breakpoint for each. */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.product-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--simx-border-default, #dee2e6);
    border-radius: var(--simx-radius-md, 0.5rem);
    background: var(--simx-bg-surface, #fff);
    transition: box-shadow var(--simx-duration-fast, 120ms) ease,
                transform var(--simx-duration-fast, 120ms) ease;
}

.product-card:hover {
    box-shadow: var(--simx-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.08));
    transform: translateY(-2px);
}

/* The WHOLE card is one anchor.

   It used to be two buttons — image and name — with everything between them inert, so a
   shopper clicking the card anywhere else got nothing, and no crawler could follow either
   (a <button> is not a link). The anchor carries the layout so the entire card is one hit
   target and one crawlable link. */
.product-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.product-card-link:hover,
.product-card-link:focus-visible {
    color: inherit;
    text-decoration: none;
}

/* Keyboard users get the ring on the card, not on some inner fragment of it. */
.product-card-link:focus-visible {
    outline: 2px solid var(--simx-accent, #2563eb);
    outline-offset: 2px;
}

.product-card-media {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    background: var(--simx-bg-sunken, #f8f9fa);
    cursor: pointer;
    overflow: hidden;
}

.product-card-media img {
    width: 100%;
    height: 100%;
    /* contain, not cover: merchandise photography is usually shot on white with the
       product centred, and cropping it to fill would cut the garment. */
    object-fit: contain;
    display: block;
}

/* A product with no photograph, said plainly.
 *
 * NEVER name one of these "placeholder" on its own — that is Bootstrap's loading-skeleton
 * class, and it brings `cursor: wait` and a filled grey block with it. The product page
 * did exactly that (.gallery-main.placeholder), so hovering the empty image area of a
 * product with no photo gave the shopper a spinning wait cursor over a grey rectangle:
 * an image that appeared to be loading forever, for a product that simply has no image.
 */
.product-card-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    width: 100%;
    height: 100%;
    color: var(--simx-text-tertiary, #6c757d);
    font-size: 2rem;
}

.product-card-placeholder-label {
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* A <span> inside the anchor rather than a <div> — a div inside an <a> is invalid markup
   the browser will silently restructure, and a restructured DOM breaks Blazor's diffing. */
.product-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem;
    /* Pushes price to the bottom so a row of cards lines its prices up even when the
       names wrap to different heights. */
    flex: 1 1 auto;
}

.product-card-brand {
    display: block;
    margin: 0;
    color: var(--simx-text-tertiary, #6c757d);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.product-card-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.product-card-price {
    display: block;
    margin: auto 0 0;
    padding-top: 0.5rem;
    font-size: 1.0625rem;
    font-weight: 600;
}

.price-was {
    margin-left: 0.4rem;
    color: var(--simx-text-tertiary, #6c757d);
    font-size: 0.875rem;
    font-weight: 400;
    text-decoration: line-through;
}

.product-card-stock {
    display: block;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--simx-text-tertiary, #6c757d);
}

.product-card-stock.out {
    color: var(--simx-danger-text, #b02a37);
}

/* A heading that is also a link. Without this the button default put a box around
   every product name — visible in the unstyled shop as a border round the title. */
.btn-link-plain {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.btn-link-plain:hover {
    color: var(--simx-text-link-hover, #1b4db3);
    text-decoration: underline;
}

/* ── Empty and loading ──────────────────────────────────────────────────── */

.shop-empty-state,
.shop-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3rem 1rem;
    text-align: center;
}

.product-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ── Product detail ─────────────────────────────────────────────────────── */

.product-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

.product-breadcrumb {
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--simx-text-tertiary, #6c757d);
}

.gallery-main {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--simx-border-default, #dee2e6);
    border-radius: var(--simx-radius-md, 0.5rem);
    background: var(--simx-bg-sunken, #f8f9fa);
    overflow: hidden;
}

.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* See .product-card-placeholder: this class used to be Bootstrap's ".placeholder". */
.gallery-main-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--simx-text-tertiary, #6c757d);
    font-size: 2.5rem;
}

.gallery-main-empty span {
    font-size: 0.875rem;
}

.gallery-thumbs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.gallery-thumb {
    width: 64px;
    height: 64px;
    padding: 0;
    border: 1px solid var(--simx-border-default, #dee2e6);
    border-radius: var(--simx-radius-sm, 0.375rem);
    background: var(--simx-bg-sunken, #f8f9fa);
    overflow: hidden;
    cursor: pointer;
}

.gallery-thumb.active {
    border-color: var(--simx-accent, #2f6fed);
    /* Two-pixel ring rather than a thicker border, so the thumbnail does not shift. */
    box-shadow: 0 0 0 1px var(--simx-accent, #2f6fed);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.product-title {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
    line-height: 1.2;
}

.product-brand {
    margin: 0 0 0.75rem;
    color: var(--simx-text-tertiary, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.8125rem;
}

.product-price {
    margin: 0 0 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.product-short-description {
    margin-bottom: 1.25rem;
    color: var(--simx-text-secondary, #495057);
}

.product-buybox {
    padding: 1.25rem;
    border: 1px solid var(--simx-border-default, #dee2e6);
    border-radius: var(--simx-radius-md, 0.5rem);
    background: var(--simx-bg-sunken, #f8f9fa);
}

.product-option {
    margin-bottom: 1rem;
}

.product-quantity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* ── Quantity stepper ───────────────────────────────────────────────────────
 *
 * ProductDetail renders .qty-stepper with two bare <button>s and a number input, and
 * nothing styled any of it — so the shop shipped with the browser's default grey
 * bevelled buttons next to a Bootstrap-styled field. It looked like two different
 * decades on one line.
 *
 * One bordered group rather than three separate controls: the minus, the count and
 * the plus are one thing a shopper operates, and boxing them together is what makes
 * that read at a glance.
 */
.qty-stepper {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--simx-border-default, #dee2e6);
    border-radius: var(--simx-radius-sm, 0.375rem);
    background: var(--simx-bg-surface, #fff);
    overflow: hidden;
}

.qty-stepper button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--simx-text-primary, #212529);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color var(--simx-duration-fast, 120ms) ease;
}

.qty-stepper button:hover:not(:disabled) {
    background: var(--simx-bg-hover, #f1f3f5);
}

.qty-stepper button:focus-visible {
    outline: 2px solid var(--simx-accent, #2563eb);
    /* Inset so the ring stays inside the group's rounded corners. */
    outline-offset: -2px;
}

.qty-stepper button:disabled {
    color: var(--simx-text-tertiary, #6c757d);
    cursor: not-allowed;
    opacity: 0.55;
}

.qty-stepper input {
    width: 3.25rem;
    padding: 0.4rem 0.25rem;
    border: 0;
    border-left: 1px solid var(--simx-border-subtle, #f1f3f5);
    border-right: 1px solid var(--simx-border-subtle, #f1f3f5);
    background: transparent;
    color: inherit;
    text-align: center;
    font-size: 1rem;
    /* The native spinners duplicate the two buttons either side of them, and in Chrome
       they only appear on hover — which is a control that moves as you reach for it. */
    -moz-appearance: textfield;
    appearance: textfield;
}

.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-stepper input:focus {
    outline: 0;
    box-shadow: none;
}

/* The group takes the focus ring on behalf of the field inside it. */
.qty-stepper:focus-within {
    border-color: var(--simx-accent, #2563eb);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--simx-accent, #2563eb) 25%, transparent);
}

.product-availability {
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
}

.product-add {
    width: 100%;
}

.product-add-error {
    margin-top: 0.75rem;
    color: var(--simx-danger-text, #b02a37);
    font-size: 0.9375rem;
}

.product-fulfillment {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--simx-border-subtle, #f1f3f5);
    font-size: 0.875rem;
    color: var(--simx-text-secondary, #495057);
}

.product-description,
.product-specs {
    margin-top: 2.5rem;
}

.spec-group {
    margin-bottom: 1.5rem;
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
}

.spec-table th,
.spec-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--simx-border-subtle, #f1f3f5);
    text-align: left;
    vertical-align: top;
}

.spec-table th {
    width: 35%;
    font-weight: 500;
    color: var(--simx-text-tertiary, #6c757d);
}

/* ── Narrow screens ─────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .product-grid {
        /* Two across on a phone rather than one: merchandise is browsed by scanning,
           and a single column turns twelve products into a very long scroll. */
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.875rem;
    }

    .product-detail-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .product-title {
        font-size: 1.375rem;
    }
}

/* ── Basket savings ─────────────────────────────────────────────────────────
 *
 * What the basket costs once a membership and any passes have had their say.
 * Set apart from the plain totals rows on purpose: these lines are the reason
 * the number went DOWN, and a shopper should be able to find them at a glance
 * rather than reading a column of figures to work out what happened.
 */

.basket-savings {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--simx-success-border, #a3cfbb);
    border-radius: var(--simx-radius-md, 0.5rem);
    background: var(--simx-success-bg, #f0f9f4);
}

.basket-savings-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0;
    font-size: 0.9375rem;
}

.basket-savings-row--credit,
.basket-savings-row--member {
    color: var(--simx-success-text, #0f5132);
}

.basket-savings-total {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--simx-success-border, #a3cfbb);
    font-weight: 600;
    font-size: 1.0625rem;
}

.basket-savings-notices {
    margin: 0.625rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.8125rem;
    /* Secondary, not success green: these explain, they do not celebrate. Colouring them the same
       as the savings would make a plain statement of fact read as another discount. */
    color: var(--simx-text-secondary, #495057);
}

.basket-savings-notices li + li {
    margin-top: 0.2rem;
}

.basket-savings-shortfall {
    margin-top: 0.625rem;
    padding-top: 0.625rem;
    border-top: 1px solid var(--simx-success-border, #a3cfbb);
    font-size: 0.8125rem;
    color: var(--simx-text-secondary, #495057);
}
