/**
 * Kultiva — machinery catalogue. Boards: "Catalog" (desktop), "Tablet — Catalog",
 * "Mobile — Catalog" and "Mobile — Filters sheet". Filters are one form: a bottom
 * sheet on phones, a 400 px side panel on tablets, a column from 992 px.
 */

/* ============================================
   HEADING, KEY FIGURES, GROUP PILLS
   ============================================ */

.k-cat-head {
    background: var(--k-ground);
    border-bottom: 1px solid var(--k-line);
}

.k-cat-head__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px 40px;
    padding: 10px 0 4px;
}

.k-cat-head__title {
    margin: 0;
    color: var(--k-night);
}

.k-cat-figures {
    flex-wrap: wrap;
    gap: 12px 32px;
    margin: 0;
}

.k-cat-figures dt {
    font-family: var(--k-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--k-muted);
}

:lang(hy) .k-cat-figures dt {
    font-size: 14px;
    letter-spacing: 0;
    text-transform: none;
}

.k-cat-figures dd {
    margin: 2px 0 0;
    font-size: 28px;
    font-weight: 800;
    font-stretch: 88%;
    font-variant-numeric: tabular-nums;
    color: var(--k-night);
}

.k-cat-figures .k-cat-figures__money {
    color: var(--k-green);
}

.k-cat-figures-line {
    width: 100%;
    margin: 0;
    font-size: 15px;
    color: var(--k-body);
}

.k-cat-figures-line strong {
    color: var(--k-green);
}

.k-cat-groups {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin: 8px calc(-1 * var(--k-gutter)) 0;
    padding: 4px var(--k-gutter) 14px;
    scrollbar-width: none;
}

.k-pill {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--k-chip-line);
    border-radius: 999px;
    background: var(--k-white);
    color: var(--k-ink);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.k-pill:hover {
    background: var(--k-stage);
    color: var(--k-night);
}

.k-pill[aria-current="page"] {
    border-color: var(--k-ink);
    background: var(--k-ink);
    color: var(--k-white);
    font-weight: 700;
}

.k-pill__count {
    font-family: var(--k-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--k-muted);
}

.k-pill[aria-current="page"] .k-pill__count {
    color: var(--k-on-night-2);
}

@media (min-width: 768px) {
    .k-cat-head__row {
        padding: 28px 0 24px;
    }

    .k-cat-groups {
        margin-top: 0;
        padding-bottom: 20px;
    }

    .k-pill {
        padding: 0 16px;
    }
}


/* ============================================
   LAYOUT: filters column beside the results from 992 px
   ============================================ */

.k-cat {
    padding-block: 0 56px;
}

@media (min-width: 992px) {
    .k-cat {
        display: grid;
        grid-template-columns: 264px minmax(0, 1fr);
        align-items: start;
        gap: 32px;
        padding-block: 32px 96px;
    }
}


/* ============================================
   TOOLBAR (sticky under the header below 992 px), CHIPS, COUNT
   ============================================ */

.k-cat-toolbar {
    position: sticky;
    top: 64px;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-inline: calc(-1 * var(--k-gutter));
    padding: 10px var(--k-gutter);
    border-bottom: 1px solid var(--k-line);
    background: var(--k-white);
    box-shadow: var(--k-shadow-raised);
}

.k-cat-toolbar__filters {
    min-height: 46px;
}

.k-cat-sort {
    display: flex;
    align-items: center;
    gap: 10px;
}

.k-cat-sort__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.k-cat-sort .k-select {
    min-height: 46px;
    font-size: 16px;
}

.k-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.k-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 12px 0 14px;
    border: 1px solid var(--k-chip-line);
    border-radius: 999px;
    background: var(--k-success-bg);
    color: var(--k-success);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.k-chip:hover {
    border-color: var(--k-success);
    color: var(--k-success);
}

.k-chip .bi {
    font-size: 12px;
}

.k-cat-count {
    margin: 12px 0 0;
    font-size: 15px;
    color: var(--k-body);
}

.k-cat-count strong {
    color: var(--k-night);
}

.k-cat-count a {
    color: var(--k-green-dark);
    font-weight: 600;
}

@media (min-width: 768px) {
    .k-cat-toolbar {
        top: 72px;
    }
}

@media (min-width: 992px) {
    .k-cat-toolbar {
        position: static;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 12px 24px;
        margin: 0;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .k-cat-toolbar .k-cat-count {
        margin: 0;
        font-size: 16px;
    }

    .k-cat-sort__label {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip: auto;
        font-size: 14px;
        color: var(--k-muted);
    }

    .k-cat-sort .k-select {
        min-height: 44px;
        width: auto;
        font-size: 15px;
    }
}


/* ============================================
   RESULTS
   ============================================ */

.k-results {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

/* "Show more" jumps to the first new card (#k-item-13): stop below the sticky header and toolbar */
.k-results .k-card {
    scroll-margin-top: 144px;
}

@media (min-width: 768px) {
    .k-results .k-card {
        scroll-margin-top: 156px;
    }
}

@media (min-width: 992px) {
    .k-results .k-card {
        scroll-margin-top: 96px;
    }
}

/* Phones: compact cards, the monthly payment first (board "Mobile — Catalog") */
@media (max-width: 767.98px) {
    .k-results .k-card__media {
        padding: 8px;
    }

    .k-results .k-card__media img,
    .k-results .k-card__nophoto {
        height: 112px;
        aspect-ratio: auto;
    }

    .k-results .k-card__body {
        gap: 2px;
        padding: 10px 12px 12px;
    }

    .k-results .k-card__name {
        font-size: 17px;
    }

    .k-results .k-card__price {
        display: flex;
        flex-direction: column-reverse;
        padding-top: 4px;
        border-top: 0;
    }

    .k-results .k-card__monthly {
        font-size: 15px;
        font-weight: 800;
    }

    .k-results .k-card__amount {
        font-size: 14px;
        font-weight: 400;
        color: var(--k-muted);
    }

    .k-results .k-card__amount--ask {
        font-weight: 700;
        color: var(--k-night);
    }
}

@media (min-width: 768px) {
    .k-results {
        grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
        gap: 16px;
        margin-top: 20px;
    }
}

/* Advice card: dark among the results from 768 px, light after them on phones */
.k-advice {
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
    padding: 26px;
    border-radius: 18px;
    background: var(--k-night);
    color: var(--k-white);
}

.k-advice__text {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.k-advice__eyebrow {
    font-family: var(--k-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--k-harvest);
}

:lang(hy) .k-advice__eyebrow {
    font-size: 14px;
    letter-spacing: 0;
    text-transform: none;
}

.k-advice h3 {
    margin: 0;
    color: var(--k-white);
}

.k-advice p {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--k-on-night-2);
}

.k-advice__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.k-advice .k-advice__call {
    min-height: 50px;
    border-color: var(--k-harvest);
    background: var(--k-harvest);
    color: var(--k-night);
    font-weight: 800;
}

.k-advice .k-advice__chat {
    min-height: 50px;
    border: 1px solid #4A5872;
    color: var(--k-white);
}

.k-advice--light {
    display: flex;
    margin-top: 16px;
    padding: 18px;
    background: var(--k-ground);
    color: var(--k-ink);
}

.k-advice--light h3 {
    color: var(--k-night);
}

.k-advice--light p {
    color: var(--k-body);
}

.k-advice--light .k-advice__call {
    border-color: var(--k-green);
    background: var(--k-green);
    color: var(--k-white);
}

.k-advice--light .k-advice__chat {
    border: 1.5px solid var(--k-ink);
    background: var(--k-white);
    color: var(--k-ink);
}

.k-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-top: 24px;
}

.k-more p {
    margin: 0;
    font-size: 14px;
    color: var(--k-muted);
}

.k-empty {
    margin-top: 20px;
    padding: 32px 24px;
    border: 1px dashed var(--k-chip-line);
    border-radius: 18px;
    text-align: center;
}

.k-empty h3 {
    margin: 0 0 8px;
}

.k-empty p {
    margin: 0 0 18px;
    color: var(--k-body);
}

.k-empty__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.k-fine {
    margin: 28px 0 0;
    font-size: 14px;
    color: var(--k-muted);
}


/* ============================================
   FILTERS
   ============================================ */

.k-filters__head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 12px 10px 16px;
    border-bottom: 1px solid var(--k-line);
}

.k-filters__handle {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: var(--k-chip-line);
}

.k-filters__heading h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.1;
}

.k-filters__match {
    margin: 2px 0 0;
    font-size: 14px;
    color: var(--k-muted);
}

.k-filters__body {
    display: flex;
    flex-direction: column;
}

.k-filters__top {
    display: none;
}

.k-facet {
    min-width: 0;
    margin: 0;
    padding: 14px 0;
    border: 0;
    border-bottom: 1px solid var(--k-line);
}

.k-facet__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    width: 100%;
    margin: 0 0 10px;
    padding: 0;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.3;
    color: var(--k-night);
}

.k-facet__hint,
.k-facet__terms {
    font-size: 14px;
    font-weight: 400;
    color: var(--k-muted);
}

.k-facet__terms {
    font-family: var(--k-mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

:lang(hy) .k-facet__terms {
    letter-spacing: 0;
    text-transform: none;
}

.k-facet__options {
    display: flex;
    flex-direction: column;
}

.k-facet__options--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.k-facet__note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--k-body);
}

/* An option is a label around a real input, so it works without JavaScript */
.k-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin: 0;
    font-size: 15.5px;
    cursor: pointer;
}

.k-option input {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--k-green);
}

.k-option__label {
    flex: 1;
    min-width: 0;
}

.k-option__count {
    font-family: var(--k-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--k-muted);
}

.k-option:has(input:disabled) {
    color: #6B7380;
    cursor: not-allowed;
}

/* Below 992 px the checkbox groups are chips (pressed = filled), as on the sheet board */
@media (max-width: 991.98px) {
    .k-facet__options--grid .k-option {
        justify-content: space-between;
        padding: 0 12px 0 14px;
        border: 1px solid var(--k-chip-line);
        border-radius: var(--k-radius-control);
        background: var(--k-white);
        color: var(--k-ink);
        font-size: 15px;
        font-weight: 700;
    }

    .k-facet__options--grid .k-option input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .k-facet__options--grid .k-option:has(input:checked) {
        border-color: var(--k-ink);
        background: var(--k-ink);
        color: var(--k-white);
    }

    .k-facet__options--grid .k-option:has(input:checked) .k-option__count {
        color: var(--k-on-night-2);
    }

    .k-facet__options--grid .k-option:has(input:disabled) {
        border-style: dashed;
        background: var(--k-ground);
        color: #6B7380;
        font-weight: 600;
    }

    .k-facet__options--grid .k-option:has(input:focus-visible) {
        outline: 3px solid var(--k-harvest);
        outline-offset: 2px;
        box-shadow: 0 0 0 2px var(--k-night);
    }
}

/* "Also show models priced on request" switch */
.k-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    margin: 6px 0 0;
    padding: 6px 8px 6px 12px;
    border-radius: 12px;
    background: var(--k-ground);
    font-size: 14px;
    line-height: 1.35;
    color: var(--k-ink);
    cursor: pointer;
}

.k-switch[hidden] {
    display: none;
}

.k-switch__label {
    flex: 1;
}

.k-switch__input {
    position: relative;
    flex: 0 0 48px;
    width: 48px;
    height: 28px;
    margin: 0;
    border: 2px solid #6B7380;
    border-radius: 999px;
    background: var(--k-white);
    appearance: none;
    cursor: pointer;
}

.k-switch__input::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6B7380;
    transition: transform var(--k-fast) ease-out;
}

.k-switch__input:checked {
    border-color: var(--k-green);
    background: var(--k-green);
}

.k-switch__input:checked::before {
    transform: translateX(20px);
    background: var(--k-white);
}

.k-filters__lease {
    display: none;
}

/* Sheet footer: Reset and "Show 7 tractors", stuck to the bottom */
.k-filters__foot {
    position: sticky;
    bottom: calc(-1 * var(--bs-offcanvas-padding-y, 16px));
    display: grid;
    /* Reset takes what it needs; "Show N tractors" gets the rest so the longer Armenian fits on one line */
    grid-template-columns: minmax(96px, auto) 1fr;
    gap: 8px;
    /* margin-top: auto keeps it at the bottom of the sheet when the filters are short */
    margin: auto calc(-1 * var(--bs-offcanvas-padding-x, 16px)) calc(-1 * var(--bs-offcanvas-padding-y, 16px));
    padding: 12px var(--bs-offcanvas-padding-x, 16px) max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--k-line);
    background: var(--k-white);
}

/* Phones: a sheet from 48 px below the top of the screen */
@media (max-width: 991.98px) {
    .k-filters.offcanvas-lg {
        --bs-offcanvas-height: calc(100% - 48px);
        --bs-offcanvas-zindex: 1050;
        border-radius: 20px 20px 0 0;
        box-shadow: var(--k-shadow-sheet);
    }

    .k-filters .k-facet:last-of-type {
        border-bottom: 0;
    }
}

/* Tablets: the sheet becomes a 400 px side panel, so the results stay in view */
@media (min-width: 768px) and (max-width: 991.98px) {
    .k-filters.offcanvas-lg {
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: 400px;
        height: 100%;
        max-height: none;
        border-top: 0;
        border-left: 1px solid var(--k-line);
        border-radius: 0;
        transform: translateX(100%);
    }

    .k-filters.offcanvas-lg.showing,
    .k-filters.offcanvas-lg.show:not(.hiding) {
        transform: none;
    }

    .k-filters__handle {
        display: none;
    }
}

/* Without JavaScript the sheet can't open, so the filters sit in the page above the results */
@media (max-width: 991.98px) {
    html:not(.js) .k-filters.offcanvas-lg {
        position: static;
        visibility: visible;
        width: auto;
        height: auto;
        margin-top: 16px;
        border: 1px solid var(--k-line);
        border-radius: 18px;
        box-shadow: none;
        transform: none;
    }

    html:not(.js) .k-filters__head .k-icon-btn,
    html:not(.js) .k-cat-toolbar__filters,
    html:not(.js) .k-filters__handle {
        display: none;
    }

    html:not(.js) .k-filters__foot {
        position: static;
    }
}

/* Desktop: a column with mono legends and plain rows */
@media (min-width: 992px) {
    .k-filters__body {
        flex-direction: column;
    }

    .k-filters__top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--k-line);
    }

    .k-filters__title {
        margin: 0;
        font-size: 20px;
        font-stretch: 90%;
    }

    .k-filters__top a {
        font-size: 14px;
        color: var(--k-body);
    }

    .k-facet {
        padding: 18px 0;
    }

    .k-facet__legend {
        margin-bottom: 8px;
        font-family: var(--k-mono);
        font-size: 12px;
        font-weight: 500;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--k-muted);
    }

    :lang(hy) .k-facet__legend {
        font-size: 14px;
        letter-spacing: 0;
        text-transform: none;
    }

    .k-facet__hint {
        display: none;
    }

    .k-facet__terms {
        font-size: 12px;
    }

    .k-facet__options--grid {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .k-option {
        min-height: 40px;
        font-size: 15px;
    }

    .k-option__count {
        font-size: 12.5px;
    }

    .k-filters__lease {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 18px;
        padding: 18px;
        border-radius: 14px;
        background: var(--k-warning-bg);
        font-size: 14px;
        line-height: 1.5;
        color: var(--k-body);
    }

    .k-filters__lease strong {
        font-size: 15px;
        color: var(--k-night);
    }

    .k-filters__lease a {
        font-weight: 700;
        color: var(--k-night);
    }

    /* The column applies each change at once; without JavaScript it keeps its buttons */
    .js .k-filters__foot {
        display: none;
    }

    .k-filters__foot {
        position: static;
        margin: 16px 0 0;
        padding: 0;
        border: 0;
    }
}
