/* ToolGuest shared phone layout.
 *
 * Loaded by every page after its own stylesheet, so these rules win the
 * cascade. Two jobs only:
 *
 *   1. Halve the scroll. Any list of similar cards that a page drops to one
 *      column on a phone becomes two columns. Reading a hundred previews one
 *      per screen is what made font pages 35,000px tall.
 *   2. Make the small controls tappable. Anything under 44px is below the
 *      size a thumb can hit reliably.
 *
 * Rules are scoped to what actually breaks at 320-414px. Nothing here changes
 * desktop layout.
 */

@media (max-width: 640px) {
  /* ---- Two columns for card lists -------------------------------------
   * These are the repeated-card grids across the tool pages. Each card holds
   * a short label plus a preview, so half a phone screen still fits them.
   * `minmax(0, 1fr)` lets a long unbroken string shrink instead of forcing
   * the track wider than the viewport.
   */
  .grid,
  .tools-grid,
  .cluster-grid,
  .mode-grid,
  .alg-grid,
  .build-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* A card that spans the full row stays full width. */
  .grid > .wide,
  .grid > .full,
  .tools-grid > .wide {
    grid-column: 1 / -1;
  }

  /* The trending cards are not label-plus-preview: they carry an icon, a name,
     a category line and a "Hot" badge. Halved to 184px the name column was
     left with 46px and every title truncated, so these stay one per row. */
  #trendingGrid {
    grid-template-columns: 1fr;
  }

  /* ---- Card internals survive the narrower track --------------------- */
  .card {
    padding: 11px 12px 12px;
  }
  .card-top {
    gap: 6px;
    margin-bottom: 6px;
  }
  .card-name {
    min-width: 0;
    font-size: 9.5px;
    letter-spacing: 0.03em;
    line-height: 1.25;
    /* The pin button takes 40px and the copy icon 23px out of a 134px row,
     * leaving 67px for the name. On one line that ellipsed 138 of 202 style
     * names, so the label was unreadable. Two lines fits them all. */
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  /* The word "Copy" is what pushes the name out of the track. The icon
   * still shows the action, and the card itself copies on tap. */
  .copy-tag span {
    display: none;
  }
  .copy-tag {
    padding: 3px 6px;
  }
  .card-out {
    font-size: 15px;
    line-height: 1.35;
  }

  /* ---- Tap targets ---------------------------------------------------
   * The pin button keeps the 40px box the page already gives it under
   * `pointer: coarse`. Shrinking it to fit the narrower card made 202
   * buttons per page too small to hit.
   */
  .chip {
    min-height: 36px;
  }

  /* ---- Trim the vertical padding that adds up over a long page ------- */
  .tool-seo-content {
    padding-bottom: 48px;
  }
  .tool-seo-content .seo-block {
    margin-top: 36px;
  }
  .tool-seo-content p {
    line-height: 1.65;
  }

  /* Headings inside long-form SEO copy were set at desktop scale, which
   * costs a screen of scroll for every section. */
  .tool-seo-content h2 {
    font-size: 1.25rem;
  }
  .tool-seo-content h3 {
    font-size: 0.98rem;
  }
}

/* Very narrow phones: a 320px screen leaves 148px per column, which is too
 * tight for a card with a pin button. Drop back to one column there rather
 * than clip the preview. */
@media (max-width: 359px) {
  .grid,
  .tools-grid,
  .cluster-grid,
  .mode-grid,
  .alg-grid,
  .seo-grid,
  .build-grid {
    grid-template-columns: 1fr;
  }
}
