/* ==========================================================================
   Header + search (Algolia Autocomplete v1)
   Markup: header.php (.kvik-hdr) + inc/header-search.php (.kvik-hs)
   JS:     vendor/algolia-search/js/algolia-search.js
   Loaded after @algolia/autocomplete-theme-classic, so these win.
   ========================================================================== */

:root {
    --kvik-teal: #62b0ba;
    --kvik-teal-dark: #0d9488;
    --kvik-ink: #1a1f24;
    --kvik-muted: #6b7280;
    --kvik-line: #eceff2;
    --aa-primary-color-rgb: 98, 176, 186;
    --aa-selected-color-rgb: 98, 176, 186;
    --aa-selected-color-alpha: 0.12;
    --aa-input-border-color-rgb: 210, 214, 219;
    --aa-icon-color-rgb: 107, 114, 128;
    --aa-font-family: 'Open Sans', Arial, sans-serif;
    --aa-font-size: 15px;
    --aa-search-input-height: 48px;
    --aa-panel-max-height: 660px;
    --aa-base-z-index: 100000;                 /* above the Kvikan launcher */
}

/* ── Top row layout ────────────────────────────────────────────────────── */
header .top-holder .kvik-hdr {
    display: flex;
    align-items: center;
    gap: 28px;
    min-height: 86px;
    padding: 6px 12px;
    box-sizing: border-box;
}
header .top-holder .kvik-hdr__logo {
    flex: 0 0 auto;
    padding: 4px 0 0;
}
header .top-holder .kvik-hdr__logo img {
    display: block;
    width: auto;
    max-height: 70px;
    transition: max-height .2s ease;
}
.kvik-hdr__search {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
}
.kvik-hdr__badge {
    flex: 0 0 auto;
    position: relative;
    max-width: 260px;
}
.kvik-hdr__badge--video { width: 220px; align-self: stretch; }

/* ── Search box ────────────────────────────────────────────────────────── */
.kvik-hs {
    position: relative;
    width: 100%;
    max-width: 640px;
}

/* No-JS / pre-mount fallback — same footprint as the live input (no CLS). */
.kvik-hs__fallback { margin: 0; }
.kvik-hs__fallback input {
    width: 100%;
    height: 48px;
    box-sizing: border-box;
    border: 0;
    border-radius: 999px;
    padding: 0 18px 0 48px;
    font: 15px 'Open Sans', Arial, sans-serif;
    color: var(--kvik-ink);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2362b0ba' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 17px 50% / 20px;
    -webkit-appearance: none;
    appearance: none;
}

.kvik-hs .aa-Autocomplete { width: 100%; }
.kvik-hs .aa-Form {
    border: 0;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .22), inset 0 0 0 1px rgba(255, 255, 255, .6);
    transition: box-shadow .18s ease, transform .18s ease;
}
.kvik-hs .aa-Form:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, .28); }
.kvik-hs .aa-Form:focus-within {
    border: 0;
    box-shadow: 0 0 0 4px rgba(98, 176, 186, .45), 0 8px 26px rgba(0, 0, 0, .3);
}
.kvik-hs .aa-InputWrapperPrefix { padding-left: 10px; }
.kvik-hs .aa-SubmitIcon { color: var(--kvik-teal); stroke-width: 2.2; }
.kvik-hs .aa-Input { font-size: 15px; color: var(--kvik-ink); }
.kvik-hs .aa-Input::placeholder { color: var(--kvik-muted); opacity: 1; }
.kvik-hs .aa-ClearButton { padding-right: 12px; }

/* ⌘K / Ctrl K hint */
.kvik-hs__kbd {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    padding: 4px 7px;
    border: 1px solid #e5e7eb;
    border-bottom-width: 2px;
    border-radius: 6px;
    background: #f7f8f9;
    color: var(--kvik-muted);
    font: 700 11px/1 'Open Sans', Arial, sans-serif;
    pointer-events: none;
}
.kvik-hs:focus-within .kvik-hs__kbd,
.kvik-hs:has(.aa-Input:not(:placeholder-shown)) .kvik-hs__kbd { display: none; }

/* Desktop dropdown — wider than the input, centred under it. Explicit z-index:
   it must sit above the teal nav bar and page content (cards, sliders…). */
.kvik-hs .aa-Panel {
    position: absolute !important;
    top: calc(100% + 10px) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
    width: min(820px, calc(100vw - 32px)) !important;
    max-width: none !important;
    z-index: 100001 !important;
    margin: 0;
    border: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(10, 20, 30, .35), 0 3px 10px rgba(0, 0, 0, .1);
    overflow: hidden;
    animation: kvikPanelIn .16s ease-out;
}
.kvik-hs .aa-PanelLayout {
    max-height: min(74vh, var(--aa-panel-max-height));
    padding: 0;
}
@keyframes kvikPanelIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Layout inside the panel ───────────────────────────────────────────── */
.kvik-hs-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}
.kvik-hs-grid--one { grid-template-columns: minmax(0, 1fr); }
.kvik-hs-col { padding: 6px 0 10px; min-width: 0; }
.kvik-hs-col--side {
    background: #f7f9fa;
    border-left: 1px solid var(--kvik-line);
}
.kvik-hs-home { padding: 4px 0 12px; }

/* Section headers */
.aa-Panel .aa-SourceHeader,
.aa-DetachedContainer .aa-SourceHeader { margin: 14px 16px 6px; }
.kvik-hs-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.kvik-hs-head__title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--kvik-teal-dark);
}
.kvik-hs-head__title::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--kvik-teal);
}
.kvik-hs-head__action {
    border: 0;
    background: none;
    padding: 2px 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--kvik-muted);
    cursor: pointer;
}
.kvik-hs-head__action:hover { color: var(--kvik-teal-dark); text-decoration: underline; }

/* Items */
.aa-Panel .aa-Item,
.aa-DetachedContainer .aa-Item {
    position: relative;
    min-height: 0;
    margin: 0 8px;
    padding: 0;
    border-radius: 10px;
    transition: background .12s ease;
}
.aa-Panel .aa-Item[aria-selected="true"],
.aa-DetachedContainer .aa-Item[aria-selected="true"] { background: rgba(98, 176, 186, .13); }
.kvik-hs-col .aa-Item[aria-selected="true"]::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--kvik-teal);
}

.kvik-hs-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;   /* theme's .aa-ItemLink is space-between */
    text-align: left;
    gap: 14px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    color: var(--kvik-ink);
    text-decoration: none;
}
.kvik-hs-row:hover,
.kvik-hs-row:focus { color: var(--kvik-ink); text-decoration: none; }
.kvik-hs-row--compact { padding: 8px 10px; }
.kvik-hs-row--compact > .kvik-hs-row__title { flex: 1 1 auto; min-width: 0; }

.kvik-hs-row__poster {
    flex: 0 0 44px;
    width: 44px;
    height: 66px;
    border-radius: 6px;
    overflow: hidden;
    background: linear-gradient(160deg, #e6ebee, #d5dde2);
    color: #9aa6ae;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.kvik-hs-row__poster img { display: block; width: 100%; height: 100%; object-fit: cover; }

.kvik-hs-row__avatar {
    position: relative;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(145deg, #62b0ba, #3f8f99);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, .18);
}
.kvik-hs-row__avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kvik-hs-row__icon {
    flex: 0 0 30px;
    height: 30px;
    border-radius: 8px;
    background: #eef3f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kvik-teal-dark);
}
.kvik-hs-row__icon .kvik-hs-ico { width: 16px; height: 16px; }
.kvik-hs-row__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.kvik-hs-row__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}
.kvik-hs-row--compact .kvik-hs-row__title { font-size: 14px; font-weight: 600; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kvik-hs-row__title mark {
    background: none;
    color: inherit;
    font-weight: 800;
    box-shadow: inset 0 -.38em 0 rgba(98, 176, 186, .28);
}
.kvik-hs-row__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12.5px;
    color: var(--kvik-muted);
}
.kvik-hs-rating {
    padding: 1px 7px;
    border-radius: 999px;
    background: #fff5db;
    color: #a86a00;
    font-weight: 700;
    font-size: 12px;
}
.kvik-hs-chip-sm {
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.5;
}
.kvik-hs-chip-sm--cinema { background: #ea580c; color: #fff; }

/* Action bar (see all / ask Kvikan / advanced) */
.aa-Source[data-autocomplete-source-id="actions"] {
    border-top: 1px solid var(--kvik-line);
    background: #fbfcfc;
}
.aa-Source[data-autocomplete-source-id="actions"] .aa-List {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
}
.aa-Source[data-autocomplete-source-id="actions"] .aa-Item {
    margin: 0;
    border-radius: 999px;
    background: none !important;
}
.kvik-hs-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid #d9e0e4;
    border-radius: 999px;
    background: #fff;
    color: var(--kvik-ink);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.kvik-hs-btn .kvik-hs-ico { width: 16px; height: 16px; }
.kvik-hs-btn--all { background: var(--kvik-teal-dark); border-color: var(--kvik-teal-dark); color: #fff; }
.kvik-hs-btn--kvikan { background: #f3e8ff; border-color: #e3ccff; color: #7e22ce; }
.kvik-hs-btn:hover,
.aa-Item[aria-selected="true"] .kvik-hs-btn {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
    text-decoration: none;
}
.kvik-hs-btn--all:hover,
.aa-Item[aria-selected="true"] .kvik-hs-btn--all { color: #fff; background: #0b7f75; }

/* Chips (quick links, recent searches, trending people) */
.aa-Source[data-autocomplete-source-id="quick"] .aa-List,
.aa-Source[data-autocomplete-source-id="recent"] .aa-List,
.aa-Source[data-autocomplete-source-id="trending-people"] .aa-List {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 16px 6px;
}
.aa-Source[data-autocomplete-source-id="quick"] .aa-Item,
.aa-Source[data-autocomplete-source-id="recent"] .aa-Item,
.aa-Source[data-autocomplete-source-id="trending-people"] .aa-Item {
    margin: 0;
    border-radius: 999px;
    background: none !important;
}
.kvik-hs-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border: 1px solid #e3e8eb;
    border-radius: 999px;
    background: #f5f8f9;
    color: var(--kvik-ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color .12s ease, background .12s ease;
}
.kvik-hs-chip .kvik-hs-ico { width: 16px; height: 16px; color: var(--kvik-teal-dark); }
.kvik-hs-chip:hover,
.aa-Item[aria-selected="true"] .kvik-hs-chip {
    border-color: var(--kvik-teal);
    background: #e6f3f4;
    color: var(--kvik-ink);
    text-decoration: none;
}
.kvik-hs-chip--recent { padding-right: 6px; }
.kvik-hs-chip--recent > .kvik-hs-ico { color: var(--kvik-muted); }
.kvik-hs-chip__x {
    display: inline-flex;
    padding: 3px;
    margin-left: 2px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: #9ca3af;
    cursor: pointer;
}
.kvik-hs-chip__x .kvik-hs-ico { width: 13px; height: 13px; color: inherit; }
.kvik-hs-chip__x:hover { background: #dfe6e9; color: var(--kvik-ink); }

/* "Vinsælt núna" poster strip */
.aa-Source[data-autocomplete-source-id="trending"] .aa-List {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    padding: 4px 16px 8px;
}
.aa-Source[data-autocomplete-source-id="trending"] .aa-Item {
    display: block;          /* theme centres items vertically — top-align tiles */
    align-self: start;
    margin: 0;
    border-radius: 10px;
    background: none !important;
}
.kvik-hs-tile {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--kvik-ink);
    text-decoration: none;
}
.kvik-hs-tile:hover { color: var(--kvik-ink); text-decoration: none; }
.kvik-hs-tile__poster {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(160deg, #e6ebee, #d5dde2);
    box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
    transition: transform .15s ease, box-shadow .15s ease;
}
.kvik-hs-tile__poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.kvik-hs-tile:hover .kvik-hs-tile__poster,
.aa-Item[aria-selected="true"] .kvik-hs-tile__poster {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, .26), 0 0 0 3px var(--kvik-teal);
}
.kvik-hs-tile__badge {
    position: absolute;
    left: 6px;
    top: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #ea580c;
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
}
.kvik-hs-tile__title {
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.kvik-hs-tile__year { font-size: 11.5px; color: var(--kvik-muted); margin-top: -3px; }

/* ── Mobile (≤960px): pill in the top row + full-screen overlay ────────── */
.kvik-hs-mbtn { display: none; }

@media (max-width: 960px) {
    header .top-holder .kvik-hdr {
        flex-wrap: wrap;
        gap: 10px;
        min-height: 0;
        padding: 10px 12px 12px;
    }
    header .top-holder .kvik-hdr__logo img { max-height: 46px; }
    .kvik-hdr__search { order: 3; flex: 1 0 100%; }
    .kvik-hdr__badge { order: 4; flex: 1 0 100%; max-width: none; text-align: center; }
    .kvik-hdr__badge--video { display: none; }
    .kvik-hs { max-width: none; }
    .kvik-hs__kbd { display: none; }

    .kvik-hs .aa-DetachedSearchButton {
        height: 46px;
        padding: 0 16px;
        border: 0;
        border-radius: 999px;
        background: #fff;
        box-shadow: 0 2px 10px rgba(0, 0, 0, .22);
    }
    .kvik-hs .aa-DetachedSearchButtonIcon { color: var(--kvik-teal); }
    .kvik-hs .aa-DetachedSearchButtonPlaceholder { color: var(--kvik-muted); font-size: 15px; }

    /* Fixed 🔍 left of the hamburger (which sits at top:15px/right:20px). */
    .kvik-hs-mbtn {
        position: fixed;
        top: 15px;
        right: 82px;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 55px;
        height: 55px;
        padding: 0;
        border: 0;
        background: rgba(0, 0, 0, .6);
        color: #fff;
        cursor: pointer;
    }
    body.admin-bar .kvik-hs-mbtn { top: 47px; }
}
@media (max-width: 782px) {
    body.admin-bar .kvik-hs-mbtn { top: 61px; }
}

/* Mobile overlay: single column; poster strip scrolls sideways */
.aa-DetachedContainer .kvik-hs-grid { grid-template-columns: minmax(0, 1fr); }
.aa-DetachedContainer .kvik-hs-col--side { background: none; border-left: 0; border-top: 1px solid var(--kvik-line); }
.aa-DetachedContainer .aa-DetachedFormContainer { padding: 10px 12px; }
.aa-DetachedContainer .aa-Form { border-radius: 999px; }
.aa-DetachedContainer .aa-DetachedCancelButton { white-space: nowrap; }
.aa-DetachedContainer .aa-PanelLayout { padding-bottom: 24px; }
.aa-DetachedContainer .kvik-hs-row { padding: 10px; }
.aa-DetachedContainer .aa-Source[data-autocomplete-source-id="trending"] .aa-List {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 16px;
    gap: 10px;
    padding: 4px 16px 12px;
}
.aa-DetachedContainer .aa-Source[data-autocomplete-source-id="trending"] .aa-Item {
    flex: 0 0 104px;
    scroll-snap-align: start;
}

/* ── Desktop: slim fixed bar once the top row scrolls away ─────────────── */
.kvik-hdr-spacer { height: 0; }

@media (min-width: 961px) {
    html.kvik-hdr-compact header .top-holder {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9000;
        box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
        animation: kvikHdrIn .22s ease-out;
    }
    html.kvik-hdr-compact body.admin-bar header .top-holder { top: 32px; }
    html.kvik-hdr-compact header .top-holder .kvik-hdr {
        min-height: 60px;
        padding-top: 5px;
        padding-bottom: 5px;
    }
    html.kvik-hdr-compact header .top-holder .kvik-hdr__logo img { max-height: 40px; }
    html.kvik-hdr-compact .kvik-hdr__badge { display: none; }
}
@keyframes kvikHdrIn {
    from { transform: translateY(-100%); }
    to   { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    html.kvik-hdr-compact header .top-holder,
    .kvik-hs .aa-Panel { animation: none; }
    header .top-holder .kvik-hdr__logo img,
    .kvik-hs-tile__poster,
    .kvik-hs-btn { transition: none; }
}