/* Layout compartido Home + Buy: lista izquierda, plano derecha (sticky) */

.motogp-tickets--map-layout {
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    width: 100vw;
    max-width: 100vw;
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.motogp-tickets--map-layout .motogp-tickets-head,
.motogp-tickets--map-layout .motogp-buy-section-title,
.motogp-tickets--map-layout .motogp-buy-section-intro {
    width: 100%;
    max-width: 1800px;
    padding: 0 clamp(1rem, 3vw, 2.5rem);
    box-sizing: border-box;
}

.motogp-tickets-map-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2.5rem);
    box-sizing: border-box;
    --tickets-map-sticky-top: calc(60px + 1rem);
    --tickets-map-max-h: min(calc(100dvh - var(--tickets-map-sticky-top) - 1.5rem), calc(100svh - var(--tickets-map-sticky-top) - 1.5rem), 920px);
    --plano-map-max-h: var(--tickets-map-max-h);
    --plano-map-max-w: min(720px, calc(var(--plano-map-max-h) * 711.75 / 933.04));
}

@media (min-width: 1024px) {
    .motogp-tickets-map-layout {
        display: grid;
        grid-template-columns: minmax(400px, 640px) minmax(520px, var(--plano-map-max-w));
        grid-template-rows: auto minmax(0, auto);
        column-gap: clamp(1.5rem, 3vw, 2.5rem);
        row-gap: 0.75rem;
        align-items: start;
        justify-content: center;
        width: fit-content;
        max-width: min(1800px, calc(100vw - 2rem));
    }

    .motogp-tickets-sectors-head {
        grid-column: 1;
        grid-row: 1;
    }

    .motogp-tickets-sector-list {
        grid-column: 1;
        grid-row: 2;
    }

    /* Buy: tabla + mapa en una sola fila (toggle dentro de map-col) */
    .motogp-tickets-map-layout:has(.motogp-buy-tickets-col) {
        grid-template-rows: auto;
    }

    .motogp-tickets-map-layout:has(.motogp-buy-tickets-col) .motogp-buy-tickets-col {
        grid-column: 1;
        grid-row: 1;
    }

    .motogp-tickets-map-layout:has(.motogp-buy-tickets-col) .motogp-tickets-map-col {
        grid-column: 2;
        grid-row: 1;
        align-self: stretch;
        min-height: 100%;
    }

    .motogp-tickets-map-layout:has(.motogp-buy-tickets-col) .motogp-tickets-map-head {
        grid-column: unset;
        grid-row: unset;
    }

    .motogp-tickets-map-sticky {
        position: sticky;
        top: var(--tickets-map-sticky-top);
        width: 100%;
        max-width: var(--plano-map-max-w);
    }
}

.motogp-tickets-map-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 0.15rem;
}

.motogp-plano-view-toggle .motogp-sectors-sort-track {
    width: 6.25rem;
}

.motogp-plano-view-toggle[data-active-mode="3d"] .motogp-sectors-sort-track::before {
    transform: translateX(calc(100% + 2px));
}

.motogp-sectors-sort-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    margin: 0;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

body[data-theme="light"] .motogp-sectors-sort-toggle,
html[data-theme="light"] .motogp-sectors-sort-toggle {
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] .motogp-sectors-sort-toggle,
html[data-theme="dark"] .motogp-sectors-sort-toggle {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
}

.motogp-sectors-sort-track {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 9.75rem;
    height: 30px;
}

.motogp-plano-view-toggle .motogp-sectors-sort-track {
    width: 6.25rem;
}

.motogp-sectors-sort-track::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(50% - 2px);
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s ease;
    pointer-events: none;
    z-index: 0;
}

body[data-theme="light"] .motogp-sectors-sort-track::before,
html[data-theme="light"] .motogp-sectors-sort-track::before {
    background: rgba(0, 0, 0, 0.12);
}

.motogp-sectors-sort-toggle[data-active-sort="zona"] .motogp-sectors-sort-track::before {
    transform: translateX(calc(100% + 2px));
}

.motogp-sectors-sort-btn {
    position: relative;
    z-index: 1;
    flex: 1 1 50%;
    height: 100%;
    border: 0;
    background: transparent;
    font-family: var(--motogp-font-display);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    transition: color 0.25s ease;
    padding: 0 0.35rem;
    cursor: pointer;
}

body[data-theme="light"] .motogp-sectors-sort-btn,
html[data-theme="light"] .motogp-sectors-sort-btn {
    color: rgba(0, 0, 0, 0.38);
}

.motogp-sectors-sort-btn.is-active {
    color: rgba(255, 255, 255, 0.92);
}

body[data-theme="light"] .motogp-sectors-sort-btn.is-active,
html[data-theme="light"] .motogp-sectors-sort-btn.is-active {
    color: rgba(0, 0, 0, 0.82);
}

.motogp-tickets-map-col {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

.motogp-tickets-map-sticky {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--plano-map-max-w, 720px);
}

.motogp-home-circuit-map {
    position: relative;
    width: 100%;
    max-width: var(--plano-map-max-w, 720px);
    height: auto;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #0a121e;
    line-height: 0;
}

.motogp-circuit-plano-map {
    width: 100%;
    min-height: 320px;
}

.motogp-circuit-plano-map--interactive,
.motogp-circuit-plano-map--interactive .motogp-plano-2d-map--interactive,
.motogp-circuit-plano-map--interactive .motogp-circuit-plano-3d,
.motogp-circuit-plano-map--interactive .motogp-circuit-plano-3d canvas {
    cursor: pointer;
}

.motogp-circuit-plano-3d {
    background: #050505;
    width: 100%;
    max-width: var(--plano-map-max-w, 720px);
    aspect-ratio: 711.75 / 933.04;
    max-height: var(--plano-map-max-h, var(--tickets-map-max-h, 920px));
    height: auto;
    min-height: 320px;
}

.motogp-plano-2d-map {
    width: 100%;
    max-width: var(--plano-map-max-w, 720px);
}

.motogp-circuit-plano-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.motogp-plano-2d-map #Sectores [data-plano-mesh-id] {
    transition: opacity 0.25s ease, filter 0.25s ease;
}

.motogp-plano-2d-map--interactive #Sectores [data-plano-mesh-id] {
    cursor: pointer;
}

.motogp-plano-2d-map #Sectores [data-plano-mesh-id].is-plano-dimmed {
    opacity: 0.22;
}

.motogp-plano-2d-map #Sectores [data-plano-mesh-id].is-plano-highlighted {
    opacity: 1 !important;
    filter: brightness(1.28) saturate(1.18);
}

.motogp-plano-2d-map #Sectores polygon.is-plano-highlighted,
.motogp-plano-2d-map #Sectores path.is-plano-highlighted {
    stroke: rgba(255, 255, 255, 0.85);
    stroke-width: 1.5px;
}

@media (max-width: 1023px) {
    .motogp-tickets-map-layout {
        display: flex;
        flex-direction: column;
    }

    .motogp-tickets-map-layout .motogp-tickets-map-col {
        order: 1;
    }

    .motogp-tickets-map-layout .motogp-buy-tickets-col {
        order: 2;
    }

    .motogp-tickets-map-col,
    .motogp-tickets-map-sticky,
    .motogp-home-circuit-map,
    .motogp-circuit-plano-3d,
    .motogp-plano-2d-map {
        width: 100%;
        max-width: none;
    }

    .motogp-circuit-plano-3d {
        min-height: min(78vw, 520px);
    }
}
