/* =============================================================================
   ImageToAll - Image to Text Converter
   =============================================================================
   Only loaded by /image-to-text/. Everything here is scoped to that page's own
   classes, so no existing tool can be affected by it. The shared building blocks -
   .card, .dropzone, .btn, .field, .notice, .steps, .faq, .prose - come from
   site.css and are reused rather than redefined.
   ============================================================================= */

.page-ocr .ocr-tool {
  margin-top: 1.5rem;
}

/* The tool is the page, so it gets more room than a card would usually take. */
.page-ocr .ocr-tool {
  display: grid;
  gap: 1.25rem;
}

/* -----------------------------------------------------------------------------
   The file panel: preview beside its details
   -------------------------------------------------------------------------- */

.page-ocr .ocr-file {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  align-items: start;
  padding: 0.9rem;
  border: 1px solid var(--line, #e2e6ef);
  border-radius: 12px;
  background: var(--surface-2, #f7f9fc);
}

.page-ocr .ocr-preview {
  width: 180px;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
  background:
    repeating-conic-gradient(#eef1f6 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
  display: block;
}

.page-ocr .ocr-file-meta {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.page-ocr .ocr-filename {
  margin: 0;
  font-weight: 600;
  /* A long file name must wrap rather than push the grid wider than the card. */
  overflow-wrap: anywhere;
}

.page-ocr .ocr-file-meta p {
  margin: 0;
}

.page-ocr .ocr-file-meta .btn-row {
  margin-top: 0.35rem;
}

/* -----------------------------------------------------------------------------
   Language
   -------------------------------------------------------------------------- */

.page-ocr .ocr-language select {
  width: 100%;
  max-width: 34rem;
}

/* -----------------------------------------------------------------------------
   Actions
   -------------------------------------------------------------------------- */

.page-ocr .ocr-actions {
  align-items: center;
}

.page-ocr [data-role="ocr-run"] {
  min-width: 10rem;
}

.page-ocr [data-role="ocr-run"][disabled] {
  /* A disabled button that still looks active invites the click that does nothing. */
  cursor: not-allowed;
}

/* -----------------------------------------------------------------------------
   Progress
   -------------------------------------------------------------------------- */

.page-ocr .ocr-progress {
  display: grid;
  gap: 0.4rem;
}

.page-ocr .ocr-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.925rem;
}

.page-ocr .ocr-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3, #e6ebf3);
  overflow: hidden;
}

.page-ocr .ocr-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent, #0b5cff);
  transition: width 180ms ease;
}

/* Respect a reduced-motion preference: the bar still moves, just not smoothly. */
@media (prefers-reduced-motion: reduce) {
  .page-ocr .ocr-bar > span {
    transition: none;
  }
}

/* -----------------------------------------------------------------------------
   Result
   -------------------------------------------------------------------------- */

.page-ocr .ocr-result textarea {
  width: 100%;
  min-height: 14rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9375rem;
  line-height: 1.6;
  /* Long unbroken strings - a URL read off a screenshot - should not force a scrollbar. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.page-ocr .ocr-result .btn-row {
  margin-top: 0.5rem;
}

.page-ocr .ocr-privacy {
  margin-top: 0.25rem;
}

/* -----------------------------------------------------------------------------
   The static content below the tool
   -------------------------------------------------------------------------- */

.page-ocr .ocr-content {
  margin-top: 2.5rem;
}

.page-ocr .ocr-content .section + .section {
  margin-top: 2rem;
}

/* A table inside prose can be wider than a phone. Let it scroll rather than break. */
.page-ocr .ocr-content table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.page-ocr .ocr-content table thead th {
  white-space: nowrap;
}

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

@media (max-width: 640px) {
  .page-ocr .ocr-file {
    grid-template-columns: 1fr;
  }

  .page-ocr .ocr-preview {
    width: 100%;
    max-height: 220px;
  }

  .page-ocr .ocr-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .page-ocr .ocr-actions .btn {
    width: 100%;
  }

  .page-ocr .ocr-result textarea {
    min-height: 11rem;
  }
}
