:root {
  --cava: #2a0818;
  --vino: #4c0f2e;
  --vino-claro: #6a1f43;
  --malva: #8b506d;
  --rosa: #e7d9df;
  --papel: #fbf7f8;
  --tinta: #2b1420;
  --tinta-suave: #6d5561;
  --barra-sup: 58px;
  --barra-inf: 66px;
  --t-titulo: "Montserrat", system-ui, sans-serif;
  --t-texto: "Commissioner", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--cava);
  color: var(--rosa);
  font: 400 15px/1.5 var(--t-texto);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--rosa); outline-offset: 2px; border-radius: 6px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* La mesa sobre la que apoya el libro */
.mesa {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 70% 60% at 50% 46%, #5e1a3b 0%, rgba(94, 26, 59, 0) 70%),
    radial-gradient(ellipse at 50% 120%, #1a040d 0%, rgba(26, 4, 13, 0) 60%),
    linear-gradient(180deg, #34091d 0%, #2a0818 55%, #1d0511 100%);
}

/* Marca */
.marca { display: inline-flex; flex-direction: column; align-items: center; text-decoration: none; color: #fff; line-height: 1; }
.marca__nombre { font: 600 17px/1 var(--t-titulo); letter-spacing: .16em; padding-left: .16em; }
.marca__sub { font: 500 6.6px/1 var(--t-titulo); letter-spacing: .36em; padding-left: .36em; margin-top: 4px; color: var(--rosa); }
.marca--grande .marca__nombre { font-size: 34px; }
.marca--grande .marca__sub { font-size: 11px; margin-top: 8px; }

/* Pantalla de carga */
.cargando {
  position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--cava); transition: opacity .6s var(--ease), visibility .6s;
}
.cargando.listo { opacity: 0; visibility: hidden; }
.cargando__texto { margin: 0; font: 300 15px var(--t-texto); color: var(--rosa); letter-spacing: .02em; }
.cargando__barra { width: 140px; height: 1px; background: rgba(231, 217, 223, .2); overflow: hidden; }
.cargando__barra span { display: block; height: 100%; width: 40%; background: var(--rosa); animation: carga 1.2s var(--ease) infinite; }
@keyframes carga { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Barras */
.barra-sup {
  position: fixed; top: 0; left: 0; right: 0; height: calc(var(--barra-sup) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; z-index: 10;
}
.acciones { display: flex; gap: 2px; }
.btn-ico {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; min-width: 40px; padding: 0 9px; justify-content: center;
  border-radius: 20px; color: var(--rosa); transition: background .2s, color .2s;
}
.btn-ico span { font-size: 13px; letter-spacing: .01em; display: none; }
.btn-ico:hover { background: rgba(231, 217, 223, .1); color: #fff; }
.btn-ico:active { background: rgba(231, 217, 223, .18); }
@media (min-width: 980px) { .btn-ico span { display: inline; } .btn-ico { padding: 0 13px; } }

.barra-inf {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--barra-inf) + env(safe-area-inset-bottom));
  padding: 0 max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.regla { width: min(720px, 100%); display: grid; grid-template-columns: 1fr auto; grid-template-areas: "tit num" "rango rango"; column-gap: 12px; row-gap: 6px; align-items: baseline; }
.regla__titulo { grid-area: tit; font: 500 13px var(--t-texto); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.regla__num { grid-area: num; font: 400 12px var(--t-texto); color: var(--rosa); font-variant-numeric: tabular-nums; }
.regla input { grid-area: rango; width: 100%; margin: 0; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 22px; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: rgba(231, 217, 223, .28); border-radius: 2px; }
input[type=range]::-moz-range-track { height: 2px; background: rgba(231, 217, 223, .28); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--rosa); border: 3px solid var(--vino); box-shadow: 0 0 0 1px var(--rosa); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--rosa); border: 3px solid var(--vino); box-shadow: 0 0 0 1px var(--rosa); }

/* Escenario y libro */
.escenario {
  position: fixed; left: 0; right: 0;
  top: calc(var(--barra-sup) + env(safe-area-inset-top));
  bottom: calc(var(--barra-inf) + env(safe-area-inset-bottom));
  display: grid; place-items: center;
}
.libro-caja { position: relative; }
.libro-caja::after {
  content: ""; position: absolute; left: 6%; right: 6%; bottom: -16px; height: 26px; z-index: -1;
  background: radial-gradient(ellipse at center, rgba(8, 0, 4, .55) 0%, rgba(8, 0, 4, 0) 70%);
  filter: blur(4px);
}
.libro { position: relative; }
.libro .stf__wrapper { position: relative; width: 100%; height: 100%; }
.libro .stf__block { position: absolute; inset: 0; perspective: 2200px; }
.libro .stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.libro .stf__outerShadow, .libro .stf__innerShadow, .libro .stf__hardShadow, .libro .stf__hardInnerShadow { position: absolute; left: 0; top: 0; }

.pag { background: #f4edf0; overflow: hidden; }
.pag__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.pag::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, #efe5ea 30%, #f8f2f5 50%, #efe5ea 70%); background-size: 300% 100%;
  animation: brillo 1.6s linear infinite;
}
.pag.lista::before { display: none; }
@keyframes brillo { from { background-position: 100% 0; } to { background-position: -200% 0; } }
/* Sombra del lomo */
.pag::after { content: ""; position: absolute; top: 0; bottom: 0; width: 7%; pointer-events: none; z-index: 2; }
.pag.--left::after { right: 0; background: linear-gradient(to left, rgba(20, 0, 8, .22), rgba(20, 0, 8, 0)); }
.pag.--right::after { left: 0; background: linear-gradient(to right, rgba(20, 0, 8, .2), rgba(20, 0, 8, 0)); }
.pag.--hard::after { display: none; }

.hs { position: absolute; z-index: 3; border-radius: 4px; transition: background .2s, box-shadow .2s; }
.hs:hover, .hs:focus-visible { background: rgba(139, 80, 109, .14); box-shadow: inset 0 0 0 1px rgba(139, 80, 109, .55); }
.hs.destello { animation: destello 1.8s var(--ease) 2; }
@keyframes destello { 0%, 100% { background: rgba(139, 80, 109, 0); } 45% { background: rgba(139, 80, 109, .2); box-shadow: inset 0 0 0 1px rgba(139, 80, 109, .5); } }

.flecha {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 5;
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--rosa);
  background: rgba(231, 217, 223, .06); transition: background .2s, opacity .2s;
}
.flecha:hover { background: rgba(231, 217, 223, .16); color: #fff; }
.flecha:disabled { opacity: 0; pointer-events: none; }
.flecha--ant { left: max(14px, env(safe-area-inset-left)); }
.flecha--sig { right: max(14px, env(safe-area-inset-right)); }
@media (max-width: 760px), (pointer: coarse) and (max-width: 1100px) { .flecha { display: none; } }

.pista {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; z-index: 6;
  padding: 9px 16px; border-radius: 20px; background: rgba(26, 4, 13, .82); color: #fff; font-size: 13px; white-space: nowrap;
  transition: opacity .5s; pointer-events: none;
}
.pista.fuera { opacity: 0; }

/* Paneles */
.velo { position: fixed; inset: 0; z-index: 20; background: rgba(18, 2, 9, .55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: aparecer .25s var(--ease); }
@keyframes aparecer { from { opacity: 0; } }
.panel {
  position: fixed; z-index: 30; background: var(--papel); color: var(--tinta);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(10, 0, 5, .45);
}
.panel__cab { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px 24px; }
.panel__cab h2 { margin: 0; font: 500 18px var(--t-titulo); letter-spacing: .01em; color: var(--vino); }
.panel__cuerpo { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 24px 28px; flex: 1; }
.btn-cerrar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--tinta-suave); }
.btn-cerrar:hover { background: rgba(76, 15, 46, .07); color: var(--vino); }

.panel--izq { top: 0; bottom: 0; left: 0; width: min(380px, 90vw); padding-top: env(safe-area-inset-top); animation: desdeIzq .35s var(--ease); }
@keyframes desdeIzq { from { transform: translateX(-100%); } }
.panel--busqueda { top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); max-height: min(78vh, 720px); border-radius: 16px; animation: desdeArriba .3s var(--ease); }
@keyframes desdeArriba { from { opacity: 0; transform: translate(-50%, -14px); } }
.panel--abajo { left: 0; right: 0; bottom: 0; height: min(78vh, 760px); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: desdeAbajo .35s var(--ease); }
@keyframes desdeAbajo { from { transform: translateY(100%); } }
@media (max-width: 640px) {
  .panel--busqueda { top: 0; left: 0; transform: none; width: 100vw; height: 100dvh; max-height: none; border-radius: 0; padding-top: env(safe-area-inset-top); animation: aparecer .2s; }
}

/* Índice: eco de la página "Contenido" del catálogo */
.indice { list-style: none; margin: 0 0 8px; padding: 0; }
.indice a { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: inherit; padding: 9px 0; }
.indice .n1 a { font: 600 13px var(--t-titulo); letter-spacing: .08em; text-transform: uppercase; color: var(--vino); padding-top: 16px; }
.indice .n2 a { font: 400 14.5px var(--t-texto); color: var(--tinta); padding: 6px 0 6px 14px; }
.indice a::after { content: ""; order: 2; flex: 1; border-bottom: 1px dotted rgba(76, 15, 46, .35); transform: translateY(-3px); }
.indice .num { order: 3; letter-spacing: 0; font: 500 13px var(--t-texto); color: var(--malva); font-variant-numeric: tabular-nums; }
.indice a:hover .txt { color: var(--malva); }
.indice .actual .txt { color: var(--malva); }
.locales__tit { margin: 26px 0 6px; font: 600 13px var(--t-titulo); letter-spacing: .08em; text-transform: uppercase; color: var(--vino); }
.locales { list-style: none; margin: 0; padding: 0; }
.locales li { padding: 11px 0; border-bottom: 1px solid rgba(76, 15, 46, .1); }
.locales strong { display: block; font: 600 14px var(--t-texto); color: var(--vino); }
.locales .dir { font-size: 14px; }
.locales .acc { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.locales .acc a { font-size: 13.5px; color: var(--malva); text-decoration: none; border-bottom: 1px solid rgba(139, 80, 109, .35); }
.locales .acc a:hover { color: var(--vino); border-color: var(--vino); }
.aviso { margin: 22px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--tinta-suave); }

/* Buscador */
.buscador { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 20px; border-bottom: 1px solid rgba(76, 15, 46, .12); }
.buscador > svg { color: var(--malva); flex: none; }
.buscador input { flex: 1; min-width: 0; height: 46px; border: 0; outline: 0; background: transparent; font: 400 17px var(--t-texto); color: var(--tinta); }
.buscador input::placeholder { color: #a28f98; }
.buscador input::-webkit-search-cancel-button { display: none; }
.res__grupo { margin: 18px 0 4px; font: 600 12px var(--t-titulo); letter-spacing: .06em; color: var(--malva); }
.res { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 9px 8px; margin: 0 -8px; border-radius: 10px; }
.res:hover, .res:focus-visible { background: rgba(76, 15, 46, .06); }
.res img { width: 40px; height: 57px; object-fit: cover; border-radius: 2px; box-shadow: 0 1px 4px rgba(43, 20, 32, .25); background: #eee; }
.res__tit { display: block; font: 500 14.5px/1.3 var(--t-texto); color: var(--tinta); }
.res__sub { display: block; font-size: 13px; color: var(--tinta-suave); margin-top: 2px; }
.res__sub mark, .res__tit mark { background: rgba(139, 80, 109, .2); color: inherit; border-radius: 2px; }
.res__pag { font-size: 12.5px; color: var(--malva); white-space: nowrap; }
.res__vacio { padding: 26px 0; color: var(--tinta-suave); }
.sugerencias { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; }
.sugerencias button { padding: 7px 13px; border-radius: 18px; border: 1px solid rgba(76, 15, 46, .2); font-size: 13.5px; color: var(--vino); }
.sugerencias button:hover { background: rgba(76, 15, 46, .06); }

/* Miniaturas */
.miniaturas { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 18px 14px; padding-top: 6px; }
.mini { display: grid; gap: 6px; text-align: center; }
.mini img { width: 100%; aspect-ratio: 595 / 842; object-fit: cover; border-radius: 2px; background: #eee; box-shadow: 0 2px 8px rgba(43, 20, 32, .22); transition: transform .2s var(--ease); }
.mini:hover img { transform: translateY(-3px); }
.mini span { font-size: 12px; color: var(--tinta-suave); }
.mini.actual img { outline: 2px solid var(--malva); outline-offset: 3px; }
.mini.actual span { color: var(--vino); font-weight: 600; }

/* Zoom */
.zoom { position: fixed; inset: 0; z-index: 40; background: #160410; animation: aparecer .25s var(--ease); }
.zoom__escena { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.zoom__escena.arrastrando { cursor: grabbing; }
.zoom__contenido { position: absolute; left: 0; top: 0; transform-origin: 0 0; display: flex; will-change: transform; }
.zoom__contenido img { display: block; height: 100%; width: auto; user-select: none; -webkit-user-drag: none; background: #f4edf0; }
.zoom__barra {
  position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 26px; background: rgba(42, 8, 24, .9); box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.zoom__nivel { min-width: 52px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.zoom__cerrar { margin-left: 6px; background: rgba(231, 217, 223, .12); }

/* Aviso flotante */
.aviso-flotante {
  position: fixed; left: 50%; bottom: calc(var(--barra-inf) + 18px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 22px; background: var(--papel); color: var(--vino); font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  transition: opacity .25s, transform .25s var(--ease);
}
.aviso-flotante.ver { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  :root { --barra-sup: 54px; --barra-inf: 70px; }
  .marca__nombre { font-size: 15px; }
  .marca__sub { font-size: 5.9px; }
  .acciones { gap: 0; }
  .btn-ico { min-width: 38px; padding: 0 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
