/* Shared phone and tablet guardrails for every customer-facing page. */
html {
    max-width: 100%;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    max-width: 100%;
    overflow-wrap: break-word;
}

button,
[role="button"],
input,
select,
textarea,
a {
    touch-action: manipulation;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
}

/* Keep iPhone and iPad Safari from zooming the page when a form field receives focus. */
@media (max-width: 820px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
        font-size: max(16px, 1em);
    }
}

@media (max-width: 760px) {
    html {
        scroll-padding-top: 88px;
    }

    body {
        overflow-x: clip;
    }

    .mobile-menu-toggle,
    .cart-close-button,
    .modal-close-button,
    .inventory-filter-close,
    .inventory-filter-open,
    .inventory-filter-show-results {
        min-width: 44px;
        min-height: 44px;
    }

    .cart-drawer,
    .inventory-filter-panel {
        height: 100dvh;
        max-height: 100dvh;
        overscroll-behavior: contain;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .cart-header,
    .inventory-filter-header {
        padding-top: max(18px, env(safe-area-inset-top, 0px));
    }

    .inventory-filter-show-results {
        bottom: max(0px, env(safe-area-inset-bottom, 0px));
    }

    .product-modal {
        padding:
            max(8px, env(safe-area-inset-top, 0px))
            max(8px, env(safe-area-inset-right, 0px))
            max(8px, env(safe-area-inset-bottom, 0px))
            max(8px, env(safe-area-inset-left, 0px));
    }

    .product-modal-panel {
        width: 100%;
        max-height: calc(100dvh - 16px);
        overscroll-behavior: contain;
    }

    .modal-product-content,
    .product-modal-panel {
        scrollbar-gutter: stable;
    }

    .auth-shell {
        min-height: 100dvh;
        padding:
            max(24px, env(safe-area-inset-top, 0px))
            max(14px, env(safe-area-inset-right, 0px))
            max(24px, env(safe-area-inset-bottom, 0px))
            max(14px, env(safe-area-inset-left, 0px));
    }

    .auth-card {
        width: min(100%, 520px);
    }

    .legal-header-inner {
        gap: 8px;
        padding: 10px 0 8px;
    }

    .legal-brand img {
        width: 118px;
    }

    .legal-nav {
        width: 100%;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 6px;
        padding: 0 0 2px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .legal-nav::-webkit-scrollbar {
        display: none;
    }

    .legal-nav a {
        flex: 0 0 auto;
        display: inline-flex;
        min-height: 42px;
        align-items: center;
        padding: 8px 10px;
        white-space: nowrap;
    }

    .legal-main {
        padding-top: 30px;
    }

    .legal-hero {
        gap: 22px;
    }

    .legal-callout {
        padding: 20px;
    }

    .legal-footer-links {
        gap: 10px 18px;
    }

    dialog {
        max-width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }
}

@media (max-width: 430px) {
    .accessory-market-grid {
        grid-template-columns: 1fr;
    }

    .accessory-listing-image {
        height: clamp(210px, 70vw, 270px);
        min-height: clamp(210px, 70vw, 270px);
    }

    .accessory-listing-image img {
        height: clamp(184px, 62vw, 240px);
    }

    .accessory-listing-content h3 {
        font-size: 1rem;
    }

    .accessory-listing-link {
        min-height: 44px;
    }

    .legal-hero h1 {
        font-size: clamp(2.2rem, 13vw, 3.15rem);
    }

    .legal-meta,
    .legal-section,
    .legal-callout {
        padding-right: 18px;
        padding-left: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
