/* 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: 300px;
  background: linear-gradient(
    180deg,
    rgba(245, 240, 230, 0.97) 0%,
    rgba(235, 228, 214, 0.98) 100%
  );
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0);
}

.book-sidebar.open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

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

.dark .book-sidebar {
  background: linear-gradient(
    180deg,
    rgba(38, 35, 30, 0.99) 0%,
    rgba(28, 25, 20, 0.99) 100%
  );
  border-right-color: rgba(255, 255, 255, 0.06);
}

.dark .book-sidebar.open {
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
}

/* Decorative botanical accent line */
.book-sidebar::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(
    180deg,
    var(--color-primary-400) 0%,
    var(--color-primary-600) 50%,
    var(--color-primary-400) 100%
  );
  opacity: 0.4;
}

.dark .book-sidebar::after {
  background: linear-gradient(
    180deg,
    var(--color-primary-500) 0%,
    var(--color-primary-400) 50%,
    var(--color-primary-600) 100%
  );
  opacity: 0.3;
}

.book-sidebar-header {
  padding: 1.75rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.5) 0%,
    transparent 100%
  );
}

.dark .book-sidebar-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03) 0%,
    transparent 100%
  );
}

.book-sidebar-close {
  position: absolute;
  top: 1.25rem;
  right: 1rem;
  padding: 0.625rem;
  color: #78716c;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.book-sidebar-close:hover {
  color: #292524;
  background: rgba(0, 0, 0, 0.08);
  transform: scale(1.05);
}

.book-sidebar-close:active {
  transform: scale(0.95);
}

.dark .book-sidebar-close {
  color: #d6d3d1;
  background: rgba(255, 255, 255, 0.06);
}

.dark .book-sidebar-close:hover {
  color: #fafaf9;
  background: rgba(255, 255, 255, 0.12);
}

/* ============================================
   Table of Contents Navigation
   ============================================ */
.book-toc {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.book-toc::-webkit-scrollbar {
  width: 4px;
}

.book-toc::-webkit-scrollbar-track {
  background: transparent;
}

.book-toc::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.dark .book-toc {
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.dark .book-toc::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

.book-toc-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.875rem 1.5rem;
  text-align: left;
  color: #44403c;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 3px solid transparent;
  position: relative;
}

/* Staggered entrance animation for mobile */
@media (max-width: 1023px) {
  .book-sidebar.open .book-toc-item {
    animation: tocItemSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  }

  .book-sidebar.open .book-toc-item:nth-child(1) {
    animation-delay: 0.05s;
  }
  .book-sidebar.open .book-toc-item:nth-child(2) {
    animation-delay: 0.08s;
  }
  .book-sidebar.open .book-toc-item:nth-child(3) {
    animation-delay: 0.11s;
  }
  .book-sidebar.open .book-toc-item:nth-child(4) {
    animation-delay: 0.14s;
  }
  .book-sidebar.open .book-toc-item:nth-child(5) {
    animation-delay: 0.17s;
  }
  .book-sidebar.open .book-toc-item:nth-child(6) {
    animation-delay: 0.2s;
  }
  .book-sidebar.open .book-toc-item:nth-child(7) {
    animation-delay: 0.23s;
  }
  .book-sidebar.open .book-toc-item:nth-child(8) {
    animation-delay: 0.26s;
  }
  .book-sidebar.open .book-toc-item:nth-child(9) {
    animation-delay: 0.29s;
  }
  .book-sidebar.open .book-toc-item:nth-child(10) {
    animation-delay: 0.32s;
  }
}

@keyframes tocItemSlideIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.book-toc-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #1c1917;
  padding-left: 1.75rem;
}

.book-toc-item.active {
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--color-primary-600) 12%, transparent) 0%,
    color-mix(in oklab, var(--color-primary-600) 6%, transparent) 100%
  );
  border-left-color: var(--color-primary-600);
  color: var(--color-primary-700);
  font-weight: 600;
}

/* Dark mode TOC items - MUCH better contrast */
.dark .book-toc-item {
  color: #fafaf9;
}

.dark .book-toc-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  padding-left: 1.75rem;
}

.dark .book-toc-item.active {
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--color-primary-400) 18%, transparent) 0%,
    color-mix(in oklab, var(--color-primary-400) 8%, transparent) 100%
  );
  border-left-color: var(--color-primary-400);
  color: var(--color-primary-300);
}

.book-toc-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-right: 0.875rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #57534e;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  flex-shrink: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-toc-item:hover .book-toc-number {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.05);
}

.book-toc-item.active .book-toc-number {
  background: var(--color-primary-600);
  color: white;
  box-shadow: 0 2px 8px
    color-mix(in oklab, var(--color-primary-600) 40%, transparent);
}

/* Dark mode number badges */
.dark .book-toc-number {
  color: #e7e5e4;
  background: rgba(255, 255, 255, 0.08);
}

.dark .book-toc-item:hover .book-toc-number {
  background: rgba(255, 255, 255, 0.14);
}

.dark .book-toc-item.active .book-toc-number {
  background: var(--color-primary-400);
  color: #1c1917;
  box-shadow: 0 2px 12px
    color-mix(in oklab, var(--color-primary-400) 35%, transparent);
}

.book-toc-title {
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 0.9rem;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--color-white);
}

.book-toc-item.active .book-toc-title {
  color: var(--color-white);
}

/* ============================================
   Mobile Menu Toggle
   ============================================ */
.book-menu-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  background: linear-gradient(
    135deg,
    var(--color-primary-600) 0%,
    var(--color-primary-700) 100%
  );
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 16px
      color-mix(in oklab, var(--color-primary-600) 35%, transparent),
    0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  color: white;
  z-index: 40;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
}

.book-menu-toggle:hover {
  background: linear-gradient(
    135deg,
    var(--color-primary-500) 0%,
    var(--color-primary-600) 100%
  );
  box-shadow: 0 6px 24px
      color-mix(in oklab, var(--color-primary-600) 45%, transparent),
    0 4px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.book-menu-toggle:active {
  transform: translateY(0) scale(0.98);
}

.dark .book-menu-toggle {
  background: linear-gradient(
    135deg,
    var(--color-primary-500) 0%,
    var(--color-primary-600) 100%
  );
  box-shadow: 0 4px 20px
      color-mix(in oklab, var(--color-primary-500) 30%, transparent),
    0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dark .book-menu-toggle:hover {
  background: linear-gradient(
    135deg,
    var(--color-primary-400) 0%,
    var(--color-primary-500) 100%
  );
  box-shadow: 0 6px 28px
      color-mix(in oklab, var(--color-primary-400) 40%, transparent),
    0 4px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

@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: #f5f5f4;
}

.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: var(--color-primary-600);
}

.dark .prose-book li::marker {
  color: var(--color-primary-400);
}

.prose-book blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--color-primary-600);
  background: color-mix(in oklab, var(--color-primary-600) 5%, transparent);
  font-style: italic;
  color: #57534e;
}

.dark .prose-book blockquote {
  border-left-color: var(--color-primary-400);
  background: color-mix(in oklab, var(--color-primary-400) 5%, transparent);
  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: var(--color-primary-700);
}

.dark .prose-book code {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-primary-400);
}

.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: var(--color-primary-600);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose-book a:hover {
  color: var(--color-primary-700);
}

.dark .prose-book a {
  color: var(--color-primary-400);
}

.dark .prose-book a:hover {
  color: var(--color-primary-300);
}

.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: linear-gradient(
      135deg,
      rgba(0, 0, 0, 0.6) 0%,
      rgba(0, 0, 0, 0.75) 100%
    );
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

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

  .dark .book-sidebar::before {
    background: linear-gradient(
      135deg,
      rgba(0, 0, 0, 0.75) 0%,
      rgba(0, 0, 0, 0.85) 100%
    );
  }
}
