/**
 * APD 47.0.0 · Visual Match desktop pass
 * Reference: APD Twin Capture 2.2 (Airbnb + APD, 1440 × 900).
 * Keeps Homey/APD engines intact and only normalizes the shared visual shell.
 */

@media (min-width: 1180px) {
    :root {
        --apd47-shell-max: 1329px;
        --apd47-header-row-height: 94px;
        --apd47-search-width: 850px;
        --apd47-search-height: 66px;
        --apd47-card-gap: 12px;
        --apd47-card-radius: 20px;
    }

    html body.apd47-visual-match .apd5-header.is-discovery-context {
        width: 100% !important;
        min-width: 0 !important;
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
        overflow: visible !important;
        border-bottom: 1px solid #ebebeb !important;
        background: rgba(255,255,255,.99) !important;
        box-shadow: none !important;
    }

    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-header-row {
        width: min(calc(100% - 96px), var(--apd47-shell-max)) !important;
        min-width: 0 !important;
        max-width: var(--apd47-shell-max) !important;
        height: var(--apd47-header-row-height) !important;
        min-height: var(--apd47-header-row-height) !important;
        max-height: var(--apd47-header-row-height) !important;
        margin: 0 auto !important;
        padding: 0 !important;
        display: grid !important;
        grid-template-columns: 184px minmax(0,1fr) 278px !important;
        align-items: center !important;
        column-gap: 18px !important;
        transform: none !important;
    }

    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-logo {
        width: 102px !important;
        min-width: 102px !important;
        max-width: 102px !important;
        height: 80px !important;
        min-height: 80px !important;
        max-height: 80px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        justify-self: start !important;
    }
    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-logo img {
        width: 102px !important;
        min-width: 102px !important;
        max-width: 102px !important;
        height: 32px !important;
        min-height: 32px !important;
        max-height: 32px !important;
        object-fit: contain !important;
        object-position: left center !important;
        transform: none !important;
    }

    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-main-nav {
        width: 500px !important;
        min-width: 500px !important;
        max-width: 500px !important;
        height: 80px !important;
        min-height: 80px !important;
        max-height: 80px !important;
        margin: 0 auto !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 16px !important;
        justify-self: center !important;
        transform: none !important;
    }
    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-main-nav > a {
        min-width: 88px !important;
        height: 80px !important;
        min-height: 80px !important;
        padding: 7px 4px 8px !important;
        gap: 4px !important;
        border-radius: 12px !important;
        transition: color .16s ease, transform .16s ease, background-color .16s ease !important;
    }
    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-main-nav > a:hover {
        background: #f7f7f7 !important;
        transform: translateY(-1px) !important;
    }
    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-main-nav > a:active {
        transform: scale(.97) !important;
    }

    html body.apd47-visual-match .apd5-header.is-discovery-context .apd5-header-actions {
        width: 278px !important;
        min-width: 278px !important;
        max-width: 278px !important;
        height: 80px !important;
        min-height: 80px !important;
        max-height: 80px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        justify-self: end !important;
        transform: none !important;
    }

    html body.apd47-visual-match .apd5-header.is-discovery-context:not(.is-compact) > .apd5-header-search-row,
    html body.apd47-visual-match .apd5-header.is-discovery-context.is-compact.is-search-expanded > .apd5-header-search-row {
        position: absolute !important;
        inset: 102px auto auto 50% !important;
        width: var(--apd47-search-width) !important;
        min-width: var(--apd47-search-width) !important;
        max-width: var(--apd47-search-width) !important;
        height: var(--apd47-search-height) !important;
        min-height: var(--apd47-search-height) !important;
        max-height: var(--apd47-search-height) !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: translateX(-50%) !important;
        overflow: visible !important;
    }

    html body.apd47-visual-match .apd5-header.is-discovery-context:not(.is-compact) .apd5-search,
    html body.apd47-visual-match .apd5-header.is-discovery-context.is-compact.is-search-expanded .apd5-search {
        width: var(--apd47-search-width) !important;
        min-width: var(--apd47-search-width) !important;
        max-width: var(--apd47-search-width) !important;
        height: var(--apd47-search-height) !important;
        min-height: var(--apd47-search-height) !important;
        max-height: var(--apd47-search-height) !important;
        grid-template-columns: 278px 1px 283px 1px 239px 48px !important;
        border: 1px solid #dedede !important;
        border-radius: 33px !important;
        background: #fff !important;
        box-shadow: 0 0 0 1px rgba(0,0,0,.02), 0 8px 24px rgba(0,0,0,.10) !important;
        overflow: visible !important;
    }

    html body.apd47-visual-match .apd5-search .apd5-search-field,
    html body.apd47-visual-match .apd5-search .apd5-search-field > button {
        height: 64px !important;
        min-height: 64px !important;
        max-height: 64px !important;
    }
    html body.apd47-visual-match .apd5-search .apd5-search-field > button {
        padding: 0 24px !important;
        border-radius: 32px !important;
        transition: background-color .16s ease, box-shadow .16s ease, transform .12s ease !important;
    }
    html body.apd47-visual-match .apd5-search .apd5-search-field > button:hover {
        background: #f2f2f2 !important;
    }
    html body.apd47-visual-match .apd5-search .apd5-search-field.is-active > button,
    html body.apd47-visual-match .apd5-search .apd5-search-field[aria-expanded="true"] > button,
    html body.apd47-visual-match .apd5-search .apd5-search-field > button[aria-expanded="true"] {
        background: #fff !important;
        box-shadow: 0 6px 20px rgba(0,0,0,.13) !important;
    }
    html body.apd47-visual-match .apd5-search-submit {
        width: 48px !important;
        min-width: 48px !important;
        max-width: 48px !important;
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        margin: 9px 9px 9px -9px !important;
        border-radius: 50% !important;
        box-shadow: none !important;
        transition: transform .14s ease, box-shadow .14s ease, filter .14s ease !important;
    }
    html body.apd47-visual-match .apd5-search-submit:hover {
        transform: scale(1.04) !important;
        box-shadow: 0 6px 16px rgba(13,43,108,.23) !important;
        filter: brightness(1.03) !important;
    }
    html body.apd47-visual-match .apd5-search-submit:active {
        transform: scale(.96) !important;
    }

    html body.apd47-visual-match .apd5-main,
    html body.apd47-visual-match .apd31-catalog,
    html body.apd47-visual-match .apd5-footer-grid,
    html body.apd47-visual-match .apd24-footer-bottom {
        width: min(calc(100% - 96px), var(--apd47-shell-max)) !important;
        min-width: 0 !important;
        max-width: var(--apd47-shell-max) !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box !important;
    }

    html body.apd47-visual-match .apd5-card-rail {
        width: 100% !important;
        grid-auto-columns: calc((100% - (6 * var(--apd47-card-gap))) / 7) !important;
        gap: var(--apd47-card-gap) !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        scroll-padding-left: 0 !important;
    }
    html body.apd47-visual-match .apd5-card {
        min-width: 0 !important;
        transform: none !important;
    }
    html body.apd47-visual-match .apd5-card-media {
        aspect-ratio: 179.5625 / 170.5781 !important;
        border-radius: var(--apd47-card-radius) !important;
        box-shadow: none !important;
        overflow: hidden !important;
    }
    html body.apd47-visual-match .apd5-card:hover {
        transform: none !important;
    }
    html body.apd47-visual-match .apd5-card:hover .apd5-card-media {
        box-shadow: none !important;
    }
    html body.apd47-visual-match .apd5-card-media img {
        transition: transform .28s cubic-bezier(.2,.8,.2,1) !important;
    }
    html body.apd47-visual-match .apd5-card:hover .apd5-card-media img {
        transform: scale(1.025) !important;
    }

    /* The compare drawer must never participate in document width or be visible on first paint. */
    html body.apd47-visual-match:not(.compare-property-active) .compare-property-panel-vertical,
    html body.apd47-visual-match:not(.compare-property-active) #compare-property-panel,
    html body.apd47-visual-match:not(.compare-property-active) #compare-exp-property-panel {
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

@media (min-width: 1600px) {
    :root { --apd47-shell-max: 1472px; }
}
