/* depsly — a search engine you can hold in your hand.
   Two claims to make legible: the index is small, and every answer is a
   sentence physically lifted from a stored page. The highlighter marks the
   lifted sentence; the left gutter marks which results the answer came from.
   No webfonts: an engine that pitches "no vendor" should not phone home. */

:root {
  color-scheme: light dark;

  --paper: #fcfcfd;
  --surface: #ffffff;
  --sunk: #f4f5f8;
  --ink: #12141a;
  --ink-2: #565c6b;
  /* 4.7:1 on --paper. The breadcrumb, stats and "matched on" lines are
     12px, so they need WCAG AA's 4.5:1 for normal text; the old #878d9c
     measured 3.2:1 and was effectively unreadable for some users. */
  --ink-3: #6b7280;
  --rule: #e7e9f0;
  --rule-strong: #d3d7e2;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --accent-soft: #e8edfd;
  --visited: #6b46a8;
  --brand: linear-gradient(135deg, #2563eb, #7c3aed);
  --quote: #fdf0b8;
  --quote-edge: #dcb92c;
  --shadow: 0 1px 2px rgba(18, 20, 26, 0.05), 0 8px 24px -14px rgba(18, 20, 26, 0.28);

  --sans: "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui,
    -apple-system, Inter, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  --col: 660px;
  --gutter: 40px;
  --radius: 10px;
  /* Header pad + wordmark + gap. The results column starts under the input. */
  --rail: 168px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f172a;
    --surface: #16203a;
    --sunk: #1c2745;
    --ink: #e2e8f0;
    --ink-2: #a3b0c9;
    --ink-3: #7c8aa5;
    --rule: #24304e;
    --rule-strong: #33415f;
    --accent: #7ba0ff;
    --accent-2: #a78bfa;
    --accent-soft: #182036;
    --visited: #c0a5ec;
    --quote: rgba(233, 201, 72, 0.22);
    --quote-edge: #b99a2b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -14px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── wordmark ─────────────────────────────────────────────── */

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.34em;
  margin: 0;
  font: 700 26px/1 var(--sans);
  letter-spacing: -0.035em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover { text-decoration: none; }
.wordmark .mark {
  width: 1.28em;
  height: 1.28em;
  flex: none;
  overflow: visible;
  /* The tail hangs below the ring, so the glyph reads low without a nudge. */
  margin-bottom: -0.06em;
}
.wordmark .word { white-space: nowrap; }
.wordmark .tld {
  font-weight: 500;
  font-size: 0.46em;
  letter-spacing: 0;
  color: var(--ink-2);
  vertical-align: 0.15em;
  margin-left: 0.1em;
}

/* ── search field ─────────────────────────────────────────── */

form.search {
  position: relative;
  display: flex;
  width: 100%;
}
form.search input[name="q"] {
  width: 100%;
  height: 46px;
  padding: 0 46px 0 16px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 400 15px/1 var(--sans);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
form.search input[name="q"]::placeholder { color: var(--ink-3); }
form.search input[name="q"]:hover { border-color: var(--ink-3); }
form.search input[name="q"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
form.search button {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
form.search button:hover { color: var(--accent); background: var(--sunk); }

.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
}
.suggest.open { display: block; }
.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: 400 14px/1.4 var(--sans);
  cursor: pointer;
}
.suggest button:hover,
.suggest button.active { background: var(--sunk); }

/* ── home ─────────────────────────────────────────────────── */

.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
}
.home-center {
  flex: 1;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px 0 32px;
}
.home .wordmark {
  font-size: 46px;
  letter-spacing: -0.04em;
  align-self: center;
  margin-bottom: 14px;
}
.tag {
  text-align: center;
  text-wrap: balance;
  margin: 4px 0 6px;
  font: 600 26px/1.25 var(--sans);
  letter-spacing: -0.025em;
  color: var(--ink);
}
/* The half of the promise the engine is actually judged on. */
.tag em {
  font-style: normal;
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub {
  text-align: center;
  text-wrap: balance;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0 0 28px;
}

/* The hero is the ledger: this engine's claim is its size, so show the size. */
.ledger-card {
  margin-top: 34px;
  padding: 20px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.ledger-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.ledger-title {
  font: 600 14px/1.2 var(--sans);
  color: var(--ink);
}
.ledger-ratio {
  font: 600 14px/1.2 var(--mono);
  color: var(--accent);
}
.bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--sunk);
}
.bar-packed { background: var(--brand); }
.bar-saved { background: repeating-linear-gradient(
    135deg, var(--rule-strong) 0 2px, transparent 2px 5px); }
.ledger-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  font: 400 12px/1.4 var(--mono);
  color: var(--ink-3);
}
.ledger-legend b {
  font-weight: 600;
  color: var(--ink-2);
}
.ledger-note {
  margin: 12px 0 0;
  padding-top: 11px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

.home-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}
.chip {
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  text-decoration: none;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.foot {
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 24px 0 32px;
  text-align: center;
  max-width: 46ch;
}

/* ── results header ───────────────────────────────────────── */

.serp-top {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.serp-top .wordmark { font-size: 20px; flex: none; width: 118px; }
.serp-top form.search { max-width: var(--col); }
.serp-ledger {
  margin-left: auto;
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font: 500 11.5px/1 var(--mono);
  color: var(--ink-2);
  white-space: nowrap;
}
.serp-ledger .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.wrap {
  width: min(calc(var(--col) + var(--rail) + 28px), 100%);
  margin: 0;
  padding: 24px 28px 72px var(--rail);
}

.stats {
  color: var(--ink-3);
  font: 400 12.5px/1.5 var(--mono);
  margin-bottom: 20px;
}
.dym {
  margin: 0 0 8px;
  font-size: 14.5px;
  color: var(--ink-2);
}
.dym a { font-weight: 600; }
.dym i { font-style: italic; }

/* ── answer: sentences lifted, with receipts ──────────────── */

.answer {
  margin: 0 0 30px;
  padding: 16px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.answer-kicker {
  margin: 0 0 12px;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.receipt {
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 12px;
  align-items: start;
}
.receipt + .receipt { border-top: 1px solid var(--rule); padding-top: 14px; }
.cite-num {
  grid-column: 1;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 6px;
  background: var(--sunk);
  color: var(--ink-2);
  font: 600 11px/1 var(--mono);
  text-decoration: none;
}
.cite-num:hover { background: var(--accent); color: #fff; text-decoration: none; }
.answer-text {
  grid-column: 2;
  margin: 0 0 6px;
  font: 400 16.5px/1.5 var(--sans);
  color: var(--ink);
}
.receipt:first-child .answer-text { font-size: 18px; }
.answer-text b { font-weight: 650; }
.receipt-src {
  grid-column: 2;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--ink-3);
  text-decoration: none;
}
.receipt-src:hover { text-decoration: none; }
.receipt-src:hover .source-title { color: var(--ink-2); }
.source-host {
  font: 500 12.5px/1.4 var(--mono);
  color: var(--ink-2);
  flex: none;
}
.source-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── result cards ─────────────────────────────────────────── */

.result {
  position: relative;
  margin: 0 0 26px;
  padding-left: var(--gutter);
  scroll-margin-top: 84px;
}
.result-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 5px;
}
/* One hue per host, saturation and lightness owned by the theme. */
.favicon {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font: 600 11px/1 var(--sans);
  background: hsl(var(--h, 220) 62% 95%);
  border: 1px solid hsl(var(--h, 220) 48% 87%);
  color: hsl(var(--h, 220) 46% 38%);
}
@media (prefers-color-scheme: dark) {
  .favicon {
    background: hsl(var(--h, 220) 32% 20%);
    border-color: hsl(var(--h, 220) 28% 30%);
    color: hsl(var(--h, 220) 62% 78%);
  }
}
.result-site { min-width: 0; }
.domain {
  font: 500 13px/1.35 var(--sans);
  color: var(--ink);
}
.result .url {
  font: 400 12px/1.35 var(--mono);
  color: var(--ink-3);
}
.result cite {
  font-style: normal;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result .title {
  display: block;
  margin-bottom: 3px;
  font: 500 19px/1.35 var(--sans);
  letter-spacing: -0.011em;
  color: var(--accent);
}
.result .title:visited { color: var(--visited); }
.result .snippet {
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.6;
}
.result .snippet b { color: var(--ink); font-weight: 650; }

/* The gutter is the receipt column: only quoted results occupy it. */
.cite-badge {
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--quote);
  border: 1px solid var(--quote-edge);
  color: var(--ink);
  font: 600 11px/1 var(--mono);
}

/* The signature: the lifted sentence wears the same highlighter in the
   answer and in the card it was copied from. */
mark.quote {
  background: var(--quote);
  color: inherit;
  padding: 1px 2px;
  margin: 0 -2px;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.result.flash mark.quote { animation: flash 1.1s ease-out; }
@keyframes flash {
  0%, 40% { box-shadow: 0 0 0 4px var(--quote); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.why {
  margin-top: 6px;
  font: 400 11.5px/1.4 var(--mono);
  color: var(--ink-3);
}
.why b { font-weight: 600; color: var(--ink-2); }

.result.kb-on::before {
  content: "";
  position: absolute;
  inset: -10px -14px -10px 26px;
  border-radius: var(--radius);
  background: var(--sunk);
  z-index: -1;
}

/* Same site, more pages. One rail down the group; children keep the parent's
   text edge so the rail reads as "more from here", not as a nested quote. */
.cluster { margin: 0 0 30px; }
.cluster .result { margin-bottom: 16px; }
.cluster .result:last-child { margin-bottom: 0; }
.cluster .result.child {
  margin-left: 28px;
  padding-left: calc(var(--gutter) - 12px);
  border-left: 2px solid var(--rule);
}
.cluster .result.child::after {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 12px;
  border-top: 2px solid var(--rule);
}
.cluster .result.child .cite-badge { left: -28px; }
.cluster .result.child .title { font-size: 16.5px; }
.cluster .result.child .favicon {
  width: 16px;
  height: 16px;
  font-size: 9px;
  border-radius: 4px;
}

.empty {
  color: var(--ink-2);
  padding: 6px 0 0 var(--gutter);
  font-size: 15px;
}
.empty b { color: var(--ink); }

.related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.related-label {
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: 4px;
}

.keys {
  margin: 28px 0 0;
  font: 400 11.5px/1.5 var(--mono);
  color: var(--ink-3);
}
.keys kbd {
  display: inline-block;
  min-width: 17px;
  padding: 1px 5px;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font: 500 11px/1.5 var(--mono);
  color: var(--ink-2);
  text-align: center;
}

@media (max-width: 1000px) {
  .serp-top { flex-wrap: wrap; gap: 10px 14px; padding: 10px 16px; }
  .serp-top form.search { order: 3; flex-basis: 100%; max-width: none; }
  .wrap { padding: 20px 16px 60px; }
  .result { padding-left: 30px; }
  .cite-badge { width: 20px; height: 20px; }
  .cluster .result.child { margin-left: 0; }
  .cluster .result.child .cite-badge { left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Ledger: what the hot tier holds against the long tail behind it. */
.tiers {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--ink-3);
}
.tiers b { color: var(--ink); font-weight: 650; }
.tiers span:first-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 2px;
  background: var(--brand);
  vertical-align: 0;
}
.tiers span:last-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 2px;
  background: var(--rule-strong);
}
@media (max-width: 520px) {
  .tiers { flex-direction: column; gap: 4px; }
}
