/* =====================================================================
 * Dhyani Aksharshala (DASMS) — 3D Realistic Open-Book Reader Stylesheet
 * ===================================================================== */

.br-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(9, 13, 22, 0.94);
  flex-direction: column;
}
.br-modal-overlay.is-open {
  display: flex;
}
.br-modal-overlay .br-root {
  height: 100%;
  min-height: 0;
  border-radius: 0;
}
.br-modal-overlay .br-stage {
  min-height: 0;
}

.br-root {
  --br-accent: #C84B31;
  --br-zoom: 1;
  --br-page-ratio: 0.707;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 35%, #263143 0%, #141B29 68%, #090D16 100%);
  color: #F8FAFC;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  min-height: 620px;
  position: relative;
  user-select: none;
}

.br-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.1rem;
  background: rgba(15, 23, 42, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 40;
}
.br-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex-wrap: wrap;
}
.br-part-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--br-accent);
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.br-book-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: #FFFFFF;
  font-family: var(--font-serif, Georgia, serif);
}
.br-page-pill {
  font-size: 0.82rem;
  color: #FDE68A;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.28);
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}

.br-controls-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.br-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.1);
  color: #F8FAFC;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.br-tool-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}
.br-tool-btn.is-active {
  background: var(--br-accent);
  border-color: var(--br-accent);
  color: #FFFFFF;
}
.br-tool-btn.is-close {
  background: #DC2626;
  border-color: #EF4444;
}
.br-tool-btn.is-close:hover {
  background: #B91C1C;
}

.br-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1.5rem 3.5rem;
  min-height: 460px;
}

.br-loading-banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  background: rgba(15, 23, 42, 0.92);
  color: #FDE68A;
  border: 1px solid rgba(253, 230, 138, 0.35);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  display: none;
}
.br-loading-banner.is-visible {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.br-zoom-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto;
  transition: width 0.18s ease, height 0.18s ease;
}

.br-book {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 2400px;
  transition: transform 0.52s cubic-bezier(0.22, 1, 0.36, 1);
}
.br-book.is-dual.is-at-cover {
  transform: translateX(-25%);
}
.br-book.is-dual.is-at-back {
  transform: translateX(25%);
}

.br-spread {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  transform-style: preserve-3d;
}

.br-slot {
  position: relative;
  width: 50%;
  height: 100%;
  background: #FFFDF8;
  overflow: hidden;
  border: 1px solid #DFD5C5;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.48);
  cursor: pointer;
}
.br-book.is-single .br-slot-left {
  display: none;
}
.br-book.is-single .br-slot-right {
  width: 100%;
  border-radius: 6px 12px 12px 6px;
}

.br-slot-left {
  border-radius: 10px 0 0 10px;
  border-right: 1px solid #D3C7B6;
  box-shadow:
    -6px 0 0 -1px #EDE4D5,
    -11px 0 0 -2px #DDD1BE,
    -16px 0 0 -3px var(--br-accent),
    0 24px 55px rgba(0, 0, 0, 0.48);
}
.br-slot-right {
  border-radius: 0 10px 10px 0;
  border-left: 1px solid #D3C7B6;
  box-shadow:
    6px 0 0 -1px #EDE4D5,
    11px 0 0 -2px #DDD1BE,
    16px 0 0 -3px var(--br-accent),
    0 24px 55px rgba(0, 0, 0, 0.48);
}
.br-slot.is-void {
  opacity: 0;
  pointer-events: none;
  box-shadow: none;
  border-color: transparent;
  background: transparent;
}

/* Center realistic spine fold gradient */
.br-book.is-dual:not(.is-at-cover):not(.is-at-back) .br-spread::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 38px;
  transform: translateX(-50%);
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0) 0%,
    rgba(15, 23, 42, 0.12) 38%,
    rgba(15, 23, 42, 0.28) 50%,
    rgba(15, 23, 42, 0.12) 62%,
    rgba(0, 0, 0, 0) 100%
  );
  pointer-events: none;
  z-index: 25;
}

.br-page-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, #FFFDF9 0%, #FAF5EB 100%);
  color: #1F1A17;
  overflow: hidden;
}
.br-page-inner img,
.br-page-inner canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.br-page-footer {
  position: absolute;
  bottom: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748B;
  background: rgba(255, 253, 248, 0.88);
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  pointer-events: none;
}
.br-slot-left .br-page-footer {
  left: 12px;
}
.br-slot-right .br-page-footer {
  right: 12px;
}

.br-turn-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.72);
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.br-slot-left .br-turn-hint {
  left: 10px;
}
.br-slot-right .br-turn-hint {
  right: 10px;
}
.br-slot:not(.is-void):hover .br-turn-hint {
  opacity: 1;
}

/* 3D Flipping Leaf Overlay */
.br-flip-leaf {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 35;
  display: none;
}
.br-book.is-single .br-flip-leaf {
  left: 0;
  width: 100%;
  transform-origin: left center;
}
.br-flip-leaf.is-visible {
  display: block;
}
.br-flip-leaf.is-animating {
  transition: transform 0.56s cubic-bezier(0.645, 0.045, 0.355, 1);
}
.br-leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #FFFDF8;
  border: 1px solid #DFD5C5;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}
.br-leaf-front {
  transform: rotateY(0deg);
  border-radius: 0 10px 10px 0;
}
.br-leaf-back {
  transform: rotateY(180deg);
  border-radius: 10px 0 0 10px;
}

/* Hardcover & Virtual Inside / Back Pages */
.br-cover-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0%, rgba(255, 255, 255, 0.08) 4%, rgba(0, 0, 0, 0) 10%),
    linear-gradient(150deg, #FFFBF2 0%, #F5EBDD 100%);
  border-left: 8px solid var(--br-accent);
  text-align: center;
  box-sizing: border-box;
}
.br-cover-art {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
}
.br-cover-art img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(31, 26, 23, 0.18);
}
.br-cover-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.35rem;
  border-radius: 999px;
  background: var(--br-accent);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.96rem;
  box-shadow: 0 10px 22px rgba(200, 75, 49, 0.35);
  margin: 0.5rem auto 0;
}

.br-inside-card {
  width: 100%;
  height: 100%;
  padding: 1.5rem 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 29px,
      rgba(100, 181, 246, 0.16) 29px,
      rgba(100, 181, 246, 0.16) 30px
    ),
    #FFFDF8;
  overflow-y: auto;
  text-align: left;
  box-sizing: border-box;
}
.br-inside-toc {
  list-style: none;
  padding: 0;
  margin: 0.65rem 0 0;
  display: grid;
  gap: 0.35rem;
}
.br-inside-toc-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.38rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #E2D8C8;
  background: rgba(255, 255, 255, 0.85);
  color: #1F1A17;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.br-inside-toc-btn:hover {
  border-color: var(--br-accent);
  background: #FEF3C7;
}

.br-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 1.75rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 38;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.br-nav-arrow:hover:not(:disabled) {
  background: var(--br-accent);
}
.br-nav-arrow:disabled {
  opacity: 0.25;
  cursor: default;
}
.br-nav-arrow.is-prev {
  left: 0.85rem;
}
.br-nav-arrow.is-next {
  right: 0.85rem;
}

.br-bottombar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.1rem;
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.br-slider {
  flex: 1;
  min-width: 140px;
  max-width: 340px;
  accent-color: #F59E0B;
  cursor: pointer;
}

.br-thumb-drawer {
  display: none;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  background: #0F172A;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  overflow-x: auto;
}
.br-thumb-drawer.is-open {
  display: flex;
}
.br-thumb-item {
  flex: 0 0 auto;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #E2E8F0;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.br-thumb-item.is-current {
  background: var(--br-accent);
  border-color: var(--br-accent);
  color: #FFFFFF;
}

/* Admin Upload Modal & Table Enhancements */
.bu-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.68);
  z-index: 9985;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.bu-modal-overlay.is-open {
  display: flex;
}
.bu-dropzone {
  border: 2px dashed #CBD5E1;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: #F8FAFC;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.bu-dropzone:hover {
  border-color: #C84B31;
  background: #FFF7ED;
}
.bu-file-meta {
  font-size: 0.78rem;
  color: #0F766E;
  font-weight: 600;
  margin-top: 0.3rem;
}

@media (max-width: 768px) {
  .br-stage {
    padding: 0.9rem 0.75rem;
    min-height: 410px;
  }
  .br-nav-arrow {
    width: 36px;
    height: 46px;
    font-size: 1.35rem;
  }
  .br-nav-arrow.is-prev {
    left: 0.25rem;
  }
  .br-nav-arrow.is-next {
    right: 0.25rem;
  }
}
