@import url('https://fonts.googleapis.com/css2?family=Ibarra+Real+Nova:ital,wght@0,400;0,500;0,700;1,400;1,700&display=swap');

:root {
  --ink: #181818;
  --muted: #777;
  --line: #dedede;
  --soft: #f7f7f7;
  --length: #8b0000;
  --green: #023020;
  --dict-orange: #a64b00;
  --dict-purple: #6f3f91;
}

* { box-sizing: border-box; }
html { background: #fff; }
body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: 'Ibarra Real Nova', serif;
  font-size: 18px;
  line-height: 1.45;
}
button, input { font: inherit; }
a { color: var(--green); }

.page {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 28px;
}

.sticky-search {
  position: sticky;
  z-index: 100;
  top: 0;
  margin: -10px 0 0;
  padding: 10px 0 13px;
  background: rgba(255, 255, 255, 0.975);
  box-shadow: 0 12px 18px -20px rgb(0 0 0 / 48%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
header { margin-bottom: 16px; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 500;
  line-height: 1.05;
}
.wordmark {
  letter-spacing: -0.025em;
}
.wordmark > span {
  color: #595959;
  font-weight: 400;
}

.search-form {
  display: flex;
  align-items: stretch;
  gap: 7px;
  position: relative;
}
.search-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
#box {
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid #aaa;
  border-radius: 3px;
  color: #111;
  background: #fff;
  outline: none;
}
#box:focus {
  border-color: #555;
  box-shadow: 0 0 0 1px #555;
}
button {
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #aaa;
  border-radius: 3px;
  color: #222;
  background: #f7f7f7;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #eee; }
button:disabled { color: #999; cursor: default; }
#clearbox { width: 44px; padding-inline: 0; font-size: 1.35rem; line-height: 1; }

.route-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.message { min-height: 1.3em; margin: 8px 0 0; color: var(--muted); font-size: 0.92rem; }
.message.error { color: var(--length); }

.autocomplete {
  position: absolute;
  z-index: 10;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  max-height: 310px;
  overflow-y: auto;
  padding: 3px 0;
  border: 1px solid #aaa;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 5px 14px rgb(0 0 0 / 10%);
}
.autocomplete-item {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 5px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.autocomplete-item:hover,
.autocomplete-item.active { background: #eee; }

#output { margin-top: 14px; }
.result-block {
  position: relative;
  padding: 22px 82px 21px 0;
  border-top: 1px solid var(--line);
}
.result-block:first-child { border-top-color: #bbb; }
.result-title {
  margin: 0 0 3px;
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1.15;
}
.result-title.query-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.25rem;
}
.result-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 31px;
  margin: 0 0 10px;
}
.result-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.sort-switch {
  --switch-width: 92px;
  --switch-pad: 2px;
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: var(--switch-width);
  height: 29px;
  padding: var(--switch-pad);
  margin-left: 1px;
  border: 1px solid #d3d3d3;
  border-radius: 999px;
  background: #f1f1f1;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 4%);
  isolation: isolate;
}
.sort-thumb {
  position: absolute;
  z-index: 0;
  top: 2px;
  left: 2px;
  width: calc((100% - 4px) / 2);
  height: calc(100% - 4px);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 15%), 0 0 0 1px rgb(0 0 0 / 5%);
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms ease;
}
.sort-alpha-mode .sort-thumb { transform: translateX(100%); }
.sort-option {
  position: relative;
  z-index: 1;
  min-height: 23px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #969696;
  background: transparent !important;
  font-family: 'Ibarra Real Nova', serif;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 23px;
  transition: color 180ms ease, transform 180ms ease;
}
.sort-option.active { color: #262626; transform: translateY(-0.2px); }
.sort-option:hover { color: #444; }
.sort-option::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: 220px;
  padding: 5px 8px;
  border-radius: 4px;
  color: #fff;
  background: #292929;
  box-shadow: 0 3px 10px rgb(0 0 0 / 18%);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease, transform 150ms ease;
}
.sort-option:hover::after,
.sort-option:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}
.result-actions {
  position: absolute;
  top: 14px;
  right: -2px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.copy-result,
.dismiss-result {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  transition: color 140ms ease, background-color 140ms ease, transform 140ms ease;
}
.copy-result svg {
  width: 18px;
  height: 18px;
  overflow: visible;
}
.copy-result:hover,
.dismiss-result:hover {
  color: #333;
  background: #f3f3f3 !important;
}
.copy-result:active,
.dismiss-result:active { transform: scale(0.94); }
.copy-result.copied { color: var(--green); }
.dismiss-result {
  font-size: 1.65rem;
  font-weight: 400;
  line-height: 1;
}

ul { list-style-type: none; margin: 0; padding: 0; }
.bradfords-list li { margin: 3px 0; }
.wordLength, .wordlength {
  color: var(--length);
  font-weight: bold;
  font-size: 18px;
}
.word { color: #111; }

.qat-results {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 1.18em;
  row-gap: 0.22em;
}
.qat-results li {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 1px 0;
  overflow-wrap: anywhere;
}
.qat-results.equation-results {
  display: block;
}
.qat-results.equation-results li {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  padding: 0.08em 0;
}
.equation-bindings {
  color: #8a8a8a;
  font-style: italic;
  font-size: 0.92em;
}

.dict-segment {
  font-weight: 600;
  transition: color 150ms ease;
}
.dict-segment-1 { color: var(--dict-orange); }
.dict-segment-2 { color: var(--dict-purple); }


.qat-results-host {
  transition: opacity 130ms ease, transform 180ms cubic-bezier(.2,.8,.2,1), filter 160ms ease;
}
.qat-results-host.reordering {
  opacity: 0.2;
  filter: blur(0.7px);
  transform: translateY(3px);
}
.qat-results-host.reordered {
  animation: settle-results 230ms cubic-bezier(.2,.8,.2,1);
}
@keyframes settle-results {
  0% { opacity: 0.35; transform: translateY(-3px); }
  100% { opacity: 1; transform: translateY(0); }
}
.length-group + .length-group { margin-top: 13px; }
.length-heading {
  margin: 0 0 3px;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
}

.spotlightable {
  border-radius: 2px;
  transition:
    color 180ms ease,
    opacity 180ms ease,
    filter 180ms ease,
    background-size 240ms cubic-bezier(.2,.8,.2,1),
    box-shadow 220ms ease;
}
.spotlightable.has-space {
  background-image: linear-gradient(104deg,
    transparent 0%,
    rgba(255, 232, 74, 0.68) 5%,
    rgba(255, 241, 120, 0.78) 48%,
    rgba(255, 225, 53, 0.64) 96%,
    transparent 100%);
  background-repeat: no-repeat;
  background-position: 0 76%;
  background-size: 0% 72%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
body.phrase-spotlight .spotlightable:not(.has-space) {
  color: #b3b3b3;
  opacity: 0.34;
  filter: grayscale(1);
}
body.phrase-spotlight .spotlightable.has-space {
  color: #111;
  background-size: 100% 72%;
  box-shadow: 0 0 0 1px rgb(255 222 45 / 5%);
}

.near-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 34px;
}
.near-column h3 {
  margin-bottom: 7px;
  font-size: 1.2rem;
  font-weight: 500;
}
.near-list li { width: fit-content; padding: 2px 0; }
.delta {
  margin-left: 0.28em;
  color: #888;
  font-style: italic;
}
.empty-list { color: #999; font-style: italic; }

.more-results {
  margin: 12px 0 0;
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

.reference {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}
summary { cursor: pointer; color: var(--green); }
.syntax-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin-top: 12px;
  font-size: 0.9rem;
}
code {
  padding: 0 3px;
  border-radius: 2px;
  background: #f1f1f1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
}
.reference-note { margin: 10px 0 0; color: var(--muted); font-size: 0.88rem; }

footer {
  margin-top: 18px;
  color: #888;
  font-size: 0.75rem;
  text-align: center;
}

.hidden { display: none !important; }
.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;
}

@media (max-width: 700px) {
  .page { width: min(100% - 22px, 900px); padding-top: 22px; }
  .sticky-search { margin-top: -7px; padding-top: 7px; }
  .search-form { flex-wrap: wrap; }
  .search-wrap { flex-basis: calc(100% - 51px); }
  #submit { flex: 1 1 120px; }
  #clear { flex: 1 1 120px; }
  .near-grid { grid-template-columns: 1fr; gap: 18px; }
  .result-meta-row { flex-wrap: wrap; gap: 7px 10px; }
}


@media (max-width: 430px) {
  body { font-size: 17px; }
  .result-block { padding-right: 78px; }
  .syntax-grid { gap: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .sort-thumb,
  .sort-option,
  .qat-results-host,
  .spotlightable,
  .dict-segment,
  .sort-option::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* On-demand Wiktionary definition card. */
.definition-popover {
  position: fixed;
  z-index: 1000;
  width: min(390px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 24px));
  overflow: auto;
  padding: 14px 16px 12px;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.985);
  box-shadow: 0 12px 34px rgb(0 0 0 / 18%), 0 2px 8px rgb(0 0 0 / 8%);
  color: var(--ink);
  font-family: 'Ibarra Real Nova', serif;
  font-size: 0.94rem;
  line-height: 1.36;
  animation: definition-in 145ms cubic-bezier(.2,.8,.2,1);
}
@keyframes definition-in {
  from { opacity: 0; transform: translateY(4px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.definition-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.definition-word {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 500;
  line-height: 1.1;
}
.definition-close {
  flex: 0 0 auto;
  width: 28px;
  min-height: 28px;
  margin: -5px -7px 0 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #999;
  font-size: 1.35rem;
  line-height: 1;
}
.definition-close:hover { color: #222; background: #f1f1f1 !important; }
.definition-body { display: grid; gap: 9px; }
.definition-group + .definition-group {
  padding-top: 8px;
  border-top: 1px solid #ededed;
}
.definition-pos {
  margin: 0 0 3px;
  color: #666;
  font-size: 0.78rem;
  font-style: italic;
  font-weight: 400;
}
.definition-sense {
  margin: 0 0 4px;
}
.definition-sense:last-child { margin-bottom: 0; }
.definition-fallback {
  margin: 0 0 9px;
  color: #777;
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.35;
}

.definition-loading,
.definition-empty {
  margin: 2px 0 5px;
  color: #777;
  font-style: italic;
}
.definition-source {
  display: inline-block;
  margin-top: 10px;
  color: #777;
  font-size: 0.72rem;
  text-decoration: none;
}
.definition-source:hover { color: var(--green); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .definition-popover { animation-duration: 0.01ms !important; }
}
