/* Ebadi profile garage — canonical, mobile-first card layout.
 * Image, identity and metadata occupy separate grid rows: never overlap.
 * Preserve the vertical touch-scroll/gesture rules further below.
 */
html[data-theme="light"] body .profile-page .profile-garage {
    width: 100%;
    min-width: 0;
    background: transparent;
}
html[data-theme="light"] body .profile-page .profile-garage__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row;
    gap: 10px;
    padding: 0;
    margin: 0;
    overflow: visible;
    direction: rtl;
}
html[data-theme="light"] body .profile-page :is(.profile-garage__card,.profile-garage__add-card) {
    box-sizing: border-box;
    position: relative;
    min-width: 0;
    width: 100%;
    height: 206px !important;
    border: 1px solid #e9e4dc !important;
    border-radius: 16px !important;
    background: #fff !important;
    box-shadow: 0 6px 20px rgba(31,35,40,.06) !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary {
    grid-column: 1 / -1;
    height: 208px !important;
    border-color: #c8922f !important;
    background: #fff !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card--primary::before {
    display: none !important;
}
/* The link is the card's layout root. Do not use absolute top offsets for text. */
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__body {
    display: grid !important;
    grid-template-columns: minmax(0,1fr);
    grid-template-rows: 108px minmax(0,1fr) 30px;
    row-gap: 4px;
    align-items: start;
    width: 100%;
    height: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px 8px 6px !important;
    direction: rtl;
    text-decoration: none;
}
html[data-theme="light"] body .profile-page .profile-garage__card:not(.profile-garage__card--primary) .profile-garage__body > img {
    display: block !important;
    position: static !important;
    grid-row: 1;
    grid-column: 1;
    width: 100% !important;
    max-width: 100% !important;
    height: 95px !important;
    min-width: 0;
    padding: 0;
    margin: 4px auto 0;
    object-fit: contain !important;
    object-position: center center !important;
    filter: none !important;
    mix-blend-mode: normal !important;
    transform: none !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card:not(.profile-garage__card--primary) .profile-garage__copy {
    position: static !important;
    display: flex !important;
    grid-row: 2;
    grid-column: 1;
    width: 100% !important;
    min-width: 0;
    margin: 0 !important;
    padding: 0 2px !important;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2px;
    text-align: right;
    transform: none !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__copy strong {
    display: -webkit-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal !important;
    overflow-wrap: anywhere;
    text-overflow: clip;
    color: #1f2328 !important;
    font-size: 12px !important;
    font-weight: 800;
    line-height: 1.4 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__plate {
    max-width: 100%;
    margin: 0 !important;
    color: #76716b !important;
    font-size: 11px !important;
    line-height: 1.4 !important;
}
/* Featured vehicle: media on the left, title on the right; footer spans both. */
html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary .profile-garage__body {
    grid-template-columns: minmax(0,1fr) minmax(0,1.08fr);
    grid-template-rows: minmax(0,1fr) 30px;
    column-gap: 10px;
    padding: 22px 12px 10px !important;
    align-items: center;
}
html[data-theme="light"] body .profile-page .profile-garage__card--primary .profile-garage__body > img {
    display: block !important;
    position: static !important;
    grid-row: 1;
    grid-column: 2;
    width: 100% !important;
    max-width: 100% !important;
    height: 120px !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    object-position: center center !important;
    filter: none !important;
    mix-blend-mode: normal !important;
    transform: none !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary .profile-garage__copy {
    display: flex !important;
    position: static !important;
    grid-row: 1;
    grid-column: 1;
    width: 100% !important;
    min-width: 0;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 10px 0 0 !important;
    margin: 0 !important;
    text-align: right;
    transform: none !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card--primary .profile-garage__copy strong {
    font-size: 14px !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__meta,
html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary .profile-garage__meta {
    display: flex !important;
    position: static !important;
    grid-row: -2 / -1;
    grid-column: 1 / -1;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box;
    width: 100% !important;
    height: 30px !important;
    min-width: 0;
    padding: 4px 2px 0 !important;
    margin: 0 !important;
    border-top: 1px solid #e9e4dc !important;
    background: transparent !important;
    visibility: visible !important;
    opacity: 1 !important;
    direction: rtl;
}
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__meta small,
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__meta b {
    color: #76716b !important;
    font-size: 11px !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__meta b {
    color: #1f2328 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card > .profile-garage__default-badge {
    position: absolute !important;
    z-index: 3;
    top: 8px !important;
    right: 10px !important;
    bottom: auto !important;
    left: auto !important;
    background: #f7ebd5 !important;
    border: 1px solid #e9e4dc !important;
    color: #9a681c !important;
}
html[data-theme="light"] body .profile-page .profile-garage__menu {
    position: absolute;
    z-index: 5;
    top: 8px;
    right: auto;
    left: 8px;
    background: #fff !important;
    color: #1f2328 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__add-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #1f2328 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__list > .profile-garage__add-card:only-child {
    grid-column: 1 / -1;
}
@media (max-width: 375px) {
    html[data-theme="light"] body .profile-page .profile-garage__list { gap: 8px; }
    html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary .profile-garage__body {
        column-gap: 8px;
        padding-inline: 8px !important;
    }
}

/* 3.19.27: Let the browser own the entire Profile scroll, including when
 * a gesture starts on a saved-car image, card, or the add-vehicle tile.
 * The old mobile overrides combined overflow:clip, touch-action:pan-y on nested
 * layers, and iOS-composited card tap effects. No nested scroll port is needed. */
@media (max-width: 640px) and (pointer: coarse) {
    html[data-theme="light"] body .profile-page .profile-garage,
    html[data-theme="light"] body .profile-page .profile-garage__list,
    html[data-theme="light"] body .profile-page .profile-garage__card,
    html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary,
    html[data-theme="light"] body .profile-page .profile-garage__add-card,
    html[data-theme="light"] body .profile-page .profile-garage__body,
    html[data-theme="light"] body .profile-page .profile-garage__copy,
    html[data-theme="light"] body .profile-page .profile-garage__meta,
    html[data-theme="light"] body .profile-page .profile-garage__body > img {
        touch-action: auto !important;
        overscroll-behavior-y: auto !important;
        -webkit-overflow-scrolling: auto !important;
        will-change: auto !important;
    }
    html[data-theme="light"] body .profile-page .profile-garage,
    html[data-theme="light"] body .profile-page .profile-garage__list,
    html[data-theme="light"] body .profile-page .profile-garage__card,
    html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary,
    html[data-theme="light"] body .profile-page .profile-garage__add-card {
        overflow: visible !important;
        contain: none !important;
    }
    html[data-theme="light"] body.ebadi-profile-touch-scroll {
        height: auto !important;
        min-height: 100svh !important;
        overflow-x: clip !important;
        overflow-y: visible !important;
        overscroll-behavior-y: auto !important;
        touch-action: auto !important;
    }
    html[data-theme="light"] body .profile-page .profile-route {
        height: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
    }
}

/* Beat stale v26 per-card rules if a PWA has both styles during a rollout. */
@media (max-width: 640px) and (pointer: coarse) {
    html[data-theme="light"] body.ebadi-profile-touch-scroll .profile-page .profile-garage__card,
    html[data-theme="light"] body.ebadi-profile-touch-scroll .profile-page .profile-garage__card.profile-garage__card--primary,
    html[data-theme="light"] body.ebadi-profile-touch-scroll .profile-page .profile-garage__add-card {
        overflow: visible !important;
        touch-action: auto !important;
        -webkit-overflow-scrolling: auto !important;
        will-change: auto !important;
    }
    html[data-theme="light"] body.ebadi-profile-touch-scroll .profile-page .profile-garage__body,
    html[data-theme="light"] body.ebadi-profile-touch-scroll .profile-page .profile-garage__body > img,
    html[data-theme="light"] body.ebadi-profile-touch-scroll .profile-page .profile-garage__copy,
    html[data-theme="light"] body.ebadi-profile-touch-scroll .profile-page .profile-garage__meta {
        touch-action: auto !important;
    }
}

/* iOS garage gesture fix — deliberately limited to interactive garage tiles.
 * Vertical swipes must belong to the page, not the link tap animation or image
 * dragging. Keep all card layout, borders, colors and the 3-dot menu unchanged. */
@media (max-width: 640px) and (pointer: coarse) {
    html body .mobile-app.profile-page .profile-garage :is(
        .profile-garage__body,
        .profile-garage__add-card,
        .profile-garage__menu,
        .profile-garage__body > img
    ) {
        touch-action: pan-y pinch-zoom !important;
    }
    .profile-page .profile-garage__body > img {
        -webkit-user-drag: none;
        user-select: none;
        -webkit-user-select: none;
    }
    /* Both the old :active effect and the new JS .is-pressed effect
       transformed full-card links while the finger was moving. */
    html body .mobile-app.profile-page .profile-garage :is(
        .profile-garage__body, .profile-garage__add-card
    ):is(:active, .is-pressed) {
        transform: none !important;
        filter: none !important;
    }
}
