/* ============================================================
   valah search — Catppuccin Latte/Mocha with pride accents.

   Companion to valah.blog: same palette, same 4px radius, same
   rainbow rule used for post headers and tag underlines there.

   Loaded from <head> after sxng-ltr.min.css, but core's dark palette
   is `:root.theme-dark` (specificity 0,2,0), so every selector here is
   given one extra step (html:root… = 0,2,1) to win without !important.
   ============================================================ */

/* ---------- Catppuccin Latte (light) ---------- */
html:root,
html:root.theme-light {
  color-scheme: light;

  --radius: 4px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --v-bg: #e6e9ef;         /* mantle   */
  --v-raised: #eff1f5;     /* base     */
  --v-sunken: #dce0e8;     /* crust    */
  --v-ink: #4c4f69;        /* text     */
  --v-ink-rgb: 76, 79, 105;
  --v-ink-soft: #5c5f77;   /* subtext1 */
  --v-muted: #6c6f85;      /* subtext0 */
  --v-rule: #ccd0da;       /* surface0 */
  --v-accent: #8839ef;     /* mauve    */
  --v-accent-soft: #7287fd;/* lavender */
  --v-accent-ink: #eff1f5;
  --v-link: #1e66f5;       /* blue     */
  --v-link-visited: #8839ef;
  --v-url: #179299;        /* teal     */
  --v-error: #d20f39;      --v-error-bg: #f7dbe0;
  --v-warning: #df8e1d;    --v-warning-bg: #f6eedb;
  --v-success: #40a02b;    --v-success-bg: #e2f2dd;
  --v-shadow: 0 1px 2px rgba(76, 79, 105, .06), 0 4px 12px rgba(76, 79, 105, .08);
  --v-focus: rgba(136, 57, 239, .30);

  /* Pride progress, in Catppuccin hues — mirrors valah.blog's --pride. */
  --pride: linear-gradient(90deg,
    #d20f39, #fe640b, #df8e1d, #40a02b, #1e66f5, #8839ef);
}

/* ---------- Catppuccin Mocha (dark) ---------- */
html:root.theme-dark {
  color-scheme: dark;

  --v-bg: #1e1e2e;         /* base     */
  --v-raised: #313244;     /* surface0 */
  --v-sunken: #181825;     /* mantle   */
  --v-ink: #cdd6f4;        /* text     */
  --v-ink-rgb: 205, 214, 244;
  --v-ink-soft: #bac2de;   /* subtext1 */
  --v-muted: #a6adc8;      /* subtext0 */
  --v-rule: #45475a;       /* surface1 */
  --v-accent: #cba6f7;     /* mauve    */
  --v-accent-soft: #b4befe;/* lavender */
  --v-accent-ink: #1e1e2e;
  --v-link: #89b4fa;       /* blue     */
  --v-link-visited: #cba6f7;
  --v-url: #94e2d5;        /* teal     */
  --v-error: #f38ba8;      --v-error-bg: #2b1f2b;
  --v-warning: #f9e2af;    --v-warning-bg: #2a2731;
  --v-success: #a6e3a1;    --v-success-bg: #1f2b24;
  --v-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
  --v-focus: rgba(203, 166, 247, .35);

  --pride: linear-gradient(90deg,
    #f38ba8, #fab387, #f9e2af, #a6e3a1, #89b4fa, #cba6f7);
}

/* "auto" follows the OS preference */
@media (prefers-color-scheme: dark) {
  html:root.theme-auto {
    color-scheme: dark;

    --v-bg: #1e1e2e;
    --v-raised: #313244;
    --v-sunken: #181825;
    --v-ink: #cdd6f4;
    --v-ink-rgb: 205, 214, 244;
    --v-ink-soft: #bac2de;
    --v-muted: #a6adc8;
    --v-rule: #45475a;
    --v-accent: #cba6f7;
    --v-accent-soft: #b4befe;
    --v-accent-ink: #1e1e2e;
    --v-link: #89b4fa;
    --v-link-visited: #cba6f7;
    --v-url: #94e2d5;
    --v-error: #f38ba8;      --v-error-bg: #2b1f2b;
    --v-warning: #f9e2af;    --v-warning-bg: #2a2731;
    --v-success: #a6e3a1;    --v-success-bg: #1f2b24;
    --v-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
    --v-focus: rgba(203, 166, 247, .35);

    --pride: linear-gradient(90deg,
      #f38ba8, #fab387, #f9e2af, #a6e3a1, #89b4fa, #cba6f7);
  }
}

/* ---------- Map the palette onto SearXNG's own variables ----------
   One rule, all four theme classes: whichever one is active keeps
   enough specificity to override core's :root / :root.theme-dark. */
html:root,
html:root.theme-light,
html:root.theme-dark,
html:root.theme-auto {
  --color-base-font: var(--v-ink);
  --color-base-font-rgb: var(--v-ink-rgb);
  --color-base-background: var(--v-raised);
  --color-base-background-mobile: var(--v-bg);
  --color-url-font: var(--v-url);
  --color-url-visited-font: var(--v-link-visited);
  --color-header-background: var(--v-raised);
  --color-header-border: var(--v-rule);
  --color-footer-background: var(--v-bg);
  --color-footer-border: var(--v-rule);
  --color-sidebar-border: var(--v-rule);
  --color-sidebar-font: var(--v-ink);
  --color-sidebar-background: var(--v-raised);
  --color-backtotop-font: var(--v-ink-soft);
  --color-backtotop-border: var(--v-rule);
  --color-backtotop-background: var(--v-raised);
  --color-btn-background: var(--v-accent);
  --color-btn-font: var(--v-accent-ink);
  --color-show-btn-background: var(--v-muted);
  --color-show-btn-font: var(--v-raised);
  --color-search-border: var(--v-rule);
  --color-search-shadow: var(--v-shadow);
  --color-search-background: var(--v-raised);
  --color-search-font: var(--v-ink);
  --color-search-background-hover: var(--v-accent);
  --color-error: var(--v-error);
  --color-error-background: var(--v-error-bg);
  --color-warning: var(--v-warning);
  --color-warning-background: var(--v-warning-bg);
  --color-success: var(--v-success);
  --color-success-background: var(--v-success-bg);
  --color-categories-item-selected-font: var(--v-accent);
  --color-categories-item-border-selected: var(--v-accent);
  --color-autocomplete-font: var(--v-ink);
  --color-autocomplete-border: var(--v-rule);
  --color-autocomplete-shadow: var(--v-shadow);
  --color-autocomplete-background: var(--v-raised);
  --color-autocomplete-background-hover: var(--v-sunken);
  --color-answer-font: var(--v-ink-soft);
  --color-answer-background: var(--v-bg);
  --color-result-background: var(--v-raised);
  --color-result-border: var(--v-rule);
  --color-result-url-font: var(--v-url);
  --color-result-vim-selected: var(--v-sunken);
  --color-result-vim-arrow: var(--v-accent);
  --color-result-link-font: var(--v-link);
  --color-result-link-font-highlight: var(--v-accent);
  --color-result-link-visited-font: var(--v-link-visited);
  --color-result-publishdate-font: var(--v-muted);
  --color-result-engines-font: var(--v-muted);
  --color-result-search-url-border: var(--v-rule);
  --color-result-search-url-font: var(--v-ink-soft);
  --color-result-image-span-font: var(--v-ink-soft);
  --color-result-image-span-font-selected: var(--v-raised);
  --color-result-image-background: var(--v-raised);
  --color-result-keyvalue-col-table: var(--v-bg);
  --color-result-keyvalue-odd: var(--v-bg);
  --color-result-keyvalue-even: var(--v-raised);
  --color-result-detail-font: var(--v-ink);
  --color-result-detail-label-font: var(--v-muted);
  --color-result-detail-background: var(--v-raised);
  --color-result-detail-hr: var(--v-rule);
  --color-result-detail-link: var(--v-link);
  --color-settings-tr-hover: var(--v-sunken);
  --color-settings-engine-description-font: var(--v-muted);
  --color-settings-table-group-background: var(--v-bg);
  --color-toolkit-badge-font: var(--v-raised);
  --color-toolkit-badge-background: var(--v-muted);
  --color-toolkit-kbd-font: var(--v-raised);
  --color-toolkit-kbd-background: var(--v-ink-soft);
  --color-toolkit-dialog-border: var(--v-rule);
  --color-toolkit-dialog-background: var(--v-raised);
  --color-toolkit-tabs-label-border: var(--v-rule);
  --color-toolkit-tabs-section-border: var(--v-rule);
  --color-toolkit-select-background: var(--v-sunken);
  --color-toolkit-select-border: var(--v-rule);
  --color-toolkit-select-background-hover: var(--v-rule);
  --color-toolkit-input-text-font: var(--v-ink);
  --color-toolkit-checkbox-onoff-off-background: var(--v-rule);
  --color-toolkit-checkbox-onoff-on-background: var(--v-rule);
  --color-toolkit-checkbox-onoff-on-mark-background: var(--v-accent);
  --color-toolkit-checkbox-input-border: var(--v-rule);
  --color-toolkit-engine-tooltip-background: var(--v-raised);
  --color-toolkit-engine-tooltip-border: var(--v-rule);
  --color-favicon-background-color: var(--v-sunken);
  --color-favicon-border-color: var(--v-rule);
  --color-doc-code: var(--v-ink-soft);
  --color-doc-code-background: var(--v-sunken);
  --color-line-number: var(--v-muted);
  --color-bar-chart-primary: var(--v-accent);
  --color-bar-chart-secondary: var(--v-link);
}

/* ---------------- the theme itself ---------------- */

body {
  font-family: var(--font-sans);
}

/* The blog's 3px rainbow rule, reused as a top rib. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--pride);
  z-index: 1000;
}

::selection {
  background: var(--v-accent);
  color: var(--v-accent-ink);
}

a { text-underline-offset: 2px; }
a:hover { color: var(--v-accent-soft); }

:focus-visible {
  outline: 2px solid var(--v-accent);
  outline-offset: 2px;
}

/* ---- top-right nav ---- */
#links_on_top {
  font-family: var(--font-sans);
  font-size: .82rem;
}
#links_on_top a { color: var(--v-muted); }
#links_on_top a:hover { color: var(--v-accent); }

/* ---- index wordmark: pride gradient, like the blog's masthead ----
   Core paints the stock SearXNG logo as a background on .title and hides
   the h1; drop both so the instance name is the masthead. */
.index .title {
  background-image: none;
  min-height: 0;
  margin: 2.2rem auto 1.6rem;
}
.index h1 { visibility: visible; }
.index .title h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2.1rem, 6vw, 3rem);
  letter-spacing: -.025em;
  line-height: 1.1;
  margin: .1em 0 .7em;
  /* Hug the text so the gradient spans exactly the wordmark, not the page. */
  width: fit-content;
  margin-inline: auto;
  padding-bottom: .08em;
  background-image: var(--pride);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .index .title h1 { color: var(--v-ink); -webkit-text-fill-color: currentColor; }
}

/* ---- results page header keeps the compact core layout ---- */
#search_header .logo img,
#search_header .logo svg { opacity: .9; }

/* ---- search box ---- */
.search_box {
  border-radius: var(--radius);
  box-shadow: var(--v-shadow);
  transition: box-shadow .15s ease;
}
.search_box:focus-within {
  box-shadow: 0 0 0 3px var(--v-focus), var(--v-shadow);
}
#q {
  border-radius: var(--radius) 0 0 var(--radius);
  font-family: var(--font-sans);
  caret-color: var(--v-accent);
}
#send_search {
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: background-color .15s ease;
}
#clear_search { color: var(--v-muted); }

/* ---- category tabs: pride underline on the active one ---- */
button.category {
  font-family: var(--font-sans);
  border-radius: var(--radius) var(--radius) 0 0;
}
button.category.selected {
  border-bottom-color: transparent;
  background-image: var(--pride);
  background-size: 100% 2px;
  background-position: bottom;
  background-repeat: no-repeat;
}

/* ---- results: serif titles to echo the blog ---- */
#urls h3,
#urls .title,
.result h3 {
  font-family: var(--font-serif);
  letter-spacing: -.01em;
}
#urls .content { font-family: var(--font-sans); }

/* ---- footer ---- */
footer {
  font-family: var(--font-sans);
  font-size: .8rem;
  border-top: 1px solid var(--v-rule);
}
footer a { color: var(--v-muted); }
footer a:hover { color: var(--v-accent); }

@media (prefers-reduced-motion: reduce) {
  .search_box, #send_search { transition: none; }
}
