/* TERXO 3D — bloque promocional en ficha + página del visor + hero en index */

/* ── Hero 3D en portada de ficha ── */
.hero-3d-wrap {
    display: block;
    position: relative;
    flex-shrink: 0;
    width: min(100%, 255px);
    max-width: 255px;
}

.hero-3d-frame {
    width: 100%;
    min-height: clamp(238px, 50vw, 340px);
    border-radius: 24px;
    background-color: #fff;
    padding: 3px;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    border: 3px solid #0a0a0a;
    box-shadow: none;
}

.hero-3d-crop {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: calc(clamp(238px, 50vw, 340px) - 6px);
    overflow: hidden;
    border-radius: 18px;
}

.hero-3d-binkies {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--hero-w, 100%);
    height: var(--hero-h, 100%);
    border: 0;
    pointer-events: auto;
    background: #fff;
    transform: translate(-50%, -50%) scale(var(--hero-scale, 1.34));
    transform-origin: center center;
}

.hero-3d-poster {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin: 0 auto;
}

.hero-3d-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 12;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #e53935;
    color: #fff;
    font-family: 'Syne', 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 3px 3px 0 #0a0a0a;
    border: 2px solid #0a0a0a;
    transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.hero-3d-expand:hover {
    background: #c62828;
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #0a0a0a;
}

.hero-3d-expand:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 #0a0a0a;
}

@media (max-width: 900px) {
    .top-panel .hero-3d-wrap {
        width: min(100%, 220px);
        max-width: 220px;
    }

    .hero-3d-frame {
        min-height: clamp(204px, 44vw, 272px);
        border-radius: 22px;
        padding: 3px;
    }

    .hero-3d-crop {
        min-height: calc(clamp(204px, 44vw, 272px) - 6px);
        border-radius: 17px;
    }

    .hero-3d-binkies {
        transform: translate(-50%, -50%) scale(var(--hero-scale, 1.32));
    }
}

@media (max-width: 768px) {
    .top-panel:has(.hero-3d-wrap) {
        grid-template-columns: auto minmax(0, 1fr);
        column-gap: 0;
        row-gap: 8px;
        align-items: stretch;
    }

    .top-panel .hero-3d-wrap {
        grid-column: 1;
        grid-row: 3;
        justify-self: start;
        align-self: stretch;
        width: 140px;
        max-width: 140px;
        display: flex;
        flex-direction: column;
        margin: 0;
        z-index: 1;
    }

    .top-panel:has(.hero-3d-wrap) .hero-3d-frame {
        flex: 1 1 auto;
        width: 100%;
        height: 100%;
        min-height: 175px;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        border-top-right-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-right: none !important;
        box-shadow: none !important;
    }

    .top-panel:has(.hero-3d-wrap) .hero-3d-crop {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector {
        grid-column: 2;
        grid-row: 3;
        align-self: stretch;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        gap: 6px;
        width: 100% !important;
        max-width: none !important;
        min-width: 0;
        min-height: 175px;
        margin: 0;
        padding: 8px 8px 10px;
        box-sizing: border-box;
        background: #e4e5ea;
        border: 2px solid #0a0a0a;
        border-left: none;
        box-shadow: none !important;
        position: relative;
        z-index: 20 !important;
        isolation: isolate;
        overflow: visible;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector.active {
        z-index: 50 !important;
    }

    .top-panel:has(.hero-3d-wrap) .variant-trigger {
        min-height: 52px;
        height: auto;
        flex: 0 0 auto;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
        padding: 10px 12px;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
        background: transparent !important;
        cursor: pointer;
        position: relative;
        z-index: 3;
    }

    .top-panel:has(.hero-3d-wrap) .variant-trigger .variant-spec-head {
        gap: 8px;
        align-items: center;
        width: 100%;
    }

    .top-panel:has(.hero-3d-wrap) .variant-trigger .variant-spec-head strong {
        font-size: 0.85rem !important;
        line-height: 1.15;
    }

    .top-panel:has(.hero-3d-wrap) .variant-trigger .variant-market {
        font-size: 0.58rem !important;
        padding: 3px 8px !important;
        line-height: 1.2;
    }

    .top-panel:has(.hero-3d-wrap) .variant-dropdown {
        z-index: 200 !important;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions {
        position: relative !important;
        z-index: 1;
        top: auto !important;
        right: auto !important;
        flex: 1 1 auto;
        align-self: stretch;
        margin: 0 !important;
        padding: 4px 0 0;
        width: 100% !important;
        max-width: none !important;
        min-height: 0;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: repeat(2, minmax(0, 1fr));
        gap: 5px !important;
        align-items: stretch;
        justify-items: stretch;
        overflow: hidden;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-item:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-item:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-item:nth-child(3) {
        grid-column: 1;
        grid-row: 2;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-item--compare {
        grid-column: 2;
        grid-row: 2;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-item,
    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-item--compare {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
        height: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        min-height: 42px;
        gap: 5px !important;
        margin: 0 !important;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-counter > span:not([id]) {
        display: none !important;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-compare-label {
        display: none !important;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-button,
    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .btn-compare-detail {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
        margin: 0 !important;
        padding: 0 !important;
        flex-shrink: 0;
        box-shadow: 2px 2px 0 #0a0a0a !important;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-button > span[style] {
        width: 20px !important;
        height: 20px !important;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .btn-compare-detail .compare-icon {
        font-size: 1.15rem !important;
        line-height: 1;
    }

    .top-panel:has(.hero-3d-wrap) .variant-selector .floating-actions .action-counter {
        font-size: 0.65rem !important;
        font-weight: 800;
        line-height: 1;
        text-align: center;
        flex: 0 0 auto;
        min-width: 0;
        margin: 0 !important;
    }
}

@media (max-width: 640px) {
    .top-panel .hero-3d-wrap {
        width: 140px;
        max-width: 140px;
        margin: 0;
    }

    .top-panel:has(.hero-3d-wrap) .hero-3d-frame {
        width: 100%;
        min-height: 175px;
        border-radius: 26px;
        border-top-right-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        padding: 2px;
        border-width: 2px;
        box-shadow: none;
    }

    .top-panel:has(.hero-3d-wrap) .hero-3d-crop {
        min-height: 0;
        border-radius: 22px;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .hero-3d-binkies {
        transform: translate(-50%, -50%) scale(var(--hero-scale, 1.36));
    }

    .hero-3d-poster {
        width: 100%;
        max-height: none;
    }

    .hero-3d-expand {
        top: 6px;
        right: 6px;
        width: 30px;
        height: 30px;
        border-radius: 8px;
        font-size: 1.35rem;
        box-shadow: 2px 2px 0 #0a0a0a;
    }
}

/* ── Bloque compacto en ficha (neobrutalista blanco, móvil-first) ── */
.viewer3d-block {
    width: 100%;
    min-width: 0;
    margin-top: 0 !important;
    padding: 16px 0 !important;
    max-width: none !important;
    border-top: 3px solid #0a0a0a !important;
    position: relative;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
}

.viewer3d-block::before {
    display: none !important;
}

.viewer3d-block-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    padding: 12px 14px;
    background: #ffffff;
    color: #0a0a0a;
    border: 3px solid #0a0a0a;
    border-radius: 0;
    box-shadow: 4px 4px 0 #0a0a0a;
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.viewer3d-block-inner:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #0a0a0a;
}

.viewer3d-block-inner:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 #0a0a0a;
}

.viewer3d-block-thumb {
    position: relative;
    flex: 0 0 52px;
    width: 52px;
    height: 64px;
    border-radius: 0;
    background: #fff;
    border: 3px solid #0a0a0a;
    box-shadow: 3px 3px 0 #6ee7ff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer3d-block-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 4px;
}

.viewer3d-thumb-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    font-family: 'Syne', 'Montserrat', sans-serif;
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #0a0a0a;
    background: #6ee7ff;
    border: 2px solid #0a0a0a;
    border-radius: 0;
    padding: 2px 5px;
    line-height: 1;
    box-shadow: 2px 2px 0 #0a0a0a;
}

.viewer3d-block-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.viewer3d-block-head {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.viewer3d-block-copy h3 {
    font-family: 'Syne', 'Montserrat', sans-serif !important;
    font-size: 0.82rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: #0a0a0a !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
    white-space: nowrap;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.viewer3d-block-model {
    font-size: 0.72rem;
    font-weight: 700;
    color: #0a0a0a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.viewer3d-block-desc {
    font-size: 0.68rem;
    line-height: 1.35;
    color: #3a3a3a;
    margin: 0;
    font-weight: 500;
}

.viewer3d-block-arrow {
    flex: 0 0 auto;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    color: #0a0a0a;
    margin-left: auto;
    padding-left: 8px;
}

@media (min-width: 640px) {
    .viewer3d-block {
        padding: 20px 0 !important;
    }

    .viewer3d-block-inner {
        gap: 16px;
        padding: 14px 18px;
    }

    .viewer3d-block-thumb {
        flex: 0 0 60px;
        width: 60px;
        height: 72px;
        box-shadow: 4px 4px 0 #6ee7ff;
    }

    .viewer3d-block-copy h3 {
        font-size: 0.9rem !important;
    }

    .viewer3d-block-model {
        font-size: 0.78rem;
    }

    .viewer3d-block-desc {
        font-size: 0.72rem;
    }
}

/* ── Página del visor 3D: estudio de producto ──
   Un fondo de estudio gris medio (ni blanco ni negro: se ven igual los móviles claros y los oscuros) y el móvil
   como protagonista. Los controles son una sola pieza oscura, como el equipo del estudio, y no tapan el modelo.
   El lienzo de Binkies es transparente: el fondo es siempre el de esta página. */
.viewer3d-page,
.hero-3d-frame {
    --st-ink: #17171a;
    --st-ink-soft: #3c3c40;
    --st-dock: #17171a;
    --st-dock-ink: #f1f0ec;
    --st-dock-soft: #bdbcb7;
    --st-dock-line: rgba(241, 240, 236, 0.16);
    --st-gutter: clamp(14px, 2.2vw, 28px);
    --st-font: 'Familjen Grotesk', system-ui, sans-serif;
    --st-icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
    --st-icon-reset: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12a8 8 0 1 0 2.6-5.9L4 8.5'/%3E%3Cpath d='M4 4v4.5h4.5'/%3E%3C/svg%3E");
    --st-icon-parts: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='7' y='3' width='10' height='18' rx='2.5'/%3E%3Cpath d='M12 7.5h.01M3 12h4M17 12h4'/%3E%3C/svg%3E");
    --st-icon-full: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5'/%3E%3C/svg%3E");
    --st-icon-ar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l8 4.5v9L12 21l-8-4.5v-9zM4 7.5l8 4.5 8-4.5M12 12v9'/%3E%3C/svg%3E");
}

.viewer3d-page,
.hero-3d-studio {
    background:
        radial-gradient(52% 58% at 50% 44%, #cdccc8 0%, rgba(205, 204, 200, 0) 72%),
        linear-gradient(180deg, #a8a7a3 0%, #b7b6b2 66%, #c6c5c0 82%, #d3d2cd 100%);
}

.viewer3d-page {
    margin: 0;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--viewer3d-vh, 1vh) * 100);
    overflow: hidden;
    overscroll-behavior: none;
    color: var(--st-ink);
    font-family: var(--st-font);
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

.viewer3d-page ::selection {
    color: var(--st-dock-ink);
    background: var(--st-ink);
}

.viewer3d-page :focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* El pie que añade el despliegue no tiene sitio en una página a pantalla completa */
.viewer3d-page .site-footer-tab {
    display: none;
}

.viewer3d-layout {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* —— Nombre del móvil y color elegido —— */
.viewer3d-header {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    max-width: min(30vw, 420px);
    padding: var(--st-gutter);
    padding-top: max(var(--st-gutter), env(safe-area-inset-top));
    padding-left: max(var(--st-gutter), env(safe-area-inset-left));
    pointer-events: none;
}

.viewer3d-header-copy {
    display: flex;
    flex-direction: column;
}

.viewer3d-header-copy h1,
.viewer3d-header-copy h2 {
    margin: 0;
    font-size: clamp(1.5rem, 2.6vw, 2.25rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

.viewer3d-color-active {
    margin: 6px 0 0;
    font-size: 1rem;
    line-height: 1.3;
    color: var(--st-ink-soft);
}

.viewer3d-color-active[hidden] {
    display: none;
}

.viewer3d-hint {
    order: 1;
    margin: 14px 0 0;
    font-size: 0.875rem;
    line-height: 1.35;
    color: var(--st-ink-soft);
    transition: opacity 0.4s ease;
}

/* Cumplido su papel: en cuanto se mueve el móvil, el aviso se va */
.viewer3d-page--touched .viewer3d-hint {
    opacity: 0;
}

.viewer3d-hint[hidden] {
    display: none;
}

/* —— Cerrar —— */
.viewer3d-close {
    position: fixed;
    top: max(var(--st-gutter), env(safe-area-inset-top));
    right: max(var(--st-gutter), env(safe-area-inset-right));
    z-index: 6;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--st-dock-ink);
    background: var(--st-dock);
    font-size: 0;
    text-decoration: none;
    box-shadow: 0 10px 22px -12px rgba(0, 0, 0, 0.55);
    transition: transform 0.18s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.viewer3d-close::before,
.viewer3d-parts-close::before {
    content: '';
    width: 20px;
    height: 20px;
    background: currentColor;
    -webkit-mask: var(--st-icon-close) center / contain no-repeat;
    mask: var(--st-icon-close) center / contain no-repeat;
}

.viewer3d-close:hover {
    transform: scale(1.06);
}

/* —— Plató: el móvil ocupa todo el alto que dejan los controles —— */
.viewer3d-body {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.viewer3d-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

/* Sombra de contacto sobre el suelo del estudio */
.viewer3d-stage::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 1.5%;
    width: min(44vh, 60%);
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(23, 23, 26, 0.34), rgba(23, 23, 26, 0));
    transform: translateX(-50%);
    pointer-events: none;
}

.viewer3d-model,
.viewer3d-binkies {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    --poster-color: transparent;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.viewer3d-model[hidden] {
    display: none !important;
}

.viewer3d-binkies--fading {
    opacity: 0.4;
}

.viewer3d-binkies-credit {
    position: absolute;
    right: var(--st-gutter);
    bottom: 10px;
    z-index: 1;
    margin: 0;
    font-size: 0.75rem;
    color: var(--st-ink-soft);
    pointer-events: none;
}

/* —— Carga, cambio y error —— */
.viewer3d-loading,
.viewer3d-swap,
.viewer3d-error {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    font-size: 1rem;
    text-align: center;
}

.viewer3d-loading[hidden],
.viewer3d-swap[hidden],
.viewer3d-error[hidden] {
    display: none !important;
}

.viewer3d-loading p,
.viewer3d-swap p,
.viewer3d-error p {
    margin: 0;
    max-width: 34ch;
}

.viewer3d-swap {
    pointer-events: none;
}

/* El texto solo vale para el cambio de color: al girar a una parte o restablecer basta el indicador */
.viewer3d-swap:not(.viewer3d-swap--color) p {
    display: none;
}

.viewer3d-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(23, 23, 26, 0.2);
    border-top-color: var(--st-ink);
    border-radius: 50%;
    animation: viewer3d-spin 0.8s linear infinite;
}

@keyframes viewer3d-spin {
    to { transform: rotate(360deg); }
}

.viewer3d-fallback-link {
    color: inherit;
    font-weight: 600;
    text-underline-offset: 3px;
}

/* —— Mando: una sola pieza oscura con colores y acciones —— */
.viewer3d-toolbar {
    z-index: 3;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    align-self: center;
    max-width: calc(100% - 2 * var(--st-gutter));
    margin-bottom: max(var(--st-gutter), env(safe-area-inset-bottom));
    padding: 6px;
    box-sizing: border-box;
    border-radius: 16px;
    color: var(--st-dock-ink);
    background: var(--st-dock);
    box-shadow: 0 18px 34px -18px rgba(0, 0, 0, 0.6);
}

.viewer3d-toolbar[hidden] {
    display: none !important;
}

.viewer3d-colors {
    order: -1;
    display: flex;
    align-items: center;
    min-width: 0;
    margin-right: 4px;
    padding-right: 8px;
    border-right: 1px solid var(--st-dock-line);
    overflow-x: auto;
    scrollbar-width: none;
}

.viewer3d-colors::-webkit-scrollbar {
    display: none;
}

.viewer3d-colors[hidden] {
    display: none !important;
}

.viewer3d-colors-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Muestra redonda dentro de un área de 44 px; el borde claro separa los colores oscuros del mando */
.viewer3d-color-btn {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: var(--st-dock-ink);
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.viewer3d-color-btn::before {
    content: '';
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--viewer3d-color, #8e8e93);
    box-shadow: inset 0 0 0 1px rgba(241, 240, 236, 0.4);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.viewer3d-color-btn:hover::before {
    transform: scale(1.1);
}

.viewer3d-color-btn.is-active::before {
    box-shadow:
        inset 0 0 0 1px rgba(241, 240, 236, 0.4),
        0 0 0 3px var(--st-dock),
        0 0 0 5px var(--st-dock-ink);
}

.viewer3d-color-btn:focus-visible {
    outline-offset: -2px;
}

.viewer3d-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    color: inherit;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.viewer3d-btn[hidden] {
    display: none !important;
}

.viewer3d-btn::before {
    content: '';
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: var(--btn-icon, var(--st-icon-ar)) center / contain no-repeat;
    mask: var(--btn-icon, var(--st-icon-ar)) center / contain no-repeat;
}

#viewer3dReset {
    --btn-icon: var(--st-icon-reset);
}

#viewer3dPartsBtn {
    --btn-icon: var(--st-icon-parts);
}

.viewer3d-btn:hover {
    background: rgba(241, 240, 236, 0.12);
}

.viewer3d-btn[aria-pressed='true'] {
    color: var(--st-dock);
    background: var(--st-dock-ink);
}

/* —— Partes del móvil —— */
.viewer3d-parts {
    position: absolute;
    top: calc(var(--st-gutter) + 56px);
    right: var(--st-gutter);
    bottom: 8px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    width: min(300px, 34vw);
    border-radius: 16px;
    overflow: hidden;
    color: var(--st-dock-ink);
    background: var(--st-dock);
    box-shadow: 0 18px 34px -18px rgba(0, 0, 0, 0.6);
}

.viewer3d-parts[hidden] {
    display: none !important;
}

.viewer3d-parts-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--st-dock-line);
}

.viewer3d-parts-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.viewer3d-parts-close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: inherit;
    background: transparent;
    font-size: 0;
    cursor: pointer;
}

.viewer3d-parts-close:hover {
    background: rgba(241, 240, 236, 0.12);
}

.viewer3d-parts-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 8px;
    list-style: none;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--st-dock-line) transparent;
}

.viewer3d-parts-item {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    color: inherit;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.viewer3d-parts-item:hover {
    background: rgba(241, 240, 236, 0.12);
}

.viewer3d-parts-item.is-active {
    color: var(--st-dock);
    background: var(--st-dock-ink);
}

.viewer3d-parts-detail {
    flex: 0 0 auto;
    max-height: 40%;
    padding: 12px 16px 14px;
    overflow-y: auto;
    border-top: 1px solid var(--st-dock-line);
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--st-dock-soft);
}

.viewer3d-parts-detail:empty {
    display: none;
}

.viewer3d-parts-detail strong {
    display: block;
    margin-bottom: 2px;
    font-weight: 600;
    color: var(--st-dock-ink);
}

.viewer3d-parts-detail p {
    margin: 0;
}

/* —— Móvil: nombre arriba, plató en medio y mando abajo, sin taparse —— */
@media (max-width: 768px) {
    .viewer3d-page,
    .hero-3d-frame {
        --st-gutter: 12px;
    }

    .viewer3d-header {
        position: relative;
        flex: 0 0 auto;
        max-width: none;
        padding-right: 68px;
    }

    .viewer3d-header-copy h1,
    .viewer3d-header-copy h2 {
        font-size: 1.375rem;
    }

    .hero-3d-studio::after {
        display: none;
    }

    .viewer3d-color-active {
        margin-top: 2px;
        font-size: 0.9rem;
    }

    /* El aviso flota sobre el plató para no restarle alto al móvil */
    .viewer3d-hint {
        position: absolute;
        top: 100%;
        left: var(--st-gutter);
        right: var(--st-gutter);
        margin: 0;
        text-align: center;
    }

    .viewer3d-body {
        flex-direction: column;
    }

    /* En vertical el modelo se ajusta al ancho y queda pequeño: se acerca, salvo con Partes abierto,
       cuando el plató se encoge. Sin sombra, porque el móvil ya no llega al suelo */
    .viewer3d-stage {
        overflow: hidden;
    }

    .viewer3d-binkies {
        transform: scale(1.3);
    }

    .viewer3d-body:has(.viewer3d-parts:not([hidden])) .viewer3d-binkies {
        transform: none;
    }

    .viewer3d-stage::before {
        display: none;
    }

    .viewer3d-binkies-credit {
        bottom: 2px;
        font-size: 0.7rem;
    }

    .viewer3d-toolbar {
        align-self: stretch;
        max-width: none;
        margin: 0 var(--st-gutter) max(var(--st-gutter), env(safe-area-inset-bottom));
    }

    /* El borde se difumina para que se note que hay más colores al deslizar */
    .viewer3d-colors {
        flex: 1 1 auto;
        margin-right: 0;
        padding-right: 20px;
        border-right: 0;
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
        mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
    }

    .viewer3d-btn {
        margin-left: auto;
        padding: 0 12px;
    }

    .viewer3d-colors:not([hidden]) ~ .viewer3d-btn {
        margin-left: 0;
    }

    /* Restablecer se queda en icono para que quepan colores y acciones en una fila; el texto sigue para lectores */
    #viewer3dReset {
        width: 44px;
        padding: 0;
        font-size: 0;
    }

    /* Partes entra bajo el plató, que se encoge: el móvil sigue a la vista mientras se elige */
    .viewer3d-parts {
        position: static;
        flex: 0 0 auto;
        width: auto;
        margin: 0 var(--st-gutter) 8px;
    }

    .viewer3d-parts-list {
        display: flex;
        flex: 0 0 auto;
        gap: 4px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

    .viewer3d-parts-list::-webkit-scrollbar {
        display: none;
    }

    .viewer3d-parts-list li {
        flex: 0 0 auto;
    }

    .viewer3d-parts-item {
        width: auto;
        white-space: nowrap;
    }

    .viewer3d-parts-detail {
        max-height: 124px;
    }
}

/* Pantallas bajas en horizontal: el nombre no le quita alto al móvil */
@media (max-width: 960px) and (max-height: 500px) {
    .viewer3d-header {
        position: absolute;
        max-width: 34vw;
    }

    .viewer3d-hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .viewer3d-spinner {
        animation-duration: 2.4s;
    }

    .viewer3d-page *,
    .viewer3d-page *::before {
        transition: none !important;
    }
}

/* ── Transición entre ficha ⇄ visor 3D (suave) ── */
@view-transition { navigation: auto; }

/* Con el marco ampliado ambos ocupan toda la pantalla: las dos vistas coinciden y nada se deforma */
.hero-3d-frame,
.viewer3d-layout { view-transition-name: terxo-3d-stage; }

::view-transition-group(terxo-3d-stage) {
    animation-duration: 0.55s;
    animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

/* El contenido del escenario se mezcla sin saltos */
::view-transition-old(terxo-3d-stage),
::view-transition-new(terxo-3d-stage) {
    animation-duration: 0.55s;
    animation-timing-function: ease-in-out;
    height: 100%;
    object-fit: cover;
}

::view-transition-old(root) { animation: 0.3s ease-out both vt-fade-out; }
::view-transition-new(root) { animation: 0.4s 0.05s ease-in-out both vt-fade-in; }
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }


@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    }

/* Fondo gris del 3D en la ficha (el visor tiene su propio fondo de estudio) */
.hero-3d-frame,
.hero-3d-crop,
.hero-3d-poster { background-color: #e4e5ea; }
.hero-3d-binkies { background: transparent; }

/* ── Ampliar el 3D de la ficha en el sitio (el mismo iframe, sin recargar) ──
   Termina idéntico al visor: mismo fondo, mismas piezas (.viewer3d-*) y el móvil en el mismo plató.
   Con !important porque las reglas móviles de la ficha fijan borde, radio y relleno con más especificidad. */
.hero-3d-locked { overflow: hidden; }
.hero-3d-wrap--open .hero-3d-frame {
    position: fixed !important;
    inset: 0;
    z-index: 2147483000;
    width: 100% !important;
    max-width: none;
    height: 100% !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    color: var(--st-ink);
    font-family: var(--st-font);
}
.hero-3d-wrap--open .hero-3d-crop {
    z-index: 1;
    width: 100%;
    min-height: 0 !important;
    height: 100%;
    border-radius: 0 !important;
    background: transparent;
}
.hero-3d-wrap--open .hero-3d-binkies {
    top: calc((var(--st-top) + var(--st-bottom)) / 2);
    width: 100%;
    height: calc(var(--st-bottom) - var(--st-top));
    transform: translate(-50%, -50%) scale(var(--st-scale));
}
.hero-3d-wrap--moving .hero-3d-binkies {
    width: var(--hero-w);
    height: var(--hero-h);
}
.hero-3d-wrap--open > .hero-3d-expand { display: none; }

.hero-3d-studio {
    position: absolute;
    inset: 0;
}

/* La misma sombra de contacto del plató del visor; en vertical el móvil no llega al suelo */
.hero-3d-studio::after {
    content: '';
    position: absolute;
    left: 50%;
    top: calc(var(--st-bottom) * 0.985 - 34px);
    width: min(44vh, 60%);
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(23, 23, 26, 0.34), rgba(23, 23, 26, 0));
    transform: translateX(-50%);
}

.hero-3d-ring {
    position: fixed;
    z-index: 2;
    box-sizing: border-box;
    pointer-events: none;
}

.hero-3d-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.hero-3d-overlay > .viewer3d-close,
.hero-3d-overlay > .viewer3d-parts,
.hero-3d-overlay > .viewer3d-toolbar { pointer-events: auto; }

.hero-3d-overlay .viewer3d-toolbar { margin-top: auto; }

/* Encima del mando, sin taparlo: aquí no hay plató que los separe como en la página del visor */
.hero-3d-overlay .viewer3d-parts { bottom: calc(100% - var(--st-bottom) + 8px); }
.hero-3d-overlay .viewer3d-parts-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.hero-3d-overlay .viewer3d-binkies-credit { bottom: calc(100% - var(--st-bottom) + 10px); }
.hero-3d-overlay .viewer3d-binkies-credit[hidden],
.hero-3d-overlay .viewer3d-hint[hidden] { display: none; }

@media (max-width: 768px) {
    /* Como en el visor: Partes va en su sitio, bajo el plató que se encoge */
    .hero-3d-overlay .viewer3d-parts { margin-top: auto; }
    .hero-3d-overlay .viewer3d-parts:not([hidden]) ~ .viewer3d-toolbar { margin-top: 0; }
    .hero-3d-overlay .viewer3d-binkies-credit { bottom: calc(100% - var(--st-bottom) + 2px); }
}

.hero-3d-overlay .viewer3d-close {
    padding: 0;
    border: 0;
    cursor: pointer;
}

.hero-3d-overlay-full {
    --btn-icon: var(--st-icon-full);
    text-decoration: none;
}
