/* ==========================================================================
   ELEGANZ — REVISTA DIGITAL
   Paleta y tipografías tomadas del portafolio impreso.
   ========================================================================== */

:root {
  --ink: #0a0a0a;
  --ink-soft: #1c1c1c;
  --cream: #faf9f5;
  --gold: #b8791d;
  --gold-bright: #f6a930;
  --muted: rgba(250, 249, 245, .55);
  --page-ratio: 1.4151; /* A4: 842 / 595 */
  --flip-speed: .85s;
  --ui: 'Montserrat', 'Open Sans', Arial, sans-serif;
  --display: 'Playfair Display', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--ui);
  overscroll-behavior: none;
}

/* Texto solo para lectores de pantalla y buscadores (NO display:none) */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Estructura ---------- */

.viewer {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background:
    radial-gradient(1200px 800px at 50% 45%, #171614 0%, var(--ink) 70%);
}

/* ---------- Barra superior ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(184, 121, 29, .18);
  background: rgba(10, 10, 10, .6);
  backdrop-filter: blur(6px);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--cream);
  margin-right: auto;
  min-width: 0;
}

.brand img { height: 34px; width: auto; display: block; }

.brand span {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: .12em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tools { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(184, 121, 29, .35);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: rgba(184, 121, 29, .16); border-color: var(--gold); }
.btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.btn.icon { width: 38px; padding: 0; }
.btn.is-off { color: var(--muted); border-color: rgba(250, 249, 245, .14); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn .label { display: inline; }

/* ---------- Escenario del libro ---------- */

.stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 22px 68px;
  min-height: 0;
  overflow: hidden;
}

/* El lienzo mide dos páginas de ancho y se centra a mano: al ser más ancho
   que el escenario, la alineación de grid lo pegaría a la izquierda.
   Con el libro cerrado se recorre media página para centrar la portada. */
.paper-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform .5s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, .55));
}

#paper {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

#paper:active { cursor: grabbing; }

/* Mientras la hoja gira se apaga la sombra: recalcularla en cada cuadro
   cuesta caro en celulares. */
.paper-wrap.flipping { filter: none; }

/* ---------- Flechas laterales ---------- */

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(184, 121, 29, .35);
  background: rgba(10, 10, 10, .55);
  color: var(--cream);
  cursor: pointer;
  z-index: 30;
  transition: background .2s, opacity .2s;
}

.nav-arrow:hover { background: rgba(184, 121, 29, .3); }
.nav-arrow[disabled] { opacity: .22; cursor: default; }
.nav-arrow.left { left: 12px; }
.nav-arrow.right { right: 12px; }
.nav-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Barra inferior ---------- */

.bottombar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 18px 14px;
  z-index: 30;
}

.counter {
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 78px;
  text-align: center;
}

.counter b { color: var(--gold-bright); font-weight: 600; }

.progress {
  flex: 0 1 320px;
  height: 3px;
  border-radius: 3px;
  background: rgba(250, 249, 245, .13);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transition: width .4s ease;
}

/* ---------- Miniaturas ---------- */

.thumbs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 42vh;
  padding: 16px 18px 22px;
  background: rgba(8, 8, 8, .96);
  border-top: 1px solid rgba(184, 121, 29, .25);
  transform: translateY(102%);
  transition: transform .35s cubic-bezier(.22, .61, .36, 1);
  z-index: 60;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
}

.thumbs.open { transform: translateY(0); }

.thumbs button {
  display: inline-block;
  width: 82px;
  margin: 0 6px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  cursor: pointer;
  vertical-align: top;
}

.thumbs button img { display: block; width: 100%; height: auto; border-radius: 2px; }

.thumbs button em {
  display: block;
  margin-top: 5px;
  font-style: normal;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--muted);
}

.thumbs button:hover { border-color: rgba(184, 121, 29, .6); }
.thumbs button[aria-current="true"] { border-color: var(--gold-bright); }
.thumbs button[aria-current="true"] em { color: var(--gold-bright); }

/* ---------- Lightbox / zoom ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, .95);
  display: none;
  place-items: center;
  z-index: 90;
  cursor: zoom-out;
  overflow: hidden;
}

.lightbox.open { display: grid; }

.lightbox img {
  max-width: 94vw;
  max-height: 92dvh;
  transform-origin: center center;
  transition: transform .25s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox.zoomed { cursor: grab; }
.lightbox.zoomed img { transition: none; max-width: none; max-height: none; }

.lightbox .close {
  position: absolute;
  top: 16px; right: 18px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(250, 249, 245, .25);
  background: rgba(0, 0, 0, .5);
  color: var(--cream);
  font-size: 20px;
  cursor: pointer;
}

/* ---------- WhatsApp flotante ---------- */

.wa {
  position: fixed;
  right: 18px;
  bottom: 76px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 15px 0 13px;
  border-radius: 999px;
  background: #25d366;
  color: #04310f;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .45);
  z-index: 70;
  transition: transform .2s;
}

.wa:hover { transform: translateY(-2px); }

/* Con el índice abierto el botón estorba: se oculta */
body.thumbs-open .wa { opacity: 0; transform: translateY(12px); pointer-events: none; }
.wa svg { width: 19px; height: 19px; fill: currentColor; flex: none; }

/* ---------- Cargador ---------- */

.loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ink);
  z-index: 100;
  transition: opacity .5s;
}

.loader.hidden { opacity: 0; pointer-events: none; }
.loader img { width: 190px; max-width: 55vw; opacity: .95; }

.loader .bar {
  position: absolute;
  bottom: 38%;
  width: 190px;
  max-width: 55vw;
  height: 2px;
  background: rgba(250, 249, 245, .12);
  overflow: hidden;
}

.loader .bar i {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--gold-bright);
  animation: sweep 1.1s infinite ease-in-out;
}

@keyframes sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---------- Vista móvil ---------- */


@media (max-width: 900px), (orientation: portrait) and (max-width: 1100px) {
  .stage { padding: 14px 10px; }
  .nav-arrow { width: 38px; height: 38px; background: rgba(10, 10, 10, .72); }
  .nav-arrow.left { left: 4px; }
  .nav-arrow.right { right: 4px; }
  .nav-arrow svg { width: 17px; height: 17px; }
  .btn .label { display: none; }
  .btn { padding: 0 12px; }
  .brand span { display: none; }
  /* En celular la pastilla tapa la página: se queda solo el icono */
  .wa { bottom: 58px; right: 12px; width: 44px; height: 44px; padding: 0; justify-content: center; }
  .wa .wa-txt { display: none; }
  .thumbs { max-height: 34vh; }
}
