:root {
  --bg: #0b0b0b;
  --hud: rgba(20, 20, 20, 0.6);
  --hud-fg: #f4f1ea;
  --hud-border: rgba(244, 241, 234, 0.15);
  --accent: rgba(244, 241, 234, 0.9);
  --page-aspect: calc(2 / 3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--hud-fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#reader {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

/* palco mantém a proporção 2:3 e centraliza a página */
#stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}

#page {
  position: relative;
  /* a altura é limitada pelo palco; a largura segue a proporção da página */
  aspect-ratio: 2 / 3;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  /* usa min() para garantir fit em ambas dimensões */
  height: min(100%, calc((100vw - 24px) * 3 / 2));
  width: auto;
  background: #111;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
}

#page-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  background: #0f0f0f;
}

#hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 6px;
  transition: background-color 120ms ease, outline-color 120ms ease;
  outline: 2px solid transparent;
}
.hotspot:hover,
.hotspot:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline-color: rgba(255, 255, 255, 0.35);
}
/* visualização temporária de hotspots (tecla H) */
body.debug-hotspots .hotspot {
  background: rgba(80, 200, 120, 0.22);
  outline-color: rgba(80, 200, 120, 0.8);
}

/* zonas invisíveis laterais para clicar e navegar */
.nav-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 1;
}
.nav-prev { left: 0; cursor: w-resize; }
.nav-next { right: 0; cursor: e-resize; }
.nav-zone:focus { outline: none; }
/* hotspots ficam acima das zonas de navegação */
#hotspots { z-index: 2; }

/* HUD inferior */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0));
  color: var(--hud-fg);
  font-size: 13px;
  letter-spacing: 0.04em;
}

#hud button {
  background: var(--hud);
  color: var(--hud-fg);
  border: 1px solid var(--hud-border);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 120ms ease, transform 120ms ease;
}
#hud button:hover { background: rgba(40, 40, 40, 0.7); }
#hud button:active { transform: scale(0.97); }

#counter {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  background: var(--hud);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--hud-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* barra de progresso no topo */
#progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: rgba(255,255,255,0.08);
  z-index: 10;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 220ms ease;
}

/* transição suave entre páginas */
#page-img.is-loading { opacity: 0.3; }
#page-img { transition: opacity 180ms ease; }

/* mobile: HUD um pouco menor */
@media (max-width: 640px) {
  #hud button, #counter { font-size: 11px; padding: 5px 10px; }
  #stage { padding: 8px; }
}
