/* 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);
    }
}

/* Compact mobile dealer finder workspace. */
@media (max-width: 760px) {
    .cart-header {
        min-height: 96px;
        padding: 16px 16px 14px;
    }

    .cart-header h2 {
        margin-top: 3px;
        font-size: 1.75rem;
    }

    .cart-close-button {
        top: 16px;
        right: 14px;
        width: 44px;
        height: 44px;
    }

    .ffl-locator {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin: 14px 10px 0;
        padding: 12px;
        border-radius: 12px;
    }

    .ffl-locator > .ffl-locator-heading { order: 1; }
    .ffl-locator > .ffl-directory-tabs { order: 2; }
    .ffl-locator > .ffl-locator-note { order: 3; }
    .ffl-locator > .ffl-locator-controls { order: 4; }
    .ffl-locator > .ffl-directory-status { order: 5; }
    .ffl-locator > .ffl-selected-dealer { order: 6; }
    .ffl-locator > .ffl-map-details { order: 7; }
    .ffl-locator > .ffl-locator-results { order: 8; }
    .ffl-locator > .ffl-results-pager { order: 9; }
    .ffl-locator > .ffl-manual-details { order: 10; }
    .ffl-locator > .ffl-source-message { order: 11; }

    .ffl-locator-heading {
        font-size: 1.16rem;
    }

    .ffl-directory-tabs button {
        min-height: 52px;
        padding: 7px 8px;
        font-size: 0.68rem;
    }

    .ffl-directory-tabs button small,
    .ffl-locator-note,
    .ffl-directory-status {
        font-size: 0.72rem;
    }

    .ffl-locator-controls.is-transferred-mode {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
    }

    .ffl-locator-controls.is-transferred-mode .ffl-find-button {
        width: auto;
        min-width: 76px;
        min-height: 48px;
        padding: 0 12px;
        font-size: 0;
    }

    .ffl-locator-controls.is-transferred-mode .ffl-find-button::after {
        content: "Search";
        font-size: 0.74rem;
    }

    .ffl-map-details,
    .ffl-manual-details {
        border-radius: 11px;
    }

    .ffl-map-heading {
        min-height: 42px;
        padding: 12px;
        font-size: 0.78rem;
    }

    .ffl-map-status {
        display: -webkit-box;
        padding: 10px 12px 0;
        overflow: hidden;
        font-size: 0.7rem;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .ffl-map-legend {
        display: grid;
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 9px 12px 10px;
        font-size: 0.64rem;
    }

    .ffl-map-shell {
        width: 100%;
        min-height: 260px;
        margin: 0;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
        aspect-ratio: auto;
    }

    .ffl-map-shell #fflMapCanvas {
        min-height: 260px;
    }

    .ffl-map-view-switcher {
        bottom: 9px;
        left: 9px;
        max-width: calc(100% - 64px);
        padding: 2px;
    }

    .ffl-map-view-switcher button {
        min-width: 53px;
        min-height: 38px;
        padding: 5px 6px;
        font-size: 0.56rem;
    }

    .ffl-map-view-preview {
        display: none;
    }

    .ffl-map-credits {
        right: 9px;
        bottom: 8px;
    }

    .ffl-map-credits summary {
        display: grid;
        width: 40px;
        min-height: 38px;
        place-items: center;
        padding: 0;
        font-size: 0;
    }

    .ffl-map-credits summary::before {
        margin: 0;
        font-size: 0.82rem;
    }

    .ffl-map-shell .leaflet-control-zoom a {
        width: 40px;
        height: 40px;
        line-height: 40px;
    }

    .ffl-map-external-link {
        min-height: 42px;
        padding: 11px 12px;
        font-size: 0.7rem;
    }

    .ffl-locator-results {
        gap: 7px;
    }

    .ffl-locator-results:not(:empty)::before {
        content: "Matching dealers";
        padding: 4px 2px 0;
        color: #d7d7d7;
        font-size: 0.7rem;
        font-weight: 900;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .ffl-result-card {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 7px 10px;
        padding: 11px;
        border-radius: 9px;
    }

    .ffl-result-number {
        width: 32px;
        height: 32px;
    }

    .ffl-result-copy {
        gap: 2px !important;
    }

    .ffl-result-card strong {
        font-size: 0.84rem;
    }

    .ffl-result-card span,
    .ffl-result-card small {
        font-size: 0.66rem;
    }

    .ffl-result-phone.is-unavailable {
        display: none;
    }

    .ffl-result-card .secondary-button {
        grid-column: 2;
        width: auto;
        min-height: 40px;
        padding: 8px 16px;
        font-size: 0.7rem;
    }

    .ffl-results-pager {
        grid-template-columns: 82px minmax(0, 1fr) 82px;
        gap: 8px;
    }

    .ffl-results-pager span {
        grid-column: 2;
        grid-row: 1;
        font-size: 0.68rem;
    }

    .ffl-results-pager .secondary-button {
        min-height: 42px;
        padding: 8px;
        font-size: 0.7rem;
    }

    .ffl-manual-details summary {
        min-height: 44px;
        padding: 12px;
        font-size: 0.76rem;
    }
}

@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;
    }
}
