/* Google Custom Search (Programmable Search Engine) */

/*
 * The widget brings its own light styles (white result boxes, black text). The rules below
 * use the theme variables, so they follow the theme that layout.twig and theme.js set on
 * <html data-theme="…">: the visitor's saved choice, else the system preference. The
 * autocomplete dropdown (table.gssb_c) is appended to <body>, outside .gsc-control-cse.
 */

td.gsc-search-button {
  margin: 0;
}

button.gsc-search-button {
  padding: 10.5px;
  background: var(--main-nav-bg);
  border-color: var(--main-nav-bg);
}

.gsc-modal-background-image {
  background-color: black !important;
}

.gsc-above-wrapper-area-container {
  margin-top: 1rem !important;
}

.gsc-results-wrapper-overlay[style*="display: block"] {
  background-color: rgba(0, 0, 0, 0.85) !important;
}

/* Autocomplete suggestions */
table.gstl_50[style*="display: table"],
table.gssb_c[style*="display: table"] {
  margin-top: 2px !important;
  background-color: var(--post-bg) !important;
  border: 1px solid var(--post-border) !important;
}

table.gssb_c,
div.gssb_c[style] {
  background-color: var(--post-bg) !important;
  box-shadow: none !important;
}

/* The dropdown is a table (Google paints it white with a grey border) of rows with an inner
   table per suggestion: colour the whole row, not just the inner cell. */
table.gsc-completion-container {
  background: var(--post-bg) !important;
  border-color: var(--post-border) !important;
}

.gssb_a,
.gssb_a td,
.gssb_e,
.gssb_l,
.gssb_m {
  background: var(--post-bg) !important;
}

.gsc-completion-container .gssb_a,
.gsc-completion-container .gssb_a * {
  color: var(--text-color) !important;
}

.gsc-completion-container .gsc-completion-selected,
.gsc-completion-container .gsc-completion-selected td,
.gsc-completion-container .gssb_a:hover,
.gsc-completion-container .gssb_a:hover td {
  background: var(--pagination-bg) !important;
}

html[data-theme="dark"] .gsc-completion-container .gsc-completion-selected,
html[data-theme="dark"] .gsc-completion-container .gsc-completion-selected td,
html[data-theme="dark"] .gsc-completion-container .gssb_a:hover,
html[data-theme="dark"] .gsc-completion-container .gssb_a:hover td {
  background: var(--post-header-bg) !important;
}

/* Dark theme */

html[data-theme="dark"] .gsc-control-cse,
html[data-theme="dark"] .gsc-results-wrapper-overlay {
  background-color: var(--container-bg) !important;
  border-color: var(--post-border) !important;
}

html[data-theme="dark"] .gsc-results-wrapper-overlay {
  border: none !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .gsc-input-box,
html[data-theme="dark"] input.gsc-input {
  background: var(--post-bg) !important;
  border-color: var(--post-border) !important;
  color: var(--text-color) !important;
}

html[data-theme="dark"] .gsc-search-button-v2 {
  background-color: var(--main-nav-bg) !important;
  border-color: var(--post-border) !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-results,
html[data-theme="dark"] .gsc-control-cse .gsc-tabsArea,
html[data-theme="dark"] .gsc-control-cse .gsc-tabsAreaInvisible,
html[data-theme="dark"] .gsc-control-cse .gsc-tabHeader,
html[data-theme="dark"] .gsc-control-cse .gsc-tabHeader.gsc-tabhActive,
html[data-theme="dark"] .gsc-control-cse .gsc-tabHeader.gsc-tabhInactive,
html[data-theme="dark"] .gsc-control-cse .gsc-above-wrapper-area,
html[data-theme="dark"] .gsc-control-cse .gsc-orderby-container,
html[data-theme="dark"] .gsc-control-cse .gsc-cursor-box,
html[data-theme="dark"] .gsc-control-cse .gsc-webResult.gsc-result,
html[data-theme="dark"] .gsc-control-cse .gsc-webResult.gsc-result:hover,
html[data-theme="dark"] .gsc-control-cse .gs-webResult.gs-result,
html[data-theme="dark"] .gsc-control-cse .gs-no-results-result,
html[data-theme="dark"] .gsc-control-cse .gs-no-results-result .gs-snippet {
  background-color: transparent !important;
  border-color: transparent !important;
  color: var(--text-color) !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-webResult.gsc-result {
  border-bottom: 1px solid var(--post-border) !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-tabHeader.gsc-tabhActive {
  border-bottom-color: var(--text-color) !important;
}

html[data-theme="dark"] .gsc-control-cse .gs-result .gs-title,
html[data-theme="dark"] .gsc-control-cse .gs-result .gs-title *,
html[data-theme="dark"] .gsc-control-cse .gs-spelling a {
  color: #9db8f5 !important;
}

html[data-theme="dark"] .gsc-control-cse .gs-result a.gs-title:visited,
html[data-theme="dark"] .gsc-control-cse .gs-result a.gs-title:visited * {
  color: #c3a8f0 !important;
}

html[data-theme="dark"] .gsc-control-cse .gs-result .gs-snippet,
html[data-theme="dark"] .gsc-control-cse .gs-result .gs-snippet b,
html[data-theme="dark"] .gsc-control-cse .gsc-result-info,
html[data-theme="dark"] .gsc-control-cse .gsc-orderby-label,
html[data-theme="dark"] .gsc-control-cse .gsc-tabHeader,
html[data-theme="dark"] .gsc-control-cse .gs-spelling,
html[data-theme="dark"] .gsc-control-cse .gcsc-find-more-on-google {
  color: var(--text-color) !important;
}

html[data-theme="dark"] .gsc-control-cse .gs-visibleUrl,
html[data-theme="dark"] .gsc-control-cse .gs-visibleUrl-breadcrumb,
html[data-theme="dark"] .gsc-control-cse .gs-visibleUrl * {
  color: var(--muted-text-color) !important;
}

html[data-theme="dark"] .gsc-control-cse .gcsc-find-more-on-google-magnifier {
  fill: var(--text-color) !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-cursor-page {
  background-color: transparent !important;
  color: var(--link-color) !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-cursor-current-page {
  color: var(--text-color) !important;
  font-weight: bold;
}

/* Sort order dropdown */
html[data-theme="dark"] .gsc-control-cse .gsc-selected-option-container {
  background: var(--post-bg) !important;
  background-image: none !important;
  border-color: var(--post-border) !important;
  color: var(--text-color) !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-option-menu-container,
html[data-theme="dark"] .gsc-control-cse .gsc-option-menu,
html[data-theme="dark"] .gsc-control-cse .gsc-option-menu-invisible,
html[data-theme="dark"] .gsc-control-cse .gsc-option-menu-item,
html[data-theme="dark"] .gsc-control-cse .gsc-option-selector {
  background: var(--post-bg) !important;
  border-color: var(--post-border) !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-option {
  color: var(--text-color) !important;
  padding: 0 6px !important;
  width: 100% !important;
}

html[data-theme="dark"] .gsc-control-cse .gsc-option-menu-item-highlighted,
html[data-theme="dark"] .gsc-control-cse .gsc-option-menu-item-highlighted .gsc-option {
  background: var(--main-nav-bg) !important;
  color: var(--main-text-color) !important;
}
