/* ==========================================================================
   Yandex-style theme for SearXNG — Results Page & Homepage
   ========================================================================== */

:root {
    --ya-red: #fc3f1d;
    --ya-red-hover: #e63616;
    --ya-blue: #1a0dab;
    --ya-blue-dark: #0d47a1;
    --ya-green: #006621;
    --ya-purple: #660099;
    --ya-black: #000;
    --ya-white: #fff;
    --ya-text: #333;
    --ya-text-light: #777;
    --ya-text-gray: #999;
    --ya-bg: #fff;
    --ya-bg-gray: #f5f5f5;
    --ya-bg-input: #f2f2f2;
    --ya-border: #e5e5e5;
    --ya-border-light: #eee;
    --ya-tab-active: #0054b9;
    --ya-tab-inactive: #5f6368;
    --ya-answer-bg: #fff9e6;
}

/* --- BASE (scoped, no global reset) --- */
html, body {
    font-family: "YS Text", "Yandex Sans Text", "Yandex Sans", Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: var(--ya-text);
    background: var(--ya-bg);
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--ya-red);
    text-decoration: underline;
}

a:visited {
    color: var(--ya-purple);
}

/* Hide nav on results page (shows on homepage for Preferences link) */
.results_endpoint #links_on_top {
    display: none;
}

/* Preferences link on homepage — make visible, override SearXNG span hiding */
.index_endpoint #links_on_top {
    position: absolute;
    top: 16px;
    right: 24px;
    z-index: 50;
}

.index_endpoint #links_on_top a {
    color: var(--ya-text-gray);
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.index_endpoint #links_on_top a:hover {
    color: var(--ya-red);
    background: var(--ya-bg-gray);
    text-decoration: none;
}

.index_endpoint #links_on_top span {
    display: inline !important;
}

.index_endpoint #links_on_top svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   HOMEPAGE
   ========================================================================== */

.homepage-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding-top: 15vh;
}

.yandex-logo {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 28px;
    font-style: italic;
}

.yandex-logo .letter-y,
.results-logo .letter-y {
    color: var(--ya-red);
}

.yandex-logo .other-letters,
.results-logo .other-letters {
    color: var(--ya-black);
}

/* Homepage search */
.search-form {
    width: 100%;
    max-width: 620px;
    padding: 0 16px;
}

.search-input-wrapper {
    display: flex;
    border: 2px solid var(--ya-border-light);
    border-radius: 12px;
    overflow: hidden;
    background: var(--ya-bg-input);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--ya-red);
    box-shadow: 0 0 0 3px rgba(252, 63, 29, 0.12);
    background: var(--ya-white);
}

.search-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 16px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--ya-text);
}

.search-input::placeholder {
    color: var(--ya-text-gray);
}

.search-button {
    padding: 14px 28px;
    background: var(--ya-red);
    color: var(--ya-white);
    border: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-button:hover {
    background: var(--ya-red-hover);
}

/* Homepage categories */
.categories-bar {
    display: flex;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.category-link {
    color: var(--ya-blue);
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 16px;
    transition: background 0.15s ease, color 0.15s ease;
}

.category-link:hover {
    background: var(--ya-bg-gray);
    text-decoration: none;
    color: var(--ya-red);
}

.category-link.active {
    background: rgba(252, 63, 29, 0.1);
    color: var(--ya-red);
    font-weight: 500;
}

/* ==========================================================================
   RESULTS HEADER
   ========================================================================== */

.results-header {
    background: var(--ya-bg);
    border-bottom: 1px solid var(--ya-border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.results-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.results-logo {
    font-size: 22px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    font-style: italic;
}

.results-logo:hover {
    text-decoration: none;
}

.results-search-form {
    flex: 1;
    max-width: 600px;
}

.results-search-input-wrapper {
    display: flex;
    border: 2px solid var(--ya-border-light);
    border-radius: 10px;
    overflow: hidden;
    background: var(--ya-bg-input);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.results-search-input-wrapper:focus-within {
    border-color: var(--ya-red);
    box-shadow: 0 0 0 2px rgba(252, 63, 29, 0.1);
    background: var(--ya-white);
}

.results-search-input {
    flex: 1;
    padding: 9px 14px;
    font-size: 15px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--ya-text);
}

.results-search-input::placeholder {
    color: var(--ya-text-gray);
}

.results-search-button {
    padding: 9px 22px;
    background: var(--ya-red);
    color: var(--ya-white);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.results-search-button:hover {
    background: var(--ya-red-hover);
}

/* ==========================================================================
   RESULTS TABS (categories)
   ========================================================================== */

.results-tabs {
    background: var(--ya-bg);
    border-bottom: 1px solid var(--ya-border);
}

.tabs-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.tab-link {
    padding: 10px 18px;
    color: var(--ya-tab-inactive);
    font-size: 14px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-link:hover {
    color: var(--ya-text);
    text-decoration: none;
}

.tab-link.active {
    color: var(--ya-tab-active);
    border-bottom-color: var(--ya-tab-active);
    font-weight: 500;
}

/* ==========================================================================
   RESULTS CONTAINER
   ========================================================================== */

.results-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    gap: 40px;
}

.results-main {
    flex: 1;
    max-width: 680px;
    min-width: 0;
}

/* Stats line */
.results-stats {
    font-size: 12px;
    color: var(--ya-text-light);
    margin-bottom: 20px;
}

/* ==========================================================================
   ANSWER BOX (instant answers)
   ========================================================================== */

.answer-box {
    background: linear-gradient(135deg, #fff9e6 0%, #fff 100%);
    border: 1px solid rgba(252, 63, 29, 0.2);
    border-left: 3px solid var(--ya-red);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.answer-box h3 {
    font-size: 16px;
    color: var(--ya-text);
    margin-bottom: 6px;
    font-weight: 500;
}

.answer-box a {
    font-size: 13px;
}

/* ==========================================================================
   INFOBOX
   ========================================================================== */

.infobox {
    background: var(--ya-bg-gray);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
}

.infobox h2 {
    font-size: 18px;
    margin-bottom: 8px;
    font-weight: 500;
}

.infobox img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
}

.infobox p {
    font-size: 14px;
    color: var(--ya-text);
    line-height: 1.5;
}

.infobox-urls a {
    display: inline-block;
    margin-right: 12px;
    font-size: 13px;
    color: var(--ya-blue);
}

/* ==========================================================================
   SUGGESTIONS
   ========================================================================== */

.suggestions {
    margin-bottom: 22px;
}

.suggestions h3 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--ya-text);
}

.suggestion-item {
    display: inline-block;
    padding: 7px 16px;
    margin: 0 6px 6px 0;
    background: var(--ya-bg-gray);
    border-radius: 18px;
    font-size: 13px;
    color: var(--ya-blue);
    transition: background 0.15s ease, color 0.15s ease;
}

.suggestion-item:hover {
    background: rgba(252, 63, 29, 0.08);
    color: var(--ya-red);
    text-decoration: none;
}

/* ==========================================================================
   RESULT ITEM (standard SearXNG classes: .result .result-*)
   ========================================================================== */

.result {
    margin-bottom: 24px;
    padding: 0 0 20px 0;
    border-bottom: 1px solid var(--ya-border-light);
}

.result:last-child {
    border-bottom: none;
}

/* URL line */
.result .url_wrapper,
.result .url_header {
    font-size: 13px;
    color: var(--ya-green) !important;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.result .url_wrapper .url_o1,
.result .url_wrapper .url_o2,
.result .url_header .url_o1,
.result .url_header .url_o2 {
    color: var(--ya-green);
}

/* Favicon in URL line */
.result .favicon img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Title */
.result h3 {
    font-size: 18px;
    line-height: 1.3;
    margin: 0 0 3px 0;
    font-weight: 400;
}

.result h3 a {
    color: var(--ya-blue);
    text-decoration: none;
}

.result h3 a:visited {
    color: var(--ya-purple);
}

.result h3 a:hover {
    color: var(--ya-red);
    text-decoration: underline;
}

/* Content snippet */
.result .content {
    font-size: 14px;
    color: var(--ya-text);
    line-height: 1.55;
    word-wrap: break-word;
    max-width: 680px;
}

.result .content .highlight {
    font-weight: 700;
}

.result .content:empty {
    display: none;
}

/* Engine badges */
.result .engines {
    margin-top: 8px;
    font-size: 11px;
    color: var(--ya-text-gray);
}

.result .engines span {
    display: inline-block;
    background: var(--ya-bg-gray);
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 4px;
}

/* Published date */
.result .published_date {
    font-size: 12px;
    color: var(--ya-text-light);
}

/* Cache link */
.result .cache_link {
    font-size: 12px;
    color: var(--ya-blue);
    margin-left: 6px;
}

/* ==========================================================================
   NO RESULTS
   ========================================================================== */

.no-results {
    padding: 40px 0 60px;
    text-align: center;
    color: var(--ya-text-light);
    font-size: 16px;
}

.no-results p {
    font-size: 16px;
    line-height: 1.5;
}

/* ==========================================================================
   PAGINATION
   ========================================================================== */

.pagination {
    display: flex;
    gap: 6px;
    margin-top: 36px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.pagination a,
.pagination .current {
    padding: 8px 14px;
    font-size: 15px;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.pagination a {
    color: var(--ya-blue);
}

.pagination a:hover {
    background: rgba(26, 13, 171, 0.06);
    text-decoration: none;
}

.pagination .current {
    color: var(--ya-text);
    font-weight: 700;
    background: transparent;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.results-sidebar {
    width: 300px;
    flex-shrink: 0;
}

.sidebar-widget {
    background: var(--ya-bg-gray);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.sidebar-widget h3 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--ya-text);
}

.sidebar-widget p {
    font-size: 13px;
    color: var(--ya-text);
    line-height: 1.5;
}

.sidebar-widget img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
}

.sidebar-widget a {
    font-size: 13px;
    color: var(--ya-blue);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

/* Hide standard SearXNG footer */
body > footer,
footer:not(.footer) {
    display: none;
}

/* Custom Yandex footer (from template) */
.footer {
    background: var(--ya-bg-gray);
    padding: 16px 0;
    margin-top: 40px;
    border-top: 1px solid var(--ya-border);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--ya-text-gray);
    flex-wrap: wrap;
    gap: 8px;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a,
.footer a {
    color: var(--ya-blue);
    font-size: 12px;
}

/* ==========================================================================
   DARK THEME
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --ya-blue: #5c9df5;
        --ya-blue-dark: #4dabe1;
        --ya-green: #4dabe1;
        --ya-purple: #c58af9;
        --ya-red: #fc3f1d;
        --ya-black: #d9d9d9;
        --ya-white: #1a1a1a;
        --ya-text: #d9d9d9;
        --ya-text-light: #888;
        --ya-text-gray: #888;
        --ya-bg: #1a1a1a;
        --ya-bg-gray: #242424;
        --ya-bg-input: #2a2a2a;
        --ya-border: #333;
        --ya-border-light: #333;
        --ya-tab-active: #5c9df5;
        --ya-tab-inactive: #888;
        --ya-answer-bg: #1a231a;
    }

    html, body {
        color-scheme: dark;
    }

    .results-header {
        background: #1a1a1a;
    }

    .results-tabs {
        background: #1a1a1a;
    }

    .search-input-wrapper:focus-within,
    .results-search-input-wrapper:focus-within {
        background: #333;
    }

    .answer-box {
        background: linear-gradient(135deg, #2a2a1a 0%, #1a1a1a 100%);
    }

    .infobox,
    .sidebar-widget,
    .footer {
        background: #242424;
    }

    .result {
        border-bottom-color: #333;
    }

    .suggestion-item {
        background: #2a2a2a;
    }

    .suggestion-item:hover {
        background: rgba(252, 63, 29, 0.12);
        color: var(--ya-red);
    }

    .result .engines span {
        background: #333;
        color: #888;
    }

    .pagination a:hover {
        background: rgba(92, 157, 245, 0.1);
    }

    .category-link.active {
        background: rgba(252, 63, 29, 0.15);
    }

    ::selection {
        background: rgba(252, 63, 29, 0.25);
    }
}

/* Light theme selection */
::selection {
    background: rgba(252, 63, 29, 0.15);
    color: inherit;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 900px) {
    .results-container {
        flex-direction: column;
        padding: 16px;
        gap: 24px;
    }

    .results-sidebar {
        width: 100%;
    }

    .results-main {
        max-width: 100%;
    }

    .results-header-inner {
        padding: 0 12px;
        gap: 12px;
    }

    .results-logo {
        font-size: 20px;
    }

    .tabs-inner {
        padding: 0 12px;
    }
}

@media (max-width: 640px) {
    html, body {
        font-size: 13px;
    }

    .results-header-inner {
        flex-wrap: wrap;
    }

    .results-logo {
        font-size: 20px;
    }

    .results-search-form {
        order: 3;
        max-width: 100%;
        width: 100%;
        flex-basis: 100%;
    }

    .tabs-inner {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 8px;
    }

    .tab-link {
        padding: 10px 14px;
        font-size: 13px;
    }

    .results-container {
        padding: 12px;
    }

    .result h3 {
        font-size: 16px;
    }

    .result h3 a {
        font-size: 16px;
    }

    .result .content {
        font-size: 13px;
    }

    .result .url_wrapper,
    .result .url_header {
        font-size: 12px;
    }

    .pagination a,
    .pagination .current {
        padding: 6px 10px;
        font-size: 13px;
    }

    /* Homepage */
    .homepage-container {
        padding-top: 10vh;
        padding-left: 12px;
        padding-right: 12px;
    }

    .yandex-logo {
        font-size: 36px;
    }

    .search-form {
        padding: 0;
    }

    .search-input {
        padding: 12px 14px;
        font-size: 15px;
    }

    .search-button {
        padding: 12px 20px;
        font-size: 15px;
    }
}

@media (max-width: 400px) {
    .yandex-logo {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .search-button {
        padding: 12px 16px;
    }

    .search-input {
        padding: 12px 10px;
    }

    .tabs-inner {
        gap: 0;
    }

    .tab-link {
        padding: 8px 10px;
        font-size: 12px;
    }
}
