/* ==========================================================================
   Discovery Search page only (template-search-integration.php + assets/js/search.js)
   Uses the colour settings from main.css.

   Contents
     1. Search form
     2. Page layout (filters + results)
     3. Filters column
     4. Results toolbar and active filters
     5. Result items and details
     6. Pagination
     7. Cite window
     8. Small screens
   ========================================================================== */


/* 1. Page header with the search box
   Before a search: the title centred above a large search box.
   After a search (.has-search): the same header, shorter and aligned to the start.
   ========================================================================== */

.discovery__hero {
    position: relative;
    isolation: isolate;
    background: var(--c-brand-dark);
    color: #fff;
}
.discovery__hero-media { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.discovery__hero-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Darkens the photo evenly so the white text and the search box stand out (same as .page-hero) */
.discovery__hero--image::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(to top, rgba(5, 25, 43, .85) 0%, rgba(5, 25, 43, .65) 55%, rgba(5, 25, 43, .5) 100%);
}
.discovery__hero-inner { padding-block: clamp(2.25rem, 6vw, 4rem) clamp(1.75rem, 4vw, 2.5rem); }
.discovery__title {
    margin: 0;
    color: #fff;
    font-size: clamp(1.75rem, 1.2rem + 1.9vw, 2.6rem);
    letter-spacing: -.02em;
    text-align: center;
}
.discovery__lead {
    max-width: 60ch;
    margin: .6rem auto 0;
    color: rgba(255, 255, 255, .9);
    font-size: 1.075rem;
    text-align: center;
}

.dsearch { display: grid; gap: .75rem; max-width: 880px; margin: 1.5rem auto 0; }
/* The white box: field list + search words (one row per search row) + Search button */
.dsearch__box {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    padding: .5rem;
    border-radius: var(--radius-lg);
    background: var(--c-paper);
    box-shadow: var(--shadow);
}
.dsearch__rows { flex: 1; min-width: 0; display: grid; gap: .5rem; }
.dsearch__row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: .5rem;
}
.dsearch__row--extra { grid-template-columns: 90px 160px minmax(0, 1fr) 2.9rem; }
.dsearch__field, .dsearch__bool, .dsearch__input { min-height: 2.9rem; color: var(--c-ink); }
.dsearch__field, .dsearch__bool { background-color: var(--c-soft); font-size: .95rem; }
.dsearch__bool { font-weight: 600; }
.dsearch__input { padding: .65rem .9rem; font-size: 1.05rem; }
.dsearch__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-paper);
    color: var(--c-muted);
    cursor: pointer;
}
.dsearch__remove:hover { color: #b3261e; border-color: #b3261e; }
.dsearch__submit { flex: none; min-height: 2.9rem; padding-inline: 1.5rem; }
.dsearch__submit .icon { width: 1.1rem; height: 1.1rem; }

/* "Add a search row" and "Need help?" (opens the Help panel): outlined buttons on the dark header */
.dsearch__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.dsearch__action {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 2.25rem;
    padding: .4rem .85rem;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: var(--radius);
    background: none;
    color: #fff;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s, border-color .15s;
}
.dsearch__action:hover { border-color: #fff; background: rgba(255, 255, 255, .12); }
.dsearch__action:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 2px; }
.dsearch__action .icon { width: 1rem; height: 1rem; }
.dsearch__action--help { margin-inline-start: auto; }

/* After a search: shorter header, title above the full-width search box */
.has-search .discovery__hero-inner { padding-block: 1.5rem 1.25rem; }
.has-search .discovery__title { font-size: 1.5rem; text-align: start; }
.has-search .discovery__lead { display: none; }
.has-search .dsearch { max-width: none; margin-top: 1rem; }


/* 2. Before a search: trending searches and search tips. After: filters + results
   ========================================================================== */

.has-search [data-intro] { display: none; }
.discovery:not(.has-search) .discovery__body { display: none; }

/* Trending searches: a row under the header - heading with icon, then the searches as numbered buttons */
.trending { border-bottom: 1px solid var(--c-line); background: var(--c-soft); }
.trending__inner { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding-block: 1.1rem; }
.trending__title { display: inline-flex; align-items: center; gap: .55rem; margin: 0; color: var(--c-ink); font-size: .95rem; font-weight: 600; white-space: nowrap; }
.trending__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
    background: var(--c-brand);
    color: var(--c-on-brand);
}
.trending__icon .icon { width: 1.1rem; height: 1.1rem; }
.trending__list { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.trending__list a {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .75rem .35rem .4rem;
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-paper);
    color: var(--c-ink);
    font-size: .92rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color .15s, color .15s;
}
.trending__list a:hover { border-color: var(--c-brand); color: var(--c-brand); }
.trending__list a:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 2px; }
.trending__rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    border-radius: 3px;
    background: var(--c-brand-soft);
    color: var(--c-brand);
    font-size: .78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.trending__list a:hover .trending__rank { background: var(--c-brand); color: var(--c-on-brand); }
html[data-contrast="high"] .trending__list a { background: #000; }

.discovery__intro { padding-block: 2rem var(--section); }
.discovery__intro .login-prompt { margin: 0 auto 2rem; }

/* Search tips: one compact row, four cells separated by lines */
.search-tips__title { margin: 0 0 .75rem; font-size: 1.05rem; }
.search-tips__list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
    background: var(--c-paper);
}
.search-tip { padding: .9rem 1.1rem; }
.search-tip + .search-tip { border-inline-start: 1px solid var(--c-line); }
.search-tip__title { margin: 0 0 .2rem; color: var(--c-ink); font-size: .92rem; font-weight: 600; }
.search-tip__text { margin: 0; color: var(--c-muted); font-size: .9rem; line-height: 1.5; }
.search-tip__text bdi { white-space: nowrap; } /* an English example inside Arabic text stays on one line */

.discovery__body {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: start;
    padding-block: 2rem var(--section);
}


/* 3. Filters column
   ========================================================================== */

.filters {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-inline-end: .5rem;
    scrollbar-width: thin;
}
.filters__head {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    margin-bottom: .5rem;
}
.filters__title { margin: 0; font-size: 1.1rem; }
.filters__clear {
    margin-inline-start: auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--c-brand);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.filters__clear:hover { text-decoration: underline; }
.filters__close { display: none; }

.filters__group { padding-block: 1rem; border-top: 1px solid var(--c-line); }
.filters__group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 .65rem;
    color: var(--c-ink);
    font-size: .95rem;
    font-weight: 600;
}
summary.filters__group-title { cursor: pointer; list-style: none; margin: 0; }
summary.filters__group-title::-webkit-details-marker { display: none; }
summary.filters__group-title .icon { width: 1rem; height: 1rem; color: var(--c-muted); transition: transform .15s; }
details[open] > summary.filters__group-title { margin-bottom: .65rem; }
details[open] > summary.filters__group-title .icon { transform: rotate(180deg); }

.filters .check { font-size: .92rem; padding-block: .2rem; }
.filters .check + .check { margin-top: .15rem; }
.check__label { flex: 1; overflow-wrap: anywhere; }
.check__count { color: var(--c-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

.facet__values { list-style: none; margin: 0; padding: 0; }
.facet__values li + li { margin-top: .1rem; }
.facet__more {
    margin-top: .4rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--c-brand);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.facet__more:hover { text-decoration: underline; }

.year-range { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: end; }
.year-range label { display: grid; gap: .2rem; font-size: .85rem; color: var(--c-muted); font-weight: 400; }
.year-range input { padding: .45rem .55rem; }


/* 4. Results toolbar and active filters
   ========================================================================== */

.results__toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .75rem 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--c-line);
    scroll-margin-top: 1rem;
}
.results__status { margin: 0; color: var(--c-ink); font-weight: 600; }
.results__tools { display: flex; align-items: center; gap: .75rem; }
.results__sort { display: flex; align-items: center; gap: .5rem; font-size: .92rem; font-weight: 400; color: var(--c-muted); }
.results__sort select { width: auto; padding: .4rem .6rem; }
.results__filters-button { display: none; }

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
}
.active-filters li {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding-inline-start: .65rem;
    border: 1px solid var(--c-line);
    border-inline-start: 3px solid var(--c-brand);
    border-radius: 2px;
    background: var(--c-paper);
    font-size: .9rem;
}
.active-filters button {
    display: inline-flex;
    padding: .35rem .45rem;
    border: 0;
    background: none;
    color: var(--c-muted);
    cursor: pointer;
}
.active-filters button:hover { color: #b3261e; }
.active-filters .icon { width: .9rem; height: .9rem; }

.results__message { padding-block: 2rem; color: var(--c-muted); }
.results__message p { max-width: 55ch; }

.results__list { list-style: none; margin: 0; padding: 0; transition: opacity .15s; }
.is-loading .results__list,
.is-loading .active-filters,
.is-loading .pagination { opacity: .45; pointer-events: none; }

/* Loading: shown while a search runs (assets/js/search.js setLoading) */
.search-progress {
    position: relative;
    height: 3px;
    margin: -.25rem 0 1rem;
    overflow: hidden;
    border-radius: 999px;
    background: var(--c-brand-soft);
}
.search-progress::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    border-radius: inherit;
    background: var(--c-brand);
    animation: gl-progress 1.1s ease-in-out infinite;
}
@keyframes gl-progress {
    from { left: -40%; }
    to { left: 100%; }
}
.spinner,
.results__status.is-busy::before {
    content: "";
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -.15em;
    animation: gl-spin .7s linear infinite;
}
.results__status.is-busy::before { margin-inline-end: .55em; color: var(--c-brand); }
.dsearch__submit.is-busy { cursor: progress; opacity: .9; }
@keyframes gl-spin { to { transform: rotate(360deg); } }

/* Placeholder results while the first answer loads */
.is-loading .results__list:has(.result--skeleton) { opacity: 1; }
.result--skeleton { pointer-events: none; }
.result--skeleton > div { display: grid; gap: .6rem; align-content: start; }
.skeleton {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, #edf0f3 25%, #f7f9fa 37%, #edf0f3 63%);
    background-size: 400% 100%;
    animation: gl-shimmer 1.4s ease infinite;
}
.skeleton--cover { width: 72px; height: 96px; }
.skeleton--title { width: 70%; height: 1.15rem; }
.skeleton--line { width: 95%; height: .8rem; }
.skeleton--short { width: 45%; }
@keyframes gl-shimmer {
    from { background-position: 100% 0; }
    to { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    .search-progress::before { left: 0; width: 100%; opacity: .5; animation: none; }
    .spinner, .results__status.is-busy::before, .skeleton { animation: none; }
}


/* 5. Result items
   ========================================================================== */

.results__list { display: grid; gap: 1rem; margin-top: 1.25rem; }
.result {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    padding: 1.35rem 1.5rem;
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
    background: var(--c-paper);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, border-color .15s;
}
.result:hover { border-color: #c9d4de; box-shadow: var(--shadow); }
.result--image { grid-template-columns: 76px minmax(0, 1fr); }
.result__cover { width: 76px; height: auto; border-radius: 4px; box-shadow: 0 2px 8px rgba(19, 33, 46, .18); }
.result--skeleton { border-color: var(--c-line); box-shadow: none; }

.result__title { margin: 0 0 .35rem; font-size: 1.15rem; line-height: 1.35; }
.result__title-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--c-brand);
    font: inherit;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
}
.result__title-button:hover { text-decoration: underline; text-underline-offset: .18em; }

.result__authors, .result__source, .result__meta { margin: 0 0 .2rem; font-size: .92rem; }
.result__authors { color: var(--c-ink); }
.result__source { color: var(--c-muted); font-style: italic; }
.result__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .45rem; color: var(--c-muted); font-size: .85rem; }
/* Material type badge: colour by kind (search.js typeClass) */
.result__type {
    padding: .15rem .5rem;
    border-radius: var(--radius);
    background: var(--c-soft);
    color: var(--c-ink);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.result__type--book { background: #e8f1fb; color: #0b4a7d; }
.result__type--article { background: #e9f5ee; color: #1d6b3a; }
.result__type--news { background: #fdf3e1; color: #8a5a00; }
.result__year { font-variant-numeric: tabular-nums; }
html[data-contrast="high"] .result__type { background: #000; color: #fff; outline: 1px solid currentColor; }
.result__available { color: var(--c-success); font-weight: 500; }

.result__abstract {
    margin: .6rem 0 0;
    font-size: .95rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1rem; }
/* The buttons on each result: PDF (filled), View online, Cite, Save (outlined), Details (plain, at the end) */
.result__action {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 2.25rem;
    padding: .4rem .85rem;
    border: 1px solid #c9d4de;
    border-radius: 8px;
    background: var(--c-paper);
    color: var(--c-brand);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .15s, background-color .15s, color .15s, box-shadow .15s;
}
.result__action:hover { border-color: var(--c-brand); background: var(--c-brand-soft); color: var(--c-brand); text-decoration: none; }
.result__action:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 2px; }
.result__action .icon { flex: none; width: 1rem; height: 1rem; }
.result__action--primary { border-color: var(--c-brand); background: var(--c-brand); color: var(--c-on-brand); }
.result__action--primary:hover { border-color: var(--c-brand-dark); background: var(--c-brand-dark); color: var(--c-on-brand); }
/* Details opens the abstract and record fields: a quieter button at the end of the row */
.result__action.result__toggle { margin-inline-start: auto; border-color: transparent; background: none; color: var(--c-muted); }
.result__action.result__toggle:hover { border-color: transparent; background: var(--c-soft); color: var(--c-ink); }
.result__action.result__toggle[aria-expanded="true"] { color: var(--c-ink); }
/* Save (My Library): gold star once saved */
.result__save.is-saved { border-color: #e3c56d; background: #fdf8ea; color: var(--c-ink); }
.result__save.is-saved .icon { color: var(--c-accent); }
.result__save.is-saved:hover { border-color: var(--c-accent); background: #fbf0d0; color: var(--c-ink); }
.result__save:disabled { opacity: .6; cursor: progress; }
.results__library .icon { width: 1rem; height: 1rem; color: var(--c-accent); }
.saved-note {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 0 0 1rem;
    padding: .7rem 1rem;
    border: 1px solid #ecd9a3;
    border-radius: var(--radius-lg);
    background: #fdf8ea;
    color: var(--c-ink);
    font-size: .95rem;
}
.saved-note .icon { flex: none; width: 1.1rem; height: 1.1rem; color: var(--c-accent); }
.saved-note a { font-weight: 600; }
html[data-contrast="high"] .saved-note { border-color: var(--c-line); background: #000; }

.result__details {
    margin-top: 1rem;
    padding: 1.25rem;
    background: var(--c-soft);
    border-radius: var(--radius);
}
.result__loading { margin: 0; color: var(--c-muted); }
.result__links { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.result__full-abstract { font-size: .95rem; }
.result__fields { display: grid; gap: .5rem; margin: 1rem 0 0; font-size: .92rem; }
.result__fields div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 1rem; }
.result__fields dt { color: var(--c-muted); }
.result__fields dd { margin: 0; overflow-wrap: anywhere; }


/* 5b. Details panel: slides in from the side, same look as the Help panel (main.css)
   ========================================================================== */

.record-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(5, 25, 43, .35);
}
.record-panel {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    width: min(580px, 100%);
    background: var(--c-paper);
    box-shadow: -12px 0 40px rgba(5, 25, 43, .2);
    transform: translateX(100%);
    transition: transform .25s ease;
}
.record-panel.is-open { transform: none; }
.admin-bar .record-panel { top: 32px; }
@media (max-width: 782px) { .admin-bar .record-panel { top: 46px; } } /* the WordPress toolbar is taller there */
html.record-open { overflow: hidden; } /* the page behind does not scroll */

.record-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--c-line);
}
.record-panel__label { margin: 0; color: var(--c-muted); font-size: .9rem; font-weight: 600; }
.record-panel__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--c-line);
    border-radius: 50%;
    background: var(--c-paper);
    color: var(--c-ink);
    cursor: pointer;
}
.record-panel__close:hover { border-color: var(--c-brand); color: var(--c-brand); }
.record-panel__close .icon { width: 1.1rem; height: 1.1rem; }

.record-panel__body { flex: 1; overflow-y: auto; padding: 1.5rem; overscroll-behavior: contain; }
.record-panel__title { margin: 0 0 .5rem; color: var(--c-ink); font-size: 1.3rem; line-height: 1.35; }
.record-panel__summary .result__actions { margin-top: 1.1rem; }
.record-panel__links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.record-panel__more { margin-top: 1.5rem; }

/* Sections divided by a line: Abstract, About this item */
.record-panel__section { padding-top: 1.25rem; margin-top: 1.25rem; border-top: 1px solid var(--c-line); }
.record-panel__more > .record-panel__section:first-child { margin-top: 0; }
.record-panel__heading { margin: 0 0 .75rem; color: var(--c-ink); font-size: 1rem; }
.record-panel__abstract p { margin: 0 0 .75rem; font-size: .95rem; line-height: 1.65; }
.record-panel__abstract p:last-child { margin-bottom: 0; }

/* Record fields: label and value, one row each, separated by lines */
.record-panel__fields { margin: 0; font-size: .92rem; }
.record-panel__fields div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 1rem;
    padding-block: .65rem;
    border-top: 1px solid var(--c-line);
}
.record-panel__fields div:last-child { border-bottom: 1px solid var(--c-line); }
.record-panel__fields dt { color: var(--c-muted); }
.record-panel__fields dd { margin: 0; color: var(--c-ink); overflow-wrap: anywhere; white-space: pre-line; }

@media (max-width: 640px) {
    .record-panel__body { padding: 1.25rem 1rem; }
    .record-panel__fields div { grid-template-columns: 1fr; gap: .15rem; }
}


/* 6. Pagination
   ========================================================================== */

.pagination { margin-top: 2rem; }
.pagination ul { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.pagination a {
    display: inline-block;
    min-width: 2.6rem;
    padding: .5rem .75rem;
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    text-align: center;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}
.pagination a:hover { border-color: var(--c-brand); }
.pagination a[aria-current="page"] { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); font-weight: 600; }
.pagination__gap { padding: .5rem .25rem; color: var(--c-muted); }
.pagination__note { margin-top: 1rem; color: var(--c-muted); font-size: .9rem; }


/* 7. Cite window
   ========================================================================== */

.cite-dialog {
    width: min(640px, calc(100vw - 2rem));
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: var(--c-paper);
    color: var(--c-text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.cite-dialog::backdrop { background: rgba(10, 20, 30, .55); }
.cite-dialog__inner { display: grid; gap: 1rem; padding: 1.5rem; }
.cite-dialog__head { display: flex; justify-content: space-between; align-items: center; }
.cite-dialog__head h2 { margin: 0; font-size: 1.25rem; }
.cite-dialog__close { display: inline-flex; padding: .3rem; border: 0; background: none; color: var(--c-muted); cursor: pointer; }
.cite-dialog__style { display: flex; align-items: center; gap: .75rem; }
.cite-dialog__style select { width: auto; }
.cite-dialog__output {
    min-height: 5rem;
    padding: 1rem;
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-soft);
    font-size: .95rem;
    overflow-wrap: anywhere;
}
.cite-dialog__output p { margin: 0; }
.cite-dialog__output pre { margin: 0; white-space: pre-wrap; font-size: .85rem; }
.cite-dialog__foot { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; }
.cite-dialog__copied { color: var(--c-success); font-weight: 600; }


/* 8. Small screens: filters become a side panel
   ========================================================================== */

@media (max-width: 900px) {
    .discovery__body { grid-template-columns: minmax(0, 1fr); }
    .results__filters-button { display: inline-flex; }

    .filters {
        position: fixed;
        top: 0;
        bottom: 0;
        inset-inline-start: 0;
        z-index: 100;
        width: min(360px, 88vw);
        max-height: none;
        padding: 1.25rem;
        background: var(--c-paper);
        box-shadow: 0 0 0 100vmax rgba(10, 20, 30, 0);
        transform: translateX(-105%);
        transition: transform .2s, box-shadow .2s;
        visibility: hidden;
    }
    .filters-open .filters {
        transform: none;
        visibility: visible;
        box-shadow: 0 0 0 100vmax rgba(10, 20, 30, .5);
    }
    .filters__close {
        display: inline-flex;
        padding: .3rem;
        border: 0;
        background: none;
        color: var(--c-ink);
        cursor: pointer;
    }
    .filters__clear { margin-inline-start: auto; }
}

@media (max-width: 900px) {
    .search-tips__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-tip:nth-child(3) { border-inline-start: 0; }
    .search-tip:nth-child(n+3) { border-top: 1px solid var(--c-line); }
}

@media (max-width: 640px) {
    /* Search box: field list and words under each other, Search button full width below */
    .dsearch__box { flex-direction: column; align-items: stretch; }
    .dsearch__row { grid-template-columns: 1fr; }
    .dsearch__row--extra { grid-template-columns: 1fr 1fr 2.75rem; }
    .dsearch__row--extra .dsearch__input { grid-column: 1 / -1; grid-row: 2; }
    .dsearch__field, .dsearch__bool { min-height: 2.6rem; }
    .dsearch__submit { width: 100%; justify-content: center; }
    .dsearch__action--help { margin-inline-start: 0; }
    .search-tips__list { grid-template-columns: 1fr; }
    .search-tip + .search-tip { border-inline-start: 0; border-top: 1px solid var(--c-line); }
    .trending__inner { align-items: flex-start; flex-direction: column; }
    .result { padding: 1.1rem 1rem; }

    .result--image { grid-template-columns: 56px minmax(0, 1fr); }
    .result__actions { gap: .4rem; }
    .result__action { padding: .4rem .7rem; font-size: .875rem; }
    .result__cover { width: 56px; }
    .result__fields div { grid-template-columns: 1fr; gap: 0; }
    .results__tools { width: 100%; justify-content: space-between; }
}
