/* ---------------------------------------------------------------------------
   EXT:yacy frontend styles.

   This renders inside a site theme the extension knows nothing about, so apart
   from the accent every colour is mixed from currentColor - the text colour of
   whatever surrounds it. A light theme and a dark one both get sensible
   contrast without a media query, and an integrator can retheme the whole
   search by setting the custom properties below on any ancestor. Every colour
   has a plain fallback declaration first, for browsers without color-mix().
   --------------------------------------------------------------------------- */

.tx-yacy-suggest,
.tx-yacy-content-domains,
.tx-yacy-active-filters,
.tx-yacy-facet-panel,
.tx-yacy-facets,
.tx-yacy-count,
.tx-yacy-results,
.tx-yacy-pagination {
    --tx-yacy-accent: #0b6ecf;
    --tx-yacy-line: rgba(128, 128, 128, .32);
    --tx-yacy-line: color-mix(in srgb, currentColor 22%, transparent);
    --tx-yacy-muted: rgba(128, 128, 128, .95);
    --tx-yacy-muted: color-mix(in srgb, currentColor 62%, transparent);
    --tx-yacy-surface: rgba(128, 128, 128, .07);
    --tx-yacy-surface: color-mix(in srgb, currentColor 5%, transparent);
    --tx-yacy-hover: rgba(128, 128, 128, .14);
    --tx-yacy-hover: color-mix(in srgb, currentColor 10%, transparent);
    --tx-yacy-radius: .5rem;
}

.tx-yacy-suggest :focus-visible,
.tx-yacy-content-domains :focus-visible,
.tx-yacy-active-filters :focus-visible,
.tx-yacy-facet-panel > :focus-visible,
.tx-yacy-facets :focus-visible,
.tx-yacy-results :focus-visible,
.tx-yacy-pagination :focus-visible {
    outline: 2px solid var(--tx-yacy-accent);
    outline-offset: 2px;
    border-radius: .2rem;
}

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

.tx-yacy-suggest {
    list-style: none;
    margin: 0;
    padding: .25rem;
    position: absolute;
    z-index: 10;
    min-width: 16rem;
    /* The dropdown floats over the page, so it cannot borrow a background the
       way the rest can - it needs an opaque one of its own. canvas/canvastext
       are the browser's own page colours and follow the reader's colour scheme;
       the plain declarations above them are the fallback for browsers without
       system colours. */
    background: #fff;
    color: #1a1a1a;
    background: canvas;
    color: canvastext;
    border: 1px solid var(--tx-yacy-line);
    border-radius: var(--tx-yacy-radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

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

.tx-yacy-suggest button {
    display: block;
    width: 100%;
    padding: .35rem .75rem;
    border: 0;
    border-radius: .3rem;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.tx-yacy-suggest button:hover,
.tx-yacy-suggest button:focus {
    background: var(--tx-yacy-hover);
}

/* --- Document kind: a segmented control ----------------------------------- */

.tx-yacy-content-domains {
    margin: 0 0 1.25rem;
}

.tx-yacy-content-domain-list {
    list-style: none;
    margin: 0;
    padding: .25rem;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    background: var(--tx-yacy-surface);
    border-radius: calc(var(--tx-yacy-radius) + .25rem);
}

.tx-yacy-content-domain a,
.tx-yacy-content-domain span {
    display: block;
    padding: .4rem 1rem;
    border-radius: var(--tx-yacy-radius);
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease;
}

.tx-yacy-content-domain a:hover {
    background: var(--tx-yacy-hover);
}

.tx-yacy-content-domain.active span {
    background: var(--tx-yacy-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

/* --- Applied filters ------------------------------------------------------ */

.tx-yacy-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin: 0 0 1.25rem;
}

.tx-yacy-active-filters-label {
    font-weight: 600;
    margin-right: .25rem;
}

.tx-yacy-active-filter {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .35rem .25rem .7rem;
    border: 1px solid var(--tx-yacy-line);
    border-radius: 2rem;
    background: var(--tx-yacy-surface);
    font-size: .9em;
    line-height: 1.5;
}

.tx-yacy-active-filter-facet {
    color: var(--tx-yacy-muted);
}

.tx-yacy-active-filter-value {
    font-weight: 600;
    /* A host or an author can be long; keep one chip from taking the whole row. */
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tx-yacy-active-filter-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    text-decoration: none;
    color: var(--tx-yacy-muted);
    line-height: 1;
    transition: background-color .15s ease, color .15s ease;
}

.tx-yacy-active-filter-remove:hover {
    background: var(--tx-yacy-accent);
    color: #fff;
    text-decoration: none;
}

/* --- Facets, as cards on a grid ------------------------------------------- */

/* The whole block folds away too, one level up from the categories. Its toggle
   is a button rather than a bare heading, so it does not read as a seventh
   category label. */
.tx-yacy-facet-panel-label {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin: 0 0 1rem;
    padding: .35rem .8rem;
    border: 1px solid var(--tx-yacy-line);
    border-radius: 2rem;
    background: var(--tx-yacy-surface);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    transition: background-color .15s ease;
}

.tx-yacy-facet-panel-label::-webkit-details-marker {
    display: none;
}

.tx-yacy-facet-panel-label:hover {
    background: var(--tx-yacy-hover);
}

.tx-yacy-facet-panel-label::after {
    content: "";
    width: .4rem;
    height: .4rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-.08em, -.08em);
    transition: transform .15s ease;
}

.tx-yacy-facet-panel[open] > .tx-yacy-facet-panel-label::after {
    transform: rotate(-135deg) translate(-.08em, -.08em);
}

/* Shut, the toggle carries the block's whole bottom margin. */
.tx-yacy-facet-panel:not([open]) > .tx-yacy-facet-panel-label {
    margin-bottom: 1.75rem;
}

.tx-yacy-facets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem;
    margin: 0 0 1.75rem;
}

.tx-yacy-facet {
    border: 1px solid var(--tx-yacy-line);
    border-radius: var(--tx-yacy-radius);
    padding: .85rem 1rem 1rem;
    min-width: 0;
    /* Folded cards should not keep the height of open ones, or a collapsed
       column leaves gaps in the grid. */
    align-self: start;
}

.tx-yacy-facet:not([open]) {
    padding-bottom: .85rem;
}

/* The label is the <summary> of a <details>, so it is the control that folds
   the category away. The default disclosure triangle is replaced by a chevron
   on the right, which sits better against the right aligned counts. */
.tx-yacy-facet-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin: 0 0 .5rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--tx-yacy-line);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tx-yacy-muted);
    cursor: pointer;
    list-style: none;
}

.tx-yacy-facet-label::-webkit-details-marker {
    display: none;
}

.tx-yacy-facet-label::after {
    content: "";
    flex: none;
    width: .45rem;
    height: .45rem;
    margin-right: .15rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-.1em, -.1em);
    transition: transform .15s ease;
}

.tx-yacy-facet[open] > .tx-yacy-facet-label::after {
    transform: rotate(-135deg) translate(-.1em, -.1em);
}

.tx-yacy-facet-label:hover {
    color: inherit;
}

/* Folded away, the rule under the label would read as a stray divider. */
.tx-yacy-facet:not([open]) > .tx-yacy-facet-label {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.tx-yacy-facet-elements {
    list-style: none;
    margin: 0;
    padding: 0;
    /* A peer can offer far more values than fit; scroll inside the card rather
       than letting one facet stretch the whole row. */
    max-height: 16rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.tx-yacy-facet-element {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    border-radius: .3rem;
    /* Sit flush with the card edge while still showing a full width hover. */
    margin: 0 -.4rem;
    padding: .05rem .4rem;
    transition: background-color .15s ease;
}

.tx-yacy-facet-element:hover {
    background: var(--tx-yacy-hover);
}

.tx-yacy-facet-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
    color: inherit;
}

a.tx-yacy-facet-name:hover {
    text-decoration: underline;
}

.tx-yacy-facet-count {
    flex: none;
    color: var(--tx-yacy-muted);
    font-size: .8em;
    font-variant-numeric: tabular-nums;
}

/* An applied value is not a link - mark it so it reads as the reason the list
   below it is short. */
.tx-yacy-facet-element.active {
    background: var(--tx-yacy-hover);
}

.tx-yacy-facet-element.active .tx-yacy-facet-name {
    font-weight: 700;
}

.tx-yacy-facet-element.active .tx-yacy-facet-name::before {
    content: "✓";
    margin-right: .3rem;
    color: var(--tx-yacy-accent);
}

/* --- Result list ---------------------------------------------------------- */

.tx-yacy-count {
    margin: 0 0 1rem;
    color: var(--tx-yacy-muted);
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
}

.tx-yacy-results {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 0 0 2rem;
}

.tx-yacy-result {
    min-width: 0;
}

.tx-yacy-result a {
    color: inherit;
}

.tx-yacy-result strong {
    font-size: 1.05rem;
    line-height: 1.35;
}

/* The URL is orientation, not prose: one line, clipped, and quiet enough that
   the title keeps the weight. */
.tx-yacy-result-url {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    color: var(--tx-yacy-muted);
    font-size: .82rem;
    text-decoration: none;
}

.tx-yacy-result-url:hover {
    text-decoration: underline;
}

.tx-yacy-result-description {
    margin-top: .25rem;
    /* Keep a long snippet to a readable measure and a predictable height. */
    max-width: 68ch;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Image hits: a grid of tiles rather than a column of full size images. The
   peer returns whatever the page linked, from a 16px favicon to an SVG with no
   intrinsic size, so every tile is a fixed box and the image is fitted into it. */
.tx-yacy-results--images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 1rem;
}

.tx-yacy-results--images .tx-yacy-result a {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    height: 100%;
    text-decoration: none;
    font-size: .82rem;
    line-height: 1.4;
    /* File names run long and have no spaces to break at. */
    overflow-wrap: anywhere;
}

.tx-yacy-results--images img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    /* contain, not cover: many hits are logos or diagrams that a crop ruins. */
    object-fit: contain;
    background: var(--tx-yacy-surface);
    border: 1px solid var(--tx-yacy-line);
    border-radius: var(--tx-yacy-radius);
    transition: border-color .15s ease;
}

.tx-yacy-results--images .tx-yacy-result a:hover {
    text-decoration: underline;
}

.tx-yacy-results--images .tx-yacy-result a:hover img {
    border-color: var(--tx-yacy-accent);
}

/* --- Pagination ----------------------------------------------------------- */

.tx-yacy-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    margin: 0 0 1.5rem;
    color: var(--tx-yacy-muted);
    font-size: .85rem;
}

.tx-yacy-pagination .paginator-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: .3rem .55rem;
    border: 1px solid transparent;
    border-radius: var(--tx-yacy-radius);
    color: inherit;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    transition: background-color .15s ease, color .15s ease;
}

.tx-yacy-pagination .paginator-page:hover {
    background: var(--tx-yacy-hover);
}

.tx-yacy-pagination .paginator-page.active {
    background: var(--tx-yacy-accent);
    border-color: var(--tx-yacy-accent);
    color: #fff;
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .tx-yacy-content-domain a,
    .tx-yacy-content-domain span,
    .tx-yacy-active-filter-remove,
    .tx-yacy-facet-element,
    .tx-yacy-facet-label::after,
    .tx-yacy-facet-panel-label,
    .tx-yacy-facet-panel-label::after,
    .tx-yacy-results--images img,
    .tx-yacy-pagination .paginator-page {
        transition: none;
    }
}
