/* Phones and small tablets: fixes shared by every page.
 *
 * Loaded after the page's own stylesheet (base.html), so it wins ties. The
 * site clips horizontal overflow (html, body { overflow-x: clip }), so a
 * layout that is too wide is not scrollable, it is cut off or squeezed:
 * that is what "scrambled" looked like on a phone. Each rule below fixes one
 * page that did this; tests/test_mobile.py keeps them from coming back.
 */

/* Code blocks scroll sideways inside their own box instead of widening the page. */
pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
img, video { max-width: 100%; }

/* One column below 860px: three plan cards, and the contact form beside its
   text, were squeezed to 100-160px each. minmax(0, 1fr) lets a column shrink
   below its widest word. */
@media (max-width: 860px) {
    .pricing-grid { grid-template-columns: minmax(0, 1fr); max-width: 520px; margin-left: auto; margin-right: auto; }
    .contact-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
    .account-grid { grid-template-columns: minmax(0, 1fr); }
    /* responsive.css already says this, but site.css redefines the grid after
       importing it, so the 280px sidebar column won and the preview got 0px. */
    .theme-gallery-container { grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 0 16px; }
}
@media (max-width: 640px) {
    .product-tour-pair { grid-template-columns: minmax(0, 1fr); }
}

/* The header on a phone: the menu button beside the logo, and the account
   buttons on their own row. Signed in, the wide account chip pushed the menu
   button onto a third row that used a third of the screen. */
@media (max-width: 640px) {
    .navbar { padding: 10px 16px; gap: 8px 10px; }
    .nav-toggle { order: 1; margin-left: auto; }
    .nav-auth { order: 2; flex: 1 1 100%; justify-content: flex-start; }
}

@media (max-width: 768px) {
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

    /* iOS Safari zooms the whole page when a field under 16px gets focus, and
       leaves it zoomed: the other half of "scrambled" on an iPhone. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
    select, textarea { font-size: 16px; }

    /* A long button label wraps instead of widening the column (the account
       page's "Get Pro: 300 downloads a month" made the whole page wider). */
    .btn, .cookie-btn { white-space: normal; }
    .btn-block { text-align: center; justify-content: center; }

    p, li, td, th, dd, h1, h2, h3, h4 { overflow-wrap: break-word; }

    /* Wide tables scroll inside themselves. */
    table.api-table, .gp-article table, .tool-page table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Finger-sized targets for the links people tap most. */
    .footer a, footer a { padding-top: 6px; padding-bottom: 6px; }
    .footer li, footer li { margin-bottom: 2px; }
}

/* Checkout: the pack name was squeezed to ~100px beside the big price. */
@media (max-width: 480px) {
    .checkout-pack { flex-wrap: wrap; }
    .checkout-pack-price { font-size: 1.6rem; }
}
