/* book.css */

/* GLOBAL STYLES */
:root {
    --sidebar-width: 300px;
    --right-sidebar-width: 250px;
    --content-padding: 2rem;
    /* --gradient-height: 100px; /* Removed */
    --transition-speed: 0.3s;
  }
  
  body {
      background: #0e0e10;
      color: #e6e6e6;
      font-family: Georgia, 'Times New Roman', serif;
      font-size: 1.1rem;
      line-height: 1.75;
      margin: 0;
      /* Apply padding transition for smooth sidebar toggle */
      padding-left: 0; /* Start with 0, JS will add if needed */
      transition: padding-left var(--transition-speed) ease-in-out;
      min-height: 100vh;
      position: relative;
  }
  
  /* --- BUTTON --- */
  .left-sidebar-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background-color: #2a2a2e;
    color: #e6e6e6;
    border: 1px solid #444;
    font-size: 1.5rem;
    cursor: pointer;
    width: 45px;
    height: 45px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease, opacity var(--transition-speed) ease, transform var(--transition-speed) ease; /* Add opacity/transform */
  }
  .left-sidebar-toggle:hover {
      background-color: #3a3a3e;
  }
  
  /* Style for when button is hidden by scroll */
  .left-sidebar-toggle.scrolled-hidden {
      opacity: 0.3; /* Make it faint instead of fully hidden */
      pointer-events: none; /* Disable click when faint */
      transform: translateY(-5px); /* Subtle movement */
  }
  
  
  /* --- LEFT SIDEBAR --- */
  .left-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #121214;
    border-right: 1px solid #282828;
    padding: 1rem;
    padding-top: 70px; /* Space for fixed toggle button */
    overflow-y: auto;
    box-sizing: border-box;
    transition: transform var(--transition-speed) ease-in-out, opacity var(--transition-speed) ease; /* Animate toggle & scroll hide */
    z-index: 1000;
    transform: translateX(0); /* Start visible */
  }
  
  /* Manual Hide (via toggle button) */
  .left-sidebar.hidden {
    transform: translateX(-100%);
    pointer-events: none; /* Prevent interaction when hidden */
  }
  
  /* Auto-Hide (via scroll) */
  .left-sidebar.scrolled-hidden {
      transform: translateX(-100%); /* Same visual hiding */
      opacity: 0; /* Fade out */
      pointer-events: none;
  }
  
  /* Ensure manual hide takes precedence if both classes are somehow present */
  .left-sidebar.hidden.scrolled-hidden {
       transform: translateX(-100%);
       opacity: 1; /* Reset opacity if manually hidden */
  }
  
  
  .toc-wrapper { }
  
  .chapter-label {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #ccc;
  }
  .left-sidebar ul {
    list-style: none;
    padding-left: 15px;
    margin: 0 0 1rem 0; /* Add bottom margin */
  }
  .left-sidebar li {
    margin-bottom: 0.4rem;
  }
  
  /* TOC Links - Trying without !important first */
  .left-sidebar ul li a {
    color: #6f90ae;
    text-decoration: underline; /* Underline by default */
    display: block;
    padding: 2px 0;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
  }
  .left-sidebar ul li a:hover {
    color: #a8c5e0;
    background-color: rgba(255, 255, 255, 0.05);
  }
  .left-sidebar ul li a:visited {
    color: #775d99;
  }
  
  /* Current page item */
  .current {
    color: #e0e0e0;
    font-style: italic;
    cursor: default;
    display: block;
    padding: 2px 0;
    text-decoration: none; /* Ensure no underline */
  }
  
  /* --- CONTENT WRAPPER (Full width, no margin changes) --- */
  .content-wrapper {
      display: flex;
      /* No margin-left transition needed */
      width: 100%; /* Take full width dictated by body padding */
  }
  
  /* --- MAIN CONTENT BLOCK (Centers within wrapper) --- */
  .content-block {
    flex-grow: 1;
    padding: var(--content-padding);
    min-width: 0;
    position: relative;
  }
  
  header, main {
      max-width: 700px; /* Max width for readability */
      margin-left: auto;
      margin-right: auto; /* Center within content-block */
  }
  header { margin-bottom: 2rem; }
  header > p { text-align: center; font-style: italic; color: #aaa; margin: 0 auto 1.5rem auto; }
  .nav { text-align: center; margin: 1rem auto 2rem; }
  .nav a { margin: 0 1rem; font-weight: 500; color: #7f9eb8; text-decoration: none;} /* Links */
  .nav a:hover { color: #a8c5e0; text-decoration: underline; }
  .nav a:visited { color: #775d99; }
  
  main {
    position: relative; /* Keep for potential future absolute elements */
    padding-bottom: 2rem; /* Reduced padding now gradient is gone */
    background-color: #0e0e10;
    text-align: left;
  }
  
  hr { border: none; border-top: 6px solid #d03d3d; margin: 3rem auto; width: 80%; }
  h1 { font-size: 2.5rem; text-align: center; color: #fff; margin-top: 0; margin-bottom: 0.5rem; transition: color 0.3s ease; }
  h2 { font-size: 1.5rem; text-align: center; color: #aaa; margin-top: 0; margin-bottom: 1.5rem; font-weight: normal; }
  /* Apply glitch only to main book title */
  h1.title-glitch:hover { animation: glitch 0.3s infinite; color: #ddd; }
  @keyframes glitch {
      0% { text-shadow: 2px 0 #537895, -2px 0 #9ea7b8; }
      50% { text-shadow: -2px 0 #537895, 2px 0 #9ea7b8; }
      100% { text-shadow: 2px 0 #537895, -2px 0 #9ea7b8; }
  }
  
  /* --- Previous/Next Chapter Navigation --- */
  .chapter-nav {
      display: flex;
      justify-content: space-between; /* Pushes links to edges */
      margin-top: 3rem; /* Space above nav */
      padding-top: 1.5rem; /* Space below main content */
      border-top: 1px solid #333; /* Separator line */
      font-size: 0.95rem;
  }
  .prev-link-container,
  .next-link-container {
      flex-basis: 48%; /* Roughly half each, allows wrapping */
  }
  .prev-link-container {
      text-align: left;
  }
  .next-link-container {
      text-align: right;
  }
  .chapter-nav a {
      color: #8aa6c1; /* Slightly different color */
      text-decoration: none;
      transition: color 0.2s ease;
  }
  .chapter-nav a:hover {
      color: #c0d8f0;
      text-decoration: underline;
  }
  
  /* --- RIGHT SIDEBAR --- */
  .right-sidebar {
    width: var(--right-sidebar-width);
    flex-shrink: 0;
    padding: var(--content-padding);
    padding-top: calc(var(--content-padding) + 10px);
    background-color: #0e0e10;
    opacity: 0.75;
    position: sticky;
    top: 0;
    height: calc(100vh - var(--content-padding) * 2);
    box-sizing: border-box;
    overflow-y: auto;
  }
  
  /* RIGHT EDGE FADE */
  .right-gradient {
    position: fixed;
    top: 0;
    right: 0;
    width: 100px; /* Reduced width */
    height: 100%;
    background: linear-gradient(to left, #0e0e10 30%, transparent 100%);
    pointer-events: none;
    z-index: 999; /* Below sidebar toggle */
  }
  
  /* NO FOOTER GRADIENT RULES */
  
  
  /* --- RESPONSIVE --- */
  @media (max-width: 900px) {
    body {
        padding-left: 0 !important; /* Ensure no padding on mobile */
    }
    .left-sidebar {
        /* JS adds .hidden, styles handle transform */
        /* Ensure it's not also scrolled-hidden confusingly */
         opacity: 1;
         transform: translateX(-100%); /* Start hidden */
    }
    .left-sidebar.hidden {
         transform: translateX(-100%); /* Explicitly hidden */
    }
    .left-sidebar.scrolled-hidden { display: none; } /* Don't use scroll hide on mobile */
  
    .left-sidebar-toggle {
       /* Keep toggle visible */
       top: 5px; left: 5px; width: 40px; height: 40px; font-size: 1.3rem;
       opacity: 1 !important; /* Ensure toggle is always opaque */
       transform: none !important; /* No scroll effect */
    }
    .content-wrapper { display: block; }
    .content-block { padding: 1rem; }
    .right-sidebar, .right-gradient { display: none; }
    main, header { max-width: 100%; }
    main { padding-bottom: 1rem; } /* Adjust mobile bottom padding */
    header h1 { font-size: 2rem; }
    header > p { font-size: 1rem; }
    .nav a { margin: 0 0.5rem; font-size: 0.9rem;}
  
    /* Adjust chapter nav layout on mobile */
    .chapter-nav {
        margin-top: 2rem;
        padding-top: 1rem;
        flex-direction: column; /* Stack links */
    }
      .prev-link-container,
      .next-link-container {
         flex-basis: auto; /* Reset basis */
         text-align: center; /* Center links */
         padding: 0.3rem 0;
     }
  }