/* ============================================================
   MILÓS — Experiencia: movimiento, gestos y vista completa de la pieza.
   Cada bloque dice qué skill lo decidió.

   Regla que se respeta en todo el archivo (/animation-performance):
   solo se animan transform, opacity y stroke-dashoffset. Nada que obligue
   al navegador a recalcular el tamaño de las cosas en cada cuadro.
   ============================================================ */

/* ---------- /apple-design: material translúcido en el encabezado ---------- */
.header::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 16px; pointer-events: none;
  background: linear-gradient(color-mix(in srgb, var(--noche) 70%, transparent), transparent);
}
@media (prefers-reduced-transparency: reduce) {
  .header { background: var(--noche); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .shop__bar { background: var(--noche); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ---------- Brillo que recorre la marca (el metal que atrapa la luz) ----------
   /animation-performance: un degradado recortado al texto se vuelve a pintar en cada
   cuadro, así que NO corre siempre. brillo.js enciende la clase 1,6 s cada 9 s y la apaga.
   Entre destellos el costo es cero. */
.hero__word, .footer__word, .ley__num, .intro__word {
  background-image: linear-gradient(100deg, #9c6a28 0%, #f3dca4 24%, #d6ae62 40%, #fdf0cd 52%, #c08a3e 70%, #e8cd93 100%);
  background-size: 240% 100%;
  background-position: 100% 50%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero__word, .footer__word, .ley__num, .intro__word { color: var(--oro); -webkit-text-fill-color: var(--oro); }
}
/* Las dos animaciones van juntas y en el mismo orden: así encender el brillo NO
   reinicia ni cancela la entrada de la marca (se emparejan por posición en la lista). */
.hero__word.gleam {
  animation:
    subir 1000ms var(--ease-out) var(--intro-pausa, 2250ms) forwards,
    gleam 1600ms var(--ease-in-out);
}
@keyframes gleam { from { background-position: 100% 50%; } to { background-position: 0% 50%; } }
@media (prefers-reduced-motion: reduce) { .hero__word.gleam { animation: none; } }

/* ---------- /choreograph: todo lo que entra al bajar por la página ----------
   Un solo gesto repetido: sube 18 px y aparece. Lo que está junto entra escalonado,
   no todo a la vez, con separaciones que se achican (70, 55, 45 ms). */
[data-revelar] {
  opacity: 0; transform: translateY(18px);
  transition: opacity 760ms var(--ease-out), transform 760ms var(--ease-out);
  transition-delay: var(--retraso, 0ms);
}
[data-revelar].revelado { opacity: 1; transform: none; }
/* Si el navegador no hace el seguimiento (IntersectionObserver), todo se ve igual. */
.sin-revelar [data-revelar] { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  [data-revelar] { transform: none; transition-duration: 240ms; }
}

/* ---------- /choreograph: entrada de la portada ----------
   Las franjas suben en ola cuando el telón de la entrada termina (≈2,25 s)
   — o enseguida si la entrada ya se vio en esta visita. */
:root { --intro-pausa: 2250ms; }
.intro-vista { --intro-pausa: 60ms; }
.hero__cols li { animation: lab-sube 620ms var(--ease-out) both; }
.hero__cols li:nth-child(1) { animation-delay: calc(var(--intro-pausa) + 320ms); }
.hero__cols li:nth-child(2) { animation-delay: calc(var(--intro-pausa) + 390ms); }
.hero__cols li:nth-child(3) { animation-delay: calc(var(--intro-pausa) + 445ms); }
@keyframes lab-sube { from { opacity: 0; transform: translateY(12px); } }

/* ---------- /choreograph: ola de la grilla ---------- */
.grid { transition: opacity 120ms var(--ease-out); }
.grid.saliendo { opacity: 0; }

/* ---------- /remove-animations: sello chico en vez del velo (filtros, uso frecuente) ---------- */
#titulo-tienda { display: inline-flex; align-items: center; gap: 12px; }
.sello svg { display: block; overflow: visible; }
.sello__ring { fill: none; stroke: var(--oro); stroke-width: 1.2; stroke-dasharray: 107; stroke-dashoffset: 0; transform: rotate(-90deg); transform-origin: 20px 20px; }
.sello text { font-family: var(--serif); font-size: 21px; fill: var(--oro); }
.sello.on .sello__ring { animation: lab-sello 520ms var(--ease-in-out); }
@keyframes lab-sello { from { stroke-dashoffset: 107; } }

/* ---------- Transición al cambiar de colección desde la portada ----------
   0–150ms   el velo aparece
   0–700ms   el anillo dorado se dibuja alrededor de la M
   60–460ms  la M entra: opacidad + escala + desenfoque
   ~450ms    la grilla cambia por debajo
   800–1000  el velo se va */
.morph {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: color-mix(in srgb, var(--noche) 94%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 200ms ease, visibility 0s linear 200ms;
}
.morph.on { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 150ms var(--ease-out), visibility 0s; }
.morph__svg { overflow: visible; }
.morph__ring {
  fill: none; stroke: var(--oro); stroke-width: 1;
  stroke-dasharray: 553; stroke-dashoffset: 553;     /* 2π · 88 ≈ 553 */
  transform: rotate(-90deg); transform-origin: 100px 100px;
}
.morph__ring--in { stroke: color-mix(in srgb, var(--oro) 50%, transparent); stroke-width: 0.6; stroke-dasharray: 490; stroke-dashoffset: 490; }
.morph__e { font-family: var(--serif); font-size: 112px; fill: var(--oro); opacity: 0; transform-origin: 100px 100px; }
.morph.on .morph__ring { animation: draw 700ms var(--ease-in-out) forwards; }
.morph.on .morph__ring--in { animation: draw 700ms var(--ease-in-out) 80ms forwards; }
.morph.on .morph__e { animation: mono-in 420ms var(--ease-out) 60ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes mono-in {
  from { opacity: 0; transform: scale(0.94); filter: blur(5px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}
.morph__label { margin: 0; font-size: 10px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--marfil); opacity: 0; }
.morph.on .morph__label { animation: fade-in 300ms ease 240ms forwards; }

/* ---------- /find-animation-opportunities: confirmación en el botón ---------- */
#agregar.hecho { background: var(--oro-claro); color: var(--noche); opacity: 1; }
#agregar { transition: transform 160ms var(--ease-out), background-color 180ms ease, color 180ms ease; }

/* ---------- /choreograph: fila que sale del carrito (FLIP) ---------- */
.cart-item--sale {
  position: absolute; left: 0; right: 0; pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.cart-item--sale.ya { opacity: 0; transform: translateX(28px); }

/* ---------- /gestures: galería deslizable ---------- */
.modal__media { aspect-ratio: auto; position: relative; }
.galeria {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  overscroll-behavior-x: contain; touch-action: pan-x;
}
.galeria::-webkit-scrollbar { display: none; }
.galeria__foto { flex: 0 0 100%; aspect-ratio: 4 / 5; scroll-snap-align: start; position: relative; background: var(--carbon); }
.galeria__foto img { width: 100%; height: 100%; object-fit: cover; }
.galeria__vista { position: absolute; left: 14px; bottom: 14px; font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--niebla); }
.galeria__puntos { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; gap: 7px; pointer-events: none; }
.galeria__puntos span { width: 5px; height: 5px; border-radius: 50%; background: color-mix(in srgb, var(--marfil) 28%, transparent); transition: background-color 180ms ease, transform 180ms var(--ease-out); }
.galeria__puntos span.on { background: var(--oro); transform: scale(1.4); }

/* ---------- /emil-design-eng + /mobile-native ----------
   1. Al abrir la ficha el foco va al título (lo lee primero un lector de pantalla).
   2. La X mide 44×44 px: mínimo cómodo para el dedo.
   3. El final de la ficha deja lugar a la barra inferior del iPhone. */
#modal-titulo:focus, #modal-titulo:focus-visible { outline: none; }
.modal__close-form .icon-btn { width: 44px; height: 44px; }
.modal__info { padding-bottom: calc(clamp(24px, 4vw, 48px) + env(safe-area-inset-bottom, 0px)); }

/* ---------- Vista completa de la pieza ----------
   Computadora: pantalla completa, fotos en grilla 2×2 y la información fija
   a la derecha mientras bajas por las fotos. */
.modal__ref { margin: 0; font-size: 11px; color: var(--niebla); letter-spacing: 0.16em; text-transform: uppercase; }
.modal__desc { border-top: 1px solid var(--linea); padding-top: 20px; margin-top: 6px; display: grid; gap: 12px; }
.modal__desc .muted { margin: 0; line-height: 1.65; }
.modal__subtitulo { margin: 0; font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--oro); }
.modal__detalles { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 9px; font-size: 13px; line-height: 1.5; color: var(--niebla); }
.modal__detalles li { position: relative; padding-left: 18px; }
.modal__detalles li::before { content: "◆"; position: absolute; left: 0; top: 0; font-size: 7px; line-height: 2.6; color: var(--oro); }
@media (min-width: 761px) {
  .modal {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: none;
  }
  .modal__body { grid-template-columns: minmax(0, 1.5fr) minmax(380px, 1fr); align-items: start; min-height: 100%; }
  .galeria { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; overflow: visible; scroll-snap-type: none; touch-action: auto; }
  .galeria__foto { flex: none; }
  .galeria__puntos { display: none; }
  .modal__info {
    position: sticky; top: 0; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 72px clamp(26px, 3.2vw, 54px) 44px; gap: 17px;
    border-left: 1px solid var(--linea);
  }
  .modal__info h3 { font-size: clamp(28px, 2.6vw, 38px); }
  .modal__close-form { position: fixed; top: 16px; right: 20px; }
}

/* ---------- /gestures + /apple-design: en el celular la ficha sube desde abajo ---------- */
.sheet__handle { display: none; }
@media (max-width: 760px) {
  .modal {
    width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0;
    border: none; border-top: 1px solid color-mix(in srgb, var(--oro) 30%, transparent);
    border-radius: 18px 18px 0 0; overscroll-behavior: contain;
    opacity: 1; transform: translateY(0);
    /* Curva tipo iOS: muy empinada al inicio, se asienta suave */
    transition: transform 500ms var(--ease-drawer), overlay 500ms allow-discrete, display 500ms allow-discrete;
  }
  .modal:not([open]) { opacity: 1; transform: translateY(100%); transition-duration: 300ms; }
  @starting-style { .modal[open] { opacity: 1; transform: translateY(100%); } }
  .sheet__handle {
    display: block; position: sticky; top: 0; z-index: 3; height: 30px; margin-bottom: -30px;
    touch-action: none; cursor: grab;
  }
  .sheet__handle::before {
    content: ""; position: absolute; left: 50%; top: 11px; width: 42px; height: 4px; margin-left: -21px;
    border-radius: 3px; background: color-mix(in srgb, var(--oro) 55%, transparent);
  }
  .modal__close-form { top: 20px; }
}

/* ---------- Reducir movimiento: se colapsa la coreografía, se mantiene la opacidad ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero__cols li, .grid > li { animation: fade 200ms ease both; animation-delay: 0ms; }
  /* Estos tres arrancan en opacity:0 y la animación los sube. Sin animación hay que
     devolverlos a la vista a mano, o la marca no se vería. */
  .hero__word, .hero__claim, .hero__kicker { animation: none; opacity: 1; transform: none; }
  .hero__glow, .hero__chispas i { animation: none; }
  .hero__chispas { display: none; }
  .sello.on .sello__ring { animation: none; }
  .sello-card.revelado .trazo, .sello-card.revelado .trazo--2 { animation: none; stroke-dashoffset: 0; }
  .cart-item--sale { transition: opacity 150ms ease; }
  .cart-item--sale.ya { transform: none; }
  .card__media::after { display: none; }
  @media (max-width: 760px) {
    .modal, .modal:not([open]) { transform: none; transition-property: opacity, overlay, display; transition-duration: 200ms; }
    .modal:not([open]) { opacity: 0; }
    @starting-style { .modal[open] { transform: none; opacity: 0; } }
  }
}
