/* Book-style UI for Cultivation Guides */

/* ============================================
   Book Wrapper & Container
   ============================================ */
.book-wrapper {
  min-height: 80vh;
  padding: 2rem 1rem;
}

@media (min-width: 1024px) {
  .book-wrapper {
    padding: 3rem 2rem;
  }
}

.book-container {
  position: relative;
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  background: linear-gradient(to right, #c4a882 0%, #d4c4a8 1%, #f5f0e6 3%, #faf8f4 100%);
  border-radius: 4px 12px 12px 4px;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.05),
    inset 4px 0 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Dark mode book container */
.dark .book-container {
  background: linear-gradient(to right, #3d3425 0%, #4a3f30 1%, #2d2820 3%, #1f1b16 100%);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 4px 0 15px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Book Spine Effect
   ============================================ */
.book-spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to right,
    rgba(0, 0, 0, 0.15) 0%,
    rgba(0, 0, 0, 0.08) 30%,
    rgba(0, 0, 0, 0.03) 70%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 10;
}

/* ============================================
   Table of Contents Sidebar
   ============================================ */
.book-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: linear-gradient(135deg, #f5f0e6 0%, #ebe4d6 100%);
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.book-sidebar.open {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  .book-sidebar {
    position: relative;
    transform: translateX(0);
    width: 260px;
    flex-shrink: 0;
  }
}

.dark .book-sidebar {
  background: linear-gradient(135deg, #2d2820 0%, #252019 100%);
  border-right-color: rgba(255, 255, 255, 0.1);
}

.book-sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.dark .book-sidebar-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.book-sidebar-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.5rem;
  color: #78716c;
  transition: color 0.2s;
}

.book-sidebar-close:hover {
  color: #44403c;
}

.dark .book-sidebar-close {
  color: #a8a29e;
}

.dark .book-sidebar-close:hover {
  color: #e7e5e4;
}

/* ============================================
   Table of Contents Navigation
   ============================================ */
.book-toc {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.book-toc-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1.5rem;
  text-align: left;
  color: #57534e;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.book-toc-item:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #292524;
}

.book-toc-item.active {
  background: rgba(180, 83, 9, 0.1);
  border-left-color: #b45309;
  color: #92400e;
  font-weight: 600;
}

.dark .book-toc-item {
  color: #a8a29e;
}

.dark .book-toc-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #e7e5e4;
}

.dark .book-toc-item.active {
  background: rgba(251, 191, 36, 0.1);
  border-left-color: #fbbf24;
  color: #fcd34d;
}

.book-toc-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-right: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #78716c;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  flex-shrink: 0;
}

.book-toc-item.active .book-toc-number {
  background: #b45309;
  color: white;
}

.dark .book-toc-number {
  color: #78716c;
  background: rgba(255, 255, 255, 0.05);
}

.dark .book-toc-item.active .book-toc-number {
  background: #fbbf24;
  color: #1f1b16;
}

.book-toc-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.875rem;
  line-height: 1.4;
}

/* ============================================
   Mobile Menu Toggle
   ============================================ */
.book-menu-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #faf8f4;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: #57534e;
  z-index: 40;
  transition: all 0.2s;
}

.book-menu-toggle:hover {
  background: #f5f0e6;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.dark .book-menu-toggle {
  background: #2d2820;
  border-color: rgba(255, 255, 255, 0.1);
  color: #a8a29e;
}

.dark .book-menu-toggle:hover {
  background: #3d3425;
}

@media (min-width: 1024px) {
  .book-menu-toggle {
    display: none;
  }
}

/* ============================================
   Main Content Area
   ============================================ */
.book-content {
  position: relative;
  flex: 1;
  min-height: 70vh;
  background: #faf8f4;
  /* Paper texture effect */
  background-image:
    repeating-linear-gradient(
      120deg,
      rgba(0, 0, 0, 0.01),
      rgba(0, 0, 0, 0.01) 1px,
      transparent 1px,
      transparent 60px
    );
}

.dark .book-content {
  background: #1f1b16;
  background-image:
    repeating-linear-gradient(
      120deg,
      rgba(255, 255, 255, 0.005),
      rgba(255, 255, 255, 0.005) 1px,
      transparent 1px,
      transparent 60px
    );
}

.book-page {
  padding: 2rem;
  padding-left: 3rem;
}

@media (min-width: 768px) {
  .book-page {
    padding: 3rem 4rem;
  }
}

/* Page edge effect */
.book-page-edge {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to left,
    rgba(0, 0, 0, 0.08) 0%,
    rgba(0, 0, 0, 0.03) 30%,
    transparent 100%
  );
  pointer-events: none;
}

.dark .book-page-edge {
  background: linear-gradient(to left,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.1) 30%,
    transparent 100%
  );
}

/* ============================================
   Chapter Styles
   ============================================ */
.book-chapter {
  display: none;
  animation: fadeIn 0.3s ease;
}

.book-chapter.active {
  display: block;
}

.book-chapter.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.book-chapter-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
}

.book-chapter-number {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.875rem;
  font-style: italic;
  color: #78716c;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
}

.dark .book-chapter-number {
  color: #a8a29e;
}

.book-chapter-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: #292524;
  line-height: 1.3;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .book-chapter-title {
    font-size: 2.5rem;
  }
}

.dark .book-chapter-title {
  color: #fafaf9;
}

.book-chapter-divider {
  display: flex;
  justify-content: center;
}

/* ============================================
   Chapter Content & Typography
   ============================================ */
.book-chapter-content {
  max-width: 65ch;
  margin: 0 auto;
}

.book-subsections {
  margin-top: 3rem;
}

.book-subsection {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.dark .book-subsection {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.book-subsection-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #44403c;
  margin-bottom: 1.5rem;
}

.dark .book-subsection-title {
  color: #e7e5e4;
}

/* ============================================
   Prose Book Typography (Markdown Rendered)
   ============================================ */
.prose-book {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1rem;
  line-height: 1.8;
  color: #44403c;
}

.dark .prose-book {
  color: #d6d3d1;
}

.prose-book h1,
.prose-book h2,
.prose-book h3,
.prose-book h4 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-weight: 600;
  color: #292524;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.dark .prose-book h1,
.dark .prose-book h2,
.dark .prose-book h3,
.dark .prose-book h4 {
  color: #fafaf9;
}

.prose-book h1 { font-size: 1.75rem; }
.prose-book h2 { font-size: 1.5rem; }
.prose-book h3 { font-size: 1.25rem; }
.prose-book h4 { font-size: 1.125rem; }

.prose-book p {
  margin-bottom: 1.25rem;
  text-align: justify;
  hyphens: auto;
}

.prose-book strong {
  font-weight: 700;
  color: #292524;
}

.dark .prose-book strong {
  color: #fafaf9;
}

.prose-book em {
  font-style: italic;
}

.prose-book ul,
.prose-book ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose-book ul {
  list-style-type: disc;
}

.prose-book ol {
  list-style-type: decimal;
}

.prose-book li {
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.prose-book li::marker {
  color: #b45309;
}

.dark .prose-book li::marker {
  color: #fbbf24;
}

.prose-book blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid #b45309;
  background: rgba(180, 83, 9, 0.05);
  font-style: italic;
  color: #57534e;
}

.dark .prose-book blockquote {
  border-left-color: #fbbf24;
  background: rgba(251, 191, 36, 0.05);
  color: #a8a29e;
}

.prose-book code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
  padding: 0.2em 0.4em;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 0.25rem;
  color: #b45309;
}

.dark .prose-book code {
  background: rgba(255, 255, 255, 0.1);
  color: #fbbf24;
}

.prose-book pre {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #292524;
  border-radius: 0.5rem;
  overflow-x: auto;
}

.prose-book pre code {
  padding: 0;
  background: transparent;
  color: #e7e5e4;
  font-size: 0.875rem;
}

.prose-book table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.prose-book th,
.prose-book td {
  padding: 0.75rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  text-align: left;
}

.dark .prose-book th,
.dark .prose-book td {
  border-color: rgba(255, 255, 255, 0.1);
}

.prose-book th {
  background: rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.dark .prose-book th {
  background: rgba(255, 255, 255, 0.05);
}

.prose-book a {
  color: #b45309;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose-book a:hover {
  color: #92400e;
}

.dark .prose-book a {
  color: #fbbf24;
}

.dark .prose-book a:hover {
  color: #fcd34d;
}

.prose-book hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.dark .prose-book hr {
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   Chapter Footer & Navigation
   ============================================ */
.book-chapter-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.dark .book-chapter-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.book-chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.book-nav-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.875rem;
  color: #57534e;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  transition: all 0.2s;
}

.book-nav-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #292524;
}

.dark .book-nav-btn {
  color: #a8a29e;
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.dark .book-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e7e5e4;
}

.book-page-indicator {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.875rem;
  font-style: italic;
  color: #78716c;
}

.dark .book-page-indicator {
  color: #78716c;
}

/* ============================================
   Mobile Sidebar Overlay
   ============================================ */
@media (max-width: 1023px) {
  .book-sidebar::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: -1;
  }

  .book-sidebar.open::before {
    opacity: 1;
    visibility: visible;
  }
}
