/* Read text from a picture (/tools/ocr/). Only what site.css does not already give.
   Tokens only, never raw hex; the page follows the visitor's light or dark setting
   like every other page. Values and contrast are documented in DESIGN.md. */

/* ---------- The card ---------- */

.ocr-card { margin-block-end: var(--gap-l); }
.ocr-card h2 { margin-block-end: var(--gap-s); }

/* ---------- Dropping a file ---------- */

.ocr-drop {
  margin-block-start: var(--gap-l);
  border: 2px dashed var(--field-line);
  border-radius: var(--radius-s);
  background: var(--bg);
  padding: clamp(24px, 5vw, 44px) var(--gap-l);
  text-align: center;
}
.ocr-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.ocr-drop-icon { color: var(--link); }
.ocr-drop-lead { margin: var(--gap-m) 0 4px; font-size: var(--fs-lede); font-weight: 600; }
.ocr-drop-or { margin: 0 0 var(--gap-m); color: var(--muted); font-size: var(--fs-small); }
.ocr-formats { margin: var(--gap-m) 0 0; color: var(--muted); font-size: var(--fs-small); }
.ocr-formats + .ocr-formats { margin-block-start: 4px; }
.ocr-refused:not(:empty) {
  margin: var(--gap-m) 0 0; font-weight: 600; color: var(--link);
}

/* ---------- Once a file has been chosen ----------
   The drop zone is replaced rather than added to: a teacher skims, so the box has to
   look different, not just say something different. */

.ocr-picked {
  margin-block-start: var(--gap-l);
  border: 2px solid var(--accent);
  border-radius: var(--radius-s);
  background: var(--surface);
  padding: var(--gap-l);
  display: flex; flex-wrap: wrap; gap: var(--gap-l); align-items: center;
}
.ocr-thumb {
  flex: 0 0 auto;
  inline-size: 116px; min-block-size: 150px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--sky);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.ocr-thumb img { display: block; inline-size: 100%; block-size: auto; }
.ocr-thumb svg { color: var(--link); }
.ocr-picked-text { flex: 999 1 300px; min-width: 0; }
.ocr-ready {
  display: flex; align-items: center; gap: var(--gap-s);
  margin: 0 0 var(--gap-s);
  font: 500 var(--fs-label)/1 var(--f-mono);
  letter-spacing: .08em; text-transform: uppercase; color: var(--link);
}
.ocr-tick {
  display: inline-flex; align-items: center; justify-content: center;
  inline-size: 22px; block-size: 22px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
}
.ocr-picked-name {
  margin: 0 0 2px; font-size: var(--fs-lede); font-weight: 600;
  overflow-wrap: anywhere;
}
.ocr-picked-about { margin: 0 0 var(--gap-m); color: var(--muted); font-size: var(--fs-small); }

/* Said aloud to a screen reader, never shown: the block above is the visual answer. */
.ocr-said {
  position: absolute; inline-size: 1px; block-size: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.ocr-again { margin: 0 0 var(--gap-l); flex: 1 0 100%; }

/* The real input sits under the label, reachable by keyboard but never seen.
   clip-path rather than display:none, so focus still lands on it. */
#file {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
/* The input is hidden, so its focus ring is drawn on whichever label is pointing at it. */
.ocr-card:has(#file:focus-visible) label[for="file"] {
  outline: 3px solid var(--focus); outline-offset: 3px;
}
label.btn { cursor: pointer; }

/* ---------- Choices ---------- */

.ocr-options {
  display: flex; flex-wrap: wrap; gap: var(--gap-xl);
  margin-block-start: var(--gap-xl);
}
.ocr-langs, .ocr-gives { flex: 1 1 300px; min-width: 0; }
.ocr-langs { border: 0; padding: 0; margin: 0; }
.ocr-langs legend, .ocr-gives .eyebrow { padding: 0; margin-block-end: var(--gap-s); display: block; }
.ocr-gives p:last-child { margin: 0; color: var(--muted); }

.ocr-langs { display: flex; flex-wrap: wrap; gap: var(--gap-s); }
.ocr-langs legend { flex: 1 0 100%; }
.ocr-pill {
  display: inline-flex; align-items: center; gap: var(--gap-s);
  min-height: 44px; padding: 8px 16px;
  border: 2px solid var(--field-line); border-radius: var(--pill);
  background: var(--surface); cursor: pointer;
}
.ocr-pill:hover { background: var(--accent-soft); }
.ocr-pill:has(:checked) {
  background: var(--accent); border-color: var(--accent);
  color: var(--on-accent); font-weight: 600;
}
.ocr-pill input { accent-color: var(--ink); inline-size: 16px; block-size: 16px; }

.ocr-go {
  margin-block-start: var(--gap-l);
  padding-block-start: var(--gap-l);
  border-block-start: 1px solid var(--line);
}

/* ---------- While it works, and when it will not ---------- */

.ocr-progress {
  margin: var(--gap-l) 0 0; font-weight: 600;
}
.ocr-notice {
  margin: var(--gap-l) 0 0;
  border: 1px solid var(--card-line); border-radius: var(--radius-s);
  background: var(--surface); padding: var(--gap-m) var(--gap-l);
}
.ocr-notice .btn { margin-block-start: var(--gap-s); }

/* ---------- The result ---------- */

.ocr-result {
  display: flex; flex-wrap: wrap; gap: var(--gap-l);
  margin-block: var(--gap-xl);
}
.ocr-source { flex: 1 1 300px; min-width: 0; max-inline-size: 380px; }
.ocr-read { flex: 999 1 520px; min-width: 0; }
.ocr-result .eyebrow { display: block; margin-block-end: var(--gap-s); }

.ocr-preview img { inline-size: 100%; block-size: auto; border-radius: 6px; border: 1px solid var(--line); }
.ocr-pages { display: flex; flex-wrap: wrap; gap: var(--gap-s); margin-block-start: var(--gap-m); }
.ocr-pages button {
  flex: 1 1 56px; min-inline-size: 56px; min-block-size: 56px;
  font: 500 var(--fs-label)/1 var(--f-mono);
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.ocr-pages button[aria-current="true"] { border: 2px solid var(--accent); color: var(--ink); }

.ocr-textbox { display: flex; flex-direction: column; }
.ocr-toolbar {
  display: flex; flex-wrap: wrap; gap: var(--gap-s); align-items: center;
  padding: var(--gap-m) var(--gap-l);
  border-block-end: 1px solid var(--line);
  background: var(--bg);
  border-start-start-radius: var(--radius); border-start-end-radius: var(--radius);
}
.ocr-counted { margin-inline-start: auto; color: var(--muted); font-size: var(--fs-small); }
.ocr-text {
  padding: var(--gap-l); min-block-size: 18rem; max-block-size: 34rem; overflow-y: auto;
  white-space: pre-wrap; line-height: 1.7;
}
.ocr-text:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.ocr-text p { margin: 0 0 var(--gap-m); }
.ocr-text p[dir="rtl"] { text-align: right; }
.ocr-foot {
  margin: 0; padding: var(--gap-m) var(--gap-l);
  border-block-start: 1px solid var(--line); background: var(--bg);
  color: var(--muted); font-size: var(--fs-small);
  border-end-start-radius: var(--radius); border-end-end-radius: var(--radius);
}

/* A word the engine was unsure about. A button, so it is reachable by keyboard. */
.ocr-unsure {
  font: inherit; padding: 0 2px; cursor: pointer;
  border: 0; border-block-end: 2px solid var(--link);
  background: var(--accent-soft); color: inherit;
  border-radius: 3px;
}
.ocr-unsure[aria-expanded="true"] { outline: 2px solid var(--focus); outline-offset: 1px; }

.ocr-crop {
  margin-block-start: var(--gap-m);
  border: 1px solid var(--card-line); border-radius: var(--radius-s);
  background: var(--surface); padding: var(--gap-m) var(--gap-l);
}
.ocr-crop img {
  display: block; max-inline-size: 100%; block-size: auto;
  border: 1px solid var(--line); border-radius: 6px; background: var(--sky);
}
.ocr-crop p { margin: var(--gap-s) 0 0; color: var(--muted); font-size: var(--fs-small); }

/* ---------- The two notes and the call to action ---------- */

.ocr-notes { margin-block-end: var(--gap-xl); }
.ocr-cta { margin-block-end: var(--space-section); }

/* ---------- Narrow screens ---------- */

@media (max-width: 760px) {
  .ocr-source { max-inline-size: none; }
  .ocr-counted { margin-inline-start: 0; flex: 1 0 100%; }
  .ocr-picked { gap: var(--gap-m); }
  .ocr-thumb { inline-size: 88px; min-block-size: 114px; }
}

/* ---------- Print ---------- */

@media print {
  .ocr-card, .ocr-source, .ocr-toolbar, .ocr-notes, .ocr-cta { display: none; }
  .ocr-text { max-block-size: none; overflow: visible; }
}
