/*
 * TEC · Master Motion System (B07). Transiciones breves de UI por estado emitido y estados de
 * capa que gobierna TEC-32 (tec-atmosphere.js). Solo transform/opacity; nunca geometría, producto,
 * etiqueta, precio, CTA ni sombra de contacto. Sin JS no hay perfil y todo queda en estado final.
 * Static (perfil o reduced) = estado inmediato. Easing UI P: cubic-bezier(0.22, 1, 0.36, 1).
 */

:root {
  --tec-ease-ui: cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tec-motion-indicator {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

@keyframes tec-motion-rise {
  from { opacity: 0.85; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes tec-motion-from-start {
  from { transform: translateX(-100%); }
  to { transform: none; }
}

@keyframes tec-motion-from-end {
  from { transform: translateX(100%); }
  to { transform: none; }
}

@keyframes tec-motion-backdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* The prepared artwork stays visible as the coordinator changes ownership. */
[data-tec-layer-state='active'] {
  will-change: translate, rotate, opacity;
}

/* ---------- Transiciones de UI (no consumen cupo ambiental) ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* HOME-16 / AA-01: entrada decorativa 400 ms del indicador de la card ganadora. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-atmosphere[data-tec-active='true'] .tec-atmosphere__body {
    animation: tec-motion-indicator 400ms var(--tec-ease-ui);
  }

  /* HOME-15 card-emphasis: puntero fino o foco, indicador .85→1 (sin escalar la escena). */
  @media (hover: hover) and (pointer: fine) {
    html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-atmosphere__link:is(:hover, :focus-visible) .tec-atmosphere__cta {
      animation: tec-motion-indicator 280ms var(--tec-ease-ui);
    }

    /* CAT-05 / SS-03 / HOME-10 photo-emphasis: el producto no se escala; borde decorativo
       en opacidad (alternativa «si no, borde» del registro). */
    html[data-tec-motion-profile] .tec-card::after {
      content: '';
      position: absolute;
      inset: 0;
      border: var(--tec-border-width, 1px) solid var(--tec-color-amber, #957353);
      border-radius: inherit;
      opacity: 0;
      pointer-events: none;
      transition: opacity 250ms var(--tec-ease-ui);
    }

    html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-card:is(:hover, :focus-within)::after {
      opacity: 1;
    }
  }

  /* SS-03 indicador del carrusel 220 ms y CAT-02 chip activo 200 ms. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-carousel__dot[data-tec-current='true'] {
    animation: tec-motion-indicator 220ms var(--tec-ease-ui);
  }

  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-chip[aria-current='location'] {
    animation: tec-motion-indicator 200ms var(--tec-ease-ui);
  }

  /* KIT-04 selección: semántica inmediata; indicador .85→1 en 220 ms. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-choice__input:checked + .tec-choice__card .tec-choice__indicator {
    animation: tec-motion-indicator 220ms var(--tec-ease-ui);
  }

  /* KIT-05 Quiet Purchase Bar: aparece tras la primera elección válida, 300 ms Y8→0. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-kit__bar:not([hidden]) {
    animation: tec-motion-rise 300ms var(--tec-ease-ui);
  }

  /* COM-01 cart-submit: estado pendiente inmediato; énfasis 200 ms sin decidir el resultado. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) :is([data-tec-kit-state='pending'] [data-tec-kit-add], [data-tec-purchase-state='pending'] [type='submit']) {
    animation: tec-motion-indicator 200ms var(--tec-ease-ui);
  }

  /* COM-06 / HOME-27 menú (panel desde el borde inicial) 300 ms; backdrop 0→base. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-menu[open] {
    animation: tec-motion-from-start 300ms var(--tec-ease-ui);
  }

  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-menu[open]::backdrop {
    animation: tec-motion-backdrop 300ms var(--tec-ease-ui);
  }

  /* COM-02 / HOME-28 bolsa (panel desde el borde final) 320 ms. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) dialog[data-tec-cart-panel][open] {
    animation: tec-motion-from-end 320ms var(--tec-ease-ui);
  }

  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) dialog[data-tec-cart-panel][open]::backdrop {
    animation: tec-motion-backdrop 320ms var(--tec-ease-ui);
  }

  /* COM-04 búsqueda: translateY 8→0 y .85→1, 280 D / 220 M. */
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) dialog[data-tec-search-panel][open] {
    animation: tec-motion-rise 220ms var(--tec-ease-ui);
  }

  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) dialog[data-tec-search-panel][open]::backdrop {
    animation: tec-motion-backdrop 220ms var(--tec-ease-ui);
  }

  @media screen and (min-width: 1024px) {
    html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) dialog[data-tec-search-panel][open] {
      animation-duration: 280ms;
    }
  }
}

/* Reduced motion: velo fuera desde CSS inicial (TEC-32 tampoco prepara capas en Static). */
@media (prefers-reduced-motion: reduce) {
  .tec-flow-veil {
    display: none;
  }
}

/* RC3-04: one semantic heading, with clearance for the serif descenders. */
[data-tec-heading]::after {
  content: '';
  display: block;
  inline-size: clamp(36px, 6vw, 82px);
  block-size: 1px;
  margin-block-start: .32em;
  background: currentColor;
  opacity: .7;
  transform-origin: left center;
}

[data-tec-heading-line] { display: block; }

@media (prefers-reduced-motion: no-preference) {
  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) [data-tec-heading-line] {
    --tec-heading-cut: calc((1 - var(--tec-heading-progress, 1)) * .12lh);
    mask-image: repeating-linear-gradient(to bottom, black 0 calc(1lh - var(--tec-heading-cut)), transparent calc(1lh - var(--tec-heading-cut)) 1lh);
    transform: translateY(calc((1 - var(--tec-heading-progress, 1)) * .28em));
  }

  html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) [data-tec-heading]::after {
    transform: scaleX(var(--tec-heading-rule, 1));
  }
}

/* RC3-07 / RC3-09. The opening and its product surface share the same material palette. */
.tec-ambient-section { --tec-ambient-ink: #59402e; --tec-ambient-paper: #e5d7c2; }
.tec-ambient-section[data-tec-scene-key='BL'] { --tec-ambient-ink: #41442b; --tec-ambient-paper: #dedfc8; }
.tec-ambient-section[data-tec-scene-key='MR'] { --tec-ambient-ink: #334851; --tec-ambient-paper: #dce5e4; }
.tec-ambient-section[data-tec-scene-key='TE'] { --tec-ambient-ink: #293e2d; --tec-ambient-paper: #dbdfcc; }
.tec-ambient-section[data-tec-scene-key='AR'] { --tec-ambient-ink: #5a311c; --tec-ambient-paper: #e8d7c1; }
.tec-ambient-section[data-tec-scene-key='UB'] { --tec-ambient-ink: #51313c; --tec-ambient-paper: #e8dadd; }
.tec-ambient-section[data-tec-scene-key='SH'] { --tec-ambient-ink: #4d3424; --tec-ambient-paper: #e2d1b6; }

.tec-ambient-opening {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  min-block-size: clamp(182px, 27vw, 248px);
  color: var(--tec-text-inverse);
  background: var(--tec-ambient-ink);
}

.tec-ambient-media {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.tec-ambient-media > picture {
  position: absolute;
  inset: 0;
  display: block;
}

.tec-ambient-media [data-tec-ambient-background] {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: 61% 52%;
}

.tec-ambient-media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgb(32 22 18 / .87) 0%, rgb(32 22 18 / .70) 44%, rgb(32 22 18 / .14) 83%),
    linear-gradient(0deg, rgb(32 22 18 / .25), transparent 24%);
}

.tec-ambient-layer {
  position: absolute;
  inset: -36% -6% -36% auto;
  inline-size: min(58%, 660px);
  pointer-events: none;
}

.tec-ambient-layer img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
  object-position: 90% 50%;
  transform-origin: center;
  opacity: .72;
}

.tec-ambient-layer img:is([data-tec-layer-id='BL-02'], [data-tec-layer-id='BL-03'], [data-tec-layer-id='TE-02']) {
  transform-origin: 84% 15%;
}
.tec-ambient-layer img:is([data-tec-layer-id='AE-03'], [data-tec-layer-id='UB-03']) {
  object-position: 85% 86%;
  transform-origin: 85% 77%;
}
.tec-ambient-layer img:is([data-tec-layer-id='AR-03'], [data-tec-layer-id='MR-03'], [data-tec-layer-id='TE-03'], [data-tec-layer-id='SH-03']) {
  opacity: .36;
}
.tec-ambient-layer img[data-tec-layer-id='SH-02'] { object-position: 100% 52%; }

.tec-ambient-products {
  display: grid;
  gap: var(--tec-s5);
  padding: clamp(16px, 2.2vw, 30px);
  background: linear-gradient(180deg, var(--tec-ambient-paper), var(--tec-surface-page) 100%);
  border-inline: 1px solid var(--tec-ambient-paper);
}

@media (max-width: 1023px) {
  .tec-ambient-layer--secondary { display: none; }
}

@media (max-width: 767px) {
  .tec-ambient-layer { inline-size: 68%; }
  .tec-ambient-media::after {
    background: linear-gradient(90deg, rgb(32 22 18 / .88), rgb(32 22 18 / .64) 72%, rgb(32 22 18 / .25));
  }
}

.tec-catalog-group.tec-ambient-section { gap: 0; }
.tec-catalog-group .tec-ambient-opening .tec-catalog-group__head {
  position: relative;
  margin: 0;
  justify-content: center;
  padding: clamp(20px, 4vw, 64px);
  max-inline-size: 74ch;
}
.tec-ambient-opening :is(.tec-catalog-eyebrow, .tec-catalog-group__title, .tec-catalog-group__lead) { color: inherit; }
.tec-ambient-opening .tec-catalog-group__title { font-size: clamp(31px, 4vw, 58px); }
.tec-catalog-group > .tec-ambient-products > :is(.tec-featured, .tec-catalog-group__grid) { margin-block: 0; }

.tec-chapter .tec-ambient-opening { min-block-size: clamp(238px, 26vw, 360px); }
.tec-chapter .tec-ambient-opening .tec-chapter__band-content {
  position: relative;
  justify-content: center;
  padding: clamp(20px, 4vw, 64px);
  max-inline-size: 64ch;
}
.tec-chapter .tec-ambient-opening .tec-chapter__title {
  font-size: clamp(34px, 4vw, 62px);
  font-style: normal;
}
.tec-chapter .tec-ambient-opening .tec-chapter__text {
  margin-block-start: 0;
  font-family: var(--tec-font-serif);
  font-style: italic;
  font-size: clamp(17px, 2vw, 24px);
}
.tec-chapter .tec-chapter__format {
  padding-block: 0 var(--tec-s3);
  border-block-end: 1px solid var(--tec-ambient-paper);
}
.tec-chapter .tec-chapter__format-title {
  color: var(--tec-text-secondary);
  font-size: var(--tec-type-eyebrow);
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.tec-chapter .tec-chapter__format .tec-chapter__grid {
  margin-block: var(--tec-s3) 0;
}
.tec-chapter .tec-chapter__format .tec-card__cta-label {
  position: static;
  inline-size: auto;
  block-size: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}
.tec-chapter .tec-chapter__format .tec-card__cta {
  justify-content: space-between;
  border-block-start: 1px solid var(--tec-border-decorative);
  padding-block-start: var(--tec-s2);
  margin-block-start: var(--tec-s2);
}
.tec-chapter .tec-chapter__format .tec-card__cta::before { content: none; }
.tec-chapter .tec-chapter__format .tec-card__price { padding-inline-end: 0; }

/* TEC-32 presents media behind editorial content and interactive cards. */
.tec-cinema,
.tec-cinema__poster,
.tec-cinema__poster img,
.tec-cinema__decoder,
.tec-cinema__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tec-cinema__poster img,
.tec-cinema__decoder,
.tec-cinema__frame {
  object-fit: cover;
  object-position: var(--tec-cinema-focal, center);
}

.tec-cinema ~ .tec-cinema,
:has(> [data-tec-cinema-selected]) > .tec-cinema:not([data-tec-cinema-selected]),
.tec-cinema__frame {
  visibility: hidden;
}

.tec-cinema[data-tec-cinema-selected] {
  visibility: visible;
}

.tec-cinema[data-tec-cinema-state='frozen'] {
  z-index: 1;
}

[data-tec-cinema-state='active'] > .tec-cinema__frame,
[data-tec-cinema] > .tec-cinema__frame--held {
  visibility: visible;
}

@media (prefers-reduced-motion: reduce), (prefers-reduced-data: reduce) {
  [data-tec-cinema] > .tec-cinema__frame { visibility: hidden; }
}

/* CANVAS V04 · viewport-sized architecture retained inside its section. */
.tec-ambient-section { position: relative; isolation: isolate; color: var(--tec-text-inverse); }
.tec-environment {
  position: absolute;
  pointer-events: none;
  inset: 0;
  z-index: -1;
  background: var(--tec-ambient-ink);
}
.tec-environment__viewport {
  position: sticky;
  inset-block-start: var(--tec-catalog-header-offset, 0px);
  block-size: min(100%, 100svh);
  min-block-size: 0;
  isolation: isolate;
  overflow: clip;
}
.tec-environment__viewport > .tec-ambient-media { z-index: auto; }
.tec-environment__viewport > .tec-ambient-media::after { background: none; }
.tec-environment__viewport > .tec-ambient-media [data-tec-ambient-background] { object-position: center; }
.tec-ambient-section:has(> .tec-environment) .tec-ambient-opening {
  background: transparent;
}
.tec-ambient-section:has(> .tec-environment) .tec-ambient-products {
  background: transparent;
  border: 0;
}
.tec-catalog-group > .tec-environment { inset-inline: min(0px, (100% - 100vw) / 2); }
.tec-chapter .tec-ambient-opening { min-block-size: clamp(360px, 68svh, 760px); }
.tec-ambient-opening > [data-tec-cinema-role='intro'] { z-index: -1; }
.tec-ambient-opening > [data-tec-cinema-role='intro'] {
  clip-path: polygon(
    var(--tec-intro-wipe, 0%) 0,
    100% 0,
    100% 100%,
    max(0%, var(--tec-intro-wipe, 0%) - var(--tec-material-angle, 20%)) 100%);
}
[data-tec-scene-key='BL'] { --tec-material-angle: 34%; }
[data-tec-scene-key='MR'] { --tec-material-angle: 24%; }
[data-tec-scene-key='TE'] { --tec-material-angle: 42%; }
[data-tec-scene-key='AR'] { --tec-material-angle: 28%; }
[data-tec-scene-key='UB'] { --tec-material-angle: 12%; }
[data-tec-scene-key='SH'] { --tec-material-angle: 18%; }
.tec-ambient-opening :is(.tec-chapter__band-content,.tec-catalog-group__head) {
  background: linear-gradient(90deg, rgb(30 22 17 / .89), rgb(30 22 17 / .72) 75%, transparent);
}
.tec-chapter .tec-chapter__format { border-block-end-color: rgb(249 244 234 / .45); }
.tec-chapter .tec-chapter__format-title {
  width: fit-content;
  color: var(--tec-text-inverse);
  background: var(--tec-ambient-ink);
  padding: .45em .8em;
}
.tec-chapter .tec-chapter__text strong,
.tec-atmosphere__text strong { font-family: var(--tec-font-sans); font-weight: 700; }
html[data-tec-motion-profile]:not([data-tec-motion-profile='static']) .tec-environment__viewport {
  clip-path: polygon(calc((1 - var(--tec-threshold, 1)) * 18%) 0,100% 0,100% 100%,0 100%,0 calc((1 - var(--tec-threshold, 1)) * 26%));
}
@media (prefers-reduced-motion: reduce) {
  .tec-environment__viewport,
  .tec-ambient-opening > [data-tec-cinema-role='intro'] { clip-path: none !important; }
}

.tec-product__media--environment {
  position: relative;
  isolation: isolate;
  padding: clamp(10px, 2.8vw, 36px);
  overflow: clip;
  background: var(--tec-color-taupe);
}
.tec-product__media--environment > .tec-ambient-media { z-index: -1; }
.tec-product__media--environment > .tec-ambient-media::after { background: none; }
.tec-product__media--environment > .tec-scene { background: transparent; }

.tec-chapter .tec-ambient-opening { overflow: visible; }
.tec-chapter .tec-ambient-opening > [data-tec-cinema-role='intro'] {
  inset-inline: min(0px, calc((100% - 100vw) / 2));
  width: auto;
}
.tec-chapter__band-content { position: relative; }


.tec-featured .tec-scene__fallback {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
@media (prefers-reduced-motion: no-preference) {
  .tec-catalog-group[data-tec-active='true'] .tec-featured .tec-scene__fallback {
    clip-path: polygon(0 0,100% 0,100% 100%,calc((1 - var(--tec-scene-motion, 1)) * 7%) 100%,0 calc(var(--tec-scene-motion, 1) * 100%));
  }
  .tec-featured .tec-card__link:focus-visible .tec-scene__fallback {
    clip-path: none;
  }
}
