/* ==========================================================================
   Arun Search — brand stylesheet
   https://search.arunkumar.works

   Loaded by Nginx (sub_filter injects a <link> before </head>) AFTER the
   stock simple-theme stylesheet, so same-specificity rules here win.

   NOTHING in the SearXNG image is modified. The simple theme exposes its
   whole palette as CSS custom properties on :root.theme-*, so the colour
   work below is just a variable re-map. Structural rules are kept minimal
   and additive so an image upgrade cannot break the site — worst case a
   rule stops applying and you get stock SearXNG.

   File: /usr/local/searxng/branding/arun-search.css
   Served at: /branding/arun-search.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Brand tokens
   -------------------------------------------------------------------------- */
:root {
  --brand-blue: #4d8dff;
  --brand-blue-strong: #2f6fe4;
  --brand-blue-soft: #85b3ff;
  --brand-blue-glow: rgba(77, 141, 255, 0.25);

  --brand-bg: #0e1320;
  --brand-surface: #161d2d;
  --brand-surface-2: #1c2438;
  --brand-border: #263149;
  --brand-fg: #dbe2f0;
  --brand-fg-muted: #93a0ba;

  --brand-radius: 12px;
  --brand-radius-lg: 26px;
  --brand-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* --------------------------------------------------------------------------
   2. Dark palette — re-maps the simple theme's own variables.
      Applies to the forced dark style, the black style, and to visitors
      whose OS is dark while the theme is left on "auto".
   -------------------------------------------------------------------------- */
:root.theme-dark,
:root.theme-black {
  --color-base-font: var(--brand-fg);
  --color-base-font-rgb: 219, 226, 240;
  --color-base-background: var(--brand-bg);
  --color-base-background-mobile: var(--brand-bg);

  --color-url-font: #7fbf9a;
  --color-url-visited-font: #b08ce8;

  --color-header-background: var(--brand-bg);
  --color-header-border: var(--brand-border);
  --color-footer-background: var(--brand-bg);
  --color-footer-border: var(--brand-border);

  --color-sidebar-border: var(--brand-border);
  --color-sidebar-font: var(--brand-fg);
  --color-sidebar-background: var(--brand-surface);

  --color-backtotop-font: var(--brand-fg);
  --color-backtotop-border: var(--brand-border);
  --color-backtotop-background: var(--brand-surface-2);

  --color-btn-background: var(--brand-blue);
  --color-btn-font: #ffffff;
  --color-show-btn-background: var(--brand-surface-2);
  --color-show-btn-font: var(--brand-fg);

  --color-search-border: var(--brand-border);
  --color-search-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --color-search-background: var(--brand-surface);
  --color-search-font: var(--brand-fg);
  --color-search-background-hover: var(--brand-blue);

  --color-error: #ff8080;
  --color-error-background: #3a1f22;
  --color-warning: #f0c674;
  --color-warning-background: #3a3222;
  --color-success: #74d99f;
  --color-success-background: #1d3327;

  --color-categories-item-selected-font: var(--brand-blue-soft);
  --color-categories-item-border-selected: var(--brand-blue);

  --color-autocomplete-font: var(--brand-fg);
  --color-autocomplete-border: var(--brand-border);
  --color-autocomplete-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  --color-autocomplete-background: var(--brand-surface);
  --color-autocomplete-background-hover: var(--brand-surface-2);

  --color-answer-font: var(--brand-fg);
  --color-answer-background: var(--brand-surface);

  --color-result-background: var(--brand-surface);
  --color-result-border: var(--brand-border);
  --color-result-url-font: var(--brand-fg-muted);
  --color-result-vim-selected: var(--brand-surface-2);
  --color-result-vim-arrow: var(--brand-blue);
  --color-result-description-highlight-font: #ffffff;
  --color-result-link-font: var(--brand-blue-soft);
  --color-result-link-font-highlight: #ffffff;
  --color-result-link-visited-font: #b08ce8;
  --color-result-publishdate-font: var(--brand-fg-muted);
  --color-result-engines-font: var(--brand-fg-muted);
  --color-result-search-url-border: var(--brand-border);
  --color-result-search-url-font: var(--brand-fg);
  --color-result-image-span-font: var(--brand-fg);
  --color-result-image-span-font-selected: #ffffff;
  --color-result-image-background: var(--brand-surface);

  --color-result-keyvalue-col-table: var(--brand-surface-2);
  --color-result-keyvalue-odd: var(--brand-surface);
  --color-result-keyvalue-even: var(--brand-surface-2);

  --color-result-detail-font: var(--brand-fg);
  --color-result-detail-label-font: var(--brand-fg-muted);
  --color-result-detail-background: var(--brand-surface-2);
  --color-result-detail-hr: var(--brand-border);
  --color-result-detail-link: var(--brand-blue-soft);

  --color-settings-tr-hover: var(--brand-surface-2);
  --color-settings-engine-description-font: var(--brand-fg-muted);
  --color-settings-table-group-background: rgba(255, 255, 255, 0.04);

  --color-toolkit-badge-font: #ffffff;
  --color-toolkit-badge-background: var(--brand-blue-strong);
  --color-toolkit-kbd-font: #ffffff;
  --color-toolkit-kbd-background: var(--brand-surface-2);
  --color-toolkit-dialog-border: var(--brand-border);
  --color-toolkit-dialog-background: var(--brand-surface);
  --color-toolkit-tabs-label-border: var(--brand-border);
  --color-toolkit-tabs-section-border: var(--brand-border);
  --color-toolkit-select-background: var(--brand-surface-2);
  --color-toolkit-select-border: var(--brand-border);
  --color-toolkit-select-background-hover: var(--brand-border);
  --color-toolkit-input-text-font: var(--brand-fg);
  --color-toolkit-checkbox-onoff-off-background: var(--brand-surface-2);
  --color-toolkit-checkbox-onoff-on-background: var(--brand-surface-2);
  --color-toolkit-checkbox-onoff-on-mark-background: var(--brand-blue);
  --color-toolkit-checkbox-onoff-on-mark-color: #ffffff;
  --color-toolkit-checkbox-onoff-off-mark-background: #5b678a;
  --color-toolkit-checkbox-onoff-off-mark-color: #ffffff;
  --color-toolkit-checkbox-label-background: var(--brand-surface-2);
  --color-toolkit-checkbox-label-border: var(--brand-border);
  --color-toolkit-checkbox-input-border: var(--brand-blue);
  --color-toolkit-engine-tooltip-border: var(--brand-border);
  --color-toolkit-engine-tooltip-background: var(--brand-surface-2);

  --color-doc-code: #cfe0ff;
  --color-doc-code-background: #1b2740;
  --color-bar-chart-primary: var(--brand-blue);
  --color-bar-chart-secondary: #6fd3c0;
  --color-line-number: var(--brand-fg-muted);
  --color-favicon-background-color: var(--brand-surface-2);
  --color-favicon-border-color: var(--brand-border);
}

:root.theme-black {
  --brand-bg: #000000;
  --brand-surface: #0d0f14;
  --brand-surface-2: #14171f;
}

@media (prefers-color-scheme: dark) {
  :root.theme-auto {
    --color-base-background: var(--brand-bg);
    --color-base-background-mobile: var(--brand-bg);
    --color-header-background: var(--brand-bg);
    --color-footer-background: var(--brand-bg);
    --color-result-background: var(--brand-surface);
    --color-search-background: var(--brand-surface);
    --color-btn-background: var(--brand-blue);
    --color-categories-item-selected-font: var(--brand-blue-soft);
    --color-categories-item-border-selected: var(--brand-blue);
    --color-result-link-font: var(--brand-blue-soft);
  }
}

/* Visitors who deliberately pick the light style still get the blue accent. */
:root.theme-light {
  --color-btn-background: var(--brand-blue-strong);
  --color-categories-item-selected-font: var(--brand-blue-strong);
  --color-categories-item-border-selected: var(--brand-blue-strong);
  --color-search-background-hover: var(--brand-blue-strong);
  --color-toolkit-checkbox-onoff-on-mark-background: var(--brand-blue-strong);
  --color-toolkit-checkbox-input-border: var(--brand-blue-strong);
}

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */
body {
  font-family: var(--brand-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   3b. Ambient background

   Two very low-opacity radial washes instead of a flat fill, so the page has
   depth without competing with the content. Fixed attachment keeps them from
   sliding around while scrolling results. Colour only -- no image request.
   -------------------------------------------------------------------------- */
:root.theme-dark body,
:root.theme-black body {
  background-color: var(--brand-bg);
  background-image:
    radial-gradient(900px 520px at 50% -5%, rgba(77, 141, 255, 0.10), transparent 70%),
    radial-gradient(700px 500px at 100% 100%, rgba(37, 86, 216, 0.07), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Stronger on the homepage, where there is space for it. */
:root.theme-dark body.index_endpoint,
:root.theme-black body.index_endpoint {
  background-image:
    radial-gradient(820px 520px at 50% 22%, rgba(77, 141, 255, 0.16), transparent 66%),
    radial-gradient(900px 500px at 50% 105%, rgba(37, 86, 216, 0.10), transparent 72%);
}

/* --------------------------------------------------------------------------
   4. Homepage — wordmark + hero search
   -------------------------------------------------------------------------- */
/* <body> is `display:flex; flex-direction:column`, so the hero just grows to
   fill whatever the footer leaves. The theme's `margin-top: 26vh` is dropped:
   combined with a min-height it pushed the page past 100vh and forced the
   vertical scrollbar. */
#main_index {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  padding: 2rem 1rem 3rem;
  box-sizing: border-box;
}

#main_index .index {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

/* The stock theme paints img/searxng.png as a background on .index .title
   and hides the h1 text with `visibility:hidden`. Clear that so the brand
   mark (::before) + wordmark (h1) + tagline (::after) can stack instead. */
#main_index .index .title {
  background: none;
  min-height: 0;
  margin: 0 auto;
}

/* Logo mark above the wordmark. */
#main_index .index .title::before {
  content: "";
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 1.1rem;
  background-image: url("/branding/logo.svg");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

/* h1 holds general.instance_name from settings.yml ("Arun Search"). */
#main_index .index .title::before {
  filter: drop-shadow(0 12px 28px rgba(77, 141, 255, 0.38));
}

#main_index .index .title h1 {
  background: linear-gradient(180deg, #ffffff 0%, #c3d4f2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 2.9rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 0.35rem;
  color: var(--color-base-font);
  visibility: visible;
  white-space: nowrap;
}

/* Tagline. Purely decorative — safe to change or delete. */
#main_index .index .title::after {
  content: "Search freely. Search privately.";
  display: block;
  font-size: 0.95rem;
  color: var(--brand-fg-muted);
  margin-bottom: 1.9rem;
}

#main_index .search_box {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.38);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius-lg);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#main_index .search_box:focus-within {
  border-color: var(--brand-blue);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.38), 0 0 0 3px var(--brand-blue-glow);
}

@media screen and (max-width: 50em) {
  #main_index .index .title h1 {
    font-size: 2.1rem;
  }
  #main_index .index .title::before {
    width: 52px;
    height: 52px;
  }
}

/* --------------------------------------------------------------------------
   5. Search box
   -------------------------------------------------------------------------- */
#q,
#send_search,
#clear_search {
  background-color: var(--color-search-background);
  border-color: var(--color-search-border);
}

#q:focus {
  outline: none;
}

.search_box:focus-within {
  box-shadow: 0 0 0 3px var(--brand-blue-glow);
  border-radius: var(--brand-radius-lg);
}

#send_search:hover,
#clear_search:hover {
  color: var(--brand-blue-soft);
}

/* Autocomplete dropdown */
.autocomplete {
  border-radius: var(--brand-radius);
  overflow: hidden;
}

.autocomplete ul li.active,
.autocomplete ul li:hover {
  color: var(--brand-blue-soft);
}

/* --------------------------------------------------------------------------
   6. Results header — replace the stock SearXNG mark with the brand wordmark
   -------------------------------------------------------------------------- */
/* The theme pins the logo grid column to a fixed 3rem, which clips any
   wordmark. `auto` lets the column size to the brand mark + text instead.
   Safe at every breakpoint: below 20rem the theme sets #search_logo to
   display:none, so the column simply collapses to zero. */
#search_header {
  grid-template-columns: auto minmax(0, 1fr);
}

#search_logo > svg {
  display: none;
}

#search_logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}

#search_logo::before {
  content: "";
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  background-image: url("/branding/logo.svg");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

#search_logo::after {
  content: "Arun Search";
  font-size: 1.18rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--color-base-font);
}

@media screen and (max-width: 50em) {
  #search_logo::after {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   7. Category tabs — pill style
   -------------------------------------------------------------------------- */
#categories .category_button,
#categories_container .category_button {
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

#categories input[type="checkbox"]:checked + .category_button,
#categories .category_button.selected {
  background-color: rgba(77, 141, 255, 0.14);
}

/* --------------------------------------------------------------------------
   8. Results
   -------------------------------------------------------------------------- */
article.result {
  border-radius: var(--brand-radius);
  transition: background-color 0.15s ease;
}

article.result:hover {
  background-color: var(--brand-surface-2);
}

article.result h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

article.result .engines span {
  border-radius: 999px;
}

#pagination .next_page button,
#pagination .previous_page button {
  border-radius: var(--brand-radius);
}

#sidebar .sidebar-collapsible,
#sidebar .answer,
#sidebar .infobox {
  border-radius: var(--brand-radius);
}

/* --------------------------------------------------------------------------
   9. Footer — About | Privacy | Contact | GitHub come from
      brand.custom.links in settings.yml
   -------------------------------------------------------------------------- */
footer {
  border-top: 1px solid var(--color-footer-border);
  padding: 1.6rem 1rem 2.2rem;
  font-size: 0.85rem;
  color: var(--brand-fg-muted);
}

/* Nginx injects <p class="brand-footer"> as the first child of <footer>.
   The stock paragraph (Powered by SearXNG - <version> / Source code /
   Issue tracker / Engine stats / custom links) is hidden in its favour.
   If the injection ever stops matching after an upgrade this rule simply
   finds nothing to hide and the stock footer reappears intact. */
footer > p:not(.brand-footer) {
  display: none;
}

.brand-footer {
  line-height: 1.9;
  margin: 0;
  text-align: center;
}

.brand-footer .brand-footer-line {
  display: block;
  color: var(--brand-fg-muted);
  letter-spacing: 0.01em;
}

.brand-footer .brand-footer-links {
  display: block;
  margin-top: 0.15rem;
}

.brand-footer .brand-footer-links a {
  padding: 0 0.3rem;
}

footer a {
  color: var(--brand-fg-muted);
  text-decoration: none;
  padding: 0 0.15rem;
}

footer a:hover {
  color: var(--brand-blue-soft);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   10. Top-right nav (About / Preferences)
   -------------------------------------------------------------------------- */
#links_on_top a:hover {
  color: var(--brand-blue-soft);
}

/* --------------------------------------------------------------------------
   11. Focus visibility (accessibility)
   -------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}


/* --------------------------------------------------------------------------
   12. Layout & responsiveness

   The stock theme has a hard gap in its responsive ladder: #results is laid
   out as 10rem margin + 45rem results + 5rem gap + 25rem sidebar + 2rem =
   87rem (1392px), but the breakpoint that switches to a single column is
   79.75em (1276px). Every viewport between 1276px and 1392px therefore
   overflows and shows a horizontal scrollbar. .page_with_header has the same
   flaw: a fixed `width: 85em` (1360px).

   Fixed below by making both containers centred and fluid, which also gives
   the header and the result column a shared alignment.
   -------------------------------------------------------------------------- */

/* Nothing may exceed the viewport.

   `overflow-x: clip` -- NOT `hidden`. Per spec, `overflow-x: hidden` with
   `overflow-y: visible` forces the computed overflow-y to `auto`, which turns
   <body> into its own scroll container and produces a SECOND scrollbar next
   to the document one. `clip` does no such thing. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* The theme pins `body { height: 100vh }`, so any content even one pixel
   taller than the viewport overflows and scrolls. `min-height` lets the page
   grow instead, while still filling the screen when content is short. */
body {
  height: auto;
  min-height: 100vh;
}

img,
svg,
video,
iframe,
table {
  max-width: 100%;
}

/* Long URLs and unbroken strings must wrap rather than widen the page. */
#urls,
article.result {
  min-width: 0;
}

article.result h3,
article.result .content,
article.result .url_wrapper,
.brand-footer {
  overflow-wrap: anywhere;
}

/* Full-bleed header bar with a centred inner row, so the rule under the
   header still spans the window while its content lines up with the results. */
#main_results form#search {
  background: var(--color-header-background);
  border-bottom: 1px solid var(--color-header-border);
}

#main_results #search_header {
  background: none;
  border-bottom: none;
}

@media screen and (min-width: 79.75em) {
  #main_results #search_header {
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.4em 1.5rem 0;
    column-gap: 1rem;
  }

  /* Fluid columns: the result column absorbs whatever is left after the
     sidebar, so this can no longer overflow at any width. */
  #main_results #results {
    grid-template-columns: minmax(0, 1fr) minmax(0, 22rem);
    gap: 0 2.5rem;
    max-width: 80rem;
    margin: 1.25rem auto 0;
    padding: 0 1.5rem;
    box-sizing: border-box;
  }
}

/* About / Preferences / Stats pages — replaces the fixed `width: 85em`. */
.page_with_header {
  width: auto;
  max-width: 80rem;
  margin: 2em auto;
  padding: 0 1.25rem;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   13. Brand header on the About / Preferences / Stats pages

   Those pages do not use #search_logo; they render
   <img class="logo" src="img/searxng.png">. Nginx swaps that anchor for the
   markup below (see sub_filter in the site config).
   -------------------------------------------------------------------------- */
.brand-header {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  text-decoration: none;
}

.brand-header img {
  width: 40px;
  height: 40px;
  display: block;
}

.brand-header span {
  font-size: 1.7rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  color: var(--color-base-font);
}

@media screen and (max-width: 50em) {
  .brand-header img {
    width: 32px;
    height: 32px;
  }
  .brand-header span {
    font-size: 1.35rem;
  }
}
