
#carGallery {
    position: relative;
    width: 100%;
    margin: 0 auto;
    text-align: center;
}

#brandList {
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 20px;
    margin-top: 10px;
    position: relative;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 10px 0;
}

#brandList::-webkit-scrollbar {
    height: 8px;
}

#brandList::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.badge {
    position: absolute;
    top: 5px;
    left: 5px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px;
    color: white;
}

.brandBox {
    position: relative;
    width: 140px;
    height: 140px;
    background: #f7f7f7;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    cursor: pointer;
}

.brandWithModels {
    display: flex;
    align-items: center;
    position: relative;
}

.hidden {
    display: none;
}

.inactive {
    opacity: 0.3;
    filter: blur(1px);
}

.inlineModelList {
    display: flex;
    flex-wrap: nowrap;
    margin-left: 20px;
    gap: 10px;
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
    pointer-events: none;

}

.brandBox:hover {
    transform: scale(1.05);
}

.brandBox > img {
    height: auto;
    max-width: 70%;
    max-height: 50%;
}

.badge.year {
    left: auto;
    right: 8px;
    background: #707070;
}

.inlineModelList img {
    width: auto;
    height: auto;
}

.brandBox .inactive {
    opacity: 0.3;
    filter: blur(1px);
}

.inlineModelList.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.inlineModelList.hidden {
    display: none;
}

.modelCard {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}
.modelCard p {
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 0px;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    padding: 0 4px;
}

.modelCard:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 14px rgba(0,0,0,0.15);
}

.close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: var(--red);
    color: white;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s ease;
    z-index: 200;
    border: none;
}

.close-btn .hidden {
    display: none !important;
}
.close-btn .show {
    display: block !important;
}

.close-btn:hover {
    background-color: #e60000;
}

#liveryInfo {
    width: 100%;
    max-width: 100%;
    margin-bottom: 2rem;
    padding: 0 1rem;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
}

#liveryInfo.show {
    opacity: 1;
    transform: translateY(0);
}

#liveryHeaderRow {
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
#liveryLogo {
    width: 60px;
    height: auto;
}

#liveryHeaderRow h3 {
    font-size: 1.6rem;
    margin: 0;
}

#liveryHeaderRow .badges {
    display: flex;
    gap: 0.5rem; /* 👈 spazio tra GT3 e 2025 */
    align-items: center;
}

#liveryHeaderRow .badge {
    position: static !important;  /* ✅ OVERRIDE */
    top: unset;
    left: unset;
    right: unset;
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 5px;
}

#liveryDescription {
    font-style: italic;
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: left;
    padding-left: 20px;
    color: #444;
}

#canvasLoader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

#canvasLoader.show {
    display: flex;
}

#canvasLoader.hidden {
    display: none;
}

#liveryDetails {
    flex: 1 1 400px;
    width: auto;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    background: #f9f9f9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

#liveryDetails ul {
    display: grid;
    grid-template-columns: repeat(4, minmax(200px, 1fr));
    gap: 10px 20px;
    list-style: none;
    padding: 20px;
    margin: 0;
}

#liveryDetails li {
    background: #fff;
    border: 1px solid #eee;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    font-size: 0.95rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

#liveryDetails li:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#liveryFlexContainer {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.section-title {
    font-family:  'Monument Extended';
    font-size: 1.5rem;
    border-left: 5px solid var(--pink);
}

#liveryFlexContainer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

#showroomContainer {
    flex: 3;
}

#trophiesContainer {
    flex: 1;
    max-height: 500px;
    overflow-y: auto;
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding-right: 15px;   /* o la misura che preferisci */
    box-sizing: border-box;
}

#trophyList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#trophyList li {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: left;
}

.gold {color: var(--gold)}
.silver {color: var(--silver)}
.bronze {color: var(--bronze)}

@media (max-width: 1150px) {
    #liveryFlexContainer {
        flex-direction: column;   /* impila in verticale */
        align-items: stretch;
    }

    #showroomContainer,
    #trophiesContainer {
        flex: 1 1 100%;
        width: 100%;
        max-height: none;         /* evita scrollbar corta su mobile */
        order: 2;                  /* dopo lo showroom (già così per DOM, ma esplicitiamo) */
    }

    #liveryDetails ul {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

@media screen and (max-width: 768px) {
    #liveryHeaderRow {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding-left: 0;
    }
    #liveryHeaderRow h3 {
        flex-direction: column;
        gap: 0.2rem;
    }
    #liveryDescription {
        text-align: center;
        margin: 0.5rem 1rem 1rem;
    }
    #showroom {
        border-radius: 12px;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
        height: 250px;
        background: var(--white);
    }
    /* lista marchi più stretta e scorrevole */
    #brandList {
        gap: 10px;
        padding: 6px 0;
        scroll-snap-type: x mandatory;
    }
    .brandWithModels { scroll-snap-align: start; }

    /* box brand ~50% (da 140 -> 70px) */
    .brandBox {
        width: 72px;
        height: 72px;
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }
    .brandBox img {
        width: 64%;
        max-height: 50%;
    }

    /* badge più piccole */
    .badge {
        padding: 2px 5px;
        font-size: 10px;
        border-radius: 4px;
    }
    .badge.year { right: 6px; }

    /* lista modelli in linea più fitta */
    .inlineModelList {
        gap: 8px;
        margin-left: 12px;
    }

    /* card modello ~50-60% (da 120 -> 70px) */
    .modelCard {
        width: 74px;
        height: 74px;
        margin: 6px;
        padding: 6px;
        border-radius: 10px;
    }
    .inlineModelList img {
        width: 72%;
        height: auto;
    }

    .modelCard p {
        font-size: 0.65rem;
        margin-top: 2px;
        line-height: 1.1;
    }

    #liveryDetailsList li {
        font-size: 0.6rem;   /* ancora più compatto su mobile */
    }

    #liveryDetailsList li strong {
        font-size: 0.7rem;
    }

    #liveryDetails ul {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }
}

@media (max-width: 530px) {
    #liveryName {
        display: none;
    }
    .brandBox { width: 64px; height: 64px; }
    .modelCard { width: 66px; height: 66px; }
    .modelCard p { font-size: 0.6rem; }
    #brandList { gap: 8px; }
}



/* ---- IMMAGINI MODEL LIST (desktop + mobile) ---- */

/* la card diventa una piccola griglia: immagine che riempie, titolo sotto */
.modelCard{
    display: grid;
    grid-template-rows: 1fr auto;   /* img cresce, testo resta in basso */
    place-items: center;
}

/* immagine sempre centrata, senza “baselines” Safari */
.modelCard > img{
    display: block;         /* elimina il gap di baseline su Safari */
    width: auto;            /* lascia proporzioni reali */
    max-width: 80%;         /* non oltrepassa i bordi in orizzontale */
    max-height: 70%;        /* non schiaccia il testo; evita overflow verticale */
    object-fit: contain;    /* nessun crop */
    -webkit-user-drag: none;
}

/* tuning su mobile */
@media (max-width: 768px){
    .modelCard > img{
        max-width: 78%;
        max-height: 62%;
    }
}

.brandWithModels.is-hidden {
    display: none !important;
}

.modelCard.is-active {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.modelCard {
    cursor: pointer;
    background: transparent;
    border: 0;
    padding: 0;
    text-align: inherit;
}

#showroomContainer {
    position: relative;
}

#showroomPreview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
    z-index: 10;
    display: none; /* nascosta di default */
}

/* Spegne la scena 3D */
#showroom.is-hidden {
    display: none;
}

/* =========================
   SHOWROOM DIMENSIONS FIX
   ========================= */

/* Il container deve avere una dimensione propria (altezza) */
#showroomContainer{
    position: relative;
    flex: 1 1 600px;     /* stessa logica del canvas */
    height: 500px;       /* stessa altezza di #showroom desktop */
    min-width: 0;        /* evita overflow in flex */
}

/* Il canvas Three deve riempire il container */
#showroom{
    width: 100%;
    height: 100%;        /* non 500px fisso: eredita dal container */
    flex: none;          /* evita interferenze con flex parent */
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: var(--white);
}

/* La preview riempie lo stesso box del canvas */
#showroomPreview{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
    z-index: 10;
    display: none;       /* come già fai: visibile solo quando showPreview() */
}

/* Spegne solo la scena 3D */
#showroom.is-hidden{
    display: none;
}

/* Mobile: stessa altezza del tuo #showroom (250px) */
@media screen and (max-width: 768px){
    #showroomContainer{
        height: 250px;
    }
}

