/* ── DICE Design System · Flipbook Viewer ── */

/* Container */
#dice-viewer {
  margin-top: clamp(40px,5vw,64px);
}

.app {
  background: #232f44;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  min-height: 560px;
  position: relative;
  user-select: none;
  width: 100%;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(13,22,36,.9);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  flex-wrap: wrap;
  position: relative;
  z-index: 12;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--terracotta, #d86034);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fira Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Fira Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .22em;
  color: rgba(255,245,225,.5);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255,245,225,.6);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  padding: 0;
  text-decoration: none;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover {
  background: rgba(255,255,255,.1);
  color: #fff5e1;
}

.icon-button:focus-visible {
  outline: 2px solid #3f97a6;
  outline-offset: 1px;
}

.icon-button.active {
  background: rgba(216,96,52,.2);
  color: #d98e63;
}

.page-counter {
  font-family: 'Fira Sans', sans-serif;
  font-size: 11px;
  color: rgba(255,245,225,.5);
  padding: 0 8px;
  min-width: 52px;
  text-align: center;
  white-space: nowrap;
}

.zoom-value {
  font-family: 'Fira Sans', sans-serif;
  font-size: 11px;
  color: rgba(255,245,225,.45);
  padding: 0 4px;
  min-width: 36px;
  text-align: center;
}

/* fullscreen icons toggle */
.fullscreen-exit { display: none; }
.app.is-fullscreen .fullscreen-enter { display: none; }
.app.is-fullscreen .fullscreen-exit  { display: block; }

/* ── Viewer stage ── */
.viewer {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.viewer-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 32px;
  overflow: hidden;
}

.scale-wrapper {
  transform-origin: center center;
  transition: transform .22s ease;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.book-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: min(860px, 90vw);
}

/* ── Desktop book (StPageFlip target) ── */
.desktop-book {
  display: block;
  position: relative;
}

.desktop-book .paper-underlay,
.desktop-book .book-spine,
.desktop-book .page-zone {
  display: none; /* StPageFlip replaces these */
}

/* StPageFlip canvas wrapper */
#fb-book-container {
  display: block;
}

/* ── Mobile book (usado em todos os tamanhos) ── */
.mobile-book {
  display: none; /* sobrescrito via JS para todos os tamanhos */
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
}

.mobile-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 70px rgba(0,0,0,.55);
  background: #0d1a28;
}

.mobile-page {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16/9;
  object-fit: contain;
  transition: opacity .35s ease;
}

.mobile-page.mobile-under {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}

.mobile-page-shadow {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,.15) 0%, transparent 12%, transparent 88%, rgba(0,0,0,.12) 100%);
  pointer-events: none;
}

.page-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

.page-zone.page-zone-left  { left: 0; }
.page-zone.page-zone-right { right: 0; }

/* Mobile swipe hint */
.mobile-swipe-hint {
  font-family: 'Fira Sans', sans-serif;
  font-size: 10px;
  color: rgba(255,245,225,.25);
  letter-spacing: .1em;
  margin-top: 10px;
  text-align: center;
}

/* ── Thumbnails panel ── */
.thumbnails {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 200px;
  background: rgba(10,18,30,.97);
  border-right: 1px solid rgba(255,255,255,.07);
  z-index: 10;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.22,1,.36,1);
}

.thumbnails:not([hidden]) {
  transform: translateX(0);
}

.thumbnails-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.thumbnails-header strong {
  font-family: 'Fira Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255,245,225,.4);
}

.thumbnail-grid {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thumbnail-grid::-webkit-scrollbar { width: 4px; }
.thumbnail-grid::-webkit-scrollbar-track { background: transparent; }
.thumbnail-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.thumb-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background .14s, border-color .14s;
  width: 100%;
  flex-shrink: 0;
}

.thumb-btn:hover { background: rgba(255,255,255,.05); }
.thumb-btn.active {
  background: rgba(216,96,52,.14);
  border-color: rgba(216,96,52,.35);
}
.thumb-btn:focus-visible { outline: 2px solid #3f97a6; outline-offset: 1px; }

.thumb-img {
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  background: #0a1420;
  display: block;
}

.thumb-meta { min-width: 0; flex: 1; }

.thumb-num {
  display: block;
  font-family: 'Fira Sans', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255,245,225,.35);
}

.thumb-name {
  display: block;
  font-family: 'Fira Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,245,225,.72);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Scrim ── */
.scrim {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 9;
  cursor: pointer;
}

/* ── Loading ── */
.loading[style*="display:none"],.loading[hidden]{display:none!important}
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: 'Fira Sans', sans-serif;
  font-size: 13px;
  color: rgba(255,245,225,.5);
  background: #232f44;
  z-index: 20;
  pointer-events: none;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,245,225,.18);
  border-top-color: rgba(216,96,52,.8);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Fullscreen mode ── */
.app.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
  min-height: 100dvh;
}

/* ── Responsive ── */
@media (max-width: 767px) {
  .desktop-book { display: none !important; }
  .mobile-book  { display: flex !important; }
  .viewer-center { padding: 16px 12px 20px; }
  .thumbnails { width: 180px; }
  .toolbar { padding: 8px 10px; gap: 2px; }
  .icon-button { width: 30px; height: 30px; }
  .icon-button svg { width: 16px; height: 16px; }
  .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .scale-wrapper { transition: none; }
  .thumbnails { transition: none; }
  .loading-spinner { animation: none; border-top-color: rgba(216,96,52,.8); }
}
