/* ==========================================================================
   CodeToolz Knowledge Center — shared search component
   One results design for Article Search, Resource Search and the entrance
   Unified Search (prototype assets/css/style.css: "Shared inline search
   results (.sr) — identical on all three pages"). Loads after kc-articles.css,
   which provides the tokens, fonts, .btn and .search-field. Also holds the
   resource preview dialog, which search results open on every page.
   Every rule is scoped under `.kc`.
   ========================================================================== */

/* .sr-anchor wraps the .search-field so the results panel floats directly
   below the box. The panel overlays page content — no layout shift.
   Stacking: the site header (Elementor, sticky) sits in a z-index: 10 section,
   so the open panel stays at 9 — above the page, below the sticky header when
   the page scrolls (the prototype's 60 would paint over this site's header). */
.kc .sr-anchor { position: relative; }
.kc .sr-anchor.is-open { z-index: 9; }
.kc .sr {
	position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 1;
	display: flex; flex-direction: column; max-height: min(66vh, 560px);
	background: #fff; border: 1px solid var(--ctkc-line-strong); border-radius: var(--ctkc-r-panel);
	box-shadow: var(--ctkc-sh-pop); overflow: hidden;
	text-align: left;
}
.kc .sr[hidden] { display: none; }

/* ---------- Theme reset guard ----------
   hello-elementor styles every bare <button> (pink border, pink hover/focus
   fill, uppercase). Restate the prototype look for the panel's buttons. */
.kc .sr button, .kc .preview-dialog button { text-transform: none; letter-spacing: normal; }
.kc .sr .btn--ghost:focus, .kc .preview-dialog .btn--ghost:focus { background: #fff; color: var(--ctkc-navy); border-color: var(--ctkc-line-strong); }
.kc .sr .btn--ghost:hover, .kc .preview-dialog .btn--ghost:hover { background: var(--ctkc-surface-alt); border-color: var(--ctkc-line-hover); color: var(--ctkc-navy); }
.kc .preview-dialog .btn--primary:focus { background: var(--ctkc-navy); color: #fff; border-color: var(--ctkc-navy); }
.kc .preview-dialog .btn--icon { width: 44px; padding: 0; }
body .kc .preview-dialog a.btn--primary, body .kc .preview-dialog a.btn--primary:hover { color: #fff; }

/* ---------- Header: status + clear ---------- */
.kc .sr__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--ctkc-surface-alt); border-bottom: 1px solid var(--ctkc-line); }
.kc .sr__status { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; line-height: 1.6; color: var(--ctkc-ink-muted); }
.kc .sr__status strong { color: var(--ctkc-ink); font-weight: 700; }
.kc .sr__close { flex: none; display: grid; place-items: center; width: 28px; height: 28px; min-height: 0; margin: 0 0 0 auto; padding: 0; border: 0; border-radius: var(--ctkc-r-sm); background: none; color: var(--ctkc-ink-muted); cursor: pointer; transition: background var(--ctkc-ease), color var(--ctkc-ease); }
.kc .sr__close:hover, .kc .sr__close:focus { background: #fff; color: var(--ctkc-ink); box-shadow: none; border: 0; }
.kc .sr__close:focus-visible { outline: 2px solid var(--ctkc-blue); outline-offset: 0; }
.kc .sr-spinner { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ctkc-line-strong); border-top-color: var(--ctkc-blue); animation: ctkc-spin .7s linear infinite; }

/* ---------- Tabs (Unified Search only) ---------- */
.kc .sr__tabs { flex: none; display: flex; gap: 2px; padding: 0 10px; overflow-x: auto; scrollbar-width: none; background: #fff; border-bottom: 1px solid var(--ctkc-line); }
.kc .sr__tabs::-webkit-scrollbar { display: none; }
.kc .sr-tab { position: relative; flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; margin: 0; padding: 0 12px; border: 0; border-radius: 0; background: none; box-shadow: none; cursor: pointer; font: inherit; font-size: 14px; line-height: 1.2; font-weight: 500; color: var(--ctkc-ink-soft); white-space: nowrap; transition: color var(--ctkc-ease); }
.kc .sr-tab:hover, .kc .sr-tab:focus { background: none; border: 0; color: var(--ctkc-ink); box-shadow: none; }
.kc .sr-tab:focus-visible { outline: 2px solid var(--ctkc-blue); outline-offset: -4px; }
.kc .sr-tab[aria-selected="true"] { color: var(--ctkc-navy); font-weight: 600; }
.kc .sr-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 2px 2px 0 0; background: var(--ctkc-green); }
.kc .sr-tab__n:not(:empty) { min-width: 22px; padding: 1px 6px; border-radius: 999px; background: var(--ctkc-surface-alt); border: 1px solid var(--ctkc-line); font-size: 11.5px; line-height: 1.5; font-weight: 600; color: var(--ctkc-ink-soft); text-align: center; }
.kc .sr-tab[aria-selected="true"] .sr-tab__n { background: var(--ctkc-blue-050); border-color: #CFDBF3; color: var(--ctkc-blue); }

/* ---------- Scroll region: the list scrolls under the fixed header/tabs ---------- */
.kc .sr__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; }
.kc .sr__scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
.kc .sr__list { list-style: none; display: flex; flex-direction: column; margin: 0; padding: 5px; }
.kc .sr-item { margin: 0; }
.kc .sr-item + .sr-item { border-top: 1px solid var(--ctkc-line); }

/* ---------- One result row (a link for articles/directories/files, a Preview button for resources/forms) ---------- */
.kc .sr-row { position: relative; width: 100%; display: flex; align-items: center; gap: 13px; margin: 0; padding: 10px 11px; text-align: left; background: none; border: 0; border-radius: var(--ctkc-r-card); box-shadow: none; font: inherit; font-weight: inherit; line-height: inherit; color: inherit; text-decoration: none; white-space: normal; cursor: pointer; transition: background var(--ctkc-ease); }
body .kc a.sr-row, body .kc a.sr-row:hover { color: inherit; }
.kc .sr-row:focus { border: 0; color: inherit; box-shadow: none; }
.kc .sr-row:focus:not(:focus-visible):not(.is-active):not(:hover) { background: none; }
.kc .sr-row:hover, .kc .sr-row:focus-visible, .kc .sr-row.is-active { background: var(--ctkc-surface-alt); outline: none; }
.kc .sr-row:focus-visible { box-shadow: inset 0 0 0 2px var(--ctkc-blue); }
.kc .sr-row::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--ctkc-green); opacity: 0; transition: opacity var(--ctkc-ease); }
.kc .sr-row:hover::before, .kc .sr-row:focus-visible::before, .kc .sr-row.is-active::before { opacity: 1; }
.kc .sr-row:hover .sr-title, .kc .sr-row:focus-visible .sr-title, .kc .sr-row.is-active .sr-title { color: var(--ctkc-blue); }

.kc .sr-thumb { flex: none; display: grid; place-items: center; overflow: hidden; background: var(--ctkc-surface-sunk); border: 1px solid var(--ctkc-line); border-radius: var(--ctkc-r-sm); }
.kc .sr-thumb--media { width: 74px; height: 44px; }
.kc .sr-thumb--media img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* No featured image: same neutral well as the cards. */
.kc .sr-thumb--placeholder { color: var(--ctkc-line-hover); background: linear-gradient(135deg, var(--ctkc-surface-sunk), var(--ctkc-blue-050)); }
.kc .sr-thumb--placeholder .icon { width: 18px; height: 18px; stroke-width: 1.6; }
.kc .sr-thumb--doc { width: 42px; height: 52px; align-items: end; padding-top: 6px; background: #fff; }
.kc .sr-thumb--doc img { display: block; width: 32px; height: auto; aspect-ratio: 600 / 780; object-fit: cover; object-position: top; background: #fff; border: 1px solid var(--ctkc-line); border-bottom: 0; border-radius: 2px 2px 0 0; }
.kc .sr-thumb--icon { width: 46px; height: 46px; color: var(--ctkc-navy); background: #fff; }
.kc .sr-logo { max-width: 38px; max-height: 34px; width: auto; height: auto; object-fit: contain; }
.kc .sr-logo + .icon { display: none; }

.kc .sr-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kc .sr-kicker { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; line-height: 1.5; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ctkc-blue); }
.kc .sr-kicker .icon { color: var(--ctkc-blue); }
.kc .sr-title { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--ctkc-ink); transition: color var(--ctkc-ease); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kc .sr-title mark { background: var(--ctkc-blue-050); color: inherit; border-radius: 3px; padding: 0 1px; }
.kc .sr-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; font-size: 12.5px; line-height: 1.5; color: var(--ctkc-ink-muted); }
.kc .sr-where { display: inline-flex; align-items: center; gap: 4px; }
.kc .sr-metatext { color: var(--ctkc-ink-muted); }
.kc .sr-dot { color: var(--ctkc-line-strong); }
.kc .sr-format { padding: 0 6px; border: 1px solid var(--ctkc-line); border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; line-height: 16px; color: var(--ctkc-ink-muted); }
.kc .sr-action { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; line-height: 1.4; font-weight: 600; color: var(--ctkc-blue); white-space: nowrap; }
.kc .sr-action .icon { color: var(--ctkc-blue); }

/* ---------- States: no results / error, load more, loading skeleton ---------- */
.kc .sr-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 20px; margin: 4px; text-align: center; font-size: 14px; line-height: 1.55; color: var(--ctkc-ink-soft); background: var(--ctkc-surface-alt); border: 1px dashed var(--ctkc-line-strong); border-radius: var(--ctkc-r-card); }
.kc .sr-state strong { font-size: 15px; color: var(--ctkc-ink); overflow-wrap: anywhere; }
.kc .sr-state .btn { margin-top: 8px; }
.kc .sr-state__icon { width: 36px; height: 36px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 50%; background: var(--ctkc-surface-sunk); color: var(--ctkc-ink-muted); font-weight: 700; }
.kc .sr-state__icon--error { background: #FDECEC; color: #B42318; }
.kc .sr__more { display: flex; justify-content: center; padding: 8px; border-top: 1px solid var(--ctkc-line); }
.kc .sr__more:has(> [hidden]) { display: none; }
.kc .sr__more .btn[hidden] { display: none; }
.kc .sr__more .btn[aria-busy="true"] { opacity: .7; cursor: progress; }
/* Loading with the PCC Customization loader image (centred, as on PCC pages). */
.kc .sr-loader { display: flex; justify-content: center; padding: 20px 12px; }
.kc .sr-loader img.ctkc-loader-gif { width: 72px; height: 72px; }
.kc .sr-skeleton { display: flex; gap: 13px; align-items: center; padding: 11px; }
.kc .sr-skeleton + .sr-skeleton { border-top: 1px solid var(--ctkc-line); }
.kc .sr-skeleton i { flex: none; width: 74px; height: 44px; border-radius: var(--ctkc-r-sm); }
.kc .sr-skeleton span { flex: 1; display: grid; gap: 8px; }
.kc .sr-skeleton b { display: block; height: 10px; border-radius: 5px; }
.kc .sr-skeleton b:nth-child(1) { width: 25%; } .kc .sr-skeleton b:nth-child(2) { width: 70%; height: 13px; } .kc .sr-skeleton b:nth-child(3) { width: 50%; }
.kc .sr-skeleton i, .kc .sr-skeleton b { background: linear-gradient(90deg, var(--ctkc-surface-sunk) 0%, #E7ECF2 50%, var(--ctkc-surface-sunk) 100%); background-size: 200% 100%; animation: ctkc-shimmer 1.2s linear infinite; }

/* ---------- Preview dialog (resource cards + search results) ---------- */
.kc .preview-dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: var(--ctkc-r-panel); box-shadow: var(--ctkc-sh-pop); color: var(--ctkc-ink); background: #fff; }
.kc .preview-dialog::backdrop { background: rgba(1, 28, 68, .55); }
.kc .preview-dialog__inner { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.kc .preview-dialog__head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--ctkc-line); }
.kc .preview-dialog__head h2 { font-size: 19px; font-weight: 700; line-height: 1.35; }
.kc .preview-dialog__head p { margin-top: 4px; font-size: 14px; color: var(--ctkc-ink-muted); }
.kc .preview-dialog__body { padding: 24px; background: var(--ctkc-surface-sunk); overflow: auto; }
.kc .preview-img { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; background: #fff; border: 1px solid var(--ctkc-line); box-shadow: 0 10px 28px rgba(1, 28, 68, .12); }
.kc .preview-dialog__foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--ctkc-line); }
.kc .pv-note { margin-right: auto; font-size: 13px; }

/* ---------- Responsive ---------- */
/* Stacked layouts (phones + tablets): one search box and one panel geometry on
   every page, whatever the page header holds or the query returns.
   - The box is pinned to the prototype's sizes so theme / Elementor input and
     button styles, a long localized label or a narrow screen cannot resize it.
   - --ctkc-sr-max (kc-search.js) fits the panel to the room under the sticky
     header + field in the visible viewport, the same on every page.
   - The min-height is the loading state's height, so loading, a single
     result, no results and errors all share one panel size (no jump while
     typing); longer lists grow up to the max and scroll inside. */
@media (max-width: 860px) {
	.kc .ctkc-search .search-field--hero { box-sizing: border-box; flex-wrap: nowrap; height: 58px; min-height: 58px; padding: 5px 5px 5px 14px; }
	.kc .ctkc-search .search-field > .icon { flex: none; width: 20px; height: 20px; }
	.kc .ctkc-search .search-field input { height: 42px; min-height: 0; line-height: normal; border-radius: 0; box-shadow: none; -webkit-appearance: none; appearance: none; }
	.kc .ctkc-search .search-field input::placeholder { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.kc .ctkc-search .search-field .btn { flex: none; height: 42px; min-height: 42px; margin: 0; font-size: 15px; line-height: 1; }
	.kc .sr { max-height: min(var(--ctkc-sr-max, 66vh), 560px); min-height: min(var(--ctkc-sr-max, 280px), 280px); }
	.kc .sr__scroll { display: flex; flex-direction: column; }
	.kc .sr__list { flex: 1 0 auto; }
	.kc .sr-state { flex: 1 0 auto; justify-content: center; }
}
@media (max-width: 640px) {
	.kc .sr { max-height: min(var(--ctkc-sr-max, 72vh), 480px); }
	.kc .sr-row { gap: 11px; padding: 10px; }
	.kc .sr-thumb--media { width: 62px; height: 38px; }
	.kc .sr-action { font-size: 12.5px; }
	.kc .sr-tab { padding: 0 10px; }
	.kc .preview-dialog__body { padding: 16px; }
}
/* Narrow panels (phones, and the entrance hero, which sits inside Elementor's
   own side gutters): sized by the panel's width, not the viewport. The action
   drops under the text instead of squeezing the title to a word per line. */
.kc .sr { container-type: inline-size; }
.kc .sr__status strong { white-space: nowrap; }
@container (max-width: 420px) {
	.kc .sr-row { flex-wrap: wrap; align-items: flex-start; row-gap: 4px; }
	.kc .sr-thumb--media { width: 56px; height: 34px; margin-top: 2px; }
	.kc .sr-text { flex: 1 1 calc(100% - 80px); }
	.kc .sr-action { margin-left: auto; }
	.kc .sr-tab { padding: 0 8px; font-size: 13.5px; }
	.kc .sr__tabs { padding: 0 6px; }
}

@media (prefers-reduced-motion: reduce) {
	.kc .sr-spinner, .kc .sr-skeleton i, .kc .sr-skeleton b { animation: none; }
}

@media print {
	.kc .ctkc-search { display: none !important; }
}
