/*
 * TEC · Sensory Scene / Layer Stack (TEC-09). B03.
 * Orden R: fondo opaco 0 → posterior 1 → producto 2 → frontal 3 → UI HTML 4.
 * B03 entrega el fallback estático íntegro y la estructura del escenario. El coordinador
 * TEC-32 (B07) es el único que podrá preparar capas; aquí no hay bucles ni transiciones.
 */

.tec-scene {
  position: relative;
  isolation: isolate;
  display: block;
  inline-size: 100%;
  aspect-ratio: var(--tec-scene-ratio, 4 / 5);
  overflow: hidden;
  background: var(--tec-surface-panel);
  contain: layout paint;
}

.tec-scene__fallback,
.tec-scene__stage,
.tec-scene__layer {
  position: absolute;
  inset: 0;
}

.tec-scene__fallback {
  z-index: var(--tec-z-scene-background);
}

/* El fallback 800×1000 llena la caja reservada sin deformarse ni recortar el producto. */
.tec-scene__img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}

.tec-scene--contain .tec-scene__img {
  object-fit: contain;
}

/* Escenario preparado: no visible ni accesible hasta el intercambio atómico de B07. */
.tec-scene__stage {
  z-index: var(--tec-z-scene-back);
  pointer-events: none;
}

.tec-scene__stage[hidden] {
  display: none;
}

.tec-scene__layer {
  pointer-events: none;
}

.tec-scene__layer[data-tec-layer-role='background'] {
  z-index: var(--tec-z-scene-background);
}

.tec-scene__layer[data-tec-layer-role='back'] {
  z-index: var(--tec-z-scene-back);
}

.tec-scene__layer[data-tec-layer-role='product'] {
  z-index: var(--tec-z-scene-product);
}

.tec-scene__layer[data-tec-layer-role='front'] {
  z-index: var(--tec-z-scene-front);
}

.tec-scene__layer > img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

/* El producto transparente nunca se recorta: contain y anclaje del manifiesto. */
.tec-scene__layer[data-tec-layer-role='product'] > img {
  object-fit: contain;
  object-position: var(--tec-scene-anchor, 50% 50%);
}

/* Estado de error: el bloque conserva su caja; la card decide omitirse si no hay medio. */
.tec-scene[data-tec-scene-state='error'] .tec-scene__img {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .tec-scene *,
  .tec-scene *::before,
  .tec-scene *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Keep the entire V04 product composition visible in either orientation. */
.tec-scene--pdp .tec-scene__fallback picture { display: block; width: 100%; height: 100%; }
.tec-scene--pdp .tec-scene__fallback .tec-scene__img { object-fit: contain; }
