/* Match History / Variations Layout */
.match-history-list {
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

/* Variations Navigation Grid */
/* Variations Navigation Grid */
.variations-nav-grid {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    /* Allow items to wrap */
    gap: 1.5rem;
    margin-bottom: 0.5rem;
    padding: 1.5rem;
    background-color: transparent;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.var-nav-item {
    position: relative;
    width: 150px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    /* Vertical stack */
    align-items: center;
    justify-content: space-between;
    /* Space out items */
    transition: all 0.3s ease;
    padding: 5px;
}

.var-nav-item:hover .var-thumb {
    transform: scale(1.1);
}

.var-nav-item.active .var-number {
    color: #000;
    opacity: 0.1;
}

.var-nav-item.active .var-thumb {
    /* filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2)); */
}

.var-number {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: #999;
    z-index: 1;
    line-height: 1;
    transition: all 0.3s ease;
    margin-bottom: 5px;
    /* Spacing below number */
}

/* Remove special styling for :has(img) as we now enforce vertical stack always */
.var-nav-item:has(img) .var-number {
    position: static;
    transform: none;
}

.var-thumb {
    width: 100%;
    flex: 1;
    /* Take remaining space */
    position: relative;
    z-index: 2;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 0;
}

.var-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1)); */
}

/* Existing History Item Styles */
.history-item {
    position: relative;
    padding-top: 0;
    display: none;
    animation: fadeIn 0.5s ease-out;
    flex-direction: column;
    gap: 2rem;
}

.history-item.active {
    display: flex;
}

/* Row 1: Top (Number + Header) */
.history-row-top {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 4rem;
    align-items: flex-end;
    height: 80px;
    overflow: visible;
}

/* Row 2: Mid (Player + Icons + Mockups) */
.history-row-mid {
    display: grid;
    grid-template-columns: 150px 1.3fr 1fr;
    gap: 0;
    align-items: center;
    height: 400px;
    overflow: visible;
}

/* Row 3: Base (Caption + Description) */
.history-row-base {
    display: grid;
    grid-template-columns: 220px 1fr;
    /* Mesma largura da coluna 1 do row-top */
    gap: 4rem;
    align-items: flex-start;
    padding-top: 1.5rem;
}

.base-caption {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: #333;
    text-align: center;
    line-height: 1.4;
    margin-left: -5rem;
}

.base-description {
    padding-left: 0;
}

.base-description p {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    margin: 0;
    max-width: 100%;
}

.history-number {
    font-family: var(--font-heading);
    font-size: 8rem;
    font-weight: 300;
    color: var(--color-mid-gray);
    line-height: 1;
    margin-top: -3.5rem;
    margin-left: -10rem;
    text-align: center;
    pointer-events: none;
}

.history-header-top,
.history-header {
    margin-bottom: 1.5rem;
    padding-left: 0;
}

.col-player {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.assets-cluster {
    margin-top: 0;
    /* Managed by row-mid align-items center */
}

.col-mockups {
    display: flex;
    gap: 0;
    transform: scale(1.1);
    transform-origin: center;
    z-index: 2;
}

.mockup-view:first-child {
    margin-right: -7rem;
    z-index: 3;
}



.match-caption {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: #333;
    border-top: none;
    padding-top: 0;
    width: 100%;
    text-align: center;
    position: relative;
    left: -5rem;
    line-height: 1.4;
}

.caption-player {
    font-weight: 400;
    font-size: 0.9rem;
    color: #666;
    letter-spacing: 1px;
}

.caption-match {
    font-weight: 400;
    color: #000;
}

.caption-match strong {
    font-weight: 900;
    font-size: 1rem;
}

.match-description {
    padding-top: 0.5rem;
    border-top: 1px solid transparent;
    /* To match top alignment if needed */
}

/* Col 1: Player + Info */
.col-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    min-width: 150px;
}

.player-info {
    margin-top: 1rem;
    text-align: center;
}

.player-info .match-caption {
    left: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.player-info .match-description {
    font-size: 0.85rem;
    color: #666;
}

.player-info .match-description p {
    font-size: 0.85rem;
    margin: 0;
}

/* Col 2: Assets/Marcas */
.col-assets {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.no-assets {
    color: #ccc;
    font-size: 2rem;
}

.player-cutout {
    width: 100%;
    height: 400px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
    z-index: 1;
    /* Ensure player is above number */
    margin-left: -5rem;
}

.player-cutout img {
    max-height: 100%;
    width: auto;
    object-fit: contain;
}


/* Col 2: Details */

.match-date {
    display: block;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 2.2rem;
    color: #222;
    margin-bottom: 0px;
}

.match-title {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 1.3rem;
    color: #666;
}

.assets-cluster {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    align-content: center;
    margin-bottom: 2rem;
}

/* Smart Grid Logic based on diagram instructions */

/* N=1: 1x1 */
.assets-cluster:has(> :nth-child(1):last-child) .asset-icon {
    flex: 0 0 100%;
    max-height: 370px;
    max-width: 500px;
}

/* N=2: 2x1 */
.assets-cluster:has(> :nth-child(2):last-child) .asset-icon {
    flex: 0 0 calc(50% - 0.5rem);
    max-height: 370px;
}

/* N=3: 3x1 */
.assets-cluster:has(> :nth-child(3):last-child) {
    flex-wrap: nowrap;
}

.assets-cluster:has(> :nth-child(3):last-child) .asset-icon {
    flex: 1 1 0;
    max-height: 250px;
    width: 0;
    /* Allow flex-grow to take over */
}

/* N=4: 2x2 */
.assets-cluster:has(> :nth-child(4):last-child) .asset-icon {
    flex: 0 0 calc(50% - 0.5rem);
    max-height: 180px;
}

/* N=5: 3+2 (centered) */
.assets-cluster:has(> :nth-child(5):last-child) .asset-icon {
    flex: 0 0 calc(33.33% - 0.5rem);
    max-height: 150px;
}

/* N=6: 3x2 */
.assets-cluster:has(> :nth-child(6):last-child) .asset-icon {
    flex: 0 0 calc(33.33% - 0.5rem);
    max-height: 150px;
}

/* N=7: 4+3 (centered) */
.assets-cluster:has(> :nth-child(7):last-child) .asset-icon {
    flex: 0 0 calc(25% - 0.5rem);
}

/* N=8: 4x2 */
.assets-cluster:has(> :nth-child(8):last-child) .asset-icon {
    flex: 0 0 calc(25% - 0.5rem);
}

/* N=9: 5+4 (centered) */
.assets-cluster:has(> :nth-child(9):last-child) .asset-icon {
    flex: 0 0 calc(20% - 0.5rem);
}

/* N=10: 5x2 */
.assets-cluster:has(> :nth-child(10):last-child) .asset-icon {
    flex: 0 0 calc(20% - 0.5rem);
}

/* N=11: 6+5 (centered) */
.assets-cluster:has(> :nth-child(11):last-child) .asset-icon {
    flex: 0 0 calc(16.66% - 0.5rem);
}

/* N=12: 6x2 */
.assets-cluster:has(> :nth-child(12):last-child) .asset-icon {
    flex: 0 0 calc(16.66% - 0.5rem);
}

.match-description p {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    max-width: 90%;
}


.mockup-view {
    flex: 1;
    aspect-ratio: 3/4;
    background-color: transparent;
    border-radius: 0;
    position: relative;
    overflow: hidden;
}

.mockup-view::after {
    content: 'MOCKUP';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    color: #bbb;
    font-weight: 700;
}

/* Asset Icons (Real Images) */
.asset-icon {
    display: block;
    height: auto;
    width: auto;
    max-width: 220px;
    max-height: 140px;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.asset-icon:hover {
    transform: scale(1.05);
}



/* Remove old placeholder styles if no longer needed, keeping for robustness if mixed */
.logo-box {
    display: none;
    /* Hide old boxes in favor of imgs */
}

.mockup-view img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0;
}

.mockup-view::after {
    content: none;
    /* Remove 'MOCKUP' text when img is present */
}

@media (max-width: 1024px) {
    .history-content-grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2rem;
    }

    .col-player {
        order: 1;
    }

    .col-details {
        order: 2;
        align-items: center;
    }

    .assets-cluster {
        align-items: center;
    }

    .cluster-row {
        justify-content: center;
    }

    .col-mockups {
        order: 3;
        justify-content: center;
    }

    .mockup-view {
        max-width: 200px;
    }

    /* Variations Nav Grid */
    .variations-nav-grid {
        gap: 0.75rem;
    }

    .var-nav-item {
        width: 90px;
    }

    /* Match History */
    .match-history-list {
        gap: 3rem;
    }
}

@media (max-width: 768px) {

    /* Variations Nav */
    .variations-nav-grid {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .var-nav-item {
        width: 70px;
    }

    .var-number {
        font-size: 1.5rem;
        margin-bottom: 3px;
    }

    .var-thumb {
        padding-top: 0;
    }

    .var-thumb img {
        max-height: 70px;
    }

    /* History Item */
    .history-row-top {
        grid-template-columns: 1fr;
        height: auto;
        gap: 0.5rem;
    }

    .history-row-mid {
        grid-template-columns: 1fr;
        height: auto;
        gap: 1rem;
    }

    .history-row-base {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .history-number {
        font-size: 3.5rem;
        margin: 0 auto;
    }

    .col-player .player-cutout img {
        max-height: 250px;
    }

    .col-mockups {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .mockup-view {
        max-width: 150px;
    }

    .mockup-view:first-child {
        margin-right: 0;
    }

    .base-caption {
        margin-left: 0;
        text-align: center;
    }

    .base-description {
        text-align: center;
    }

    /* Assets Cluster */
    .assets-cluster {
        gap: 0.5rem;
    }

    .cluster-row {
        gap: 0.5rem;
    }

    .asset-badge {
        max-width: 40px;
        max-height: 40px;
    }
}

@media (max-width: 480px) {
    .var-nav-item {
        width: 60px;
    }

    .var-number {
        font-size: 1.2rem;
    }

    .var-thumb img {
        max-height: 55px;
    }

    .history-number {
        font-size: 2.5rem;
    }

    .mockup-view {
        max-width: 120px;
    }

    .player-cutout img {
        max-height: 200px;
    }
}