/* Theme colors */
:root {
  color-scheme: light dark;
  --bg: #fafaf8;
  --fg: #202020;
  --muted: #636363;
  --line: #deded9;
  --border: #c9c9c5;
  --fill: #efefeb;
  --link: #2457a7;

  /* Shared landing-page and search controls. */
  --home-amber: #e7a15a;
  --home-accent: #995a21;
  --home-search-bg: #fffdf8;

  /* DuckDuckGo result colors */
  --result-link: #1a0dab;
  --result-visited: #6c00a2;
  --domain: #222;
  --url: #666;
  --snippet: #494949;
  --globe-bg: #e5e5e0;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23636363' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --fg: #f3f3f0;
    --muted: #a5a5a2;
    --line: #343434;
    --border: #484847;
    --fill: #252525;
    --link: #91b5f4;

    --home-accent: var(--home-amber);
    --home-search-bg: #201e1a;

    --result-link: #adc2fc;
    --result-visited: #a591dc;
    --domain: rgb(255 255 255 / 90%);
    --url: #ccc;
    --snippet: #e8e8e8;
    --globe-bg: #363636;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23a5a5a2' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* Base: shared defaults and one size for small UI text. */
* { box-sizing: border-box; }
html {
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
body {
  --pad-left: 1rem;
  margin: 0;
  padding: 1rem 1rem 1rem var(--pad-left);
  background: var(--bg);
  color: var(--fg);
}
h1, h2, h3, p, ul { margin: 0; }
h1, h2, h3 { font-size: inherit; font-weight: inherit; }
ul { padding: 0; list-style: none; }
input, select { font: inherit; color: inherit; margin: 0; border: 0; background: none; }
.wrap { width: min(100%, 40rem); }
.search-form, .result-location { min-width: 0; }
.filters, .meta, .result .domain, .result .url,
.result .description, .pagination { font-size: 0.875rem; }

/* Links: source-row interaction highlights only the result title. */
a { color: inherit; text-decoration: none; }
a.link { color: var(--link); text-decoration: underline; text-underline-offset: 0.2em; }
a:focus-visible, select:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.result .title a { color: var(--result-link); text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
.result .title a:visited { color: var(--result-visited); }
.result .title a:hover,
.result .title a:focus-visible,
.result-source:hover + .title a,
.result-source:focus-visible + .title a { text-decoration: underline; }

/* Search-page layout */
.page-content {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding: 0;
}
.search-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1rem 1rem 2.5rem var(--pad-left);
}
.search-content:has(.pagination) { padding-bottom: 0; }
#results {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.page-header { margin-top: 0.5rem; }
.separator {
  height: 0;
  overflow: hidden;
  margin: 0.75rem -1rem 0.875rem calc(-1 * var(--pad-left));
  border: 0;
  border-top: 1px solid var(--line);
}
/* Search field shared with the landing page. */
.search-field {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-height: 3.5rem;
  padding: 0.4375rem 0.5rem 0.4375rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--home-search-bg);
  line-height: 1.7;
}
.search-icon { flex: none; color: var(--muted); }
.search-field input {
  min-width: 0;
  flex: 1;
  width: 100%;
  padding: 0.375rem 0;
  font-size: 1rem;
}
.search-field input:focus-visible { outline: none; }
.search-field input::placeholder { color: var(--muted); opacity: 1; }
.search-field button {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--home-amber);
  color: #2d241d;
  cursor: pointer;
}
.search-field button:hover { background: color-mix(in srgb, var(--home-amber) 90%, #2d241d); }
.search-field button:focus-visible { outline: 2px solid var(--home-accent); outline-offset: 5px; }

/* Keep the original compact proportions on the results page. */
.search-form .search-field {
  height: 46px;
  min-height: 0;
  gap: 0.625rem;
  padding: 0.375rem 0.375rem 0.375rem 1rem;
  border-radius: 24px;
  line-height: 1.5;
}
.search-form .search-icon { width: 18px; height: 18px; }
.search-form .search-field input { padding: 0.25rem 0; }
.search-form .search-field button { width: 2rem; height: 2rem; }

/* Header filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.625rem;
}
.page-links {
  display: flex;
  gap: 1rem;
  margin-left: auto;
}
.page-links a.link, .pagination a { color: var(--muted); text-decoration: none; text-underline-offset: 0.2em; }
.page-links a.link:hover,
.page-links a.link:focus-visible,
.pagination a:hover,
.pagination a:focus-visible { color: var(--fg); text-decoration: underline; }
select.select {
  height: 2rem;
  appearance: none;
  cursor: pointer;
  field-sizing: content;
  padding: 0.25rem 1.125rem 0.25rem 0;
  border-radius: 0;
  background: var(--chevron) right center / 0.75rem no-repeat;
}
select.select option { background: var(--bg); color: var(--fg); }

@media (min-width: 52rem) {
  .page-content { --pad-left: 10rem; }
}

/* Results */
.meta { margin-bottom: 0.875rem; color: var(--muted); }
.meta b { color: var(--fg); font-weight: 500; }
.result { margin-bottom: 1.25rem; }
#results:has(.pagination) .result:last-of-type { margin-bottom: 0; }
.result-source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  max-width: 100%;
}
.result-globe {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 4px;
  border-radius: 50%;
  background: var(--globe-bg);
  color: var(--url);
}
/* A background-colored stroke slightly thins the filled globe artwork. */
.result-globe path { stroke: var(--globe-bg); stroke-width: 0.75; }
.result-location {
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}
.result .domain, .result .url {
  line-height: 1;
  /* Protect descenders without adding space between the two lines. */
  padding-block: 0.25em;
  margin-block: -0.25em;
}
.result .domain, .result .url, .result .title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result .domain { color: var(--domain); }
.result .url { color: var(--url); }
.result .title {
  margin-top: 0.25rem;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.35;
}
.result .description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin-top: 0.125rem;
  line-height: 1.4;
  color: var(--snippet);
}

/* Center pagination in the space between the last result and the footer. */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: auto 0;
  padding-block: 2.5rem;
}
.pagination .current { font-weight: 600; }

/* Footer shared with the landing page. */
.site-container {
  width: min(100% - 3rem, 64rem);
  margin-inline: auto;
}
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.7;
}
.site-footer-brand { display: block; width: 240px; max-width: 100%; }
.site-footer-brand img { display: block; width: 100%; height: auto; }
.site-footer-links { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin-left: auto; }
.site-footer a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 0.2em; }
.site-footer a:focus-visible { outline: 2px solid var(--home-accent); outline-offset: 5px; }

/* Full-width divider, with two footer rows aligned to the search results. */
.page-content .site-footer {
  width: 100%;
  margin-inline: 0;
  padding-inline: var(--pad-left) 1rem;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: flex-start;
}
.page-content .site-footer-links {
  width: min(100%, 40rem);
  margin-left: 0;
  justify-content: flex-start;
}

@media (max-width: 48rem) {
  .site-footer { flex-direction: column; align-items: flex-start; }
  .site-footer-links { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; width: 100%; margin-left: 0; justify-content: flex-start; }
}

@media (max-width: 36rem) {
  .search-field, .search-form .search-field {
    height: 2.75rem;
    min-height: 0;
    gap: 0.5rem;
    padding: 0.3125rem 0.3125rem 0.3125rem 0.875rem;
    border-radius: 1.5rem;
    line-height: 1.5;
  }
  .search-icon { width: 18px; height: 18px; }
  .search-field input { padding: 0.25rem 0; }
  .search-field button { width: 2rem; height: 2rem; }
  .result .description { -webkit-line-clamp: 3; }
  .site-container { width: calc(100% - 2.5rem); }
  .site-footer-brand { width: 180px; }
}
