/* One canonical profile garage layout at EVERY viewport width:
 * featured saved-default car FIRST, across two columns; the remaining
 * vehicles and add-vehicle tile share a two-column grid below it.
 * Loaded after earlier light styles; do not stack the previous v1 layer.
 */
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;
    align-items: stretch;
    gap: 10px;
    padding: 0;
    margin: 0;
    overflow: visible;
    direction: rtl;
}
html[data-theme="light"] body .profile-page .profile-garage__card,
html[data-theme="light"] body .profile-page .profile-garage__add-card {
    position: relative;
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    height: 206px !important;
    border-radius: 17px;
    border: 1px solid #dfe5e9 !important;
    background: #fff !important;
    box-shadow: 0 5px 15px rgba(32, 43, 50, .065) !important;
    overflow: hidden;
}
/* The default car is the FIRST item in markup and owns the entire first row.
 * All later ordinary cars and the Add tile occupy the two-column rows. */
html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary {
    grid-column: 1 / -1 !important;
    height: 208px !important;
    border: 1px solid #d7b277 !important;
    border-radius: 20px !important;
    background: radial-gradient(circle at 12% 28%,rgba(210,144,48,.13),transparent 41%),linear-gradient(145deg,#fffaf2,#fff 60%) !important;
    box-shadow: 0 8px 20px rgba(76,60,38,.085) !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card--primary::before {
    pointer-events: none;
    background: none !important;
}
html[data-theme="light"] body .profile-page .profile-garage__body {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
}
html[data-theme="light"] body .profile-page .profile-garage__card:not(.profile-garage__card--primary) .profile-garage__body > img {
    position: absolute;
    top: 23px !important;
    right: 5px !important;
    left: 5px !important;
    width: calc(100% - 10px) !important;
    height: 81px !important;
    object-fit: contain;
    filter: drop-shadow(0 6px 6px rgba(30,40,50,.10));
}
html[data-theme="light"] body .profile-page .profile-garage__card:not(.profile-garage__card--primary) .profile-garage__copy {
    position: absolute;
    top: 118px !important;
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    text-align: right;
}
html[data-theme="light"] body .profile-page .profile-garage__card:not(.profile-garage__card--primary) .profile-garage__copy strong {
    width: 100%;
    font-size: 11px !important;
    line-height: 17px !important;
    color: #172028 !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
html[data-theme="light"] body .profile-page .profile-garage__card:not(.profile-garage__card--primary) .profile-garage__plate {
    margin-top: 1px !important;
    max-width: 100%;
    font-size: 9px !important;
    color: #48525b !important;
}
/* The large default car preserves the desktop image-left, copy-right layout
 * at phone widths rather than collapsing into another tiny grid card. */
html[data-theme="light"] body .profile-page .profile-garage__card--primary .profile-garage__body > img {
    top: 26px !important;
    right: auto !important;
    left: 4px !important;
    width: 56% !important;
    height: 132px !important;
    object-fit: contain;
    filter: drop-shadow(0 10px 11px rgba(32,42,48,.15)) !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary .profile-garage__copy {
    top: 62px !important;
    right: 12px !important;
    left: auto !important;
    width: 40% !important;
    align-items: flex-start;
    gap: 9px;
    text-align: right;
}
html[data-theme="light"] body .profile-page .profile-garage__card--primary .profile-garage__copy strong {
    color: #172028 !important;
    font-size: clamp(12px, 3.2vw, 15px) !important;
    line-height: 1.6 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card--primary .profile-garage__plate {
    margin-top: 1px !important;
    max-width: 100%;
    font-size: 10px !important;
    color: #48525b !important;
}
/* Legacy refinements painted a black footer and had higher precedence than
 * the first light-theme patch. Remove that black band for every card. */
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__meta {
    position: absolute !important;
    z-index: 2 !important;
    right: 10px !important;
    bottom: 9px !important;
    left: 10px !important;
    height: 27px !important;
    box-sizing: border-box;
    display: flex !important;
    flex-wrap: nowrap;
    justify-content: space-between !important;
    align-items: flex-end !important;
    padding: 5px 1px 0 !important;
    border-top: 1px solid #e6e9ed !important;
    background: transparent !important;
    color: #505d66 !important;
    visibility: visible !important;
    opacity: 1 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__meta small {
    display: block !important;
    color: #6e7982 !important;
    font-size: var(--eb-type-caption) !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card .profile-garage__meta b {
    display: block !important;
    color: #2f3941 !important;
    font-size: var(--eb-type-caption) !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card--primary .profile-garage__meta {
    right: 13px !important;
    left: 13px !important;
    bottom: 11px !important;
}
html[data-theme="light"] body .profile-page .profile-garage__card > .profile-garage__default-badge {
    top: 10px !important;
    right: 11px !important;
    border: 1px solid #e2c28f !important;
    background: #fff1d8 !important;
    color: #985b13 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__menu {
    top: 9px;
    left: 9px;
    right: auto;
    z-index: 5;
    background: rgba(255,255,255,.97) !important;
    color: #2c3640 !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: #172028 !important;
}
html[data-theme="light"] body .profile-page .profile-garage__add-card strong { color: #172028 !important; }
/* Tiny devices still keep readable text, two columns, and the large card. */
@media (max-width: 375px) {
    html[data-theme="light"] body .profile-page .profile-garage__list { gap: 7px; }
    html[data-theme="light"] body .profile-page .profile-garage__card:not(.profile-garage__card--primary) .profile-garage__copy strong { font-size: 10px !important; }
    html[data-theme="light"] body .profile-page .profile-garage__card--primary .profile-garage__body > img { width: 53% !important; }
    html[data-theme="light"] body .profile-page .profile-garage__card.profile-garage__card--primary .profile-garage__copy { width: 43% !important; right: 9px !important; }
}

/* With an empty garage, use the available width for the Add tile. */
html[data-theme="light"] body .profile-page .profile-garage__list > .profile-garage__add-card:only-child { grid-column: 1 / -1; }


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

/* Profile consolidation: vehicle documents and compact account transactions.
 * Only profile composition is defined here; control styles remain in Design System. */
.profile-vehicle-documents{margin:24px 0}
.profile-vehicle-documents__details{border:1px solid var(--eb-border);border-radius:16px;background:var(--eb-surface);overflow:hidden}
.profile-vehicle-documents__details>summary{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:64px;padding:14px 16px;cursor:pointer;list-style:none;color:var(--eb-text)}
.profile-vehicle-documents__details>summary::-webkit-details-marker{display:none}
.profile-vehicle-documents__details>summary strong{display:block;font-size:14px;font-weight:800}
.profile-vehicle-documents__details>summary small{display:block;margin-top:4px;font-size:12px;color:var(--eb-muted)}
.profile-vehicle-documents__details[open]>summary{border-bottom:1px solid var(--eb-border)}
.profile-vehicle-documents__content{padding:16px}
.profile-vehicle-documents .vehicle-documents-v2{margin:0}
.profile-vehicle-documents .vehicle-documents-v2__list{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}
.profile-vehicle-documents .vehicle-documents-v2__card{min-width:0}
.profile-vehicle-documents :is(select,input[type="file"]){max-width:100%}
.profile-account-transactions{margin:24px 0;padding:16px;border-radius:16px}
.profile-account-transactions__head{display:flex;align-items:center;justify-content:space-between;gap:12px}
.profile-account-transactions__head h2{margin:0;color:var(--eb-text)}
.profile-account-transactions__head p{margin:4px 0 0;color:var(--eb-muted);font-size:12px}
.profile-account-transactions__list{display:grid;gap:8px;margin-top:12px}
.profile-account-transactions__row{display:flex;justify-content:space-between;align-items:center;gap:12px;min-width:0;padding:12px;border:1px solid var(--eb-border);border-radius:12px;background:var(--eb-surface-soft)}
.profile-account-transactions__row>div{min-width:0}
.profile-account-transactions__row strong{display:block;color:var(--eb-text);font-size:13px;font-weight:700}
.profile-account-transactions__row small{display:block;margin-top:4px;color:var(--eb-muted);font-size:11px}
.profile-account-transactions__row>bdi{flex:none;color:var(--eb-text);font-size:12px;font-weight:800}
.profile-account-transactions__empty{margin:12px 0 0;color:var(--eb-muted);font-size:13px}
