/* libro Registros de Fate: el visor que comparten la página pública (/libro) y la app. Todo vive bajo .libro. */
@font-face { font-family: "Amatic SC"; src: url("fonts/amatic-sc-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Amatic SC"; src: url("fonts/amatic-sc-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("fonts/caveat-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IM Fell English"; src: url("fonts/im-fell-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

.libro {
  --cuero: #6b4428; --cuero-osc: #3d2516; --cuero-claro: #8a5a36;
  --laton: #d79a4e; --laton-osc: #8c5a26;
  --grafito: #3a3029; --grafito-suave: rgba(58, 48, 41, 0.72); --lapiz-rojo: #b3262f;
  --papel: #f2e1c0;
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: 100%; color: var(--grafito); font-family: "Amatic SC", "IM Fell English", Georgia, serif;
  -webkit-user-select: none; user-select: none;
}
.libro *, .libro *::before, .libro *::after { box-sizing: border-box; }
.libro button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- libro abierto ---------- */
.libro-abierto { position: relative; display: flex; width: min(96vw, 1180px, calc((100vh - 210px) * 1.342)); perspective: 2600px; }
.libro-abierto.una { width: min(94vw, 860px); }
.libro-abierto::before { /* tapas de cuero asomando */
  content: ""; position: absolute; inset: -10px -12px; border-radius: 10px; z-index: -1;
  background: var(--tapa, linear-gradient(160deg, #8a2f2a, #6a1f1d 50%, #4a1414)); border: 3px solid #1a0907;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.55);
}
.libro-hoja {
  position: relative; flex: 1 1 0; aspect-ratio: 848 / 1264; overflow: hidden; container-type: inline-size;
  background: var(--papel) url("marco.jpg") center / 100% 100% no-repeat;
}
.libro-hoja.izq { box-shadow: inset -26px 0 30px -18px rgba(60, 35, 15, 0.55); }
.libro-hoja.der { box-shadow: inset 26px 0 30px -18px rgba(60, 35, 15, 0.55); }
.libro-abierto.una .libro-hoja.izq { display: none; }
.libro-hoja .num { position: absolute; bottom: 2.6%; font: 400 3cqw "Amatic SC", serif; color: var(--grafito-suave); }
.libro-hoja.izq .num { left: 9%; } .libro-hoja.der .num { right: 9%; }

/* contenido de una hoja: dentro del marco de engranes */
.hoja-cont { position: absolute; inset: 14% 11% 20% 11%; display: flex; flex-direction: column; overflow: hidden; }
.hoja-cont .capitulo { font: 400 2.7cqw "IM Fell English", serif; font-style: italic; color: var(--grafito-suave); text-align: center; }
.hoja-cont h2 { margin: 0.1em 0 0; text-align: center; font: 700 7cqw/1 "Amatic SC", serif; color: var(--grafito);
  text-shadow: 0.4px 0.3px 0 rgba(58, 48, 41, 0.5); }
.hoja-cont .divisor { display: block; width: 92%; margin: 0.4em auto 0.6em; opacity: 0.85; }
.hoja-cont .texto { flex: 1; overflow: hidden; font: 400 3.7cqw/1.18 "Amatic SC", serif; letter-spacing: 0.02em;
  color: var(--grafito); text-shadow: 0.3px 0.2px 0 rgba(58, 48, 41, 0.45); white-space: pre-line; }
.hoja-cont .nota { font: 500 3.4cqw/1.15 "Caveat", cursive; color: var(--lapiz-rojo); transform: rotate(-1.2deg); margin-top: 0.4em; }
.hoja-cont img.dibujo { display: block; max-width: 100%; max-height: 70%; margin: 0 auto; object-fit: contain; mix-blend-mode: multiply; filter: sepia(0.25) contrast(1.05); }
.hoja-cont iframe.figura { flex: 1; width: 100%; border: 0; background: transparent; mix-blend-mode: multiply; }
.hoja-cont .vacia { margin: auto; text-align: center; font: 500 3.8cqw "Caveat", cursive; color: var(--grafito-suave); }

/* índice */
.hoja-cont ol.indice { list-style: none; margin: 0; padding: 0; font: 400 3.4cqw/1.22 "Amatic SC", serif; overflow: hidden; }
.hoja-cont ol.indice li { display: flex; gap: 6px; }
.hoja-cont ol.indice li.cap { margin-top: 0.4em; font-weight: 700; }
.hoja-cont ol.indice button { all: unset; cursor: pointer; display: flex; flex: 1; gap: 6px; }
.hoja-cont ol.indice button:hover, .hoja-cont ol.indice button:focus-visible { color: var(--lapiz-rojo); }
.hoja-cont ol.indice .puntos { flex: 1; border-bottom: 2px dotted rgba(58, 48, 41, 0.35); margin-bottom: 0.35em; }

/* ---------- controles ---------- */
.libro-controles { display: flex; align-items: center; gap: 12px; font: 700 22px "Amatic SC", serif; color: #f1cf98; }
.libro-controles button { border: 1px solid rgba(215, 154, 78, 0.55); background: rgba(61, 37, 22, 0.75); border-radius: 999px;
  min-width: 44px; min-height: 44px; padding: 0 14px; font: 700 22px "Amatic SC", serif; color: #f1cf98; }
.libro-controles button:hover:not(:disabled), .libro-controles button:focus-visible { background: var(--cuero); outline: none; }
.libro-controles button:disabled { opacity: 0.35; cursor: default; }


/* anotaciones del registro: subrayado y notas a lápiz rojo, tintas de los Colores */
.hoja-cont .subrayado { text-decoration: underline wavy var(--lapiz-rojo); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.hoja-cont .anotacion { display: inline-block; margin: 0.2em 0 0.2em 0.6em; font: 500 1.05em/1.1 "Caveat", cursive; color: var(--lapiz-rojo); transform: rotate(-2deg); }
.hoja-cont .tinta-rojo { color: #c0272f; } .hoja-cont .tinta-azul { color: #2f62c9; } .hoja-cont .tinta-morado { color: #8a3fc4; }

/* tapas del libro abierto según el tomo */
/* hojas de Bocetos: papel cuadriculado de inventor dentro del mismo marco */
.libro[data-tomo="bocetos"] .libro-hoja { background:
  url("marco.jpg") center / 100% 100% no-repeat; }
.libro[data-tomo="bocetos"] .hoja-cont { background-image:
  linear-gradient(rgba(70, 90, 120, 0.12) 1px, transparent 1px), linear-gradient(90deg, rgba(70, 90, 120, 0.12) 1px, transparent 1px);
  background-size: 4cqw 4cqw; }

/* ---------- polvo en la luz de la lámpara ---------- */
.polvo { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.polvo .mota { position: absolute; width: 4px; height: 4px; border-radius: 50%; opacity: 0.4;
  background: radial-gradient(circle, rgba(255, 228, 170, 0.95), rgba(255, 200, 120, 0) 70%); filter: blur(0.4px); }
.libro > :not(.polvo) { position: relative; z-index: 1; }

/* ---------- cabecera ---------- */
.cabecera { text-align: center; perspective: 600px; }
.cabecera h1 { margin: 0; font: 700 clamp(38px, 7vw, 62px)/1 "Amatic SC", serif; letter-spacing: 0.06em; color: #f6d39a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7), 0 0 26px rgba(255, 190, 90, 0.25); }
.cabecera .letra { display: inline-block; transform-origin: 50% 100%; }
.cabecera p { margin: 6px 0 0; font: 400 clamp(18px, 3vw, 24px) "Amatic SC", serif; color: rgba(241, 207, 152, 0.8); }
.libro-aviso { font: 500 26px "Caveat", cursive; color: #f1cf98; margin-top: 18vh; }

/* ---------- estante en carrusel 3D ---------- */
.estante { width: 100%; display: flex; flex-direction: column; align-items: center; outline: none; touch-action: pan-y; cursor: grab;
  overflow-x: clip; overflow-y: visible; padding-top: 28px; }
.estante:active { cursor: grabbing; }
.estante-escena { position: relative; width: 100%; height: min(64vh, 640px); perspective: 1400px; transform-style: preserve-3d; }
.tomo { position: absolute; left: 50%; top: 50%; width: min(60vw, 400px, 44vh); aspect-ratio: 320 / 420; margin-left: calc(min(60vw, 400px, 44vh) / -2);
  margin-top: calc(min(60vw, 400px, 44vh) * -0.656); transform-style: preserve-3d; will-change: transform; }
.tomo-flota { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.tomo-tapa, .tomo-paginas, .tomo-luz, .tomo-sombra { position: absolute; inset: 0; }
.tomo-tapa { transform-origin: 4% 50%; backface-visibility: hidden; z-index: 2; }
.tomo-tapa svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55)); }
.tomo-paginas { inset: 4% 4% 4% 6%; border-radius: 4px; background: #f2e1c0 url("marco.jpg") center / 100% 100%; box-shadow: inset 12px 0 18px -10px rgba(60, 35, 15, 0.6); }
.tomo-luz { inset: -16%; z-index: -1; border-radius: 34%; opacity: 0.55;
  background: radial-gradient(closest-side, var(--luz), transparent 72%); filter: blur(14px); }
.tomo-sombra { inset: auto 10% -9% 10%; height: 9%; border-radius: 50%; z-index: -2; background: rgba(0, 0, 0, 0.55); filter: blur(10px); }
/* Registros de Fate: energía amarilla que late; Empira: estrellas que titilan */
.tomo-fate .tomo-luz { opacity: 0.9; animation: energia 2.6s ease-in-out infinite; }
.tomo-fate .tomo-tapa svg { filter: drop-shadow(0 0 10px rgba(255, 208, 90, 0.8)) drop-shadow(0 0 24px rgba(255, 170, 40, 0.45)) drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55)); }
.tomo-empira .tomo-flota::before, .tomo-empira .tomo-flota::after { content: ""; position: absolute; inset: -20%; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 8% 20%, #fff, transparent), radial-gradient(1.5px 1.5px at 92% 12%, #dfe6ff, transparent),
    radial-gradient(2px 2px at 96% 58%, #fff, transparent), radial-gradient(1.5px 1.5px at 4% 70%, #cfd8ff, transparent),
    radial-gradient(2.5px 2.5px at 50% 2%, #fff, transparent), radial-gradient(1.5px 1.5px at 22% 96%, #dfe6ff, transparent),
    radial-gradient(2px 2px at 78% 98%, #fff, transparent), radial-gradient(1.5px 1.5px at 0% 40%, #fff, transparent);
  animation: titila 3.2s ease-in-out infinite; }
.tomo-empira .tomo-flota::after { transform: rotate(180deg); animation-delay: 1.6s; }
@keyframes energia { 0%, 100% { opacity: 0.6; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes titila { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.estante-pie { display: flex; align-items: center; gap: 18px; margin-top: 4px; color: #f1cf98; text-align: center; }
.estante-titulo { min-width: min(64vw, 360px); display: flex; flex-direction: column; animation: aparece 0.45s ease both; }
.estante-titulo b { font: 700 clamp(30px, 5vw, 40px)/1 "Amatic SC", serif; letter-spacing: 0.05em; }
.estante-titulo span { font: 500 clamp(18px, 2.6vw, 22px) "Caveat", cursive; color: rgba(241, 207, 152, 0.9); }
.estante-titulo small { font: 400 17px "Amatic SC", serif; opacity: 0.7; margin-top: 2px; }
@keyframes aparece { from { opacity: 0; transform: translateY(8px); } }
.estante-flecha { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 1px solid rgba(215, 154, 78, 0.55); background: rgba(40, 22, 12, 0.7);
  color: #f1cf98; font: 700 30px/1 "Amatic SC", serif; transition: transform 0.2s, background 0.2s; }
.estante-flecha:hover:not(:disabled) { transform: scale(1.08); background: rgba(90, 50, 25, 0.85); }
.estante-flecha:disabled { opacity: 0.3; cursor: default; }
.estante-puntos { display: flex; gap: 10px; margin-top: 12px; }
.estante-puntos button { width: 10px; height: 10px; padding: 0; border-radius: 50%; border: 1px solid #f1cf98; background: transparent; transition: background 0.3s, transform 0.3s; }
.estante-puntos button.on { background: #f1cf98; transform: scale(1.25); }

/* ---------- libro abierto (React) ---------- */
.libro-vista { display: flex; flex-direction: column; align-items: center; gap: 14px; outline: none; perspective: 2600px; }
.libro-vuelta { position: absolute; top: 0; bottom: 0; width: 50%; left: 50%; transform-origin: left center; transform-style: preserve-3d; z-index: 5; pointer-events: none; }
.libro-abierto.una .libro-vuelta { width: 100%; left: 0; }
.libro-vuelta > .cara { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; }
.libro-vuelta > .cara > .libro-hoja { flex: 1; }
.libro-vuelta > .cara.atras { transform: rotateY(180deg); }
.sombra-giro { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: linear-gradient(90deg, rgba(60, 35, 15, 0.55), transparent 45%); }
.cara.atras .sombra-giro { background: linear-gradient(270deg, rgba(60, 35, 15, 0.55), transparent 45%); }
.dibujo.cargando, .figura.cargando { min-height: 40%; background: repeating-linear-gradient(45deg, rgba(58, 48, 41, 0.06) 0 8px, transparent 8px 16px); }
@media (prefers-reduced-motion: reduce) { .tomo-fate .tomo-luz, .tomo-empira .tomo-flota::before, .tomo-empira .tomo-flota::after, .estante-titulo { animation: none; } }

@media (max-width: 640px) { .tomo { width: min(58vw, 240px); margin-left: calc(min(58vw, 240px) / -2); margin-top: calc(min(58vw, 240px) * -0.656); } .estante-pie { gap: 8px; } }
.estante-autor { font: 500 clamp(17px, 2.4vw, 21px) "IM Fell English", serif; font-style: italic; color: rgba(241, 207, 152, 0.75); margin: 2px 0 4px; }
.hoja-cont .capitulo.autor { margin-top: 0.2em; }

/* ---------- vitrina: la figura en su pedestal con los controles del libro ---------- */
.vitrina { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.6em; }
.vitrina .figura { flex: 1; min-height: 0; }
.vitrina-placa { text-align: center; font: 500 3.2cqw/1.15 "Caveat", cursive; color: var(--grafito); min-height: 2.4em; }
.vitrina-placa b { display: block; font: 700 3.6cqw/1.1 "Amatic SC", serif; letter-spacing: 0.03em; }
.vitrina-placa span { color: var(--lapiz-rojo); }
.vitrina-botones { display: flex; justify-content: center; gap: 1.2cqw; flex-wrap: wrap; }
.vitrina-botones button { border: 1.5px solid rgba(58, 48, 41, 0.55); background: rgba(255, 248, 230, 0.6); border-radius: 999px;
  padding: 0.25em 0.9em; font: 700 3.3cqw "Amatic SC", serif; color: var(--grafito); cursor: pointer; transition: background 0.2s, transform 0.2s; }
.vitrina-botones button:hover:not(:disabled) { background: rgba(255, 236, 200, 0.95); transform: translateY(-1px); }
.vitrina-botones button:disabled { opacity: 0.35; cursor: default; }
.hoja-cont .texto.lista { columns: 3; column-gap: 5%; }
.hoja-cont .texto.lista { line-height: 1.35; }

/* hoja grande: si no cabe, se baja con la rueda o el dedo; los controles se quedan a la mano */
.libro-vista .libro-controles { position: sticky; bottom: 10px; z-index: 6; padding: 8px 12px; border-radius: 999px;
  background: rgba(26, 14, 8, 0.82); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); }
@media (max-width: 520px) {
  .libro-vista .libro-controles { gap: 6px; padding: 6px 8px; }
  .libro-controles button { min-width: 40px; padding: 0 10px; font-size: 20px; }
  .libro-controles .txt { display: none; }
}

/* post-it con la info de la pieza: papel amarillo, cinta arriba, letra a mano */
.vitrina { position: relative; }
.postit { position: absolute; top: 2%; right: -2%; z-index: 4; width: 38%; min-width: 120px; padding: 1.6em 0.9em 0.9em;
  background: linear-gradient(170deg, #fff6a8, #f7e470 70%, #efd65a); color: #3a2f12; transform: rotate(3deg);
  box-shadow: 2px 6px 12px rgba(40, 25, 5, 0.35), inset 0 -10px 18px -12px rgba(120, 90, 10, 0.35);
  font: 500 3.1cqw/1.15 "Caveat", cursive; animation: pegar 0.35s cubic-bezier(.2, 1.4, .4, 1) both; pointer-events: none; }
.postit::before { content: ""; position: absolute; top: -0.7em; left: 50%; width: 42%; height: 1.4em; transform: translateX(-50%) rotate(-4deg);
  background: rgba(255, 255, 255, 0.55); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); }
.postit b { display: block; font: 700 3.6cqw/1.05 "Caveat", cursive; margin-bottom: 0.25em; color: #2a2208; }
.postit span { display: block; }
@keyframes pegar { from { opacity: 0; transform: rotate(9deg) scale(0.85) translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { .postit { animation: none; } }

/* brillo propio de cada libro también en el estante (no sólo al abrir): Empira azul, Bocetos rojo */
.tomo-empira .tomo-luz, .tomo-bocetos .tomo-luz { opacity: 0.85; animation: energia 3.4s ease-in-out infinite; }
.tomo-bocetos .tomo-luz { animation-duration: 3s; animation-delay: 0.8s; }
.tomo-empira .tomo-tapa svg { filter: drop-shadow(0 0 10px rgba(140, 165, 255, 0.75)) drop-shadow(0 0 26px rgba(110, 130, 255, 0.45)) drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55)); }
.tomo-bocetos .tomo-tapa svg { filter: drop-shadow(0 0 10px rgba(255, 110, 90, 0.7)) drop-shadow(0 0 24px rgba(255, 80, 60, 0.4)) drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55)); }
@media (prefers-reduced-motion: reduce) { .tomo-empira .tomo-luz, .tomo-bocetos .tomo-luz { animation: none; } }
/* los libros de los lados quedan detrás del plano de la escena en 3D: la escena no debe tragarse el toque */
.estante-escena { pointer-events: none; }
.tomo { pointer-events: auto; cursor: pointer; }
