/* Word-coordinate viewer, restyled from the demo's dark tool chrome to match the site's
   single light theme. Values are literal rather than tokenised: this file is served
   straight out of public/ and is not part of the Astro build, so it cannot see the
   token sheet. Keep the palette in step with styles/tokens.css by hand. */

.hx-viewer {
  --hxv-line: #e3e9f2;
  --hxv-surface: #ffffff;
  --hxv-text: #132036;
  --hxv-muted: #5a6a82;
  --hxv-accent: #4a90e2;
  --hxv-hit: rgba(255, 193, 7, 0.45);
  --hxv-hit-line: #b8860b;
  --hxv-box: rgba(74, 144, 226, 0.5);
  border: 1px solid var(--hxv-line);
  border-radius: 12px;
  background: var(--hxv-surface);
}

/* Sticky: the facsimile is ~3000px tall, so a static bar scrolls away the moment you
   look at a hit, taking the query and the count with it. NOTE this only works because
   .hx-viewer no longer sets overflow:hidden - any overflow other than visible on an
   ancestor silently disables position:sticky. */
.hx-viewer .hxv-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-radius: 12px 12px 0 0;
  display: flex;
  gap: 0.9rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: #eef2f8;
  border-bottom: 1px solid var(--hxv-line);
  font: 500 0.875rem/1.4 inherit;
  color: var(--hxv-text);
}

.hx-viewer input[type='search'] {
  font: inherit;
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #838fa6;
  background: var(--hxv-surface);
  color: var(--hxv-text);
  width: 18rem;
  max-width: 55vw;
}

.hx-viewer label {
  user-select: none;
  cursor: pointer;
  color: var(--hxv-muted);
  font-weight: 400;
}

.hx-viewer #hits {
  color: var(--hxv-muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.hx-viewer .hxv-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  line-height: 0;
}

.hx-viewer .hxv-page {
  width: 100%;
  display: block;
}

/* One box per recognised word, positioned from the ALTO coordinates. */
.hx-viewer .w {
  position: absolute;
  border: 1px solid transparent;
  box-sizing: border-box;
}
.hx-viewer .show .w {
  border-color: var(--hxv-box);
}
.hx-viewer .w.hit {
  background: var(--hxv-hit);
  border-color: var(--hxv-hit-line);
}
.hx-viewer .w:hover,
.hx-viewer .w:focus-visible {
  border-color: var(--hxv-accent);
}
.hx-viewer .w:hover::after,
.hx-viewer .w:focus-visible::after {
  content: attr(data-t);
  position: absolute;
  left: 0;
  top: 100%;
  background: var(--hxv-text);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font: 400 0.8rem/1.5 inherit;
  z-index: 9;
}

.hx-viewer .hxv-note {
  margin: 0;
  border-radius: 0 0 12px 12px;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--hxv-line);
  color: var(--hxv-muted);
  font: 400 0.8125rem/1.55 inherit;
}

/* Hit stepper, shown only once a search actually matches. */
.hx-viewer .hxv-nav {
  display: none;
  gap: 0.3rem;
  align-items: center;
}
.hx-viewer .hxv-nav.on {
  display: inline-flex;
}
.hx-viewer .hxv-nav button {
  font: inherit;
  line-height: 1;
  padding: 0.3rem 0.55rem;
  border: 1px solid #838fa6;
  background: var(--hxv-surface);
  color: var(--hxv-text);
  border-radius: 6px;
  cursor: pointer;
}
.hx-viewer .hxv-nav button:hover {
  border-color: var(--hxv-accent);
}
/* The hit you are currently parked on, distinct from the other matches. */
.hx-viewer .w.current {
  background: rgba(255, 140, 0, 0.55);
  border-color: #c2410c;
}
