/* Final responsive regression layer.
   Keep this file last in the cascade so installed PWAs and older component
   generations resolve to one predictable mobile layout. */

@media (max-width: 900px) {
    html,
    body {
        max-width: 100%;
        overflow-x: clip;
    }

    .app-mobile-header {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .app-mobile-brand-row {
        min-width: 0;
        gap: 10px;
    }

    .app-mobile-brand {
        min-width: 0;
        flex: 1 1 auto;
    }

    .app-mobile-brand strong {
        overflow: hidden;
        font-size: clamp(.94rem, 4.4vw, 1.2rem);
        letter-spacing: clamp(.06em, 1.7vw, .11em);
        text-overflow: clip;
        white-space: nowrap;
    }

    .app-mobile-header-actions {
        min-width: 0;
        flex: 0 0 auto;
        gap: clamp(4px, 1.4vw, 8px);
    }

    .app-mobile-header-actions > .app-icon-button,
    .app-mobile-header-actions > .fx-theme-toggle {
        width: 40px;
        min-width: 40px;
        height: 40px;
        min-height: 40px;
    }

    .app-mobile-search {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .app-mobile-search input {
        width: 100%;
        min-width: 0;
    }

    /* Listing details use their back/share/save bar, never the global header too. */
    body.app-route-detail > .app-mobile-header {
        display: none !important;
    }

    .app-route-detail .app-listing-actions {
        position: relative !important;
        inset: auto !important;
        z-index: 2;
        width: 100%;
        min-height: 62px;
        display: flex !important;
        max-width: 100%;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 10px var(--fx-mobile-page-gutter, 16px);
        box-sizing: border-box;
        pointer-events: auto;
        background: var(--fx-bg);
    }

    .app-route-detail .app-listing-actions > div {
        min-width: 0;
        max-width: calc(100% - 56px);
        flex-wrap: nowrap;
    }

    .app-route-detail .app-listing-actions > a,
    .app-route-detail .app-listing-actions button {
        position: static;
        flex: 0 0 auto;
        pointer-events: auto;
        backdrop-filter: none;
    }

    .app-route-detail .app-product-layout,
    .app-route-detail .app-product-media,
    .app-route-detail .app-main-image,
    .app-route-detail .app-product-summary,
    .app-route-detail .app-product-information {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .app-route-detail .app-main-image {
        height: clamp(240px, 68vw, 460px) !important;
        min-height: 0 !important;
        aspect-ratio: auto !important;
        overflow: hidden;
    }

    .app-route-detail .app-main-image img {
        width: 100%;
        max-width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .app-main-image img[hidden],
    .listing-card-media img[hidden],
    .app-thumbnail-row img[hidden] {
        display: none !important;
    }

    .app-route-detail .app-product-summary h1 {
        overflow-wrap: anywhere;
        font-size: clamp(1.3rem, 6.4vw, 2rem);
        line-height: 1.16;
    }

    /* Keep account identity and actions on the same text column. */
    .app-route-account_hub .app-account-header {
        grid-template-columns: 52px minmax(0, 1fr) !important;
        column-gap: 14px;
        row-gap: 10px;
        align-items: center;
        padding: 18px !important;
    }

    .app-route-account_hub .app-account-avatar {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
    }

    .app-route-account_hub .app-account-identity {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
    }

    .app-route-account_hub .app-account-identity h1,
    .app-route-account_hub .app-account-identity p {
        max-width: 100%;
        overflow: hidden;
        overflow-wrap: anywhere;
        text-overflow: ellipsis;
    }

    .app-route-account_hub .app-account-signout {
        grid-column: 2 !important;
        grid-row: 2;
        width: fit-content;
        max-width: 100%;
        justify-self: start !important;
        margin: 0;
        padding: 6px 0;
        line-height: 1.2;
    }

    /* Rails are previews, not full desktop listing cards. */
    .app-product-rail {
        grid-auto-columns: clamp(164px, 52vw, 218px) !important;
        gap: 12px !important;
        max-width: 100%;
        padding-inline: var(--fx-mobile-page-gutter, 16px) !important;
        overflow-x: auto;
    }

    .app-product-rail-item,
    .app-product-rail .app-listing-card {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .app-product-rail .app-listing-card .listing-card-media {
        width: 100%;
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: 4 / 3 !important;
        border-radius: 13px;
    }

    .app-product-rail .app-listing-card .listing-card-body {
        min-width: 0;
        padding: 10px 2px 0;
    }

    .app-product-rail .app-listing-card h3 {
        display: -webkit-box;
        min-height: 0;
        margin: 0;
        overflow: hidden;
        font-size: .9rem;
        line-height: 1.28;
        overflow-wrap: anywhere;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .app-product-rail .app-card-menu {
        width: 30px;
        min-width: 30px;
        height: 30px;
        min-height: 30px;
    }

    .app-product-rail .watch-button {
        width: 36px;
        height: 36px;
    }

    .app-product-rail .badge {
        max-width: calc(100% - 16px);
        padding: 6px 8px;
        font-size: .66rem;
    }

    .app-product-rail .app-card-meta {
        margin-top: 7px;
        overflow: hidden;
        font-size: .72rem;
        line-height: 1.35;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-product-rail .app-card-meta span:nth-child(n + 3),
    .app-product-rail .fault-summary,
    .app-product-rail .delivery-note,
    .app-product-rail .card-auction-line {
        display: none !important;
    }

    .app-product-rail .listing-card-footer {
        gap: 2px;
        margin-top: 8px;
    }

    .app-product-rail .listing-card-footer .price {
        font-size: 1rem;
        line-height: 1.15;
    }

    .app-product-rail .listing-card-footer small {
        overflow: hidden;
        font-size: .68rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-listing-cta.is-past-purchase {
        opacity: 0;
        pointer-events: none;
        transform: translateY(calc(100% + 18px));
    }
}

@media (max-width: 360px) {
    .app-mobile-header {
        gap: 10px;
        padding-inline: 12px;
    }

    .app-mobile-mark {
        width: 32px;
        height: 32px;
    }

    .app-mobile-brand {
        gap: 6px;
    }

    .app-mobile-brand strong {
        font-size: .9rem;
        letter-spacing: .055em;
    }

    .app-mobile-header-actions {
        gap: 3px;
    }

    .app-mobile-header-actions > .app-icon-button,
    .app-mobile-header-actions > .fx-theme-toggle {
        width: 36px;
        min-width: 36px;
        height: 36px;
        min-height: 36px;
    }

    .app-mobile-header-actions svg {
        width: 20px;
        height: 20px;
    }

    .app-mobile-search {
        height: 48px;
        padding-inline: 13px;
    }

    .app-mobile-search input {
        font-size: .86rem;
    }

    .app-route-detail .app-listing-actions > a,
    .app-route-detail .app-listing-actions button {
        width: 40px;
        min-width: 40px;
        height: 40px;
        min-height: 40px;
    }

    .app-route-detail .app-main-image {
        height: 240px !important;
    }

    .app-route-account_hub .app-account-header {
        grid-template-columns: 46px minmax(0, 1fr) !important;
        column-gap: 12px;
        padding: 16px;
    }

    .app-route-account_hub .app-account-avatar {
        width: 46px;
        height: 46px;
        border-radius: 14px;
    }

    .app-product-rail {
        grid-auto-columns: clamp(154px, 52vw, 190px) !important;
        gap: 10px !important;
        padding-inline: 12px !important;
    }
}

@media (min-width: 901px) and (max-width: 1100px) {
    html,
    body {
        max-width: 100%;
        overflow-x: clip;
    }

    .product-layout,
    .app-product-layout,
    .app-product-rail,
    .listing-card {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-listing-cta.is-past-purchase {
        transition: none;
    }
}
