/*
 * Products page — search, filters and product boxes of the espadanbattery-products widget
 * (docs/ROADMAP-PRODUCTS.md). Unlike the verbatim sheets beside it, this one is the theme's own design:
 * the page was redesigned on request, inside the site's identity.
 *
 * Palette and font come only from the theme-settings tokens (--esp-*), with the source values as
 * fallbacks; every other shade is mixed from them, so an admin's colours carry through.
 * Gold means amps everywhere (the plate on each picture, a chosen amp); green means a chosen group.
 * Every rule starts at .esp-site .esp-catalog… so it outranks Bootstrap's and base.css's element rules
 * and the platform's typography by specificity, not load order.
 */

.esp-site .esp-catalog {
    --cat-bg: var(--esp-bg, #1a1a1a);
    --cat-text: var(--esp-text, #fff);
    --cat-green: var(--esp-accent-start, #009441);
    --cat-gold: var(--esp-accent-end, #d6ab04);
    --cat-surface: color-mix(in srgb, var(--cat-text) 4%, var(--cat-bg));
    --cat-raised: color-mix(in srgb, var(--cat-text) 8%, var(--cat-bg));
    --cat-line: color-mix(in srgb, var(--cat-text) 13%, transparent);
    --cat-line-strong: color-mix(in srgb, var(--cat-text) 30%, transparent);
    --cat-muted: color-mix(in srgb, var(--cat-text) 64%, var(--cat-bg));
    --cat-radius: 14px;
    display: block;
    margin: 0 0 72px;
    color: var(--cat-text);
    font-family: var(--esp-font, iranYekanX);
    color-scheme: dark;
}

.esp-site .esp-catalog :is(button, input) {
    font: inherit;
    color: inherit;
}

.esp-site .esp-catalog :is(a, button, .esp-search__input):focus-visible {
    outline: 2px solid var(--cat-gold);
    outline-offset: 2px;
}

.esp-site .esp-catalog__none {
    margin: 0 0 72px;
    color: var(--esp-text, #fff);
}

/* ---- Toolbar: search, drawer opener, result count ------------------------------------------- */

.esp-site .esp-catalog .esp-catalog__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin-bottom: 16px;
}

.esp-site .esp-catalog .esp-search {
    position: relative;
    flex: 1 1 320px;
    max-width: 560px;
}

.esp-site .esp-catalog .esp-search__icon {
    position: absolute;
    inset-inline-start: 18px;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--cat-muted);
    stroke-width: 1.8;
    stroke-linecap: round;
    pointer-events: none;
}

.esp-site .esp-catalog .esp-search__input {
    display: block;
    width: 100%;
    height: 52px;
    margin: 0;
    padding-block: 0;
    padding-inline: 50px 18px;
    border: 1px solid var(--cat-line);
    border-radius: 999px;
    background: var(--cat-surface);
    font-size: 15px;
    line-height: 1.5;
    box-shadow: none;
    transition: border-color .15s ease, background-color .15s ease;
}

.esp-site .esp-catalog .esp-search__input::placeholder {
    color: var(--cat-muted);
    opacity: 1;
}

.esp-site .esp-catalog .esp-search__input:hover {
    border-color: var(--cat-line-strong);
}

.esp-site .esp-catalog .esp-search__input:focus {
    border-color: var(--cat-gold);
    background: var(--cat-raised);
    outline: none;
}

.esp-site .esp-catalog .esp-catalog__open {
    display: none;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 1px solid var(--cat-line-strong);
    border-radius: 999px;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.esp-site .esp-catalog .esp-catalog__open svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.esp-site .esp-catalog .esp-catalog__badge {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--cat-green);
    color: #fff;
    font-size: 12px;
    line-height: 1;
}

.esp-site .esp-catalog .esp-catalog__summary {
    margin: 0;
    margin-inline-start: auto;
    color: var(--cat-muted);
    font-size: 14px;
}

/* ---- Active filters ------------------------------------------------------------------------- */

.esp-site .esp-catalog .esp-catalog__active {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin-bottom: 24px;
}

.esp-site .esp-catalog .esp-catalog__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.esp-site .esp-catalog .esp-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px 0 14px;
    border: 1px solid var(--cat-line);
    border-radius: 999px;
    background: var(--cat-raised);
    color: var(--cat-text);
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
}

@media (pointer: coarse) {
    .esp-site .esp-catalog .esp-tag {
        min-height: 44px;
    }
}

.esp-site .esp-catalog .esp-tag:hover {
    border-color: var(--cat-line-strong);
    color: var(--cat-text);
}

.esp-site .esp-catalog .esp-tag__x {
    color: var(--cat-muted);
    font-size: 16px;
    line-height: 1;
}

.esp-site .esp-catalog .esp-catalog__clear {
    color: var(--esp-link-hover, #00ae4d);
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* ---- Layout --------------------------------------------------------------------------------- */

.esp-site .esp-catalog .esp-catalog__layout {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    align-items: start;
    gap: 32px;
}

/* ---- Filter panel --------------------------------------------------------------------------- */

.esp-site .esp-catalog .esp-catalog__filters {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 4px 20px 20px;
    border: 1px solid var(--cat-line);
    border-radius: var(--cat-radius);
    background: var(--cat-surface);
}

.esp-site .esp-catalog .esp-catalog__filters-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.esp-site .esp-catalog .esp-catalog__filters-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.esp-site .esp-catalog .esp-catalog__close {
    display: none;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-inline-end: -10px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.esp-site .esp-catalog .esp-catalog__close svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.esp-site .esp-catalog .esp-facet {
    min-width: 0;
    margin: 0;
    padding: 18px 0;
    border: 0;
    border-top: 1px solid var(--cat-line);
}

/* Floated, a legend joins the content instead of sitting on the fieldset's top border (which would
   draw the divider beside the title). */
.esp-site .esp-catalog .esp-facet__title {
    float: left;
    width: 100%;
    margin: 0 0 10px;
    padding: 0;
    color: var(--cat-text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
}

.esp-site .esp-catalog :is(.esp-facet__list, .esp-facet__chips) {
    clear: both;
}

/* Group: one row per category, with the number it would show. */
.esp-site .esp-catalog .esp-check {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    margin: 0 -10px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
}

.esp-site .esp-catalog .esp-check:hover {
    background: var(--cat-raised);
}

.esp-site .esp-catalog :is(.esp-check__input, .esp-amp__input) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.esp-site .esp-catalog .esp-check__box {
    position: relative;
    flex: none;
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--cat-line-strong);
    border-radius: 6px;
    transition: background-color .15s ease, border-color .15s ease;
}

.esp-site .esp-catalog .esp-check__input:checked + .esp-check__box {
    border-color: var(--cat-green);
    background: var(--cat-green);
}

.esp-site .esp-catalog .esp-check__input:checked + .esp-check__box::after {
    position: absolute;
    top: 2px;
    left: 6px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    content: "";
    transform: rotate(45deg);
}

.esp-site .esp-catalog .esp-check__input:focus-visible + .esp-check__box,
.esp-site .esp-catalog .esp-amp__input:focus-visible + .esp-amp__value {
    outline: 2px solid var(--cat-gold);
    outline-offset: 2px;
}

.esp-site .esp-catalog .esp-check__count {
    margin-inline-start: auto;
    color: var(--cat-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* Amps: a grid of values; a chosen one turns plate-gold. */
.esp-site .esp-catalog .esp-facet__chips {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.esp-site .esp-catalog .esp-amp {
    position: relative;
    display: block;
    margin: 0;
    cursor: pointer;
}

.esp-site .esp-catalog .esp-amp__value {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border: 1px solid var(--cat-line);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.esp-site .esp-catalog .esp-amp:hover .esp-amp__value {
    border-color: var(--cat-line-strong);
}

.esp-site .esp-catalog .esp-amp__input:checked + .esp-amp__value {
    border-color: var(--cat-gold);
    background: var(--cat-gold);
    color: var(--cat-bg);
}

/* An option that would show nothing stays in place, dimmed, so the list does not jump. */
.esp-site .esp-catalog :is(.esp-check, .esp-amp):has(input:disabled) {
    cursor: default;
    opacity: .38;
}

.esp-site .esp-catalog :is(.esp-check, .esp-amp):has(input:disabled):hover,
.esp-site .esp-catalog .esp-amp:has(input:disabled):hover .esp-amp__value {
    background: transparent;
    border-color: var(--cat-line);
}

.esp-site .esp-catalog .esp-catalog__filters-foot {
    padding-top: 4px;
}

.esp-site .esp-catalog :is(.esp-catalog__apply, .esp-catalog__show) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 48px;
    border: 0;
    border-radius: 999px;
    background: var(--cat-green);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* With products.js every click filters at once; the submit button is only for a page without it. */
.esp-site .esp-catalog[data-enhanced] .esp-catalog__apply,
.esp-site .esp-catalog .esp-catalog__show {
    display: none;
}

.esp-site .esp-catalog .esp-catalog__backdrop {
    display: none;
}

/* ---- Product boxes -------------------------------------------------------------------------- */

.esp-site .esp-catalog .esp-catalog__grid {
    display: grid;
    /* 270px keeps a model code such as «D26-60A» on the name's line (narrower boxes broke it at the hyphen):
       three columns from xl, two below. */
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.esp-site .esp-catalog .esp-catalog__item {
    display: block;
    min-width: 0;
}

.esp-site .esp-catalog .esp-product {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--cat-line);
    border-radius: var(--cat-radius);
    background: var(--cat-surface);
}

/* The source's hover: a gold gradient rim. */
.esp-site .esp-catalog .esp-product:hover {
    border-color: transparent;
    background:
        linear-gradient(var(--cat-surface), var(--cat-surface)) padding-box,
        linear-gradient(90deg, color-mix(in srgb, var(--cat-gold) 78%, #000), color-mix(in srgb, var(--cat-gold) 70%, #fff)) border-box;
}

.esp-site .esp-catalog .esp-product__media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    padding: 24px 20px 16px;
}

.esp-site .esp-catalog .esp-product__image {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: contain;
}

/* The amps, set like the number label on the battery case itself. */
.esp-site .esp-catalog .esp-product__plate {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 54px;
    margin: 0;
    padding: 7px 8px 6px;
    border-radius: 8px;
    background: var(--cat-gold);
    color: var(--cat-bg);
    line-height: 1;
}

.esp-site .esp-catalog .esp-product__plate-value {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.esp-site .esp-catalog .esp-product__plate-unit {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
}

.esp-site .esp-catalog .esp-product__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px 20px;
    border-top: 1px solid var(--cat-line);
}

.esp-site .esp-catalog .esp-product__name {
    margin: 0;
    color: var(--cat-text);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.6;
}

.esp-site .esp-catalog .esp-product__specs {
    display: grid;
    gap: 8px;
    margin: 0;
}

.esp-site .esp-catalog .esp-product__spec {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.esp-site .esp-catalog .esp-product__spec dt {
    color: var(--cat-muted);
    font-weight: 400;
}

.esp-site .esp-catalog .esp-product__spec dd {
    margin: 0;
    color: var(--cat-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: end;
}

/* ---- Nothing found -------------------------------------------------------------------------- */

.esp-site .esp-catalog .esp-catalog__empty {
    display: grid;
    justify-items: center;
    gap: 20px;
    padding: 56px 24px;
    border: 1px dashed var(--cat-line-strong);
    border-radius: var(--cat-radius);
    color: var(--cat-muted);
    font-size: 15px;
    line-height: 1.8;
    text-align: center;
}

.esp-site .esp-catalog .esp-catalog__empty-action {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 22px;
    border: 1px solid var(--cat-green);
    border-radius: 999px;
    color: var(--cat-text);
    font-size: 14px;
    font-weight: 600;
}

.esp-site .esp-catalog .esp-catalog__empty-action:hover {
    background: var(--cat-green);
    color: #fff;
}

/* ---- Below lg: the panel becomes a drawer (with products.js) or sits above the list (without) --- */

@media (max-width: 991.98px) {
    .esp-site .esp-catalog .esp-catalog__layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
    }

    .esp-site .esp-catalog .esp-catalog__filters {
        position: static;
        max-height: none;
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__open {
        display: inline-flex;
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__filters {
        position: fixed;
        z-index: 1050;
        top: 0;
        bottom: 0;
        inset-inline-start: 0;
        display: flex;
        flex-direction: column;
        width: min(360px, 88vw);
        max-height: none;
        padding: 0;
        overflow: hidden;
        border-width: 0;
        border-inline-end-width: 1px;
        border-radius: 0;
        background: var(--cat-bg);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform .25s ease, visibility 0s linear .25s;
    }

    .esp-site .esp-catalog[data-enhanced].is-filters-open .esp-catalog__filters {
        transform: none;
        visibility: visible;
        transition: transform .25s ease;
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__filters-head {
        padding: 8px 20px;
        border-bottom: 1px solid var(--cat-line);
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__close {
        display: inline-grid;
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__filters-body {
        flex: 1;
        overflow-y: auto;
        padding: 0 20px;
        overscroll-behavior: contain;
    }

    .esp-site .esp-catalog[data-enhanced] .esp-facet:first-child {
        border-top: 0;
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__filters-foot {
        padding: 16px 20px;
        border-top: 1px solid var(--cat-line);
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__show {
        display: flex;
    }

    .esp-site .esp-catalog[data-enhanced] .esp-catalog__backdrop {
        position: fixed;
        z-index: 1040;
        inset: 0;
        display: block;
        background: rgb(0 0 0 / .6);
    }

    .esp-site .esp-catalog .esp-facet__chips {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    }
}

/* ---- Phones: one product per row, picture beside the details -------------------------------- */

@media (max-width: 575.98px) {
    .esp-site .esp-catalog .esp-search {
        flex-basis: 100%;
        max-width: none;
    }

    .esp-site .esp-catalog .esp-catalog__grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .esp-site .esp-catalog .esp-product {
        flex-direction: row;
    }

    .esp-site .esp-catalog .esp-product__media {
        flex: 0 0 128px;
        height: auto;
        min-height: 148px;
        padding: 36px 10px 12px;
    }

    .esp-site .esp-catalog .esp-product__plate {
        top: 8px;
        inset-inline-end: auto;
        inset-inline-start: 8px;
        flex-direction: row;
        align-items: baseline;
        gap: 4px;
        min-width: 0;
        padding: 4px 8px;
    }

    .esp-site .esp-catalog .esp-product__plate-value {
        font-size: 16px;
    }

    .esp-site .esp-catalog .esp-product__plate-unit {
        margin-top: 0;
        font-size: 10px;
    }

    .esp-site .esp-catalog .esp-product__body {
        gap: 10px;
        padding: 14px 16px;
        border-top: 0;
        border-inline-start: 1px solid var(--cat-line);
    }

    .esp-site .esp-catalog .esp-product__name {
        font-size: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .esp-site .esp-catalog *,
    .esp-site .esp-catalog[data-enhanced] .esp-catalog__filters {
        transition: none;
    }
}
