/* The administration's search: the suggestions of the header's search field and the results page with its filter
   bar (content/search, which takes in the former advanced search). One file for every admin design, in
   design/standard (admin4 needs no other admin design). Two parts, each with its own block, so they can change
   independently:
   - "Suggestions": the list under the header's search field (page_search.tpl, javascript/page/search_suggest.js)
   - "Results": filters, active filter chips, sorting and the result table (content/search.tpl, searchresult.tpl) */

/* ---- Suggestions ---------------------------------------------------------------------------------------------- */

/* The panel under the field, over the page (aligned to the field's end when the window has no room on the other
   side: .a4-suggest-end, set by the script); in the narrow screen menu in the flow, under the field */
.a4-suggest {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    z-index: var(--a4-z-popover);
    width: min(36rem, calc(100vw - 2 * var(--a4-space-4)));
    max-height: min(70vh, 34rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    text-align: start;
    color: var(--a4-ink);
    background: var(--a4-surface);
    border: 1px solid var(--a4-line);
    border-radius: var(--a4-radius-s);
    box-shadow: var(--a4-shadow-m);
}

.a4-suggest[hidden] {
    display: none;
}

.a4-suggest.a4-suggest-end {
    inset-inline-start: auto;
    inset-inline-end: 0;
}

.header-search-mobile .searchblock .a4-suggest {
    position: static;
    flex-basis: 100%;
    width: auto;
    max-height: 60vh;
}

.a4-suggest-list,
.a4-suggest-list ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.a4-suggest-group + .a4-suggest-group {
    border-top: 1px solid var(--a4-line);
}

.a4-suggest-heading {
    display: block;
    padding: var(--a4-space-2) var(--a4-space-3) var(--a4-space-1);
    font-size: var(--a4-text-xs);
    font-weight: var(--a4-weight-heading);
    color: var(--a4-muted);
    text-transform: uppercase;
    letter-spacing: var(--a4-tracking);
}

.a4-suggest-count {
    font-weight: normal;
}

.a4-suggest-item > a {
    display: flex;
    align-items: flex-start;
    gap: var(--a4-space-2);
    padding: var(--a4-space-1) var(--a4-space-3);
    color: inherit;
    text-decoration: none;
}

.a4-suggest-icon {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

.a4-suggest-body {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 var(--a4-space-2);
    min-width: 0;
}

.a4-suggest-title {
    color: var(--a4-ink);
    overflow-wrap: anywhere;
}

.a4-suggest-meta {
    font-size: var(--a4-text-xs);
    color: var(--a4-muted);
}

.a4-suggest-path,
.a4-suggest-excerpt {
    flex-basis: 100%;
    font-size: var(--a4-text-xs);
    color: var(--a4-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a4-suggest mark {
    padding: 0;
    color: inherit;
    font-weight: var(--a4-weight-bold);
    background: var(--a4-accent-soft);
}

.a4-suggest-item[aria-selected="true"] > a,
.a4-suggest-item > a:hover,
.a4-suggest-all[aria-selected="true"],
.a4-suggest-all:hover {
    background: var(--a4-soft);
}

.a4-suggest-item[aria-selected="true"] > a,
.a4-suggest-all[aria-selected="true"] {
    box-shadow: inset 3px 0 0 var(--a4-accent);
}

:where([dir="rtl"]) .a4-suggest-item[aria-selected="true"] > a,
:where([dir="rtl"]) .a4-suggest-all[aria-selected="true"] {
    box-shadow: inset -3px 0 0 var(--a4-accent);
}

.a4-suggest-none {
    padding: var(--a4-space-2) var(--a4-space-3);
    color: var(--a4-muted);
}

.a4-suggest-all {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0 var(--a4-space-2);
    padding: var(--a4-space-2) var(--a4-space-3);
    font-weight: var(--a4-weight-strong);
    color: var(--a4-accent-text);
    cursor: pointer;
    border-top: 1px solid var(--a4-line);
}

.a4-suggest-all .a4-suggest-title {
    color: inherit;
}

/* a phone: the entries large enough to touch */
@media (pointer: coarse) {
    .a4-suggest-item > a,
    .a4-suggest-all {
        min-height: 44px;
        box-sizing: border-box;
        align-items: center;
    }
}

@media (forced-colors: active) {
    .a4-suggest-item[aria-selected="true"] > a,
    .a4-suggest-item > a:hover,
    .a4-suggest-all[aria-selected="true"],
    .a4-suggest-all:hover {
        outline: 2px solid Highlight;
        outline-offset: -2px;
    }
    .a4-suggest mark {
        color: MarkText;
        background: Mark;
    }
}

/* ---- Results -------------------------------------------------------------------------------------------------- */

/* The page: the words on top; below them the filter bar and the results side by side when the page is wide enough
   (the filters at the start, as narrow as a list of checkboxes allows), else the filters above the results as a
   grid of fields. Sized by the page's own width (a container), not the window's: the admin's side columns may be
   open or closed. */
.a4-search-form { container-type: inline-size; }
.a4-search-query { margin: 0 0 var(--a4-space-3); }
.a4-search-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--a4-space-3); align-items: start; }
@container (min-width: 820px) {
  .a4-search-columns { grid-template-columns: minmax(200px, 240px) minmax(0, 1fr); }
  .a4-search-filters { position: sticky; top: var(--a4-space-3); max-height: calc(100vh - 2 * var(--a4-space-3)); overflow-y: auto; }
}

/* The filter bar: a card of compact fields */
.a4-search-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  align-items: start;
  gap: var(--a4-space-2) var(--a4-space-3);
  padding: var(--a4-space-2) var(--a4-space-3);
  border: 1px solid var(--a4-line);
  border-radius: var(--a4-radius-s);
  background-color: var(--a4-card);
  font-size: var(--a4-text-s);
}
@container (min-width: 820px) {
  .a4-search-filters { grid-template-columns: minmax(0, 1fr); }
}
.a4-search-filters-head,
.a4-search-filters-foot { grid-column: 1 / -1; }
/* Folded on a narrow page (the script's "Show filters"): only the head; on a wide page there is nothing to fold */
@container (max-width: 819px) {
  .a4-search-filters.is-folded > :not(.a4-search-filters-head) { display: none; }
}
@container (min-width: 820px) {
  .a4-page .a4-search-filters-toggle { display: none !important; }
}
.a4-search-filters-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--a4-space-2); }
.a4-search-filters-head h2 { display: flex; align-items: center; gap: var(--a4-space-1); margin: 0; font-size: var(--a4-text-m); }
.a4-search-filters .a4-actions { display: flex; flex-wrap: wrap; gap: var(--a4-space-2); }
.a4-search-filters-foot { padding-top: var(--a4-space-2); border-top: 1px solid var(--a4-line); }
.a4-search-filter { gap: 2px; }
.a4-search-filter > legend,
.a4-search-filter > label { font-size: var(--a4-text-xs); }
.a4-search-filter select,
.a4-search-filter input[type="text"],
.a4-search-filter input[type="date"] { width: 100%; min-width: 0; max-width: 100%; }
.a4-search-filter .a4-check { align-items: center; gap: var(--a4-space-1); padding: 1px 0; line-height: var(--a4-leading-tight); }
.a4-search-filter .a4-check input { width: 15px; height: 15px; margin: 0; }
.a4-search-filters button[disabled] { cursor: default; opacity: .55; }

/* Content types by class group; a count is eZ Find's number of hits */
.a4-search-group + .a4-search-group { margin-top: var(--a4-space-1); }
.a4-search-group-name { margin: var(--a4-space-1) 0 0; color: var(--a4-muted); font-size: var(--a4-text-xs); }
.a4-search-count {
  margin-inline-start: auto;
  padding: 0 var(--a4-space-1);
  border-radius: var(--a4-radius-s);
  background-color: var(--a4-soft);
  color: var(--a4-muted);
  font-size: var(--a4-text-xs);
  font-variant-numeric: tabular-nums;
}
.a4-search-filter .a4-check > .a4-search-count { flex: none; }
.a4-search-more > summary { padding: 1px 0; color: var(--a4-accent-text); cursor: pointer; font-size: var(--a4-text-xs); }
.a4-search-range { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--a4-space-1) var(--a4-space-2); margin-top: var(--a4-space-1); }
.a4-search-range label { margin: 0; font-size: var(--a4-text-xs); font-weight: normal; }

/* The result header: "Results for “x” (n)" and the sort order on one line; the active filters below as chips */
.a4-search-main { min-width: 0; }
.a4-search-main > * + * { margin-top: var(--a4-space-2); }
.a4-search-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--a4-space-2) var(--a4-space-3); }
.a4-search-head h2 { margin: 0; font-size: var(--a4-text-l); overflow-wrap: anywhere; }
.a4-search-sort { display: flex; flex-wrap: wrap; align-items: center; gap: var(--a4-space-2); font-size: var(--a4-text-s); }
.a4-search-sort label { margin: 0; font-size: var(--a4-text-s); font-weight: normal; white-space: nowrap; }
.a4-search-chips { display: flex; flex-wrap: wrap; gap: var(--a4-space-1) var(--a4-space-2); }
a.a4-search-chip,
a.a4-search-chip:visited { gap: var(--a4-space-2); max-width: 100%; color: var(--a4-ink); white-space: normal; }
a.a4-search-chip:hover { border-color: var(--a4-accent); color: var(--a4-accent-text); }
a.a4-search-chip:focus-visible { outline: 3px solid var(--a4-ring); outline-offset: 1px; }
a.a4-search-chip .a4-icon { flex: none; width: 10px; height: 10px; }
.a4-search-empty { padding: var(--a4-space-3); border: 1px dashed var(--a4-line-strong); border-radius: var(--a4-radius-s); }
.a4-search-empty > * + * { margin-top: var(--a4-space-1); }
.a4-search-empty ul { margin: var(--a4-space-1) 0 0; padding-inline-start: var(--a4-space-5); }

/* The result table: dense rows; the name with its location, the words found and a PDF's pages under it */
.a4-search-table td { vertical-align: top; }
.a4-search-table .a4-search-select,
.a4-search-table .a4-search-type { width: 1%; padding-inline-end: 0; }
.a4-search-table .a4-search-name { min-width: 16em; }
.a4-search-table .a4-search-name > a { font-weight: var(--a4-weight-strong); overflow-wrap: anywhere; }
.a4-page .a4-search-table td > .a4-meta { white-space: normal; }   /* the path and the words found wrap (a table's .a4-meta does not) */
.a4-search-table .a4-search-path { display: block; color: var(--a4-muted); font-size: var(--a4-text-xs); overflow-wrap: anywhere; }
/* the words found: three lines at most (Solr's fragments can be long); cut by the box, never inside a mark */
.a4-search-table .a4-search-snippet { display: -webkit-box; margin-top: 2px; overflow: hidden; font-size: var(--a4-text-xs); overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; }
.a4-search-table .a4-search-pages { display: grid; gap: 2px; margin-top: 2px; font-size: var(--a4-text-xs); }
.a4-search-table mark { padding: 0 2px; border-radius: var(--a4-radius-s); background-color: var(--a4-warn-bg); color: var(--a4-ink); }
.a4-search-table .a4-search-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.a4-search-table .a4-search-languages a { margin-inline-end: var(--a4-space-1); font-family: var(--a4-mono); font-size: var(--a4-text-xs); }
.a4-search-table .a4-search-actions { width: 1%; text-align: end; white-space: nowrap; }
.a4-search-selection { display: flex; flex-wrap: wrap; gap: var(--a4-space-2); }
@container (max-width: 700px) {
  .a4-search-table th:nth-child(4), .a4-search-table td:nth-child(4),
  .a4-search-table th:nth-child(6), .a4-search-table td:nth-child(6) { display: none; }   /* modified and translations */
  .a4-search-table .a4-search-name { min-width: 0; }
}
@media (forced-colors: active) {
  .a4-search-table mark { background-color: Mark; color: MarkText; }
  .a4-search-count { border: 1px solid CanvasText; }
}
