:root {
    --mc-bg: #f1f5f9;
    --mc-surface: #ffffff;
    --mc-border: #e2e8f0;
    --mc-text: #0f172a;
    --mc-muted: #64748b;
    --mc-primary: #dc2626;
    --mc-primary-dark: #b91c1c;
    --mc-ring: rgba(220, 38, 38, 0.2);
    --mc-shadow-sm: 0 8px 20px rgba(2, 8, 23, 0.06);
    --mc-shadow-md: 0 18px 36px rgba(2, 8, 23, 0.12);
    --mc-mesh-1: rgba(220, 38, 38, 0.055);
    --mc-mesh-2: rgba(14, 165, 233, 0.04);
    --mc-mesh-3: rgba(249, 115, 22, 0.045);
}

.mc-card {
    background: linear-gradient(165deg, #ffffff 0%, #fafbfc 55%, #f8fafc 100%);
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 18px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.8) inset,
        0 4px 24px -6px rgba(15, 23, 42, 0.07);
}

.mc-card-hover {
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.28s ease,
        border-color 0.28s ease;
}

.mc-card-hover:hover {
    transform: translateY(-3px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 20px 40px -12px rgba(15, 23, 42, 0.12);
    border-color: rgba(252, 165, 165, 0.65);
}

/* Shared vehicle listing cards (optional hook) */
.mc-vehicle-card-shell {
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: #fff;
    box-shadow: 0 4px 24px -4px rgba(15, 23, 42, 0.07);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s ease,
        border-color 0.3s ease;
}

.mc-vehicle-card-shell:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 48px -16px rgba(15, 23, 42, 0.14);
    border-color: rgba(254, 202, 202, 0.9);
}

/* Listing card — spec pills (shared across home strips, grid, similar cars) */
.mc-vc-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
    border-radius: 9999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    line-height: 1.25rem;
    font-weight: 500;
    color: rgb(71 85 105);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 1px 2px rgba(15, 23, 42, 0.04);
}

.mc-vc-pill ion-icon {
    flex-shrink: 0;
}

/* Fixed-height meta row: scroll instead of clipping extra tags */
.mc-vehicle-card-chips {
    align-content: flex-start;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
}

.mc-vehicle-card-chips::-webkit-scrollbar {
    width: 5px;
}

.mc-vehicle-card-chips::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 9999px;
}

.mc-glass {
    background: linear-gradient(135deg, rgba(255,255,255,0.82), rgba(255,255,255,0.72));
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.mc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border-radius: 9999px;
    font-weight: 600;
    transition: all .2s ease;
    text-decoration: none;
    box-sizing: border-box;
}

.mc-btn-primary {
    background: linear-gradient(135deg, var(--mc-primary) 0%, var(--mc-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(220, 38, 38, 0.25);
}

.mc-btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.mc-btn-primary:active {
    transform: translateY(0);
}

.mc-btn-ghost {
    color: #334155;
    border: 1px solid var(--mc-border);
    background: #fff;
}

.mc-btn-ghost:hover {
    color: var(--mc-primary);
    border-color: #fecaca;
    background: #fff5f5;
}

.mc-input {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.mc-input:focus {
    border-color: var(--mc-primary);
    box-shadow: 0 0 0 4px var(--mc-ring);
    outline: none;
}

.mc-select,
.mc-textarea {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.mc-select:focus,
.mc-textarea:focus {
    border-color: var(--mc-primary);
    box-shadow: 0 0 0 4px var(--mc-ring);
    outline: none;
}

/* —— App shell: sleek page background (all public pages) —— */
body.mc-app {
    min-height: 100vh;
    color: var(--mc-text);
    /* Flat gradient only — background-attachment:fixed forces a full repaint on every scroll frame */
    background: linear-gradient(168deg, #f8fafc 0%, #f1f5f9 42%, #eef2f7 100%);
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Scrollbars (Firefox + WebKit) */
body.mc-app,
body.mc-app * {
    scrollbar-width: thin;
    scrollbar-color: rgba(220, 38, 38, 0.35) rgba(241, 245, 249, 0.8);
}

body.mc-app::-webkit-scrollbar,
body.mc-app *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.mc-app::-webkit-scrollbar-track,
body.mc-app *::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.6);
    border-radius: 8px;
}

body.mc-app::-webkit-scrollbar-thumb,
body.mc-app *::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(220, 38, 38, 0.45), rgba(185, 28, 28, 0.5));
    border-radius: 8px;
}

body.mc-app::-webkit-scrollbar-thumb:hover,
body.mc-app *::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(220, 38, 38, 0.65), rgba(185, 28, 28, 0.7));
}

/* Stronger than `body.mc-app *` above so horizontal strips can truly hide scrollbars */
body.mc-app .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
    scrollbar-color: transparent transparent;
}

body.mc-app .scrollbar-hide::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Glass auth / settings panels */
.mc-panel {
    width: 100%;
    border-radius: 1.25rem;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 250, 252, 0.98) 100%);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.95) inset,
        0 28px 56px -20px rgba(15, 23, 42, 0.14),
        0 0 0 1px rgba(15, 23, 42, 0.04);
}

/* Section surfaces (homepage modules) */
.mc-surface {
    border-radius: 1.25rem;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.88) 0%, rgba(255, 255, 255, 0.72) 100%);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 12px 32px -12px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
}

.mc-surface-muted {
    border-radius: 1rem;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.85) 100%);
    border: 1px solid rgba(226, 232, 240, 0.9);
}

/* Dropdowns / typeahead panels */
.mc-popover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 0.875rem;
    box-shadow:
        0 24px 48px -12px rgba(15, 23, 42, 0.14),
        0 0 0 1px rgba(15, 23, 42, 0.03);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
}

/* Navbar strip — solid-ish bar without backdrop-filter (blur under fixed nav makes vertical scroll janky on many GPUs) */
.mc-navbar {
    background: rgba(255, 255, 255, 0.94);
    border-bottom-color: rgba(226, 232, 240, 0.85);
    box-shadow: 0 4px 24px -8px rgba(15, 23, 42, 0.07);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Footer */
.mc-footer {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.97) 0%, rgba(241, 245, 249, 0.99) 100%);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 -12px 40px -16px rgba(15, 23, 42, 0.05);
}

.mc-footer a {
    transition: color 0.2s ease;
}

.mc-btn-secondary {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #334155;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.mc-btn-secondary:hover {
    border-color: #fecaca;
    color: var(--mc-primary);
    background: #fff;
}

.mc-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    border-radius: 9999px;
    padding: .25rem .6rem;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .01em;
}

.mc-badge-neutral {
    color: #334155;
    background: #f1f5f9;
}

.mc-badge-primary {
    color: #991b1b;
    background: #fee2e2;
}

/* Navbar: keep fixed bar light; avoid extra compositor hints — fixed positioning already promotes a layer */
.mc-navbar {
    will-change: auto;
}

/* Card hover lift: only transform — no box-shadow repaint during scroll */
.mc-vehicle-card-shell,
.mc-card-hover {
    will-change: auto; /* reset until hover */
}
.mc-vehicle-card-shell:hover,
.mc-card-hover:hover {
    will-change: transform;
}

/* Sleek shared polish */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(220, 38, 38, 0.15);
}

/* Media loading states (cars/listings) */
.mc-img-wrap {
    position: relative;
    overflow: hidden;
    background: #e5e7eb;
}

/* One thumbnail frame size everywhere: home strips, listings grid, similar cars, default card */
.mc-vehicle-card-photo {
    position: relative;
    width: 100%;
    height: 11.5rem;
    min-height: 11.5rem;
    max-height: 11.5rem;
    flex-shrink: 0;
}

/* Direct photo: always fill frame with centered crop (aligned across cards) */
.mc-vehicle-card-photo > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.mc-img-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, #eef2f7 8%, #f8fafc 18%, #eef2f7 33%);
    background-size: 220% 100%;
    animation: mc-shimmer 1.4s linear infinite;
    transition: opacity .25s ease;
    will-change: background-position;
}

.mc-img-wrap img {
    opacity: 0;
    object-fit: cover;
    object-position: center;
    /* Only transition opacity + transform — filter transitions are not GPU-composited */
    transition: opacity .28s ease, transform .5s ease;
    will-change: opacity, transform;
}

.mc-img-wrap.is-loaded .mc-img-skeleton {
    opacity: 0;
    pointer-events: none;
    animation: none; /* stop consuming GPU after image is loaded */
}

.mc-img-wrap.is-loaded img {
    opacity: 1;
    will-change: transform; /* keep only transform for hover scale */
}

@keyframes mc-shimmer {
    to { background-position-x: -220%; }
}

/* Focus visibility for keyboard users */
:focus-visible {
    outline: 2px solid var(--mc-primary);
    outline-offset: 2px;
}

.mc-btn:focus-visible,
.mc-input:focus-visible,
.mc-select:focus-visible,
.mc-textarea:focus-visible {
    outline: 2px solid var(--mc-primary);
    outline-offset: 2px;
}
