/* Find-in-book controls.
 *
 * These live inside the existing .reader-top row rather than in a bar of their
 * own: the reader is chrome-free by design and its desktop toolbar is ~50px, so
 * a second row would cost vertical space on every page. On narrow screens the row
 * wraps and the find controls take a full line.
 */

.reader-find {
  display: flex;
  align-items: center;
  gap: 4px;
  /* Shrinkable, so the row stays one line instead of wrapping the toolbar from
     50px to 92px at 1280px and below. */
  flex: 0 1 auto;
  min-width: 0;
}

#findInput {
  font: inherit;
  font-size: 13px;
  padding: 3px 8px;
  /* A flexible width rather than min/max: the row was 5px too wide at 1280px
     with a fixed 8.5rem floor, and 3-digit page counts are what push it over. */
  flex: 0 1 12rem;
  min-width: 6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: inherit;
}

/* type="search" gives the field its own clear button. Showing both that and
   #findClear put two × marks in the toolbar, side by side. Keep the styled one
   and hide the platform's. */
#findInput::-webkit-search-cancel-button,
#findInput::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

#findInput:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#findInput:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* The count must not change the toolbar's width as digits change, or the
   buttons shift under the reader's finger mid-search. */
.find-count {
  font-size: 12px;
  color: var(--muted);
  /* Must not change the toolbar's width as digits change, or the buttons shift
     under the reader's finger mid-search. 4ch fits "1 of 9" through "1 of 110"
     closely enough to stop the row wrapping. */
  min-width: 4.5ch;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.reader-find button {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: inherit;
  cursor: pointer;
}

.reader-find button:hover:not(:disabled) {
  border-color: var(--accent);
}

.reader-find button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Shown only for scans with no text layer. */
.find-none {
  font-size: 12px;
  color: var(--muted);
  /* A flex item defaults to min-width:auto, so its min-content floor competed
     with #findInput (8.5rem) + counter + three buttons inside a 301px line at
     320px and pushed the page 10px wide. min-width:0 lets it actually shrink,
     and anywhere lets its long Archive.org link wrap mid-word. */
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Match highlight, drawn over the text layer.
 *
 * Sits above the transparent .textLayer spans but below nothing else; pointer
 * events are off so the reader can still drag-select across a highlight without
 * the highlight swallowing the selection. */
#pdfTextLayer .hl {
  position: absolute;
  background: rgba(255, 214, 0, 0.42);
  border-radius: 2px;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 1;
}


/* Narrow screens: the find row takes its own full line, below the controls.
 *
 * The desktop toolbar is ~50px and stays that way down to ~1100px. Below that
 * the row wraps by design, because a 320px screen cannot fit paging, zoom, find
 * and the download button on one line. Measured heights with the find row in
 * place: 50px desktop, ~92px at 1280px before the fix, 185px at 375px, 222px at
 * 320px. The mobile figures are higher than the old 151px because search needs
 * a row of its own there - a deliberate trade for a usable box and a counter
 * rather than a 40px-wide field. */
@media (max-width: 640px) {
  .reader-find {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
  }
  #findInput {
    flex: 1 1 auto;
    max-width: none;
  }
  /* The notice takes its own line rather than competing for width with the
     box, the counter and three buttons. */
  .find-none {
    flex: 1 1 100%;
  }
}
