

/* theme */

:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #f8f9fa;
    --text: #222222;
    --muted: #70757a;
    --border: #d2d4d8;  
    --link: LinkText;
    --link-visited: VisitedText;
    --switch-on: #222222;
    --switch-knob: #ffffff;
    --radius: 12px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #202124;
    --surface: #202124;
    --surface-alt: #2a2b2e;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #45484d;
    --link: #8ab4f8;
    --link-visited: #c58af9;
    --switch-on: #e8eaed;
    --switch-knob: #202124;
    color-scheme: dark;  
}


/* Reset box-sizing so padding never makes an element wider than its width */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    /* System font stack -- browser tries each until it finds one that's available */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--link);
    text-decoration: none;
}


/* Search box */

.search-form {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 20px;
}

.search-form label {
    /* visually hidden, still read by screen readers */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 1rem;
    padding: 10px 0;
}

/* hide the ugly browser delete button search box */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

/* for settings to be all the way tot he right */
.search-row {
    width: 100%;
}

/* on home page its in the top right corner fixed */
.search-row .settings {
    position: fixed;
    top: 17px;
    right: 24px;
}

.settings {
    position: relative;
    flex: 0 0 auto;
}

.settings[hidden],
.settings-panel[hidden] {
    display: none;
}

.settings-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.settings-button:focus-visible {
    outline: 2px solid var(--border);
}

.settings-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    min-width: 200px;
    padding: 6px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: left;
}

.setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 14px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* checkbox in settings menu */
.setting input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex: 0 0 auto;
    width: 34px;
    height: 20px;
    margin: 0;
    border-radius: 999px;
    background: var(--border);
    cursor: pointer;
}

.setting input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--switch-knob);
}

.setting input[type="checkbox"]:checked {
    background: var(--switch-on);
}

.setting input[type="checkbox"]:checked::after {
    left: 16px;
}

.setting input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--muted);
    outline-offset: 2px;
}


/* Home page */

.container {
    max-width: 640px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 20px 20vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.heading {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: normal;   /* same font as the rest of the page, just bigger */
    margin: 0;
}

.subheading {
    color: var(--muted);
    margin: 4px 0 32px;
}

.container .search-form {
    padding: 0 24px;
}

.container .search-input {
    font-size: 1.1rem;
    padding: 14px 0;
}

/* Error page's "Back" button */
.container > button {
    border: none; 
    background: none;
    padding: 0;
    cursor: pointer;
}

.container > button a {
    color: var(--link); 
    font: inherit;
}


/* Results page */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.topbar .search-form {
    max-width: 640px;
}

.topbar .settings {
    margin-left: auto;   /* push to the right edge of the topbar */
}

.logo {
    font-size: 1.5rem;
    white-space: nowrap;
    flex: 0 0 160px;   /* fixed so main's left margin can line results up with the search box */
    color: var(--text);   /* same dark grey as the home page heading, not link blue */
}

.logo:visited {
    color: var(--text);
}

main {
    max-width: 720px;
    /* line the results up with the search box on wide screens */
    margin: 0 0 0 calc(24px + 160px + 24px);   /* topbar padding + logo + gap */
    padding: 8px 24px 64px 0;
}

.summary {
    color: var(--muted);
    font-size: 0.875rem;
    margin: 12px 0 20px;
}

.search-result {
    padding: 16px 18px;
    margin: 0 -18px 8px;
    border-radius: var(--radius);
    animation: fade-in 0.3s ease both;
}

.search-result .url {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result h3 {
    margin: 2px 0 6px;
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1.3;
}

.search-result h3 a:visited {
    color: var(--link-visited);
}

/* the only hover effect: underline the blue result title */
.search-result h3 a:hover {
    text-decoration: underline;
}

.description {
    margin: 0;
    color: var(--text);
    font-size: 0.925rem;
    overflow-wrap: anywhere;
}

.description strong {
    font-weight: 700;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .search-result { animation: none; }
}

/* Search modes (All / Academic / Gov / News) */

/* search box and the mode links under it, as one block in the top bar */
.topbar .search-area {
    flex: 1 1 auto;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modes {
    display: flex;
    gap: 22px;
    padding-left: 20px;   /* line up with the text inside the search box */
}

.mode {
    color: var(--muted);
    font-size: 0.875rem;
    text-decoration: none;
}

.mode:visited {
    color: var(--muted);
}

.mode:hover {
    color: var(--text);
    text-decoration: underline;
}

.mode.active,
.mode.active:visited {
    color: var(--text);
    font-weight: 600;
}

@media (max-width: 800px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 16px;
    }
    .logo { text-align: center; flex-basis: auto; }
    /* the topbar stacks into a column here, so pin the gear to the top-right corner */
    .topbar .settings {
        position: absolute;
        top: 10px;
        right: 12px;
        margin: 0;
    }
    main {
        margin: 0 auto;
        padding: 8px 16px 48px;
    }
    .topbar .search-area {
        max-width: none;
    }
}


/* Endless scroll status */

.scroll-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    color: var(--muted);
    font-size: 0.9rem;
}

.scroll-status.end {
    border-top: 1px solid var(--border);
    margin-top: 16px;
    padding-top: 16px;
}

.scroll-status .retry {
    border: none;
    background: none;
    padding: 0;
    color: var(--link);
    font: inherit;
    cursor: pointer;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--muted);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* Pagination (fallback when JavaScript is off) */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 24px 0 48px;
    color: var(--muted);
}

.pagination[hidden] {
    display: none;
}

/* Plain text links, no outline */


.query-diagnostics {
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}

.timings {
    margin: 0.5rem 0;
}
