/*
 * In-house search: the field and live results of the header, and the
 * results page (search.php of the theme). Colours from
 * Docs/identite-visuelle/tokens.json; dark mode through html.darkClass.
 */
.cw-search-form {
    --cws-surface: #FFFFFF;
    --cws-muted: #E9ECEF;
    --cws-text: #495057;
    --cws-strong: #15171A;
    --cws-secondary: #697182;
    --cws-border: #C7D6DE;
    --cws-accent: #4672D6;
    --cws-hover: rgba(70, 114, 214, .10);
    margin: 0;
}
html.darkClass .cw-search-form,
html.darkClass .cw-search-page {
    --cws-surface: #343A40;
    --cws-muted: #21252A;
    --cws-text: #B0BEC5;
    --cws-strong: #FFFFFF;
    --cws-secondary: #ADB6BD;
    --cws-border: #495057;
    --cws-hover: rgba(70, 114, 214, .22);
}

/* The field */
/* Full width of the panel, as the old search bar (the .search-form margins of the theme). */
.cw-search-field {
    position: relative;
    display: flex;
    align-items: center;
}
.cw-search-field > .fa-magnifying-glass {
    position: absolute;
    left: 18px;
    color: #697182;
    font-size: 18px;
    pointer-events: none;
}
.cw-search-form input[type="search"] {
    width: 100%;
    box-sizing: border-box;
    height: 54px;
    margin: 0;
    padding: 0 52px 0 50px;
    border: 1px solid var(--cws-border);
    border-radius: 8px;
    background: #FFFFFF;
    color: #15171A;
    font-size: 18px;
    line-height: 54px;
    -webkit-appearance: none;
    appearance: none;
}
html.darkClass .cw-search-form input[type="search"] {
    background: #15171A;
    color: #FFFFFF;
}
/* No blue ring: the field keeps its own border when focused, as the site's other inputs. */
.cw-search-form input[type="search"]:focus {
    outline: none;
    box-shadow: none;
}
.cw-search-form input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.cw-search-clear {
    position: absolute;
    right: 8px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #697182;
    font-size: 18px;
    cursor: pointer;
}
.cw-search-clear:hover { background: rgba(105, 113, 130, .15); }
.cw-search-clear[hidden] { display: none; }

/* Live results */
/* No scroll box of its own: the panel grows and the page scrolls, one scrollbar only. */
.cw-search-results {
    margin: 12px 0 0;
    overflow: hidden;
    border-radius: 8px;
    background: var(--cws-surface);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    text-align: left;
}
.cw-search-results[hidden] { display: none; }
.cw-search-status {
    margin: 0;
    padding: 18px 20px;
    color: var(--cws-secondary);
    font-style: italic;
}
.cw-search-group { padding: 6px 0; border-bottom: 3px solid var(--cws-muted); }
.cw-search-group-title {
    display: flex;
    justify-content: space-between;
    padding: 8px 20px 4px;
    color: var(--cws-secondary);
    font-size: .75em;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-decoration: none;
}
.cw-search-group-title:hover { color: var(--cws-accent); }
.cw-search-all {
    display: block;
    padding: 14px 20px;
    color: var(--cws-accent);
    font-weight: 700;
    text-decoration: none;
}
.cw-search-all:hover,
.cw-search-all.is-active { background: var(--cws-hover); }

/* A row: picture, title, the line under it */
.cw-search-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 20px;
    color: var(--cws-text);
    text-decoration: none;
}
.cw-search-item,
.cw-search-all { transition: background-color .1s ease; } /* the theme animates every link for .2s */
.cw-search-item:hover,
.cw-search-item.is-active { background: var(--cws-hover); }
.cw-search-item.is-active { box-shadow: inset 3px 0 0 var(--cws-accent); }
.cw-search-thumb {
    display: flex;
    flex: 0 0 48px;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--cws-muted);
    color: var(--cws-secondary);
    font-size: 18px;
}
.cw-search-thumb img { width: 100%; height: 100%; object-fit: contain; }
.cw-search-thumb.is-logo { background-color: #495057; color: #FFFFFF; }
.cw-search-thumb.is-logo img { box-sizing: border-box; padding: 5px; }
.cw-search-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.35; }
.cw-search-title,
.cw-search-meta { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cw-search-title { color: var(--cws-strong); font-weight: 600; }
.cw-search-meta { color: var(--cws-secondary); font-size: .85em; }

@media (max-width: 640px) {
    .search-form-container .search-form { margin: 0 16px; }
    .cw-search-item { padding: 8px 14px; }
    .cw-search-group-title { padding: 8px 14px 4px; }
}

/* Results page */
.cw-search-page {
    --cws-surface: #FFFFFF;
    --cws-muted: #E9ECEF;
    --cws-text: #495057;
    --cws-strong: #15171A;
    --cws-secondary: #697182;
    --cws-border: #C7D6DE;
    --cws-accent: #4672D6;
    --cws-hover: rgba(70, 114, 214, .10);
    box-sizing: border-box;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 50px 60px;
}
.cw-search-page .entry-title { margin: 0 0 20px; }
.cw-search-page .cw-search-form { margin-bottom: 24px; }
.cw-search-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 24px;
    padding: 0;
    list-style: none;
}
.cw-search-tabs a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--cws-surface);
    color: var(--cws-text);
    font-weight: 600;
    text-decoration: none;
}
.cw-search-tabs a span { margin-left: 6px; color: var(--cws-secondary); font-weight: 400; }
.cw-search-tabs a:hover { color: var(--cws-accent); }
.cw-search-tabs a[aria-current="page"] { background: var(--cws-accent); color: #FFFFFF; }
.cw-search-tabs a[aria-current="page"] span { color: rgba(255, 255, 255, .8); }
.cw-search-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 30px;
}
.cw-search-list .cw-search-item {
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--cws-surface);
}
.cw-search-list .cw-search-thumb { flex-basis: 64px; width: 64px; height: 64px; }
.cw-search-empty { color: var(--cws-secondary); }
@media (max-width: 900px) {
    .cw-search-page { padding: 24px 16px 40px; }
    .cw-search-list { grid-template-columns: minmax(0, 1fr); }
}
