/**
 * Copyright (c) Company System Ltd. All rights reserved.
 *
 * Styles of the Alvoble Instant Search dropdown. Colours come from the Alvoble Storefront design tokens (the CSS
 * variables the Storefront settings write), with the theme's default palette as the fallback, so a colour change in
 * Alvoble > Storefront settings reaches the dropdown. Logical properties (inline-start, inline-end) keep right-to-left
 * layouts correct. Nothing here animates: the panel simply appears.
 */

.alvo-is {
    --alvo-is-ink: var(--color-ink, #0b1b2b);
    --alvo-is-paper: #ffffff;
    --alvo-is-soft: var(--color-paper, #f7f8fa);
    --alvo-is-line: #cbd5e1;
    --alvo-is-muted: #475569;
    --alvo-is-accent: var(--color-primary, var(--color-accent, #4458d6));
    --alvo-is-accent-soft: color-mix(in srgb, var(--alvo-is-accent) 10%, #ffffff);
    --alvo-is-sale: #b42318;
    --alvo-is-new: #0f766e;
    position: relative;
}

.alvo-is [x-cloak] {
    display: none !important;
}

.alvo-is__form {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

.alvo-is__chooser {
    flex: 0 0 auto;
    max-inline-size: 12rem;
    border-start-end-radius: 0;
    border-end-end-radius: 0;
}

/* The panel overlays the page: opening it never moves anything (no layout shift). */
.alvo-is__panel {
    position: absolute;
    inset-inline: 0;
    inset-block-start: 100%;
    z-index: 50;
    margin-block-start: 0.25rem;
    background: var(--alvo-is-paper);
    color: var(--alvo-is-ink);
    border: 1px solid var(--alvo-is-line);
    border-radius: 0.5rem;
    box-shadow: 0 12px 32px rgba(11, 27, 43, 0.18);
    max-block-size: min(34rem, 75vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    text-align: start;
}

.alvo-is__bar {
    display: none;
}

.alvo-is__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 2.75rem;
    min-block-size: 2.75rem;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
}

.alvo-is__nothing {
    margin: 0;
    padding: 0.875rem 1rem;
    color: var(--alvo-is-muted);
    overflow-wrap: anywhere;
}

.alvo-is__status {
    margin: 0;
    padding: 0.875rem 1rem;
    color: var(--alvo-is-muted);
    overflow-wrap: anywhere;
}

/* One entry of the list: the link row, and next to it the "Add to cart" button for products that can be bought at once. */
.alvo-is__item {
    display: block;
}

.alvo-is__item--cart {
    display: flex;
    align-items: center;
}

.alvo-is__item--cart > .alvo-is__opt {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.alvo-is__add {
    flex: 0 0 auto;
    margin-inline-end: 0.75rem;
    min-block-size: 2.5rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--alvo-is-accent);
    border-radius: 0.375rem;
    background: var(--alvo-is-accent);
    color: #ffffff;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}

.alvo-is__add:hover {
    filter: brightness(0.92);
}

.alvo-is__add:focus-visible {
    outline: 2px solid var(--alvo-is-ink);
    outline-offset: 2px;
}

.alvo-is__add:disabled {
    cursor: progress;
    opacity: 0.75;
}

.alvo-is__add--done {
    border-color: var(--alvo-is-new);
    background: var(--alvo-is-new);
}

.alvo-is__add--failed {
    border-color: var(--alvo-is-sale);
    background: var(--alvo-is-sale);
}

.alvo-is__group + .alvo-is__group {
    border-block-start: 1px solid var(--alvo-is-line);
}

.alvo-is__heading {
    padding: 0.625rem 1rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--alvo-is-muted);
}

.alvo-is__opt {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-block-size: 3.5rem;
    padding: 0.5rem 1rem;
    border-inline-start: 3px solid transparent;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

/* The highlighted row is shown by a bar and an underlined name as well as a background, never by colour alone. */
.alvo-is__opt.is-active {
    background: var(--alvo-is-accent-soft);
    border-inline-start-color: var(--alvo-is-accent);
}

.alvo-is__opt.is-active .alvo-is__name {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.alvo-is__opt:focus-visible {
    outline: 2px solid var(--alvo-is-accent);
    outline-offset: -2px;
}

.alvo-is__thumbwrap {
    position: relative;
    flex: 0 0 auto;
    inline-size: 3rem;
    block-size: 3rem;
}

.alvo-is__thumb {
    inline-size: 3rem;
    block-size: 3rem;
    object-fit: contain;
    border-radius: 0.25rem;
    background: var(--alvo-is-soft);
}

.alvo-is__text {
    flex: 1 1 auto;
    min-inline-size: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.alvo-is__name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-size: 0.9375rem;
    line-height: 1.3;
}

.alvo-is__hit {
    font-weight: 700;
}

.alvo-is__sub,
.alvo-is__desc {
    font-size: 0.8125rem;
    color: var(--alvo-is-muted);
    overflow-wrap: anywhere;
}

.alvo-is__desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.alvo-is__meta {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.125rem;
    font-size: 0.875rem;
    text-align: end;
}

.alvo-is__price {
    font-weight: 600;
    white-space: nowrap;
}

.alvo-is__regular {
    color: var(--alvo-is-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.alvo-is__out {
    font-size: 0.75rem;
    color: var(--alvo-is-muted);
    font-style: italic;
}

.alvo-is__badges {
    display: flex;
    gap: 0.25rem;
}

.alvo-is__label {
    display: inline-block;
    padding: 0.0625rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.3;
    color: #ffffff;
    text-transform: uppercase;
}

.alvo-is__thumbwrap .alvo-is__label {
    position: absolute;
    inset-inline-start: 0;
    inset-block-start: 0;
}

.alvo-is__thumbwrap .alvo-is__label--sale {
    inset-block-start: auto;
    inset-block-end: 0;
}

.alvo-is__label--new {
    background: var(--alvo-is-new);
}

.alvo-is__label--sale {
    background: var(--alvo-is-sale);
}

/* The "see all" row, the did-you-mean row and the "Go to" row of a search redirect read as links. */
.alvo-is__opt--all,
.alvo-is__opt--suggest,
.alvo-is__opt--redirect {
    font-weight: 600;
    min-block-size: 3rem;
}

/* ----------------------------------------------------------------------------------------- small screens */

.alvo-is-lock {
    overflow: hidden;
}

@media (max-width: 767.98px) {
    .alvo-is__form {
        gap: 0.5rem 0;
    }

    .alvo-is__chooser {
        flex: 1 1 100%;
        max-inline-size: none;
        border-radius: 0.375rem;
    }

    /* The panel becomes a layer under the input that uses the visible height (the script sets the two variables
       from the visual viewport, so the on-screen keyboard does not hide the results). */
    .alvo-is__panel {
        position: fixed;
        inset-inline: 0;
        inset-block-start: var(--alvo-is-top, 4rem);
        max-block-size: var(--alvo-is-maxh, 60vh);
        margin: 0;
        border-radius: 0;
        border-inline: 0;
    }

    .alvo-is__bar {
        display: flex;
        justify-content: flex-end;
        border-block-end: 1px solid var(--alvo-is-line);
    }

    .alvo-is__opt {
        min-block-size: 3.5rem;
        padding-block: 0.5rem;
    }

    .alvo-is__thumbwrap,
    .alvo-is__thumb {
        inline-size: 4rem;
        block-size: 4rem;
    }

    .alvo-is__add {
        min-block-size: 2.75rem;
    }
}

/* ----------------------------------------------------------------------------------------- overlay presentation

   Opt-in (class alvo-is--overlay, from the Presentation setting or the theme): the panel is a layer under the header with a scrim
   behind it. On small screens it is the same full-screen layer as the dropdown there. From 768 px the layer is positioned against
   the header (the nearest positioned ancestor, so it spans the whole page width), the suggestions (phrases, categories and the
   "see all" link) sit in a narrow column on the start side and the products form a grid of pictures beside it. The script sets
   --alvo-is-top and --alvo-is-maxh from the position of the search box. Without the class nothing here applies. */

.alvo-is__scrim {
    display: none;
}

.alvo-is--overlay .alvo-is__scrim {
    display: block;
    position: fixed;
    inset-inline: 0;
    inset-block: var(--alvo-is-top, 4rem) 0;
    z-index: 49;
    background: var(--alvo-is-scrim, rgb(11 27 43 / 0.4));
}

.alvo-is--overlay .alvo-is__bar {
    display: flex;
    justify-content: flex-end;
    max-inline-size: 69rem;
    margin-inline: auto;
}

/* A picture that does not load leaves its tile empty instead of showing a broken-image icon. */
.alvo-is__thumb--missing {
    visibility: hidden;
}

@media (min-width: 768px) {
    .alvo-is.alvo-is--overlay {
        position: static;
    }

    .alvo-is--overlay .alvo-is__panel {
        position: absolute;
        inset-inline: 0;
        inset-block-start: 100%;
        max-block-size: var(--alvo-is-maxh, 70vh);
        margin: 0;
        border-radius: 0;
        border-inline: 0;
    }

    .alvo-is--overlay .alvo-is__scrim {
        position: absolute;
        inset-block: 100% auto;
        block-size: 100vh;
    }

    .alvo-is--overlay .alvo-is__list {
        display: grid;
        grid-template-columns: minmax(12rem, 1fr) minmax(0, 3fr);
        column-gap: 2rem;
        align-items: start;
        max-inline-size: 69rem;
        margin-inline: auto;
        padding: 0.5rem 1rem 1.5rem;
    }

    .alvo-is--overlay .alvo-is__group + .alvo-is__group {
        border-block-start: 0;
    }

    .alvo-is--overlay .alvo-is__group {
        grid-column: 1;
    }

    .alvo-is--overlay .alvo-is__group--products {
        grid-column: 2;
        grid-row: 1 / span 8;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
        gap: 1rem;
        align-content: start;
    }

    .alvo-is--overlay .alvo-is__group--products > .alvo-is__heading {
        grid-column: 1 / -1;
    }

    /* Only products (the empty box): one column, the pictures use the whole width. */
    .alvo-is--overlay .alvo-is__list:has(> .alvo-is__group--products):not(:has(> .alvo-is__group:not(.alvo-is__group--products))) {
        grid-template-columns: minmax(0, 1fr);
    }

    .alvo-is--overlay .alvo-is__list:has(> .alvo-is__group--products):not(:has(> .alvo-is__group:not(.alvo-is__group--products))) > .alvo-is__group--products {
        grid-column: 1;
    }

    .alvo-is--overlay .alvo-is__group--products .alvo-is__opt {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        min-block-size: 0;
        padding: 0.25rem;
        border-inline-start: 0;
        border-block-end: 3px solid transparent;
    }

    .alvo-is--overlay .alvo-is__group--products .alvo-is__opt.is-active {
        border-block-end-color: var(--alvo-is-accent);
    }

    .alvo-is--overlay .alvo-is__group--products .alvo-is__thumbwrap {
        inline-size: 100%;
        block-size: auto;
        aspect-ratio: 4 / 5;
    }

    .alvo-is--overlay .alvo-is__group--products .alvo-is__thumb {
        inline-size: 100%;
        block-size: 100%;
        object-fit: cover;
        border-radius: 0;
    }

    .alvo-is--overlay .alvo-is__group--products .alvo-is__meta {
        align-items: flex-start;
        text-align: start;
    }

    /* In the grid of pictures the button sits under the product, not beside it. */
    .alvo-is--overlay .alvo-is__group--products .alvo-is__item--cart {
        flex-direction: column;
        align-items: stretch;
    }

    .alvo-is--overlay .alvo-is__group--products .alvo-is__add {
        margin: 0 0.25rem 0.5rem;
    }
}

@media (forced-colors: active) {
    .alvo-is__add {
        border: 1px solid ButtonText;
    }

    .alvo-is__opt.is-active {
        outline: 2px solid Highlight;
        outline-offset: -2px;
    }

    .alvo-is__label {
        border: 1px solid CanvasText;
    }
}

@media (prefers-reduced-motion: reduce) {
    .alvo-is__panel {
        transition: none;
        animation: none;
    }
}

/* ---------- Magento Luma / Blank (top.search) ---------- */

.alvo-is--luma .alvo-is__form {
    position: relative;
}

.alvo-is--luma .alvo-is__chooser {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.5rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid #c2c2c2;
    background: #fff;
    font-size: 1.2rem;
}

.alvo-is--luma .alvo-is__panel {
    z-index: 201;
}

/* Luma draws the search button as a small icon; at least 24 by 24 CSS pixels as WCAG 2.2 AA asks (2.5.8). */
.alvo-is--luma .action.search {
    min-width: 24px;
    min-height: 24px;
}

.alvo-is--luma .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Field polish (1.3.0) ------------------------------------------------------------------------------------------
   One clear control instead of three: the browser's own blue cancel icon is hidden (the panel has its close button and
   Escape closes it), and the shortcut badge sits at the end of the field and steps aside as soon as there is text. */

.alvo-is input[type="search"]::-webkit-search-cancel-button,
.alvo-is input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.alvo-is__kbd {
    inset-inline-end: 0.75rem;
    pointer-events: none;
}

.alvo-is input:not(:placeholder-shown) ~ .alvo-is__kbd {
    display: none;
}
