/* =========================================================
   Proyectos · estantería (js/estante.js)
   Fondo negro con rejilla de puntos; lomos negro/grafito/blanco
   con la imagen del proyecto en semitono; la portada activa gira
   y la trama se revela en foto. Medidas a partir de --H.
   Regla de robustez: NINGUNA transición CSS en .est__cara (todo
   el movimiento lo escribe js/estante.js) y nada de filtros,
   mezclas ni backdrop-filter dentro de la estantería.
   ========================================================= */
.estante-panel { min-height: 100vh; min-height: 100svh; padding: 0; overflow: hidden; background: var(--bg); }
.snap .estante-panel[data-slide]::before { display: none; }

.estante {
  --H: min(44vh, 30vw);
  --cy: calc(50% + 6px);
  position: absolute; inset: 0; overflow: hidden; overflow: clip;
  user-select: none; -webkit-user-select: none;
  /* rejilla base de puntos (el lienzo solo pinta lo que se ilumina) */
  background: radial-gradient(circle at center, rgba(246,247,248,0.07) 0.8px, transparent 1.25px) 0 0 / var(--sep, 22px) var(--sep, 22px);
}
@media (max-width: 767px) { .estante { --H: min(64vw, 40svh); --cy: calc(46% + 10px); } }
/* tablet en vertical: piezas más grandes */
@media (min-width: 768px) and (orientation: portrait) { .estante { --H: min(36vh, 50vw); } }

.est__puntos { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; z-index: 0; }

/* banda de la estantería: recibe arrastre, rueda y clics */
.est__escena {
  position: absolute; left: 0; right: 0; z-index: 1;
  top: calc(var(--cy) - var(--H) / 2 - 56px); height: calc(var(--H) + 112px);
  touch-action: pan-y; cursor: grab;
}
.est__escena.is-arrastre { cursor: grabbing; }
.est__escena.is-arrastre .est__stage { pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .est__escena, .est__escena.is-arrastre { cursor: none; } }

/* escenario con perspectiva: las caras son planos independientes (sin preserve-3d) */
.est__stage { position: absolute; inset: 0; overflow: hidden; overflow: clip; perspective: 2200px; perspective-origin: 50% 50%; }
.est__cara {
  position: absolute; left: 50%; top: 50%; height: var(--Hp, 400px);
  margin-top: calc(var(--Hp, 400px) / -2);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 3px; overflow: hidden; will-change: transform;
  visibility: hidden; contain: layout paint;
}
.estante.is-listo .est__cara { visibility: visible; }
.est__luz { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }

/* ---------- Lomo ---------- */
.est__lomo {
  width: var(--ws); margin-left: calc(var(--ws) / -2);
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--ws) * 0.14) 0 calc(var(--ws) * 0.22);
  background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0) 30%, rgba(255,255,255,0) 72%, rgba(255,255,255,0.04)), #0d0f11;
  color: var(--t-1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.07);
}
.est__lomo--grafito { background: linear-gradient(90deg, rgba(255,255,255,0.07), rgba(255,255,255,0) 30%, rgba(255,255,255,0) 72%, rgba(255,255,255,0.05)), #1e2226; }
.est__lomo--blanco { background: linear-gradient(90deg, rgba(0,0,0,0.05), rgba(0,0,0,0) 30%, rgba(0,0,0,0) 72%, rgba(0,0,0,0.07)), #e8e9eb; color: #0b0d10; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.est__lomo-img {
  flex: none; width: 74%; aspect-ratio: 120 / 168;
  background: center / 100% 100% no-repeat;
  border-radius: 2px;
}
.est__lomo-txt {
  flex: 1 1 auto; min-height: 0; margin: calc(var(--ws) * 0.2) 0;
  writing-mode: vertical-rl; text-orientation: mixed;
  font: 400 min(calc(var(--ws) * 0.4), calc(var(--Hp, 400px) * 0.95 / var(--largo, 8))) / 1 var(--serif);
  letter-spacing: 0.01em; white-space: nowrap; overflow: hidden;
}
.est__lomo-n { flex: none; font: 300 calc(var(--ws) * 0.16) / 1 var(--sans); letter-spacing: 0.08em; opacity: 0.6; font-variant-numeric: tabular-nums; }

/* ---------- Portada ---------- */
.est__tapa { width: var(--d); margin-left: calc(var(--d) / -2); background: #0d0f11; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
.est__tapa-puntos { position: absolute; inset: 0; background: center / 100% 100% no-repeat; }
.est__tapa-foto { position: absolute; inset: 0; opacity: 0; }
.est__tapa-foto img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
/* marcas sin galería: el logo sobre una placa */
.est__tapa--logo .est__tapa-foto { display: grid; place-items: center; background: #0d0f11; }
.est__tapa--logo .est__tapa-foto img { width: 64%; height: 46%; object-fit: contain; filter: invert(1); }
.est__tapa--blanco .est__tapa-foto { background: #e8e9eb; }
.est__tapa--blanco .est__tapa-foto img { filter: none; }
/* reflejo de espectro, muy sutil, que se desliza con la inclinación */
.est__brillo {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,80,80,0.10) 40%, rgba(255,210,80,0.10) 45%, rgba(80,255,170,0.10) 50%, rgba(80,170,255,0.12) 55%, rgba(190,110,255,0.10) 60%, transparent 70%) 50% 50% / 300% 100% no-repeat;
}

/* sombra en el "suelo" bajo la portada activa (plano 2D, fuera del 3D) */
.est__sombra {
  position: absolute; left: 50%; top: calc(50% + var(--H) * 0.47);
  width: calc(var(--d) * 1.15); height: calc(var(--H) * 0.16); margin-left: calc(var(--d) * -0.575);
  background: radial-gradient(closest-side, rgba(0,0,0,0.85), rgba(0,0,0,0)); opacity: 0; pointer-events: none;
}

/* ---------- Pie: nombre, tipo y contador con máscara ---------- */
.est__pie {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 2;
  top: calc(var(--cy) + var(--H) / 2 + var(--H) * 0.1 + 26px);
  display: grid; justify-items: center; gap: 8px; pointer-events: none; text-align: center;
  width: min(760px, calc(100% - 2 * var(--gutter) - 120px));
}
.est__linea { position: relative; overflow: hidden; width: 100%; }
.est__linea > span { display: block; }
.est__linea > span + span { position: absolute; left: 0; right: 0; top: 0; }
.est__linea--nombre { font: 400 clamp(28px, 2.4vw, 40px) / 1.14 var(--serif); letter-spacing: -0.01em; color: var(--t-1); padding-bottom: 0.06em; }
.est__linea--tipo { font: 300 13px / 1.4 var(--sans); letter-spacing: 0.04em; color: var(--t-2); }
.est__linea--n { font: 400 11px / 1.4 var(--sans); letter-spacing: 0.12em; color: var(--t-3); font-variant-numeric: tabular-nums; }
.est__linea--n i { display: inline-block; width: 22px; height: 1px; background: var(--line-3); vertical-align: middle; margin: 0 6px; }

.est__flecha { position: absolute; z-index: 3; top: calc(var(--cy) + var(--H) / 2 + var(--H) * 0.1 + 24px); }
.est__flecha svg { width: 18px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.est__flecha--izq { left: var(--gutter); }
.est__flecha--der { right: var(--gutter); }

.est__pista { position: absolute; left: 0; right: 0; bottom: calc(3.5vh + env(safe-area-inset-bottom, 0px)); margin: 0; z-index: 2; text-align: center; font: 300 11px/1.4 var(--sans); letter-spacing: 0.06em; color: var(--t-2); opacity: 0.5; pointer-events: none; }
.est__pista .solo-tactil { display: none; }
@media (hover: none) { .est__pista .solo-mouse { display: none; } .est__pista .solo-tactil { display: inline; } }

/* lista real para teclado y lectores: invisible hasta recibir foco */
.est__lista { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; padding: 0; list-style: none; }
.est__lista:focus-within { clip-path: none; width: auto; height: auto; overflow: visible; left: 50%; top: auto; bottom: calc(3.5vh + 22px); transform: translateX(-50%); display: flex; gap: 6px; z-index: 4; }
.est__lista button { font: 400 12px/1 var(--sans); color: var(--t-2); background: none; border: 0; padding: 6px; border-radius: 4px; white-space: nowrap; }
.est__lista button:focus-visible { color: var(--t-1); outline: 1px solid var(--line-3); }
.est__lista:focus-within ~ .est__pista { opacity: 0; }

@media (max-width: 767px) {
  .est__linea--nombre { font-size: 26px; }
  .est__linea--tipo { font-size: 12px; }
  .est__flecha { top: calc(var(--cy) + var(--H) / 2 + var(--H) * 0.1 + 20px); }
  .est__flecha--izq { left: 12px; } .est__flecha--der { right: 12px; }
  .est__pie { width: calc(100vw - 132px); }
}

/* ---------- Cursor (anillo) ---------- */
.est-cursor { position: fixed; left: 0; top: 0; z-index: 70; width: 0; height: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s var(--ease-out); }
.est-cursor.is-on.is-escena { opacity: 1; }
.est-abierta .est-cursor { opacity: 0; }
.est-cursor__aro {
  position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid rgba(246,247,248,0.7);
  transition: transform 0.5s var(--ease-out), background-color 0.4s var(--ease-out), border-color 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out);
}
.est-cursor__punto { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--t-1); transition: transform 0.4s var(--ease-out); }
.est-cursor__txt { position: absolute; left: -40px; top: -8px; width: 80px; text-align: center; font: 500 12px/16px var(--sans); letter-spacing: 0.04em; color: var(--t-1); transform: scale(0); transition: transform 0.45s var(--ease-out); }
.est-cursor.is-lomo .est-cursor__aro { transform: scale(0.7); }
.est-cursor.is-abrir .est-cursor__aro {
  transform: scale(1.9); border-color: rgba(255,255,255,0.35);
  background: radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,0.22), rgba(255,255,255,0.06) 60%), rgba(12,14,16,0.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 0 24px rgba(140,190,255,0.18), 0 0 2px rgba(255,140,200,0.4);
}
.est-cursor.is-abrir .est-cursor__punto { transform: scale(0); }
.est-cursor.is-abrir .est-cursor__txt { transform: scale(1); }

/* ---------- Hoja con fotos y mockups ---------- */
.est-hoja { position: fixed; inset: 0; z-index: 80; background: var(--bg); overflow: hidden; }
.est-hoja::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0.8px, transparent 1.2px) 0 0 / 22px 22px; }
.est-hoja[hidden] { display: none; }
.est-abierta, .est-abierta body { overflow: hidden; }
.est-hoja__cerrar { position: absolute; z-index: 2; top: calc(16px + env(safe-area-inset-top, 0px)); right: var(--gutter); }
.est-hoja__cerrar svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.est-hoja__scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.est-hoja__galeria {
  position: relative; max-width: 1440px; margin: 0 auto;
  padding: 96px var(--gutter) calc(64px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 16px;
}
.est-hoja__cols { columns: 3 320px; column-gap: 16px; }
.est-hoja__cols .est-fig { break-inside: avoid; margin-bottom: 16px; }
.est-fig { margin: 0; border-radius: var(--r-md, 16px); overflow: hidden; background: var(--bg-1); }
.est-fig img { display: block; width: 100%; height: auto; transform: scale(var(--z, 1)); }
.est-fig.is-trama {
  -webkit-mask: radial-gradient(circle, #000 var(--r, 0px), transparent calc(var(--r, 0px) + 0.7px)) 0 0 / 14px 14px;
          mask: radial-gradient(circle, #000 var(--r, 0px), transparent calc(var(--r, 0px) + 0.7px)) 0 0 / 14px 14px;
}
.est-fig--logo { min-height: calc(100svh - 192px); display: grid; place-items: center; background: transparent; }
.est-fig--logo img { width: min(56vw, 520px); max-height: 50vh; object-fit: contain; filter: invert(1); transform: none; }

@media (max-width: 767px) {
  .est-hoja__galeria { padding-top: 80px; gap: 10px; }
  .est-hoja__cols { columns: 1; }
  .est-hoja__cols .est-fig { margin-bottom: 10px; }
  .est-fig { border-radius: 12px; }
}
@media (prefers-reduced-motion: reduce) { .est-cursor__aro, .est-cursor__punto, .est-cursor__txt { transition: none; } }

/* ---------- Barra de categorías ---------- */
.est__nav {
  position: absolute; z-index: 3; left: 50%; transform: translateX(-50%);
  top: max(calc(var(--header-h, 84px) + 14px), calc(var(--cy) - var(--H) / 2 - 56px - 58px));
  display: flex; gap: 2px; padding: 5px; border-radius: var(--r-pill, 999px);
  max-width: calc(100% - 2 * var(--gutter)); overflow-x: auto; scrollbar-width: none;
}
.est__nav::-webkit-scrollbar { display: none; }
.est__nav button {
  position: relative; z-index: 1; flex: none; border: 0; background: none; cursor: pointer;
  padding: 0 16px; height: 34px; border-radius: var(--r-pill, 999px);
  font: 500 13px/1 var(--sans); color: var(--t-2); white-space: nowrap;
  transition: color 0.35s var(--ease-out);
}
.est__nav button:hover, .est__nav button[aria-current] { color: var(--t-1); }
.est__nav button:focus-visible { outline: 1px solid var(--line-3); outline-offset: -2px; }
.est__nav-pill {
  position: absolute; left: 0; top: 5px; height: 34px; border-radius: var(--r-pill, 999px); opacity: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16), inset 0 1px 0 rgba(255,255,255,0.22);
  transition: transform 0.6s var(--ease-out), width 0.6s var(--ease-out), opacity 0.3s;
}
.est__nav.has-pill .est__nav-pill { opacity: 1; }
@media (max-width: 767px) {
  .est__nav { top: calc(var(--header-h, 64px) + 10px); left: var(--gutter); right: var(--gutter); transform: none; max-width: none; }
  .est__nav button { padding: 0 13px; height: 32px; font-size: 12px; }
  .est__nav-pill { height: 32px; }
}
@media (prefers-reduced-motion: reduce) { .est__nav-pill, .est__nav button { transition: none; } }

/* ---------- Libro que se abre (copia plana encima de la estantería) ---------- */
.est-libro { position: fixed; z-index: 81; perspective: 1800px; pointer-events: none; }
.est-libro__tapa { position: absolute; inset: 0; transform-origin: 0 50%; transform-style: preserve-3d; }
.est-libro__cara { position: absolute; inset: 0; border-radius: 3px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #0d0f11; }
.est-libro__cara img { width: 100%; height: 100%; object-fit: cover; display: block; }
.est-libro__guarda { transform: rotateY(180deg); display: grid; place-items: center;
  background: radial-gradient(circle, rgba(255,255,255,0.16) 0.9px, transparent 1.3px) 0 0 / 12px 12px, #0d0f11;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
.est-libro__guarda span { font: 400 22px/1 var(--serif); color: var(--t-2); }

/* marcas: portada + logo */
.est-hoja__par { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; max-width: 1100px; width: 100%; margin: 0 auto; }
.est-hoja__par .est-fig--logo { min-height: 0; background: #ece9e4; display: grid; place-items: center; }
.est-hoja__par .est-fig--logo img { width: 62%; max-height: 50%; filter: none; }
@media (max-width: 767px) { .est-hoja__par { grid-template-columns: 1fr; gap: 10px; } .est-hoja__par .est-fig--logo { aspect-ratio: 1; } }

/* color del proyecto al pasar el cursor por un lomo (opacidad escrita por js/estante.js) */
.est__lomo-color { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; padding: calc(var(--ws) * 0.14) 0 calc(var(--ws) * 0.22); }
.est__lomo-img--foto { background-size: cover !important; background-repeat: no-repeat; }

/* barra de categorías en celular: se desliza; un degradado avisa de que hay más */
@media (max-width: 767px) {
  .est__nav { -webkit-mask: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 22px), transparent); mask: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 22px), transparent); }
}
/* celular en horizontal (poca altura): todo más compacto */
@media (max-height: 520px) and (orientation: landscape) {
  .estante { --H: min(36vh, 24vw); --cy: 60%; }
  .est__nav { top: calc(var(--header-h, 64px) + 4px); left: 50%; right: auto; transform: translateX(-50%); max-width: calc(100% - 2 * var(--gutter)); }
  .est__nav button { height: 28px; font-size: 11.5px; } .est__nav-pill { height: 28px; }
  .est__pie { top: calc(var(--cy) + var(--H) / 2 + var(--H) * 0.1 + 10px); gap: 2px; }
  .est__linea--nombre { font-size: 20px; }
  .est__linea--n, .est__pista { display: none; }
  .est__flecha { top: calc(var(--cy) + var(--H) / 2 + var(--H) * 0.1 + 4px); }
  .est__escena { top: calc(var(--cy) - var(--H) / 2 - 24px); height: calc(var(--H) + 48px); }
}

/* ---------- Portada sin foto: color de la marca + logotipo ---------- */
.est-placa { position: absolute; inset: 0; display: grid; place-items: center; }
.est-placa img { width: 62%; height: 40%; object-fit: contain; display: block; }
.est__lomo-img--logo { background-size: 76% auto !important; background-position: center; background-repeat: no-repeat; }
.est-fig--marca { position: relative; width: min(100%, 980px); margin: 0 auto; aspect-ratio: 16 / 10; }
.est-placa--grande img { width: 46%; height: 46%; }
@media (max-width: 767px) { .est-fig--marca { aspect-ratio: 4 / 5; } .est-placa--grande img { width: 64%; } }
