/* Estilos del marco del libro 3D (embedible en otras páginas). */
.book-frame,
.book-open-btn {
  --book-ink: #f2f2ef;
  --book-muted: #9a9a94;
  --book-frame-bg: rgba(15, 15, 15, 0.5);
  --book-frame-line: rgba(255, 255, 255, 0.16);
  --book-handle-bg: #1b1b1b;
}

.book-dock {
  width: 100%;
  margin: 0 0 1.05rem;
}

.book-frame {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(720px, 92vw);
  height: min(820px, 88svh);
  min-width: 180px;
  min-height: 220px;
  overflow: visible;
  background: var(--book-frame-bg);
  border: 1px solid var(--book-frame-line);
  border-radius: 10px;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  color: var(--book-ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.book-frame.is-docked {
  position: relative;
  left: auto;
  top: auto;
  z-index: 4;
  width: 100%;
  height: clamp(220px, 36vh, 340px);
  min-width: 0;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.book-frame.is-floating {
  position: fixed;
  z-index: 60;
}

.book-frame.is-moving,
.book-frame.is-resizing {
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  user-select: none;
}

.book-frame.is-closed {
  display: none;
}

.book-frame__handle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
  padding: 0.45rem 0.55rem 0.45rem 0.85rem;
  background: var(--book-handle-bg);
  border-bottom: 1px solid var(--book-frame-line);
  border-radius: 10px 10px 0 0;
  cursor: grab;
  touch-action: none;
}

.book-frame.is-moving .book-frame__handle {
  cursor: grabbing;
}

.book-frame__grip {
  width: 14px;
  height: 10px;
  flex: 0 0 auto;
  background:
    linear-gradient(var(--book-muted), var(--book-muted)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--book-muted), var(--book-muted)) 0 4px / 100% 2px no-repeat,
    linear-gradient(var(--book-muted), var(--book-muted)) 0 8px / 100% 2px no-repeat;
  opacity: 0.7;
}

.book-frame__title {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--book-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-frame__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--book-ink);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.book-frame__close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

.book-frame__close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
}

.book-open-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0.7rem 0.92rem;
  border: 1px solid var(--book-frame-line);
  border-radius: 0;
  background: var(--book-frame-bg);
  color: var(--book-ink);
  box-shadow: none;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
}

.book-dock .book-open-btn {
  position: relative;
  left: auto;
  top: auto;
  display: block;
  width: 100%;
  transform: none;
  margin: 0;
  text-align: center;
}

.book-open-btn[hidden] {
  display: none !important;
}

.book-open-btn:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
}

.book-open-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: 3px;
}

.book-stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 0 0 10px 10px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.book-stage:active,
.book-stage.is-dragging { cursor: grabbing; }

.book-frame__resizers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.book-frame__resize {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
}

.book-frame__resize--n,
.book-frame__resize--s {
  left: 12px;
  right: 12px;
  height: 10px;
}

.book-frame__resize--e,
.book-frame__resize--w {
  top: 12px;
  bottom: 12px;
  width: 10px;
}

.book-frame__resize--n { top: -5px; cursor: ns-resize; }
.book-frame__resize--s { bottom: -5px; cursor: ns-resize; }
.book-frame__resize--e { right: -5px; cursor: ew-resize; }
.book-frame__resize--w { left: -5px; cursor: ew-resize; }

.book-frame__resize--ne,
.book-frame__resize--nw,
.book-frame__resize--se,
.book-frame__resize--sw {
  width: 16px;
  height: 16px;
}

.book-frame__resize--ne { top: -6px; right: -6px; cursor: nesw-resize; }
.book-frame__resize--nw { top: -6px; left: -6px; cursor: nwse-resize; }
.book-frame__resize--se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.book-frame__resize--sw { bottom: -6px; left: -6px; cursor: nesw-resize; }

.book-frame__resize--se::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--book-muted);
  border-bottom: 2px solid var(--book-muted);
  opacity: 0.75;
}

#book-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  opacity: 0;
  transition: opacity .6s ease;
}

.book-ready #book-canvas { opacity: 1; }

.book-frame .loader {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: .65rem .85rem;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(20,20,20,.72);
  color: var(--book-ink);
  backdrop-filter: blur(8px);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: opacity .3s ease;
}

.book-ready .loader { opacity: 0; pointer-events: none; }

.book-frame .hint {
  position: absolute;
  right: clamp(8px, 2vw, 16px);
  bottom: clamp(8px, 2vw, 16px);
  margin: 0;
  color: var(--book-muted);
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  pointer-events: none;
}

.book-frame .error-message {
  position: absolute;
  inset: 50% 8% auto;
  transform: translateY(-50%);
  margin: 0;
  padding: 1rem;
  color: var(--book-ink);
  background: rgba(20,20,20,.9);
  border: 1px solid rgba(255,255,255,.16);
  text-align: center;
  line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  .book-frame .hint { display: none; }
}

@media (max-width: 780px) {
  .book-frame.is-docked {
    height: clamp(200px, 42vh, 300px);
  }
}
