/* =========================================================
   Quíntuple selección — un solo panorama ilustrado que la cámara
   recorre en horizontal mientras se hace scroll (sin cortes ni pausas).
   Capas: lejana (.35), media (.7), mundo 1:1, frontal (1.25).
   Los textos son letreros colgantes con el lenguaje de la etiqueta.
   Medidas (--s, --stage-h, tamaño y posición de capas) en js/seleccion.js.
   ========================================================= */

.pz {
  --stage-h: calc(100svh - var(--header-h, 78px));
  --sign-top: 34px;
  position: relative;
  background: var(--cream);
}
.pz__pin {
  position: sticky;
  top: var(--header-h, 78px);
  height: var(--stage-h);
  overflow: hidden;
}
.pz__stage {
  position: relative;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: var(--cream);
}
/* velo inferior para que la línea de avance se lea sobre la ilustración */
.pz__stage::after {
  content: ""; position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; height: 78px;
  background: linear-gradient(rgba(1, 43, 20, 0), rgba(1, 43, 20, .62));
  pointer-events: none;
}

.pz__layer {
  position: absolute; left: 0; top: 0;
  z-index: 1;
  will-change: transform;
  backface-visibility: hidden;
  pointer-events: none;
}
.pz__layer[data-layer="mid"] { z-index: 2; }
.pz__world { z-index: 3; }
.pz__layer--fore { z-index: 4; }
.pz__layer > svg, .pz__layer > img { display: block; width: 100%; height: 100%; }

/* =========================================================
   Letreros colgantes
   ========================================================= */
.pz__signs { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.pz-sign {
  position: absolute; left: 0; top: var(--sign-top);
  width: 300px;
  margin: 0;
  will-change: transform, opacity;
  pointer-events: none;
}
/* cuerdas de fique que suben hasta el techo / el cielo */
.pz-sign::before {
  content: ""; position: absolute; z-index: 0;
  left: 38px; right: 38px; top: calc(var(--sign-top) * -1 - 6px); height: calc(var(--sign-top) + 2px);
  background:
    repeating-linear-gradient(180deg, #DDBB78 0 3px, #9E7A3E 3px 5px) left top / 3px 100% no-repeat,
    repeating-linear-gradient(180deg, #DDBB78 0 3px, #9E7A3E 3px 5px) right top / 3px 100% no-repeat;
}
/* listón de madera del que cuelga el letrero */
.pz-sign::after {
  content: ""; position: absolute; z-index: 2;
  left: 22px; right: 22px; top: -8px; height: 12px;
  border-radius: 3px;
  background:
    radial-gradient(circle at 16px 6px, #D3DDDA 0 1.8px, #56655F 2.2px, transparent 2.8px),
    radial-gradient(circle at calc(100% - 16px) 6px, #D3DDDA 0 1.8px, #56655F 2.2px, transparent 2.8px),
    repeating-linear-gradient(90deg, rgba(94, 56, 18, .25) 0 1px, transparent 1px 23px),
    linear-gradient(#D39A4C, #8C5A22);
  box-shadow: inset 0 1px 0 rgba(255, 236, 200, .55), 0 3px 4px rgba(40, 20, 0, .35);
}
.pz-sign__board {
  position: relative; z-index: 1;
  display: block;
  padding: 22px 20px 16px;
  background: var(--cream-50);
  color: #4A3426;
  border: 3px solid #025E32;
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 3px var(--cream-50),
    inset 0 0 0 5px #2E8A47,
    0 18px 24px -14px rgba(30, 15, 0, .55);
}
.pz-sign__board::before {
  /* grano de impresión de la etiqueta */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: var(--noise); opacity: .35; mix-blend-mode: multiply;
}
.pz-sign h3 {
  font-family: var(--font-display);
  font-size: 1.32rem; line-height: 1.12;
  color: #014320;
  margin: .25rem 0 .35rem;
}
.pz-sign p { font-size: .92rem; line-height: 1.45; }
.pz-sign__num {
  position: relative;
  min-height: 24px;
  padding-left: 46px;
  font-size: .78rem !important; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: #115547;
}
/* medallón ocre facetado con el número */
.pz-roundel {
  position: absolute; left: -32px; top: -40px;
  display: grid; place-items: center;
  width: 58px; height: 58px; border-radius: 50%;
  padding-top: 4px;
  font-family: var(--font-display); font-size: 1.5rem; letter-spacing: 0; text-transform: none;
  color: var(--cream-50);
  text-shadow: 0 1px 0 rgba(60, 25, 0, .45);
  background: conic-gradient(from 210deg, #E8AC52 0 17%, #C47A1A 17% 40%, #AE6308 40% 61%, #8C4E06 61% 79%, #D9913A 79% 100%);
  box-shadow: 0 0 0 3px var(--cream-50), 0 0 0 5px #7A4406, 0 8px 12px -4px rgba(40, 20, 0, .45);
}

/* arcos: introducción y cierre (como la pestaña de la B en la etiqueta) */
.pz-sign--arch { width: 520px; }
.pz-sign--arch .pz-sign__board {
  padding: 42px 34px 22px;
  text-align: center;
  color: var(--cream-50);
  background: var(--teal);
  border: 3px solid #025E32;
  border-bottom: 7px solid var(--ochre);
  border-radius: 280px 280px 18px 18px / 96px 96px 18px 18px;
  box-shadow:
    inset 0 0 0 3px var(--teal),
    inset 0 0 0 5px #F5E6D3,
    0 20px 26px -14px rgba(20, 10, 0, .6);
}
.pz-sign--arch .pz-sign__board::before { mix-blend-mode: soft-light; opacity: .3; }
.pz-sign__eyebrow {
  font-size: .8rem !important; font-weight: 700; letter-spacing: .26em; text-transform: uppercase;
  color: #F6C27A;
  margin-bottom: .35rem;
}
.pz-sign--intro h2 {
  font-size: clamp(2rem, 2.8vw, 2.55rem); line-height: 1.02;
  color: var(--cream-50);
  margin-bottom: .55rem;
}
.pz-sign--intro h2 em { font-style: normal; color: #F6C27A; }
.pz-compare {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px;
  margin-top: .6rem;
  font-size: .78rem !important; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.pz-compare span:first-child { color: rgba(251, 243, 230, .7); }
.pz-compare b { color: #F6C27A; }

.pz-sign--close { width: 540px; }
.pz-close__title { font-family: var(--font-display); font-size: clamp(1.45rem, 2vw, 1.85rem) !important; line-height: 1.15 !important; }
.pz-close__sub { margin: .45rem 0 .85rem; font-size: .76rem !important; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: #F6C27A; }
.pz-sign--close .btn { min-height: 46px; padding-block: .85em .7em; box-shadow: 0 0 0 3px rgba(251, 243, 230, .85); }
/* colas de cinta roja a los lados del cierre */
.pz-sign--close .pz-sign__board::after {
  content: ""; position: absolute; z-index: -1; left: -26px; right: -26px; bottom: 16px; height: 34px;
  background:
    linear-gradient(#9F0306, #9F0306) left / 40px 100% no-repeat,
    linear-gradient(#9F0306, #9F0306) right / 40px 100% no-repeat;
  clip-path: polygon(0 0, 40px 0, 40px 100%, 0 100%, 14px 50%, 0 0, 100% 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, calc(100% - 40px) 100%, calc(100% - 40px) 0, 100% 0);
}

/* nota de transición: tabla de madera en forma de flecha */
.pz-sign--note { width: 290px; }
.pz-sign--note .pz-sign__board {
  padding: 14px 40px 14px 20px;
  border: 0; border-radius: 4px;
  color: var(--cream-50);
  font-style: italic; font-size: .95rem; line-height: 1.45;
  background:
    repeating-linear-gradient(176deg, rgba(255, 220, 160, .08) 0 2px, transparent 2px 9px),
    linear-gradient(#8C5A22, #6E4418);
  clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 50%, calc(100% - 26px) 100%, 0 100%);
  box-shadow: none;
  filter: drop-shadow(0 10px 10px rgba(30, 15, 0, .35));
}
.pz-sign--note .pz-sign__board::before { display: none; }

/* =========================================================
   Línea de avance (sutil, sobre la ilustración)
   ========================================================= */
.pz-progress {
  position: absolute; z-index: 7;
  left: clamp(16px, 3vw, 40px); right: clamp(16px, 3vw, 40px); bottom: clamp(10px, 1.8vh, 18px);
  height: 30px;
}
.pz-progress__line { position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: rgba(251, 243, 230, .35); border-radius: 2px; overflow: hidden; }
.pz-progress__fill { position: absolute; inset: 0; background: #F6C27A; transform-origin: left; transform: scaleX(var(--prog, 0)); }
.pz-progress ol { position: absolute; inset: 0; }
.pz-progress li { position: absolute; top: 0; left: calc(var(--at, 0) * 100%); transform: translateX(-50%); }
.pz-progress button {
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer;
}
.pz-progress button span {
  display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: #115547; border: 1.5px solid rgba(251, 243, 230, .7);
  color: var(--cream-50); font-size: .62rem; font-weight: 700; padding-top: 1px;
  transition: background-color .3s, border-color .3s, color .3s, transform .3s var(--ease);
}
.pz-progress li.is-done button span { background: #F6C27A; border-color: #F6C27A; color: var(--forest-900); }
.pz-progress li.is-current button span { transform: scale(1.25); background: var(--cream-50); border-color: var(--cream-50); color: var(--forest-900); }
.pz-progress button:focus-visible span { outline: 2px solid #F6C27A; outline-offset: 2px; }
.pz-progress__bean {
  position: absolute; top: 50%; left: calc(var(--prog, 0) * 100%);
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4));
  pointer-events: none;
}
.pz-progress__bean svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transform: scale(.6) rotate(-30deg); transition: opacity .45s, transform .45s var(--ease); }
.pz-progress__bean[data-state="cherry"] .b-cherry,
.pz-progress__bean[data-state="perg"] .b-perg,
.pz-progress__bean[data-state="green"] .b-green,
.pz-progress__bean[data-state="roast"] .b-roast { opacity: 1; transform: none; }

/* ---------- Móvil ---------- */
@media (max-width: 759px) {
  .pz { --sign-top: 24px; }
  .pz-sign, .pz-sign--arch, .pz-sign--close, .pz-sign--note { width: min(340px, calc(100vw - 36px)); }
  .pz-sign__board { padding: 20px 18px 14px; }
  .pz-sign p { font-size: .9rem; }
  .pz-sign h3 { font-size: 1.28rem; }
  .pz-sign__num { font-size: .875rem !important; letter-spacing: .1em; }
  .pz-roundel { left: -26px; top: -36px; width: 52px; height: 52px; font-size: 1.35rem; }
  .pz-sign--arch .pz-sign__board { padding: 36px 20px 18px; border-radius: 200px 200px 16px 16px / 70px 70px 16px 16px; }
  .pz-sign--intro h2 { font-size: 2rem; }
  .pz-compare { flex-direction: column; align-items: center; font-size: .875rem !important; letter-spacing: .04em; }
  .pz-close__title { font-size: 1.4rem !important; }
  .pz-close__sub { font-size: .875rem !important; letter-spacing: .08em; }
  .pz-sign--close .pz-sign__board::after { left: -14px; right: -14px; }
}

/* =========================================================
   Animaciones de las estaciones (sólo transform / opacity)
   Corren sólo con .is-live (sección en pantalla) y .is-playing (estación visible).
   ========================================================= */
.pz__world .sel-static { display: none; }
.pz:not(.is-live) .pz__world *,
.pz__world .pz-st:not(.is-playing) * { animation-play-state: paused; }
.pz__world [class*="s2-"], .pz__world [class*="s3-"], .pz__world [class*="s4-"], .pz__world [class*="s5-"],
.pz__world .pz-arm, .pz__world .pz-cherry, .pz__world .pz-steam { transform-box: fill-box; transform-origin: center; }
.pz__world .s5-puff { transform-origin: left center; }

/* 01 · el brazo gira desde el hombro: de la rama al canasto */
.pz-arm { animation: pz-arm 5.2s var(--ease) infinite; }
.pz-cherry { animation: pz-cherry 5.2s linear infinite; }
@keyframes pz-arm { 0%, 16% { transform: rotate(0deg); } 46%, 56% { transform: rotate(-78deg); } 88%, 100% { transform: rotate(0deg); } }
@keyframes pz-cherry { 0%, 50% { opacity: 1; } 57%, 86% { opacity: 0; } 92%, 100% { opacity: 1; } }
.pz-flow { animation: pz-flow 1.4s linear infinite; }
@keyframes pz-flow { to { stroke-dashoffset: -24; } }
.pz-steam { animation: pz-steam 3.3s ease-in-out infinite; }
@keyframes pz-steam { 0% { opacity: 0; transform: translateY(8px) scaleX(.9); } 35% { opacity: .9; } 100% { opacity: 0; transform: translateY(-16px) scaleX(1.1); } }

/* 02 · Flote: superficie viva */
.s2-wave { animation: s2-wave 1.8s linear infinite; }
@keyframes s2-wave { to { transform: translateX(-30px); } }
.s2-wave2 { animation: s2-wave2 2.6s linear infinite; }
@keyframes s2-wave2 { to { transform: translateX(40px); } }
/* cada flotante sube desde el fondo, deriva hacia la nasa y desaparece en ella (ciclo de 10 s) */
.s2-drift { animation: s2-drift 10s linear infinite; }
@keyframes s2-drift {
  0% { transform: translate(-4px, 46px) scale(.75); opacity: 0; }
  4% { opacity: .9; }
  12% { transform: translate(0, -5px) scale(1); opacity: 1; }
  16% { transform: translate(2px, 0) scale(1); }
  78% { transform: translate(var(--dx), 0) scale(1); opacity: 1; }
  84% { transform: translate(calc(var(--dx) + 4px), -14px) scale(.7); opacity: 1; }
  88%, 100% { transform: translate(calc(var(--dx) + 6px), -22px) scale(.4); opacity: 0; }
}
.s2-bob { animation: s2-bob 1.7s ease-in-out infinite alternate; }
@keyframes s2-bob { from { transform: translateY(-7px) rotate(-20deg); } to { transform: translateY(6px) rotate(20deg); } }
.s2-ripple { animation: s2-ripple 1.7s ease-out infinite; }
@keyframes s2-ripple { 0% { transform: scale(.4); opacity: .95; } 100% { transform: scale(2.1); opacity: 0; } }
/* la nasa barre la superficie cada 2 s, justo cuando llega un flotante */
.s2-net { animation: s2-net 2s ease-in-out infinite; }
@keyframes s2-net {
  0% { transform: translate(6px, 24px) rotate(0deg); }
  36% { transform: translate(-12px, 27px) rotate(-3deg); }
  56% { transform: translate(0, -4px) rotate(4deg); }
  80% { transform: translate(16px, -10px) rotate(2deg); }
  100% { transform: translate(6px, 24px) rotate(0deg); }
}
.s2-sink { animation: s2-sink 6s cubic-bezier(.3, 0, .6, 1) infinite; }
@keyframes s2-sink {
  0% { transform: translate(0, 0); opacity: 0; }
  4% { opacity: 1; }
  20% { transform: translate(calc(var(--dx) * .3), 60px); }
  62%, 88% { transform: translate(var(--dx), 206px); opacity: 1; }
  100% { transform: translate(var(--dx), 206px); opacity: 0; }
}
.s2-bubble { animation: s2-bubble 4s ease-in infinite; }
@keyframes s2-bubble { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translateY(-140px); opacity: 0; } }

/* 03 · Zarandeo */
.s3-swing { animation: s3-swing .9s ease-in-out infinite alternate; }
@keyframes s3-swing { from { transform: rotate(-1.8deg); } to { transform: rotate(1.8deg); } }
.s3-fall { animation: s3-fall 2.6s cubic-bezier(.45, 0, .8, .6) infinite; }
@keyframes s3-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  12% { opacity: 1; }
  78% { transform: translateY(40px) rotate(160deg); opacity: 1; }
  100% { transform: translateY(44px) rotate(190deg); opacity: 0; }
}

/* 04 · Inspección manual */
.s4-lupa   { animation: s4-lupa 7s var(--ease) infinite; }
.s4-ring   { animation: s4-ring 7s ease-out infinite; }
.s4-hand   { animation: s4-hand 7s var(--ease) infinite; }
.s4-defect { animation: s4-defect 7s var(--ease) infinite; }
@keyframes s4-lupa {
  0% { transform: translate(0, 0); }
  14% { transform: translate(-34px, 96px); }
  30%, 54% { transform: translate(64px, 64px); }
  78% { transform: translate(110px, -26px); }
  100% { transform: translate(0, 0); }
}
@keyframes s4-ring { 0%, 28% { transform: scale(.6); opacity: 0; } 34% { transform: scale(1); opacity: 1; } 44% { transform: scale(1.12); opacity: 1; } 52%, 100% { transform: scale(1.35); opacity: 0; } }
@keyframes s4-hand {
  0%, 36% { transform: translate(210px, 190px); }
  50%, 58% { transform: translate(0, 0); }
  74%, 82% { transform: translate(194px, 84px); }
  100% { transform: translate(210px, 190px); }
}
@keyframes s4-defect {
  0%, 58% { transform: translate(0, 0); opacity: 1; }
  74% { transform: translate(194px, 84px); opacity: 1; }
  80% { transform: translate(194px, 90px); opacity: 0; }
  95% { transform: translate(0, 0); opacity: 0; }
  100% { transform: translate(0, 0); opacity: 1; }
}

/* 05 · Selector óptico */
.s5-vib { animation: s5-vib .14s linear infinite alternate; }
@keyframes s5-vib { from { transform: translateX(-.8px); } to { transform: translateX(.8px); } }
.s5-drop { animation: s5-drop 1.8s linear infinite; }
@keyframes s5-drop {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  8% { opacity: 1; }
  90% { transform: translateY(136px) rotate(220deg); opacity: 1; }
  100% { transform: translateY(144px) rotate(240deg); opacity: 0; }
}
.s5-reject { animation: s5-reject 3.6s linear infinite; }
@keyframes s5-reject {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  5% { opacity: 1; }
  46% { transform: translate(0, 94px) rotate(120deg); }
  68% { transform: translate(46px, 124px) rotate(330deg); }
  84% { transform: translate(64px, 142px) rotate(400deg); opacity: 1; }
  92%, 100% { transform: translate(66px, 148px) rotate(420deg); opacity: 0; }
}
.s5-puff { animation: s5-puff 3.6s ease-out infinite; }
@keyframes s5-puff { 0%, 42% { transform: scale(.3); opacity: 0; } 49% { transform: scale(1); opacity: .95; } 66%, 100% { transform: scale(1.6); opacity: 0; } }
.s5-scan { animation: s5-scan .9s ease-in-out infinite alternate; }
@keyframes s5-scan { from { opacity: .3; } to { opacity: 1; } }
.s5-led { animation: s5-scan .45s steps(2) infinite; }
.s5-dash { animation: s5-dash 1.6s linear infinite; }
@keyframes s5-dash { to { stroke-dashoffset: -28; } }

/* ---------- Movimiento reducido: sin fijar ni paralaje; panorama con scroll horizontal nativo ---------- */
@media (prefers-reduced-motion: reduce) {
  .pz { height: auto !important; }
  .pz__pin { position: relative; top: 0; }
  .pz__stage { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; }
  .pz__layer--fore, .pz-progress, .pz__stage::after { display: none; }
  .pz__layer { will-change: auto; }
  .pz-sign { opacity: 1 !important; pointer-events: auto !important; }
  .pz__world .sel-anim { display: none; }
  .pz__world .sel-static { display: inline; }
  .pz__world * { animation: none !important; }
}
