/* ==========================================================================
   Header Search — trigger, dropdown/inline panel, autocomplete results
   ========================================================================== */

.dqlabs-search {
    position: relative;
    align-items: center;
}

/* Desktop trigger icon */
.dqlabs-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    /* 24px here + Book a Demo's ms-4 (24px) centres the icon between the
       last nav item and the button (~35px visible gap each side). */
    margin-left: 24px;
    background: transparent;
    border: none;
    border-radius: 10px; /* rounded square, matches the hover tile */
    /* --dqlabs-search-toggle-color is set by search-ajax.js from the nav
       links' computed colour, so the icon is light on dark headers and dark
       on light ones. Fallbacks cover the moment before JS runs. */
    color: var(--dqlabs-search-toggle-color, var(--dark, #1a1a1a));
    font-size: 16px;
    cursor: pointer;
    transition: background-color .2s var(--dq-ease, ease), color .2s var(--dq-ease, ease);
}

.dqlabs-search-toggle-icon {
    display: inline-flex;
}

.dqlabs-search-toggle-icon svg,
.dqlabs-search-feedback-icon svg {
    fill: none;
}

.dqlabs-search-toggle-icon svg {
    width: 19px;
    height: 19px;
}

/* html.dark-mode is hard-coded on every page, so it can't tell a dark header
   from a light one; it's only the pre-JS fallback here. */
html.dark-mode .dqlabs-search-toggle {
    color: var(--dqlabs-search-toggle-color, #fff);
}

/* The theme turns every <button> white on :hover/:focus (button:hover,
   button:focus { color:#fff }), which beat the single-class rules above and
   made the icon vanish on light headers on hover and after closing search
   (focus returns to the icon). Pin the colour in every state, keeping the
   same JS-driven variable and fallbacks. */
html .dqlabs-search-toggle.dqlabs-search-toggle,
html .dqlabs-search-toggle.dqlabs-search-toggle:hover,
html .dqlabs-search-toggle.dqlabs-search-toggle:focus,
html .dqlabs-search-toggle.dqlabs-search-toggle:focus-visible,
html .dqlabs-search-toggle.dqlabs-search-toggle:active {
    color: var(--dqlabs-search-toggle-color, var(--dark, #1a1a1a));
}

html.dark-mode .dqlabs-search-toggle.dqlabs-search-toggle,
html.dark-mode .dqlabs-search-toggle.dqlabs-search-toggle:hover,
html.dark-mode .dqlabs-search-toggle.dqlabs-search-toggle:focus,
html.dark-mode .dqlabs-search-toggle.dqlabs-search-toggle:focus-visible,
html.dark-mode .dqlabs-search-toggle.dqlabs-search-toggle:active {
    color: var(--dqlabs-search-toggle-color, #fff);
}

/* Hover / keyboard-focus tile. Dark headers (default): a soft white tint
   under the white icon. Light headers (.is-on-light, set by search-ajax.js):
   the theme's light grey under the dark icon. */
.dqlabs-search-toggle:focus-visible {
    background-color: rgba(255, 255, 255, .12);
}

.dqlabs-search-toggle.is-on-light:focus-visible {
    background-color: var(--grey-light, #F3F4F6);
}

/* Mouse/trackpad only, so the tile doesn't stick after a tap on phones */
@media (hover: hover) {
    .dqlabs-search-toggle:hover {
        background-color: rgba(255, 255, 255, .12);
    }

    .dqlabs-search-toggle.is-on-light:hover {
        background-color: var(--grey-light, #F3F4F6);
    }
}

.dqlabs-search-toggle:focus-visible {
    outline: 2px solid var(--primary-color, #e60000);
    outline-offset: 2px;
}

/* Blurred backdrop behind the open search modal — only the page behind
   blurs; the modal itself (.dqlabs-search-panel) is a solid, sharp card
   with no blur/transparency of its own so its content stays fully legible. */
.dqlabs-search-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1019;
    background: rgba(17, 24, 39, .38);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s var(--dq-ease, ease);
}

.dqlabs-search-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

html.dqlabs-search-open,
body.dqlabs-search-open {
    overflow: hidden;
}

/* Desktop search panel — centered modal.
   Opaque at all times (no opacity fade, own stacking context via
   `isolation`) so the blurred backdrop behind it can never show or blend
   through the panel — only the page behind the modal blurs, never the
   search bar itself. Only transform/width animate. */
.dqlabs-search-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 420px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    overflow: hidden;
    z-index: 1020;
    isolation: isolate;
    transform: translate(-50%, -50%) scale(.96);
    transition: transform .2s var(--dq-ease, ease), width .22s var(--dq-ease, ease);
    pointer-events: none;
}

.dqlabs-search-panel[hidden] {
    display: none;
}

.dqlabs-search-panel.is-open {
    width: 600px;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .dqlabs-search-panel,
    .dqlabs-search-backdrop {
        transition: none;
    }
}

/* Search form (shared by desktop panel + mobile off-canvas) */
.dqlabs-search-form {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Gradient-ring border, painted as a 1px mask-cut ring instead of a flat
   `border`, so it doesn't fight the input's own fill color. */
.dqlabs-search-form::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 999px;
    padding: 1px;
    /* background: linear-gradient(150deg, rgba(255, 255, 255, .35) 0%, rgba(230, 0, 0, .3) 45%, rgba(255, 255, 255, .04) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); */
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.dqlabs-search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey, #656565);
    /* the theme sets a global `svg { fill: var(--text-color) }` — override it
       so this stroke-only glyph doesn't render as a solid filled blob. */
    fill: none;
    pointer-events: none;
    transition: color .2s var(--dq-ease, ease);
}

/* Input fill colour, registered so hover can fade it (gradients can't be
   transitioned directly). Browsers without @property just switch instantly. */
@property --dqlabs-search-fill {
    syntax: '<color>';
    inherits: false;
    initial-value: #fff;
}

.dqlabs-search-input {
    --dqlabs-search-fill: var(--white, #fff);
    width: 100%;
    height: 48px;
    outline: none !important;
    padding: 0 44px 0 46px;
    border: none;
    border-radius: 999px;
    color: var(--text-color, #1a1a1a);
    font-size: 15px;
    font-family: var(--content-font) !important;
    outline: none;
    transition: --dqlabs-search-fill .2s var(--dq-ease, ease);
    background: linear-gradient(var(--dqlabs-search-fill), var(--dqlabs-search-fill)) padding-box, linear-gradient(150deg, rgba(255, 255, 255, .35) 0%, rgba(230, 0, 0, .3) 45%, rgba(255, 255, 255, .04) 100%) border-box;
    border: 2px solid transparent;
}

.dqlabs-search-input::placeholder {
    color: var(--grey, #656565);
}

/* Hover anywhere on the bar (icon, input, clear button): theme light grey.
   Mouse/trackpad only, so the grey doesn't stick after a tap on phones. */
@media (hover: hover) {
    .dqlabs-search-form:hover .dqlabs-search-input {
        --dqlabs-search-fill: var(--grey-light, #F3F4F6);
    }
}

.dqlabs-search-clear {
    position: absolute;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--grey, #656565);
    cursor: pointer;
    transition: color .2s var(--dq-ease, ease);
}

.dqlabs-search-clear svg {
    /* the theme sets a global `svg { fill: var(--text-color) }` — override it
       so this stroke-only glyph doesn't render as a solid filled blob. */
    fill: none;
}

.dqlabs-search-clear[hidden] {
    display: none;
}

.dqlabs-search-clear:hover {
    color: var(--grey, #656565);
    background: unset;
}

/* Results list (shared). Up to 12 results: the list shows 6 rows and
   scrolls on the Y axis for the rest. search-ajax.js measures the first 6
   rows into --dqlabs-search-rows-h, so the cut always lands on a row edge
   whatever the title lengths. */
.dqlabs-search-results {
    position: relative; /* offset parent for that measurement */
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain; /* don't scroll the page/menu behind */
    -webkit-overflow-scrolling: touch;
}

/* Results container — desktop dropdown */
.dqlabs-search-panel .dqlabs-search-results {
    border-top: 1px solid #EEF0F2;
    background-color: #fff;
    border-radius: 8px;
    flex: 0 1 auto; /* still shrinks on short viewports (panel max-height) */
    min-height: 0;
    max-height: var(--dqlabs-search-rows-h, none);
    cursor: pointer;
}

.dqlabs-search-results[hidden] {
    display: none;
}

/* Skeleton loading state */
.dqlabs-search-skeleton-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 14px;
    border-bottom: 1px solid #EEF0F2;
}

.dqlabs-search-skeleton-row:last-child {
    border-bottom: none;
}

.dqlabs-search-skeleton-icon {
    width: 120px;
    height: 67px;
    flex-shrink: 0;
    border-radius: 10px;
}

.dqlabs-search-skeleton-lines {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 100%;
}

.dqlabs-search-skeleton-lines span {
    display: block;
    height: 8px;
    border-radius: 4px;
}

.dqlabs-search-skeleton-lines span:first-child {
    width: 65%;
}

.dqlabs-search-skeleton-lines span:last-child {
    width: 35%;
}

.dqlabs-search-skeleton-icon,
.dqlabs-search-skeleton-lines span {
    background: linear-gradient(90deg, var(--grey-light, #F3F4F6) 25%, #ECEEF1 37%, var(--grey-light, #F3F4F6) 63%);
    background-size: 400% 100%;
    animation: dqlabs-shimmer 1.4s ease infinite;
}

@keyframes dqlabs-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .dqlabs-search-skeleton-icon,
    .dqlabs-search-skeleton-lines span {
        animation: none;
    }
}

/* Feedback states — empty / error.
   The theme sets `p { margin: 0 !important; padding-bottom: 20px }` and a
   30px line-height. Spacing here is done with padding, which overrides the
   theme's non-!important padding, and line-heights are explicit, so the
   card keeps even spacing. */
.dqlabs-search-feedback {
    padding: 28px 24px;
    text-align: center;
    line-height: 1.5;
}

.dqlabs-search-feedback-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    border-radius: 50%;
    background-color: var(--grey-light, #F3F4F6);
    color: var(--grey, #656565);
    font-size: 16px;
}

.dqlabs-search-feedback-icon--error {
    background-color: var(--secondary-color-light, #fcd5d5);
    color: var(--primary-color, #e60000);
}

/* Title in the theme's heading font, like the site's h-tags */
.dqlabs-search-feedback .dqlabs-search-feedback-title {
    padding: 0 0 6px;
    color: var(--text-color, #1a1a1a);
    font-family: var(--heading-font, "Futura PT", sans-serif);
    font-size: 20px;
    font-weight: 500;
    letter-spacing: .5px;
    line-height: 1.3;
    overflow-wrap: anywhere; /* long unbroken search terms */
}

.dqlabs-search-feedback .dqlabs-search-feedback-hint {
    padding: 0 0 20px;
    font-family: var(--content-font, "Aptos", sans-serif);
    text-wrap: balance; /* no single orphan word on phones */
    color: var(--grey, #656565);
    font-size: 15px;
    line-height: 1.5;
}

/* error state has no button below the hint */
.dqlabs-search-feedback .dqlabs-search-feedback-hint:last-child {
    padding-bottom: 0;
}

/* Result rows */
.dqlabs-search-result {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #EEF0F2;
    transition: background-color .15s var(--dq-ease, ease);
}

.dqlabs-search-result:last-child {
    border-bottom: none;
}

.dqlabs-search-result:hover,
.dqlabs-search-result.is-active {
    background-color: var(--grey-light, #F3F4F6);
    text-decoration: none;
}

.dqlabs-search-result-thumb {
    display: block;
    /* fixed width so every row's text column lines up */
    width: 120px;
    height: 67px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--grey-light, #F3F4F6);
}

.dqlabs-search-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dqlabs-search-result-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.dqlabs-search-result-title {
    color: var(--text-color, #1a1a1a);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dqlabs-search-result-type {
    color: var(--grey, #656565);
    font-size: 11.5px;
    line-height: 1.3; /* the theme's inherited 30px made rows ~15px taller */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* Phones / tablets (below the xl breakpoint, where the menu button shows).
   Same centred modal as desktop, sized to the screen; dvh keeps it inside
   the visible area when the browser bars or keyboard take space. */
@media (max-width: 1199.98px) {
    .dqlabs-search-toggle {
        margin-left: 0;
    }

    .dqlabs-search-panel,
    .dqlabs-search-panel.is-open {
        width: calc(100vw - 32px);
        max-width: 600px;
        max-height: calc(100vh - 32px);
        max-height: calc(100dvh - 32px);
    }

    /* 16px stops iOS Safari zooming the page when the input is focused */
    .dqlabs-search-panel .dqlabs-search-input {
        font-size: 16px;
    }

    /* Compact rows so the title gets the width */
    .dqlabs-search-panel .dqlabs-search-result,
    .dqlabs-search-panel .dqlabs-search-skeleton-row {
        gap: 12px;
        padding: 10px;
    }

    .dqlabs-search-panel .dqlabs-search-result-thumb,
    .dqlabs-search-panel .dqlabs-search-skeleton-icon {
        width: 88px;
        height: 50px;
    }

    .dqlabs-search-panel .dqlabs-search-result-title {
        font-size: 14px;
    }
}
