/* Phone and small-tablet refinements. Loaded last so it can correct the earlier stylesheets
   without editing their desktop rules. Everything here is inside a media query. */

/* iOS Safari zooms the page in when a focused input's text is under 16px. Every control the
   visitor types into therefore needs at least 16px on touch screens, whatever the design size.
   conversion-flow.css scopes these as `.conversion-form .file-options input`, so matching that
   specificity is what makes the override stick. */
@media (max-width: 820px) {
  .file-options input, .file-options select,
  .conversion-form .file-options input, .conversion-form .file-options select,
  .search input, .qr-input, .qr-panel select, .qr-panel input[type=text] {
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overscroll-behavior-y: contain; }
  a, button { -webkit-tap-highlight-color: rgba(22, 93, 255, .15); }

  /* Converter actions: the primary button is the point of the page, so it goes full width and
     above "Clear files" rather than sharing a cramped row with it. */
  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
    margin-top: 18px;
  }
  .actions .primary {
    width: 100%;
    min-height: 52px;
    padding: 14px 20px;
    font-size: 16px;
    border-radius: 11px;
  }
  .actions .secondary {
    width: 100%;
    min-height: 44px;
    padding: 11px;
    font-size: 14px;
  }

  /* Page range and rotation sit on their own full-width rows instead of a squeezed inline pair. */
  .file-options {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px 0 4px;
  }
  .file-options label, .conversion-form .file-options label {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    font-size: 14px;
  }
  /* The desktop rule caps these at 170-210px, which leaves most of the row empty on a phone. */
  .file-options input, .file-options select,
  .conversion-form .file-options input, .conversion-form .file-options select {
    flex: 1;
    min-width: 0;
    max-width: none;
    min-height: 46px;
    margin-left: 0;
    padding: 11px 13px;
    border-radius: 9px;
  }

  /* Supporting copy was down at 9-10px, which is below comfortable reading size on a phone. */
  .file-upload .file-upload-limits,
  .conversion-form .drop-zone.file-upload .file-upload-limits { font-size: 11px; line-height: 1.7; }
  .file-upload .file-upload-hint,
  .conversion-form .drop-zone.file-upload .file-upload-hint { font-size: 13px; }
  .pdf-preview-more, .smart-drop-note { font-size: 11px; }

  /* Tap targets: 44px is the smallest comfortable touch area, so small text links get padding
     rather than a larger font, which would change the visual design. */
  .brand { min-height: 44px; }
  .footer-links { gap: 8px 22px; }
  .footer-links a, .footer-brand {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  /* Links inside running prose keep their natural height; padding them to 44px would open up
     the line spacing of the paragraph around them. */
  .breadcrumb { gap: 7px; font-size: 13px; flex-wrap: wrap; }
  .breadcrumb a { display: inline-flex; align-items: center; min-height: 40px; }
  .doc-page .doc-email { display: inline-flex; align-items: center; min-height: 44px; }
  .file-row .small-btn { min-width: 40px; min-height: 40px; }
  .no-engine a, .qrg-advanced-toggle, .smart-drop-more {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  /* Horizontal strips: momentum scrolling and snap so pages land squarely under the thumb. */
  .pdf-preview-strip, .header-inner #category-nav, .pe-toolbar {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pdf-preview-strip::-webkit-scrollbar, .pe-toolbar::-webkit-scrollbar { display: none; }
  .pdf-preview-strip { scroll-snap-type: x proximity; }
  .pdf-preview-page { scroll-snap-align: start; }

  /* Result screen: downloads are the payoff, so give them full-width rows and real tap areas. */
  .flow-download-main { width: 100%; min-height: 52px; justify-content: center; }
  .flow-download-list a { min-height: 52px; }
}

/* The PDF editor keeps its desktop workspace on a phone because the page canvas needs the room.
   The tool strip scrolls sideways, so it gets an edge fade to show there is more beyond it. */
@media (max-width: 600px) {
  .pe-toolbar {
    position: relative;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }
  .pe-toolbar button { min-width: 46px; }
}

@media (max-width: 380px) {
  .doc-head h1 { font-size: 27px; }
  .smart-drop-copy h2 { font-size: 16px; }
  .pdf-preview-page { width: 78px; }
  .pdf-preview-canvas { height: 94px; }
  .pdf-preview-canvas canvas { max-height: 94px; }
}

/* Pointer-coarse devices get the same minimum tap areas regardless of how wide the screen is,
   which covers tablets in landscape and touch laptops. */
@media (pointer: coarse) {
  .nav-category, .dropdown-tool, .header-button { min-height: 44px; }
  .pdf-preview-page { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .pdf-preview-strip { scroll-snap-type: none; }
}
