/* ==========================================================================
   FlipHTML5 Style Standalone 2-Page Magazine Spread - MD3 Sacred Aesthetics
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800&family=Outfit:wght@300;400;500;600;700&family=Roboto+Serif:ital,opsz,wght@0,8..144,300;0,8..144,400;0,8..144,600;1,8..144,400&display=swap');

:root {
  /* MD3 Sacred Color Tokens */
  --md-sys-color-primary: #f3ca40; /* Sacred Gold */
  --md-sys-color-on-primary: #1e1700;
  --md-sys-color-primary-container: #3d3000;
  --md-sys-color-on-primary-container: #ffe083;

  --md-sys-color-secondary: #00e5ff; /* Cyan Energy */
  --md-sys-color-tertiary: #ff4081; /* Fire Rose */

  --md-sys-color-surface: #0a080d;
  --md-sys-color-surface-container: #14111a;
  --md-sys-color-surface-container-high: #1f1b29;
  --md-sys-color-surface-container-highest: #2b2638;

  --md-sys-color-on-surface: #eae5f0;
  --md-sys-color-on-surface-variant: #cbbfc9;

  /* Typography */
  --md-sys-font-sans: 'Outfit', sans-serif;
  --md-sys-font-serif: 'Roboto Serif', serif;
  --md-sys-font-sacred: 'Cinzel', serif;

  /* Shapes & Elevation */
  --md-sys-shape-corner-m: 16px;
  --md-sys-shape-corner-l: 28px;
  --md-sys-shape-corner-full: 9999px;

  --md-sys-elevation-3: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 20px rgba(243, 202, 64, 0.15);
  --md-sys-elevation-5: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 35px rgba(243, 202, 64, 0.25);
}

.light-theme {
  --md-sys-color-surface: #faf6f0;
  --md-sys-color-surface-container: #f4eae0;
  --md-sys-color-surface-container-high: #e8d7c8;
  --md-sys-color-on-surface: #201a14;
  --md-sys-color-on-surface-variant: #524438;
  --md-sys-color-primary: #945d00;
  --md-sys-color-on-primary: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--md-sys-font-sans);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Ambient Sacred Glow Background */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
}

body::before {
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, var(--md-sys-color-primary) 0%, transparent 70%);
}

body::after {
  bottom: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #7b1fa2 0%, #00e5ff 70%);
}

/* MD3 App Bar Header */
.app-bar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 24px;
  background-color: rgba(20, 17, 26, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(243, 202, 64, 0.15);
  height: 64px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
}

.header-title {
  text-align: center;
  justify-self: center;
}

.header-title h1 {
  font-family: var(--md-sys-font-sacred);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  letter-spacing: 1.5px;
  text-align: center;
}

.header-title .subtitle {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  display: block;
}

.header-actions {
  justify-self: end;
}

.header-title .subtitle {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
}

.icon-button {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.icon-button:hover {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(243, 202, 64, 0.4);
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid rgba(243, 202, 64, 0.2);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 4px 16px;
  width: 240px;
  transition: all 0.3s;
}

.search-box:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 16px rgba(243, 202, 64, 0.3);
  width: 280px;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--md-sys-color-on-surface);
  font-size: 0.85rem;
  width: 100%;
  margin-left: 8px;
}

/* Side Drawer */
.drawer {
  position: fixed;
  top: 0;
  left: -380px;
  width: 380px;
  height: 100%;
  background-color: rgba(20, 17, 26, 0.96);
  backdrop-filter: blur(25px);
  z-index: 1000;
  transition: left 0.35s cubic-bezier(0.05, 0.7, 0.1, 1);
  box-shadow: var(--md-sys-elevation-5);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(243, 202, 64, 0.2);
}

.drawer.open {
  left: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-header h2 {
  font-family: var(--md-sys-font-sacred);
  font-size: 1.1rem;
  color: var(--md-sys-color-primary);
}

.drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.chapter-item {
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-corner-m);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--md-sys-color-on-surface-variant);
  transition: all 0.2s ease;
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.chapter-item:hover, .chapter-item.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: rgba(243, 202, 64, 0.4);
  font-weight: 600;
  transform: translateX(6px);
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 999;
}

.overlay.show {
  display: block;
}

/* Thumbnails Modal (FlipHTML5 Grid View) */
.thumbs-modal {
  display: none;
  position: fixed;
  inset: 64px 0 0 0;
  background: rgba(10, 8, 13, 0.95);
  backdrop-filter: blur(20px);
  z-index: 900;
  padding: 30px;
  overflow-y: auto;
}

.thumbs-modal.show {
  display: block;
}

.thumbs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(243, 202, 64, 0.2);
}

.thumbs-header h3 {
  font-family: var(--md-sys-font-sacred);
  color: var(--md-sys-color-primary);
}

.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px;
}

.thumb-card {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid rgba(243, 202, 64, 0.2);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--md-sys-elevation-2);
}

.thumb-card:hover {
  transform: translateY(-4px) scale(1.04);
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 20px rgba(243, 202, 64, 0.4);
}

.thumb-card .thumb-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  margin-bottom: 6px;
}

.thumb-card .thumb-title {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.3;
}

/* ==========================================================================
   2-Page Magazine Spread Stage (Flat & Crisp FlipHTML5 Layout)
   ========================================================================== */

.flipbook-wrapper {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 10px 0 10px;
  min-height: 0;
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.book-container {
  display: flex;
  width: min(960px, 98vw);
  height: 100%;
  max-height: calc(100vh - 64px - 72px - 24px);
  box-shadow: var(--md-sys-elevation-5);
  border-radius: 16px;
  position: relative;
  justify-content: center;
}

/* Individual Pages */
.page {
  display: none;
  background: linear-gradient(155deg, var(--md-sys-color-surface-container) 0%, var(--md-sys-color-surface-container-high) 100%);
  padding: 24px 26px 14px 26px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid rgba(243, 202, 64, 0.2);
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.page-inner-content {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Single Cover Page */
.page.active-single {
  width: 540px;
  height: 100%;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
}

/* Left Page of Spread */
.page.active-left {
  width: 480px;
  height: 100%;
  border-radius: 16px 0 0 16px;
  border-right: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: inset -15px 0 25px rgba(0, 0, 0, 0.35);
}

/* Right Page of Spread */
.page.active-right {
  width: 480px;
  height: 100%;
  border-radius: 0 16px 16px 0;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 15px 0 25px rgba(0, 0, 0, 0.35);
}

.page-header-mini {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--md-sys-color-secondary);
  border-bottom: 1px solid rgba(0, 229, 255, 0.2);
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.page-footer {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-sys-color-primary);
  text-align: center;
  border-top: 1px solid rgba(243, 202, 64, 0.15);
  padding-top: 8px;
  margin-top: auto;
}

/* Hard Cover Page */
.cover-page {
  background: radial-gradient(circle at center, #2e2402 0%, #120e03 100%) !important;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px solid var(--md-sys-color-primary);
}

.cover-img {
  max-width: 200px;
  border-radius: var(--md-sys-shape-corner-m);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 25px rgba(243, 202, 64, 0.3);
  margin: 16px 0;
  border: 1px solid var(--md-sys-color-primary);
}

.cover-badge {
  background: linear-gradient(90deg, var(--md-sys-color-primary) 0%, #ffab00 100%);
  color: var(--md-sys-color-on-primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 4px 14px;
  border-radius: var(--md-sys-shape-corner-full);
}

.cover-title {
  font-family: var(--md-sys-font-sacred);
  font-size: 1.85rem;
  color: var(--md-sys-color-primary);
  margin-top: 14px;
  text-shadow: 0 0 15px rgba(243, 202, 64, 0.4);
  letter-spacing: 2px;
}

.cover-subtitle {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  margin-top: 10px;
  letter-spacing: 0.5px;
}

.cover-highlight-sacred {
  font-family: var(--md-sys-font-sacred);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  letter-spacing: 2.5px;
  margin-top: 8px;
  text-shadow: 0 0 18px rgba(243, 202, 64, 0.6);
  background: rgba(243, 202, 64, 0.12);
  padding: 6px 20px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid rgba(243, 202, 64, 0.4);
  display: inline-block;
}

/* MD3 Typography */
.page-section-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--md-sys-color-secondary);
  background-color: rgba(0, 229, 255, 0.1);
  padding: 4px 12px;
  border-radius: var(--md-sys-shape-corner-full);
  margin-bottom: 10px;
  border: 1px solid rgba(0, 229, 255, 0.3);
}

.page-title {
  font-family: var(--md-sys-font-sacred);
  font-size: 1.2rem;
  color: var(--md-sys-color-primary);
  border-bottom: 2px solid rgba(243, 202, 64, 0.3);
  padding-bottom: 8px;
  margin-bottom: 14px;
  line-height: 1.3;
}

.md3-sacred-subtitle {
  font-family: var(--md-sys-font-sacred);
  font-size: 1rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  margin: 12px 0 8px 0;
  padding-left: 10px;
  border-left: 3px solid var(--md-sys-color-primary);
}

.md3-card-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--md-sys-color-secondary);
  margin: 10px 0 6px 0;
}

.md3-body-paragraph {
  font-family: var(--md-sys-font-serif);
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 10px;
}

.md3-body-paragraph strong {
  color: var(--md-sys-color-primary);
}

.md3-concept-list {
  list-style: none;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.md3-concept-item {
  background: var(--md-sys-color-surface-container-highest);
  border-left: 3px solid var(--md-sys-color-primary);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.md3-concept-item strong {
  color: var(--md-sys-color-primary);
}

/* ==========================================================================
   FlipHTML5 Style Bottom Floating Toolbar
   ========================================================================== */

.bottom-toolbar {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: rgba(20, 17, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(243, 202, 64, 0.35);
  padding: 8px 24px;
  border-radius: var(--md-sys-shape-corner-full);
  margin: 10px 0 14px 0;
  box-shadow: var(--md-sys-elevation-3);
  flex-shrink: 0;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(243, 202, 64, 0.2);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.tool-btn span {
  pointer-events: none;
}

.tool-btn:hover:not(:disabled) {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 0 12px rgba(243, 202, 64, 0.4);
}

.tool-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  border-color: transparent;
}

.page-slider-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.page-indicator {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--md-sys-color-primary);
  letter-spacing: 0.5px;
}

@media (max-width: 980px) {
  .book-container {
    width: 99vw;
    max-height: calc(100vh - 64px - 68px - 20px);
  }
  .page.active-left, .page.active-right {
    width: 50%;
  }
  .header-title .subtitle {
    display: none;
  }
  .search-box {
    width: 160px;
  }
}
