/* DESPECTA DIGITAL MAGAZINE FLIPBOOK STYLING */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;800&family=Montserrat:wght@300;400;500;600;700&family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0a1114;
  --bg-surface: #101c22;
  --bg-toolbar: rgba(14, 25, 31, 0.92);
  --gold: #d8b879;
  --gold-glow: rgba(216, 184, 121, 0.35);
  --gold-hover: #edd5a4;
  --text-primary: #f2f4ee;
  --text-muted: #95a3a8;
  --border-light: rgba(255, 255, 255, 0.12);
  --border-gold: rgba(216, 184, 121, 0.35);
  --shadow-deep: 0 25px 65px rgba(0, 0, 0, 0.75);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #15242b 0%, #080e11 100%);
  color: var(--text-primary);
  font-family: 'Vazirmatn', 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  user-select: none;
  display: flex;
  flex-direction: column;
}

/* TOP TOOLBAR */
.flip-header {
  height: 56px;
  background: var(--bg-toolbar);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  z-index: 100;
  flex-shrink: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}
.brand-logo-img {
  height: 34px;
  width: auto;
}
.brand-titles {
  display: flex;
  flex-direction: column;
}
.brand-titles .brand-name {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  line-height: 1.1;
}
.brand-titles .brand-sub {
  font-size: 8px;
  letter-spacing: 1.5px;
  color: var(--gold);
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  height: 34px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}
.tool-btn:hover {
  background: rgba(216, 184, 121, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}
.tool-btn.active {
  background: var(--gold);
  color: #0d171b;
  border-color: var(--gold);
  font-weight: 600;
}
.tool-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex-shrink: 0;
}
.tool-btn.highlight {
  background: var(--gold);
  color: #0e171b;
  border-color: var(--gold);
  font-weight: 700;
}
.tool-btn.highlight:hover {
  background: var(--gold-hover);
  color: #0e171b;
}

/* FLIPBOOK WORKSPACE */
.flipbook-workspace {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px 40px;
}

/* Book Stage & Center Alignment */
.book-stage {
  position: relative;
  width: 90vw;
  max-width: 1140px;
  height: calc(100vh - 135px);
  max-height: 760px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-deep);
  transition: transform 0.25s ease;
}

/* St.PageFlip container */
#flipbook {
  position: relative;
  width: 100%;
  height: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  border-radius: 2px;
  background: transparent;
}

/* Spine Shadow (Gutter Depth Simulation) */
.stf__parent {
  position: relative;
}
.stf__parent::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 40px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0.38) 50%, rgba(0,0,0,0.18) 100%);
  z-index: 15;
  pointer-events: none;
}

/* Side Next / Prev Floating Arrow Controls */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(16, 28, 34, 0.85);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  transition: all 0.25s ease;
  backdrop-filter: blur(8px);
}
.nav-arrow:hover {
  background: var(--gold);
  color: #0e171b;
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 0 20px var(--gold-glow);
}
.nav-arrow.prev {
  left: 18px;
}
.nav-arrow.next {
  right: 18px;
}
.nav-arrow svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* BOTTOM CONTROL BAR */
.flip-footer {
  height: 60px;
  background: var(--bg-toolbar);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  flex-shrink: 0;
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}
.footer-right {
  justify-content: flex-end;
}

.footer-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-indicator {
  font-size: 12px;
  font-weight: 500;
  color: #e2e8e5;
  font-family: 'Vazirmatn', 'Cinzel', sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
}
.page-indicator span {
  color: var(--gold);
  font-weight: 700;
}

.page-slider {
  width: 140px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* THUMBNAILS DRAWER */
.thumbs-drawer {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  height: 135px;
  background: rgba(11, 19, 23, 0.96);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-gold);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  overflow-x: auto;
  transform: translateY(115%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.6);
}
.thumbs-drawer.open {
  transform: translateY(0);
}
.thumb-item {
  flex-shrink: 0;
  width: 82px;
  height: 100px;
  border-radius: 3px;
  border: 1px solid var(--border-light);
  background: #17262e;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
}
.thumb-item:hover, .thumb-item.active {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 6px 15px var(--gold-glow);
}
.thumb-item.active {
  border-width: 2px;
}
.thumb-preview-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #091216;
}
.thumb-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-caption {
  font-size: 8.5px;
  text-align: center;
  padding: 3px 0;
  background: #111e24;
  color: #fff;
  font-family: 'Cinzel', 'Vazirmatn', serif;
}

/* TABLE OF CONTENTS MODAL FLYOUT */
.toc-flyout {
  position: absolute;
  top: 56px;
  right: 0;
  width: 380px;
  max-width: 90vw;
  bottom: 60px;
  background: rgba(14, 25, 31, 0.97);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-gold);
  z-index: 95;
  transform: translateX(105%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -15px 0 40px rgba(0,0,0,0.7);
}
.toc-flyout.open {
  transform: translateX(0);
}
.toc-flyout-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toc-flyout-head h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  font-family: 'Cinzel', 'Vazirmatn', serif;
}
.toc-close-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
}
.toc-close-btn:hover {
  color: #fff;
}
.toc-flyout-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}
.toc-flyout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 4px;
  margin-bottom: 3px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.toc-flyout-item:hover {
  background: rgba(216, 184, 121, 0.12);
}
.toc-flyout-item .left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toc-flyout-item .p-num {
  font-family: 'Cinzel', serif;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold);
}
.toc-flyout-item .p-title {
  font-size: 11.5px;
  font-weight: 500;
  color: #fff;
}
.toc-flyout-item .p-sub {
  font-size: 8.5px;
  color: var(--text-muted);
  display: block;
}

/* SOUND WAVE ANIMATION */
.sound-anim {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 12px;
}
.sound-anim span {
  width: 2px;
  background: currentColor;
  border-radius: 1px;
  animation: soundBounce 1s infinite ease-in-out;
}
.sound-anim span:nth-child(1) { height: 4px; animation-delay: 0.1s; }
.sound-anim span:nth-child(2) { height: 10px; animation-delay: 0.3s; }
.sound-anim span:nth-child(3) { height: 6px; animation-delay: 0.2s; }
.sound-anim.muted span {
  animation: none;
  height: 2px;
  background: var(--text-muted);
}
@keyframes soundBounce {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

/* HELP / SHARE MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}
.modal-dialog {
  background: #111e24;
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 26px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.85);
  position: relative;
  text-align: right;
  direction: rtl;
}
.modal-dialog h3 {
  font-size: 17px;
  color: var(--gold);
  margin-bottom: 12px;
  font-family: 'Cinzel', 'Vazirmatn', serif;
}
.modal-dialog p {
  font-size: 12.5px;
  line-height: 1.7;
  color: #cad6d4;
  margin-bottom: 14px;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 11.5px;
}
.kbd-key {
  background: #1a2c34;
  border: 1px solid var(--border-light);
  padding: 2px 7px;
  border-radius: 3px;
  font-family: monospace;
  color: var(--gold);
  direction: ltr;
}

/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
  .brand-titles .brand-sub { display: none; }
  .tool-btn span { display: none; }
  .tool-btn { padding: 0 9px; }
  .page-slider { width: 90px; }
  .nav-arrow { width: 38px; height: 38px; }
  .nav-arrow.prev { left: 8px; }
  .nav-arrow.next { right: 8px; }
}

@media (max-width: 600px) {
  .flip-header { padding: 0 10px; }
  .flip-footer { padding: 0 10px; }
  .footer-left { min-width: 0; }
  .footer-right { min-width: 0; }
  .page-slider { display: none; }
  .flipbook-workspace { padding: 5px; }
}
