/*
Theme Name: Repcar
Theme URI: https://repcarchile.cl
Description: Repcar Chile storefront. A child of Twenty Twenty-Five carrying the brand's own palette and type. Built for a 10,000-part catalogue: dense listings that stay readable, prices and codes that line up, and nothing competing with the part the shopper is looking for.
Author: RepcarChile
Template: twentytwentyfive
Version: 0.1.0
Requires PHP: 8.3
License: Proprietary
Text Domain: repcar
*/

/*
 * Almost everything lives in theme.json. What is here are the few things a
 * parts catalogue needs that a general-purpose theme has no reason to know
 * about.
 */

/* The header row is logo, search and two icons. Flex items refuse to shrink
   below their content (min-width: auto), so on a phone the search field --
   declared at 100% -- shoves the account and cart icons past the right edge
   and hands every page a horizontal scrollbar. Letting the row and the field
   shrink keeps the icons on screen at any width. */
header .wp-block-group.is-nowrap {
    min-width: 0;
    flex: 1 1 auto;
}

header .wp-block-group.is-nowrap .wp-block-search {
    min-width: 0;
    flex: 1 1 auto;
}

/* Only the search field gives ground; the account and cart icons hold their
   size, or the same squeeze crushes them into specks. */
header .wp-block-group.is-nowrap > :not(.wp-block-search) {
    flex: 0 0 auto;
}

/* The account SVG ships with no intrinsic size, so it inherits 1em and
   renders as a 14px speck beside a 35px cart. Sized to match its neighbour. */
header .wc-block-customer-account__link svg {
    width: 24px;
    height: 24px;
}

/* Product codes, prices and quantities are read by comparison, so their
   digits have to line up in a column. */
.woocommerce-Price-amount,
.repcar-sku,
.woocommerce ul.products li.product .price,
.woocommerce table.shop_table td {
    font-variant-numeric: tabular-nums;
}

/* The code is how a mechanic identifies a part -- often the only thing they
   were given. It belongs where the eye lands, not buried in a spec table. */
.repcar-sku {
    display: inline-block;
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
    color: var(--wp--preset--color--muted);
    background: var(--wp--preset--color--surface);
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 3px;
    padding: 0.125rem 0.375rem;
}

/* "Confirmando stock" is not a delivery promise, and it should not be dressed
   as one. Distinct from in-stock, but not an error either. */
.woocommerce .stock.available-on-backorder {
    color: var(--wp--preset--color--pending);
    font-weight: 600;
}

.woocommerce .stock.in-stock {
    color: var(--wp--preset--color--available);
    font-weight: 600;
}

/* The catalogue summary that opens the front page. Sits under the heading, so
   it carries the muted tone the heading does not. */
.repcar-catalogue-summary {
    margin-top: var(--wp--preset--spacing--20);
    margin-bottom: var(--wp--preset--spacing--40);
    text-align: center;
    color: var(--wp--preset--color--muted);
    font-size: var(--wp--preset--font-size--large);
    font-variant-numeric: tabular-nums;
}

/* The seventeen systems, as a set. Auto-fill rather than a fixed column count:
   the drawings are the same size at every breakpoint, so the row simply holds
   as many as fit instead of shrinking them until they stop reading. */
.repcar-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: var(--wp--preset--spacing--30);
}

/* On a phone the container drops near 300px and auto-fill collapses to a
   single file -- seventeen cards in one column is a corridor, not a
   catalogue. Two abreast keeps the whole set inside a couple of screens. */
@media (max-width: 600px) {
    .repcar-category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.repcar-category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--wp--preset--spacing--20);
    padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--30);
    background: var(--wp--preset--color--base);
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    color: var(--wp--preset--color--contrast);
    transition: border-color 120ms ease, transform 120ms ease;
}

.repcar-category-card:hover,
.repcar-category-card:focus-visible {
    border-color: var(--wp--preset--color--primary);
    transform: translateY(-2px);
}

.repcar-category-card__art {
    width: 5.5rem;
    height: 5.5rem;
}

.repcar-category-card__name {
    font-family: var(--wp--preset--font-family--heading);
    font-weight: 600;
    font-size: var(--wp--preset--font-size--large);
    line-height: 1.15;
}

/* The count is what separates a system worth opening from one with a handful
   of parts, but it is not the label -- it stays quiet next to the name. */
.repcar-category-card__count {
    font-size: var(--wp--preset--font-size--small);
    color: var(--wp--preset--color--muted);
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    .repcar-category-card {
        transition: none;
    }

    .repcar-category-card:hover,
    .repcar-category-card:focus-visible {
        transform: none;
    }
}

/* ---------------------------------------------------------------------------
   Shop listing cards

   WooCommerce builds this listing from blocks, not from the classic loop. The
   list is `ul.wc-block-product-template` and never carries the `products`
   class the classic markup uses, so a `.woocommerce ul.products li.product`
   rule silently matches nothing. The PHP hooks still fire -- the code chip and
   the availability notice arrive through them -- which makes it easy to assume
   the classic selectors apply too. They do not.

   The drawing stands for a category, not for the part: seventeen of them cover
   ten thousand references, so three neighbours in a row are the same picture.
   Rendered square it was the tallest element on the card and the only one
   carrying no information. It is a marker here. The name, the code and the
   price -- the three things that actually differ between two results -- take
   the weight.
   --------------------------------------------------------------------------- */

.wc-block-product-template {
    gap: var(--wp--preset--spacing--30);
}

li.wc-block-product {
    display: flex;
    flex-direction: column;
    gap: var(--wp--preset--spacing--20);
    padding: var(--wp--preset--spacing--30);
    background: var(--wp--preset--color--base);
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 6px;
    transition: border-color 120ms ease;
}

li.wc-block-product:hover {
    border-color: var(--wp--preset--color--primary);
}

/* The block wraps the image in a forced 1:1 box. Released, so the drawing
   takes the height it needs and the card closes up around it. */
li.wc-block-product .wc-block-components-product-image {
    margin: 0;
    aspect-ratio: auto;
}

li.wc-block-product .wc-block-components-product-image img {
    height: 6.5rem;
    width: auto;
    max-width: 100%;
    margin: 0 auto;
    object-fit: contain;
}

/* Left-aligned from here down. Centred lines give a dense catalogue a ragged
   left edge, and the eye scanning a column of part names has nothing to
   follow. */
li.wc-block-product .wp-block-post-title {
    margin: 0;
    font-family: var(--wp--preset--font-family--heading);
    font-size: var(--wp--preset--font-size--large);
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
}

li.wc-block-product .wp-block-post-title a {
    color: var(--wp--preset--color--contrast);
    text-decoration: none;
}

li.wc-block-product .wp-block-post-title a:hover {
    color: var(--wp--preset--color--primary);
}

/* The price rendered at the block's small preset, level with the code beside
   it. It is the second thing compared after the name, so it is sized like it.
   `margin-top:auto` pins it to the bottom of the card, which keeps prices on
   one line across a row of uneven titles. */
li.wc-block-product .wp-block-woocommerce-product-price {
    margin: auto 0 0;
    font-family: var(--wp--preset--font-family--heading);
    font-size: var(--wp--preset--font-size--x-large);
    font-weight: 600;
    line-height: 1.2;
    color: var(--wp--preset--color--contrast);
    text-align: left;
}

li.wc-block-product .repcar-sku {
    align-self: flex-start;
}

/* Only the exception is marked: every reference currently sits on backorder,
   so a badge on all of them would be a label, not a signal. */
.repcar-availability {
    align-self: flex-start;
    font-size: var(--wp--preset--font-size--small);
    font-weight: 600;
}

.repcar-availability--ready {
    color: var(--wp--preset--color--available);
}

/* How the shop works, stated once above the results rather than on every card.
   Said once it reads as a policy, which is what it is; repeated on every card
   it reads as a warning. */
.repcar-availability-notice {
    margin: 0 0 var(--wp--preset--spacing--40);
    padding: var(--wp--preset--spacing--30);
    background: var(--wp--preset--color--surface);
    border-left: 3px solid var(--wp--preset--color--pending);
    border-radius: 4px;
    color: var(--wp--preset--color--muted);
    font-size: var(--wp--preset--font-size--small);
}

li.wc-block-product .wp-block-button {
    margin-top: var(--wp--preset--spacing--20);
    width: 100%;
}

li.wc-block-product .wp-block-button__link {
    width: 100%;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    li.wc-block-product {
        transition: none;
    }
}

/* ---------------------------------------------------------------------------
   Single product

   The same three things the listing card leads with, in the same order and the
   same weights. A shopper who clicks a card should land on the page it
   promised, not on a differently-typeset version of it.
   --------------------------------------------------------------------------- */

/* The code is rendered here as bare text inside a "SKU:" label, where the
   listing shows it as a chip. Same value, same treatment. */
.woocommerce div.product .sku,
.wp-block-woocommerce-product-sku .sku {
    display: inline-block;
    font-size: var(--wp--preset--font-size--small);
    letter-spacing: 0.02em;
    color: var(--wp--preset--color--muted);
    background: var(--wp--preset--color--surface);
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 3px;
    padding: 0.125rem 0.375rem;
    font-variant-numeric: tabular-nums;
}

.woocommerce div.product .wp-block-woocommerce-product-price {
    font-family: var(--wp--preset--font-family--heading);
    font-weight: 600;
    line-height: 1.2;
    color: var(--wp--preset--color--contrast);
}

/* ---------------------------------------------------------------------------
   Filter column
   --------------------------------------------------------------------------- */

.repcar-filter + .repcar-filter {
    margin-top: var(--wp--preset--spacing--50);
}

.repcar-filter h3 {
    margin: 0 0 var(--wp--preset--spacing--20);
}

.repcar-category-nav {
    margin: 0;
    padding: 0;
    list-style: none;
}

.repcar-category-nav__link {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--wp--preset--spacing--20);
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    color: var(--wp--preset--color--contrast);
    text-decoration: none;
    font-size: var(--wp--preset--font-size--small);
}

.repcar-category-nav__link:hover {
    background: var(--wp--preset--color--surface);
    color: var(--wp--preset--color--primary);
}

/* The system being shown, marked rather than removed -- the shopper needs to
   see where they are and still reach the other sixteen. */
.repcar-category-nav__link.is-current {
    background: var(--wp--preset--color--surface);
    color: var(--wp--preset--color--primary);
    font-weight: 600;
    box-shadow: inset 2px 0 0 var(--wp--preset--color--primary);
}

.repcar-category-nav__count {
    color: var(--wp--preset--color--muted);
    font-variant-numeric: tabular-nums;
    font-weight: 400;
}

/* Fifty-four models do not fit a link nav's footprint, so this group is a
   select plus a button rather than a list -- laid out as a narrow column so
   it reads as one more filter in the sidebar rather than a separate widget. */
.repcar-model-nav {
    display: flex;
    flex-direction: column;
    gap: var(--wp--preset--spacing--20);
}

.repcar-model-nav__select {
    width: 100%;
    max-width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 4px;
    background: var(--wp--preset--color--base);
    color: var(--wp--preset--color--contrast);
    font-size: var(--wp--preset--font-size--small);
}

.repcar-model-nav__submit {
    width: 100%;
    border: none;
    cursor: pointer;
}

/* A filter group whose shortcode rendered nothing -- the plugin that provides
   the makes and models is deactivated -- would otherwise leave its heading
   floating over an empty box. The heading lives in the template, not in the
   shortcode, so it is hidden here: a group with no element but its heading
   has nothing to show. Precio keeps its slider block and is unaffected. */
.repcar-filter:not(:has(:not(h3))) {
    display: none;
}

/* ---------------------------------------------------------------------------
   Make / Sistema filter bar

   The hero's dominant element: choosing a make and a system beats typing a
   part name like "ABRAZADERA FIJ TUBO ESC P.28/31/PTR/BLG (B9)", which is not
   a search term anyone types. A plain GET form, so the result is a normal
   URL rather than something JavaScript has to reconstruct.
   --------------------------------------------------------------------------- */

.repcar-make-filter {
    max-width: 640px;
    margin: var(--wp--preset--spacing--40) auto 0;
}

.repcar-make-filter__row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--wp--preset--spacing--30);
}

.repcar-make-filter__field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1 1 200px;
    text-align: left;
}

.repcar-make-filter__label {
    font-size: var(--wp--preset--font-size--small);
    font-weight: 600;
    color: var(--wp--preset--color--contrast);
}

.repcar-make-filter__select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 4px;
    background: var(--wp--preset--color--base);
    color: var(--wp--preset--color--contrast);
    font-size: var(--wp--preset--font-size--medium);
}

.repcar-make-filter__submit {
    flex: 0 0 auto;
    border: none;
    cursor: pointer;
}

/* Stacked and full-width below the point the row would otherwise squeeze
   both selects into a column too narrow to read their options. */
@media (max-width: 600px) {
    .repcar-make-filter__row {
        flex-direction: column;
        align-items: stretch;
    }

    .repcar-make-filter__submit {
        width: 100%;
    }
}
