/* Rings of Power - Custom Theme
 * Parchment, gold, and ember.
 * "Three Rings for the Elven-kings under the sky..."
 */

/* ============================================
   Global - Prevent Horizontal Overflow
   ============================================ */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

/* ============================================
   CSS Custom Properties - Parchment & Gold
   ============================================ */
:root {
  --sonar-primary: #8b6914;        /* deep gold (used for primary buttons) */
  --sonar-primary-hover: #b8860b;  /* lit gold on hover */
  --sonar-accent: #c4a557;         /* aged-gold accent */
  --rop-ember: #d4541a;            /* ember red-orange (active/glow) */
  --rop-realm-elven: #6c8fa3;      /* mithril-silver-blue */
  --rop-realm-dwarven: #a06330;    /* bronze */
  --rop-realm-men: #8a3a2a;        /* rust red */

  --bg-primary: #f5ecd5;            /* parchment cream */
  --bg-secondary: #ede1c0;          /* aged parchment */
  --bg-hover: #e3d4a3;              /* highlighted parchment */
  --bg-footer: #1a1208;             /* deep forge */

  --text-primary: #2b1d0a;          /* dark ink */
  --text-secondary: #4f3a1c;        /* faded ink */
  --text-muted: #8a7651;            /* aged ink */
  --text-inverse: #f5e6c4;          /* light gold on dark */

  --border-color: #c4a557;          /* gold border */
  --border-color-soft: #d8be75;     /* softer gold */
  --border-radius: 8px;
  --shadow-sm: 0 1px 3px rgba(91,58,8,0.18);
  --shadow-md: 0 4px 14px rgba(91,58,8,0.22);

  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-display: 'Cinzel', 'Trajan Pro', 'Cormorant Garamond', Georgia, serif;
}

.theme-dark {
  --sonar-primary: #e9c46a;
  --sonar-primary-hover: #fff3c4;
  --sonar-accent: #c4a557;

  --bg-primary: #14100a;
  --bg-secondary: #1f1810;
  --bg-hover: #2a2014;
  --bg-footer: #0a0604;

  --text-primary: #f5e6c4;
  --text-secondary: #c4a557;
  --text-muted: #8a7651;
  --text-inverse: #1a1208;

  --border-color: #5b3a08;
  --border-color-soft: #4a2f06;
}

/* ============================================
   Homepage
   ============================================ */
.index_endpoint {
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.index_endpoint #links_on_top {
  position: absolute;
  top: 0;
  right: 0;
}

.index_endpoint footer {
  margin-top: auto;
}

.index {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 2rem 1rem;
  margin-top: -3rem; /* Offset to visually center accounting for footer */
}

/* Logo */
.index .title {
  background: none !important;
  margin-bottom: 0.5rem;
}

.index .title h1 {
  visibility: visible !important;
  font-size: 0;
}

/* Homepage search form - contains both search input and categories */
.index .search_box {
  width: 90vw;
  max-width: 800px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  white-space: normal !important;
}

.index .search_box:focus-within {
  border-color: transparent !important;
  box-shadow: none !important;
}

/* Force input and button to stay together on same line */
.index #q {
  flex: 1 1 auto !important;
  min-width: 200px !important;
  max-width: calc(100% - 70px) !important;
  font-size: 1.1rem !important;
  padding: 1rem 1.25rem !important;
  background: var(--bg-primary) !important;
  border: 2px solid var(--border-color) !important;
  border-radius: 10px 0 0 10px !important;
  border-right: none !important;
  transition: border-color 0.2s !important;
}

.index #q:focus {
  outline: none !important;
  border-color: var(--sonar-primary) !important;
}

.index #send_search {
  flex: 0 0 auto !important;
  padding: 0.875rem 1.5rem !important;
  margin: 0 !important;
  border-radius: 0 10px 10px 0 !important;
  border: 2px solid var(--border-color) !important;
  border-left: none !important;
}

.index .search_box:focus-within #send_search {
  border-color: var(--sonar-primary) !important;
}

/* ============================================
   Landing Page Categories - Custom Implementation
   ============================================ */
.landing-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.25rem;
  width: 100%;
  flex: 0 0 100%;
}

.landing-category {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-soft);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.landing-category:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px rgba(184, 134, 11, 0.15);
}

.landing-category.active {
  background: var(--sonar-primary);
  border-color: var(--sonar-primary-hover);
  color: var(--text-inverse);
  box-shadow: 0 0 0 2px rgba(212, 84, 26, 0.25);
}

.landing-category[data-category="elven"].active { background: var(--rop-realm-elven); border-color: var(--rop-realm-elven); }
.landing-category[data-category="dwarven"].active { background: var(--rop-realm-dwarven); border-color: var(--rop-realm-dwarven); }
.landing-category[data-category="mortal-men"].active { background: var(--rop-realm-men); border-color: var(--rop-realm-men); }

.landing-category svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Search Box - All Pages
   ============================================ */
.search_box {
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search_box:focus-within {
  border-color: var(--sonar-primary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.theme-dark .search_box:focus-within {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Search input */
#q {
  font-size: 1rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  padding: 0.875rem 1rem;
}

#q::placeholder {
  color: var(--text-muted);
}

/* Search button */
#send_search {
  background: var(--sonar-primary);
  border: none;
  border-radius: 8px;
  margin: 5px;
  padding: 0.75rem 1.25rem;
  color: var(--text-inverse);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#send_search svg {
  color: var(--text-inverse);
  fill: var(--text-inverse);
  stroke: var(--text-inverse);
}

#send_search:hover {
  background: var(--sonar-primary-hover);
}

#send_search:active {
  transform: scale(0.98);
}

/* Clear button - circular X matching landing page */
#clear_search {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px !important;
  height: 24px !important;
  padding: 0 !important;
  margin-right: 0.5rem !important;
  background: var(--bg-hover) !important;
  border: 1px solid var(--border-color-soft) !important;
  border-radius: 50% !important;
  color: var(--text-secondary) !important;
  cursor: pointer !important;
}

#clear_search:hover {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

#clear_search svg {
  width: 14px !important;
  height: 14px !important;
}

/* ============================================
   Category Tabs
   ============================================ */
#categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0 0;
  padding: 0 1rem 1.5rem;
  overflow: visible;
}

/* Note: .index #categories styles removed - using custom .landing-categories instead */

#categories label,
#categories button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color-soft);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

#categories label:hover,
#categories button:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px rgba(184, 134, 11, 0.15);
}

#categories input:checked + label,
#categories button.active,
#categories label.active {
  background: var(--sonar-primary);
  border-color: var(--sonar-primary);
  color: var(--text-inverse);
}

#categories svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Results Page Header
   ============================================ */

/* Position About/Preferences in top-right - consistent on all pages */
/* Uses absolute positioning relative to the body (endpoint class) */
.results_endpoint #links_on_top {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
}


/* Search header - uses relative positioning for independent logo placement */
#search_header {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem 0;
  width: 100%;
  position: relative;
}

/* Row container: just for search box centering */
.search_row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* Sonar wordmark - absolutely positioned left relative to header */
#search_logo {
  position: absolute;
  left: 1.5rem;
  top: 1rem;
  display: flex;
  align-items: center;
}

#search_logo .search-wordmark,
#search_logo .search-signet {
  height: 90px;
  width: auto;
  object-fit: contain;
}

/* Show our inline SVG mark; default SearXNG logo (img) is hidden separately */

/* Search view container - centered */
#search_view {
  display: flex;
  justify-content: center;
}

/* Results page search box - matches landing page style */
.results-search-box {
  display: flex !important;
  align-items: stretch !important;
  width: 750px;
}

.results-search-box #q {
  flex: 1 1 auto !important;
  font-size: 1rem !important;
  padding: 0.875rem 1rem !important;
  background: var(--bg-primary) !important;
  border: 2px solid var(--border-color) !important;
  border-radius: 10px 0 0 10px !important;
  border-right: none !important;
  transition: border-color 0.2s !important;
  outline: none !important;
}

.results-search-box #q:focus {
  border-color: var(--sonar-primary) !important;
}

.results-search-box #send_search {
  flex: 0 0 auto !important;
  padding: 0.875rem 1.25rem !important;
  margin: 0 !important;
  border-radius: 0 10px 10px 0 !important;
  border: 2px solid var(--border-color) !important;
  border-left: none !important;
  background: var(--sonar-primary) !important;
  color: var(--text-inverse) !important;
}

.results-search-box:focus-within #q {
  border-color: var(--sonar-primary) !important;
}

.results-search-box:focus-within #send_search {
  border-color: var(--sonar-primary) !important;
}

/* Hide the old search_box wrapper if present */
#search_header .search_box {
  display: none;
}

/* Categories centered */
#search_header #categories {
  width: 100%;
  justify-content: center;
  margin: 0.75rem 0;
  padding: 0;
}

#search_header #categories_container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* ============================================
   Filter Bar - 3-Column Layout
   ============================================ */
form#search {
  margin: 0;
  padding: 0;
  width: 100%;
}

#search form .search_filters,
form#search .search_filters,
.search_filters {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 0.5rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-sizing: border-box;
  min-height: 44px;
}

/* Parameter bar fully hidden per The Power of the 20 Rings design.
   Language / time / safesearch / download formats / response time are all
   hidden on the results page. */
#search form .search_filters,
form#search .search_filters,
.search_filters {
  display: none !important;
}

.filters-left,
.filters-center,
.filters-right {
  display: none !important;
}

/* Center section - results count centered */
.filters-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Right section - download buttons aligned right */
.filters-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Filter dropdowns - pill button style */
.filters-left select,
.search_filters select,
form#search .search_filters select,
#search .filters-left select,
select#language,
select[name="language"],
select[name="time_range"],
select[name="safesearch"] {
  padding: 0.5rem 1rem 0.5rem 1rem !important;
  padding-right: 1.75rem !important;
  font-size: 0.75rem !important;
  color: var(--text-secondary) !important;
  background: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.625rem center !important;
  transition: all 0.15s !important;
  max-width: none !important;
  min-width: 0 !important;
  width: auto !important;
  text-overflow: ellipsis;
}

.filters-left select:hover,
.filters-left select:focus,
.search_filters select:hover,
.search_filters select:focus {
  background-color: var(--bg-hover);
  border-color: var(--sonar-primary);
  color: var(--text-primary);
  box-shadow: none;
  outline: none;
}

/* Remove any wrapper styling that might add outline */
.filter,
.search-filter,
[class*="filter"] > div {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
}

/* Pill button style for right section elements */
.filters-right a,
.filters-right button,
.filters-right .btn,
.filters-right .format-btn {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.filters-right a:hover,
.filters-right button:hover,
.filters-right .format-btn:hover {
  background: var(--bg-hover);
  border-color: var(--sonar-primary);
  color: var(--text-primary);
}


/* Results count in center */
.filters-center #result_count,
.filters-center .result-count,
#result_count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
}


/* ============================================
   Search Results
   ============================================ */
#main_results {
  background: var(--bg-secondary);
}

#results {
  max-width: 850px;
  margin: 0 auto;
  padding: 1rem;
}

/* Answer box / Wikipedia excerpt at top */
#answers,
.answer,
#results > .answer,
#urls ~ div:first-of-type:not(article) {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

#answers p,
.answer p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0 0 0.75rem;
}

#answers a,
.answer a {
  color: var(--sonar-primary);
  text-decoration: none;
}

#answers a:hover,
.answer a:hover {
  text-decoration: underline;
}

/* Result cards */
article.result {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

article.result:hover {
  border-color: var(--sonar-primary);
  box-shadow: var(--shadow-sm);
}

/* Result title */
article.result h3,
article.result .result_title {
  margin: 0 0 0.375rem;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
}

article.result h3 a,
article.result .result_title a {
  color: var(--sonar-primary);
  text-decoration: none;
}

article.result h3 a:hover,
article.result .result_title a:hover {
  text-decoration: underline;
}

/* Result URL */
article.result .url_wrapper,
article.result .result_url,
article.result .url {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Result content */
article.result .content,
article.result p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* Engine badges */
article.result .engines {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

article.result .engines span {
  font-size: 0.6875rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: 4px;
  color: var(--text-muted);
}

/* ============================================
   Sidebar Area
   ============================================ */
#sidebar {
  padding: 0 1rem;
}

/* Number of results */
#result_count,
.result-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ============================================
   Infobox Sidebar
   ============================================ */
#infoboxes {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

#infoboxes .title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  background: none !important;
}

#infoboxes .infobox {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
}

#infoboxes .infobox h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

#infoboxes img {
  border-radius: 6px;
  margin-bottom: 0.75rem;
  max-width: 100%;
}

#infoboxes p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 0.75rem;
}

#infoboxes ul {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
}

#infoboxes li {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

#infoboxes a {
  color: var(--sonar-primary);
  text-decoration: none;
}

#infoboxes a:hover {
  text-decoration: underline;
}

/* ============================================
   Navigation
   ============================================ */
#links_on_top {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  justify-content: flex-end;
}

#links_on_top a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

#links_on_top a:hover {
  background: var(--bg-hover);
  color: var(--sonar-primary);
}

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

/* Theme toggle button (light / dark) */
.rop-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.rop-theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--sonar-primary);
}

.rop-theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Show the moon icon when in light mode (so click switches to dark);
   show the sun icon when in dark mode (so click switches to light). */
.theme-dark .rop-theme-icon-moon,
.theme-light .rop-theme-icon-sun,
:not(.theme-dark):not(.theme-light) .rop-theme-icon-moon {
  display: none;
}

.rop-theme-label {
  font-family: var(--font-display);
  letter-spacing: 0.06em;
}

@media (max-width: 768px) {
  .rop-theme-label { display: none; }
}

/* ============================================
   Pagination
   ============================================ */
#pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  flex-wrap: wrap;
}

/* Page number links - force monochrome on ALL states */
#pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary) !important;
  text-decoration: none !important;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

#pagination a:link,
#pagination a:visited,
#pagination a:active {
  color: var(--text-secondary) !important;
  text-decoration: none !important;
}

#pagination a:hover {
  background: var(--bg-hover);
  color: var(--text-primary) !important;
}

#pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary) !important;
}

/* Current page number */
#pagination .page-number-active,
#pagination .active,
#pagination span.page-number-active,
#pagination a.active {
  font-weight: 600;
  color: var(--text-primary) !important;
}

/* Pagination buttons - outline style to match other UI buttons */
#pagination form button,
#pagination button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text-secondary) !important;
  background: var(--bg-primary) !important;
  border: 1px solid var(--border-color-soft) !important;
}

#pagination form button:hover,
#pagination button:hover {
  background: var(--bg-hover) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* Previous page button - on left */
#pagination form:first-of-type {
  order: -1;
  margin-right: 0.5rem;
}

/* Next page button - on right */
#pagination form:last-of-type {
  order: 999;
  margin-left: 0.5rem;
}

/* ============================================
   Footer
   ============================================ */
footer {
  background: var(--bg-primary);
  padding: 0.5rem 1rem 0.75rem !important;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  border: none !important;
  border-top: none !important;
  box-shadow: none !important;
  line-height: 1;
  margin: 0 !important;
  min-height: 0 !important;
  height: auto !important;
}

footer p {
  margin: 0 !important;
  padding: 0 !important;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

footer a:hover {
  color: var(--text-primary);
}

/* ============================================
   Responsive
   ============================================ */

/* Results page header - stack logo above search on narrow screens */
@media (max-width: 900px) {
  #search_header {
    padding-top: 0.75rem;
  }

  #search_logo {
    position: static;
    transform: none;
    margin-bottom: 0.75rem;
  }

  #search_logo .search-wordmark,
  #search_logo .search-signet {
    height: 60px;
  }

  .search_row {
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  .index .search_box {
    max-width: 100%;
  }

  .index #q {
    font-size: 1rem;
    padding: 0.875rem 1rem;
  }

  #categories {
    gap: 0.375rem;
  }

  #categories label,
  #categories button {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
  }

  #links_on_top a span {
    display: none;
  }

  article.result {
    padding: 1rem;
  }

  /* Filter bar responsive - stack on narrow screens */
  #search form .search_filters,
  form#search .search_filters {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .filters-left,
  .filters-center,
  .filters-right {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .index #q {
    font-size: 0.9375rem;
  }
}

/* ============================================
   Rings of Power - Wordmark, Signet, Inscription
   ============================================ */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Landing page: ring + wordmark cluster */
.index .title { display: flex; justify-content: center; }
.index .title h1 { margin: 0; }

.rop-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1rem;
}

/* White Tree of Gondor heraldic mark - landing page hero */
.rop-tree {
  width: 140px;
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

.theme-dark .rop-tree {
  filter: drop-shadow(0 0 14px rgba(255, 247, 215, 0.18));
}

/* White Tree of Gondor - results page small mark */
.rop-tree-small {
  width: 48px;
  height: auto;
  flex: 0 0 auto;
}

.theme-dark .rop-tree-small {
  filter: drop-shadow(0 0 8px rgba(255, 247, 215, 0.18));
}

.rop-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.rop-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  letter-spacing: 0.18em;
  line-height: 1.0;
  color: transparent;
  background: linear-gradient(180deg, #fff3c4 0%, #e9c46a 45%, #9a6a0a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 1px 0 rgba(91, 58, 8, 0.15);
}

.theme-dark .rop-title {
  background: linear-gradient(180deg, #fff3c4 0%, #e9c46a 50%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.rop-tagline {
  margin-top: 0.45rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(0.85rem, 1.5vw, 1rem);
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* The inscription line on the landing page */
.rop-inscription {
  width: 100%;
  margin-top: 1.5rem;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  opacity: 0.85;
}

/* Results page: small tree + title */
.rop-search-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.rop-search-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: var(--sonar-primary-hover);
  white-space: nowrap;
}

.theme-dark .rop-search-title {
  color: var(--sonar-primary-hover);
}

/* Hide the SearXNG default search-wordmark <img> (the templates no longer
   reference it, but defend against any cached <img> tags) */
#search_logo .search-wordmark,
#search_logo .search-signet { display: none !important; }

/* Footer touch-up */
footer {
  font-family: var(--font-serif);
  font-style: italic;
  letter-spacing: 0.02em;
}
footer a {
  font-family: var(--font-display);
  font-style: normal;
  letter-spacing: 0.08em;
  color: var(--sonar-primary-hover);
}

/* Section accents */
article.result h3 a,
article.result .result_header a {
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

/* Realm-tinted category active states (results page) */
#categories input:checked + label,
#categories button.selected,
#categories button.active {
  background: var(--sonar-primary);
  border-color: var(--sonar-primary-hover);
  color: var(--text-inverse);
  box-shadow: 0 0 0 2px rgba(212, 84, 26, 0.2);
}
#categories #checkbox_elven:checked + label,
#categories button[name="category_elven"].selected { background: var(--rop-realm-elven); border-color: var(--rop-realm-elven); }
#categories #checkbox_dwarven:checked + label,
#categories button[name="category_dwarven"].selected { background: var(--rop-realm-dwarven); border-color: var(--rop-realm-dwarven); }
#categories #checkbox_mortal-men:checked + label,
#categories button[name="category_mortal-men"].selected { background: var(--rop-realm-men); border-color: var(--rop-realm-men); }

/* Smaller tree on tight viewports */
@media (max-width: 640px) {
  .rop-wordmark { flex-direction: column; gap: 0.5rem; align-items: center; }
  .rop-text { align-items: center; text-align: center; }
  .rop-tree { width: 108px; height: auto; }
  .rop-tree-small { width: 40px; height: auto; }
  .rop-search-title { font-size: 0.95rem; letter-spacing: 0.08em; }
  .rop-tagline { white-space: normal; }
}
