/*
 * Header search dropdown, ported from givenlv_php_8 (style/component/header.css,
 * media.css, bundle.css). Markup: common/header.twig (form.search) and
 * product/search_results.twig; behaviour: dist/js/modules/common.js.
 *
 * This file is loaded after THEME_STYLE_CSS and deliberately re-declares every
 * property of the legacy `.search` rules that are still compiled into
 * grenardi.css / main.css, so the old zwicon search box never shows through.
 */

@font-face {
    font-family: 'NotoSans';
    src: url('/dist/fonts/NotoSans/NotoSans-Regular.woff2') format('woff2'),
         url('/dist/fonts/NotoSans/NotoSans-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --search-font: 'NotoSans', sans-serif;
    --search-accent: #00238F;
    --search-overlay: rgba(0, 26, 37, 0.3);
}

/* ---------------------------------------------------------------------------
 * Root box (form.search) — desktop: floating input over the top menu row
 * ------------------------------------------------------------------------- */
.search {
    position: absolute;
    top: -56px;
    left: 0;
    right: auto;
    width: 483px;
    max-width: calc(100vw - 32px);
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    transform: none;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    /* visibility flips instantly on open (so the input can be focused at once)
       and only after the fade on close */
    transition: opacity 0.2s ease-in-out, visibility 0s linear 0.2s;
    font-family: var(--search-font);
    color: #000000;
    text-align: left;
    line-height: 1.4;
}
.search.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease-in-out, visibility 0s;
}

/* Input row */
.search .header-search {
    display: flex;
    align-items: center;
    position: relative;
    height: 44px;
    margin: 0;
}
.search .header-search svg {
    position: relative;
    z-index: 1;
    opacity: 0.7;
    margin-left: 14px;
    width: 18px;
    height: 16px;
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}
.search .header-search svg.close {
    display: none;
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
    width: 44px;
    height: 44px;
    padding: 12px;
    box-sizing: border-box;
    cursor: pointer;
    pointer-events: auto;
}
.search.active .header-search svg.close {
    display: block;
}
.search .header-search input {
    box-sizing: border-box;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0 48px 0 47px;
    border: 0;
    border-radius: 6px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    color: #000000;
    font-family: inherit;
    font-size: 16px;
    line-height: normal;
    box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.05),
                0px 11px 11px 0px rgba(0, 0, 0, 0.04),
                0px 26px 15px 0px rgba(0, 0, 0, 0.03),
                0px 45px 18px 0px rgba(0, 0, 0, 0.01),
                0px 71px 20px 0px rgba(0, 0, 0, 0);
    transition: box-shadow 0.2s ease-in-out;
}
.search .header-search input::placeholder {
    color: rgba(0, 0, 0, 0.7);
    opacity: 1;
}
.search .header-search input::-webkit-search-decoration,
.search .header-search input::-webkit-search-cancel-button {
    display: none;
}

/* Results panel */
.search .search-result {
    position: absolute;
    top: 48px;
    left: 0;
    right: auto;
    width: 100%;
    max-height: calc(100vh - 160px);
    max-height: min(85vh, calc(100dvh - 160px));
    overflow: auto;
    overscroll-behavior: contain;
    padding: 32px 32px;
    margin: 0;
    background: #ffffff;
    border: 0;
    border-radius: 4px;
    box-shadow: 0 26px 15px 0 rgba(0, 0, 0, 0.03);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
    font-size: 16px;
    line-height: 1.4;
    color: #000000;
}
.search .search-result.active {
    opacity: 1;
    visibility: visible;
}

/* Dim page overlay */
.search-result-overflow {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    background: var(--search-overlay);
}
.search-result-overflow.active {
    opacity: 1;
    visibility: visible;
}

/* ---------------------------------------------------------------------------
 * Results content (product/search_results.twig)
 * ------------------------------------------------------------------------- */
.search-result__cat {
    position: relative;
    padding-bottom: 18px;
    margin-bottom: 28px;
}
.search-result__cat:before {
    content: "";
    position: absolute;
    bottom: 0;
    left: -32px;
    right: -32px;
    height: 1px;
    background: linear-gradient(90deg, rgba(217, 217, 217, 0) 0%, #D9D9D9 50.48%, rgba(217, 217, 217, 0) 100%);
}
.search-result__cat a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-decoration: none;
    color: #000000;
    font-size: 14px;
    margin-bottom: 13px;
    transition: color 0.3s ease-in-out;
}
.search-result__cat a span {
    flex-shrink: 0;
    color: rgba(0, 0, 0, 0.5);
    font-size: 12px;
}
.search-result__cat-name {
    min-width: 0;
    overflow-wrap: anywhere;
}
.search-result__cat-name mark {
    font-weight: 700;
    background-color: unset;
    color: inherit;
}
.search-result__cat-scroll {
    max-height: 200px;
    overflow: auto;
    width: 100%;
    padding-right: 2%;
}
.scroll-hidden {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.scroll-hidden::-webkit-scrollbar {
    display: none;
}

a.search-result-prod {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #000000;
}
.search-result-prod__photo {
    width: 138px;
    height: 138px;
    flex-shrink: 0;
}
.search-result-prod__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.search-result-prod__right {
    flex: 1;
    min-width: 0;
    padding-left: 16px;
    overflow-wrap: anywhere;
}
.search-result-prod__brand {
    color: rgba(0, 0, 0, 0.4);
    font-size: 12px;
    text-transform: uppercase;
    margin-top: -12px;
}
.search-result-prod__name {
    color: #000000;
    font-size: 14px;
    margin: 7px 0 20px;
    transition: color 0.3s ease-in-out;
}
.search-result-prod__price {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 14px;
    color: #000000;
}
.search-result-prod__price .price {
    white-space: nowrap;
    color: #000000;
    line-height: 1;
    font-size: 14px;
    font-weight: 400;
    margin: 0;
    display: inline;
}
.search-result-prod__price .basePrice {
    white-space: nowrap;
    color: #000000;
    opacity: 0.4;
    text-decoration: line-through;
    line-height: 1;
    font-size: 14px;
}

.search-result__btn {
    margin-top: 31px;
}
.search-result__btn a {
    width: 100%;
    display: inline-block;
    padding: 7px 0;
    text-align: center;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
}

.search-result__no-tile {
    text-align: center;
}
/* the theme underlines class-less links on hover/focus; the reference does not */
.search-result__cat a:hover,
.search-result__cat a:focus,
.search-result__cat a:active,
a.search-result-prod:hover,
a.search-result-prod:focus {
    text-decoration: none;
}

/* Hover (desktop) and keyboard highlight (common.js) */
@media (min-width: 991px) {
    .search-result__cat a:hover,
    a.search-result-prod:hover .search-result-prod__name {
        color: var(--search-accent);
    }
}
.search-result__cat a.search--highlighted,
a.search-result-prod.search--highlighted .search-result-prod__name {
    color: var(--search-accent);
}
.search-result__btn a.search--highlighted {
    text-decoration: underline;
}
.search--highlighted {
    box-shadow: none;
}

/* ---------------------------------------------------------------------------
 * Mobile: full-screen search block (reference .mobile-search-block)
 * ------------------------------------------------------------------------- */
@media (max-width: 990px) {
    html.search-open,
    html.search-open body {
        overflow: hidden;
    }
    .search {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        width: auto;
        max-width: none;
        z-index: 1001;
        background: #ffffff;
        transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
    }
    .search.active {
        transition: opacity 0.3s ease-in-out, visibility 0s;
    }
    .search .header-search {
        height: 60px;
    }
    .search .header-search svg.open {
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 0;
        opacity: 1;
        width: 16px;
        height: 16px;
    }
    .search .header-search svg.close {
        right: 6px;
        padding: 10px;
    }
    .search .header-search input {
        height: 60px;
        line-height: 60px;
        padding: 0 56px 0 48px;
        border-radius: 0;
        box-shadow: none;
        font-size: 16px;
        transition: none;
    }
    .search .search-result {
        top: 60px;
        left: 0;
        right: 0;
        width: auto;
        max-height: calc(100vh - 60px);
        max-height: calc(100dvh - 60px);
        padding: 16px 16px 20px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        border-radius: 0;
        box-shadow: none;
        overflow-y: auto;
        overflow-x: hidden;
        transition: none;
    }
    .search .search-result::-webkit-scrollbar {
        width: 2px;
        background-color: #ffffff;
    }
    .search .search-result::-webkit-scrollbar-track {
        -webkit-box-shadow: inset 0 0 4px rgba(181, 181, 181, 0.6);
        background-color: #ffffff;
    }
    .search .search-result::-webkit-scrollbar-thumb {
        background-color: #c5c5c5;
    }
    .search-result__cat:before {
        left: -16px;
        right: -16px;
    }
}

@media (max-width: 550px) {
    .search-result-prod {
        padding: 8px 0;
    }
    .search-result-prod__photo {
        width: 96px;
        height: 96px;
    }
    .search-result-prod__brand {
        margin-top: 0;
    }
    .search-result-prod__name {
        margin: 6px 0 12px;
    }
}

/* Shops (docs index) reuse the category rows; the address takes the count's place and may shrink */
.search-result__cat--shops a span {
    flex-shrink: 1;
    min-width: 0;
    max-width: 55%;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
