/* Layout CSS - Navbar and Footer with Sketchy Styling */

/* Page Layout Container */
.page-layout {
  display: flex;
  width: 100%;
  min-height: calc(100vh - 70px); /* Minimum height minus navbar */
  position: relative;
  gap: 1rem;
}

/* Sidebar Styles */
.sidebar {
  flex-shrink: 0;
  position: sticky;
  top: 70px; /* Stick below navbar */
  align-self: flex-start;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}

.sidebar-left {
  width: var(--sidebar-width);
}

.sidebar-right {
  width: var(--toc-width);
}

.sidebar-content {
  background-color: #f9fafb;
  border-radius: 0.25rem;
  padding: 1.5rem;
  position: relative;
  height: 100%;
}

.sidebar-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 1.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0;
  border-bottom: none;
  font-family: var(--font-heading);
}

.sidebar-icon {
  width: 1.5rem;
  height: 1.5rem;
  stroke-width: 2;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  padding-left: 3rem;
  text-decoration: none;
  color: #1e293b;
  transition: all 0.2s ease;
  position: relative;
  line-height: 1.7;
  border-radius: 0.25rem;
}

/* Hand-drawn numbered circles for chapters */
.sidebar-link::before {
  content: attr(data-chapter);
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%) rotate(-5deg);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
  border: 2px solid #1e3a8a;
  box-shadow: 2px 2px 0 0 rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #1e3a8a;
  font-family: var(--font-heading);
  transition: all 0.2s ease;
  z-index: 2;
}

/* Hand-drawn background for sidebar links (like navbar) */
.sidebar-link::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border: 1px solid #3b82f6;
  border-radius: 0.25rem;
  transform: translate(-50%, -50%) rotate(-2deg);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-link:hover::before {
  transform: translateY(-50%) scale(1.1) rotate(0deg);
  background: linear-gradient(135deg, #93c5fd 0%, #60a5fa 100%);
}

.sidebar-link:hover::after {
  opacity: 1;
}

.sidebar-link:hover {
  color: #2563eb;
  transform: translateY(-1px);
}

.chapter-number {
  display: none;
}

.chapter-title {
  font-weight: 600;
  font-size: 0.95rem;
  font-family: var(--font-body);
}

/* Table of Contents Navigation */
.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toc-link {
  display: block;
  padding: 0.5rem 0.75rem;
  padding-left: 1rem;
  color: #1e293b;
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.5;
  transition: all 0.2s ease;
  position: relative;
  border-radius: 0.25rem;
}

/* Hand-drawn background for TOC links (like sidebar) */
.toc-link::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border: 1px solid #3b82f6;
  border-radius: 0.25rem;
  transform: translate(-50%, -50%) rotate(-1deg);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.toc-link:hover {
  color: #2563eb;
  transform: translateY(-1px);
}

.toc-link:hover::after {
  opacity: 1;
}

.toc-link.active {
  color: #2563eb;
  font-weight: 600;
}

.toc-link.active::after {
  opacity: 1;
}

/* Indent h3 links */
.toc-link.toc-h3 {
  padding-left: 2rem;
  font-size: 0.8125rem;
  color: #94a3b8;
}

.toc-link.toc-h3:hover {
  color: #3b82f6;
}

.toc-link.toc-h3.active {
  color: #3b82f6;
}

/* Support for level-based classes (h2, h3, etc.) */
.toc-link.toc-h2 {
  padding-left: 1rem;
}

/* Content Area - Reading Area */
.content {
  flex: 1;
  max-width: var(--content-max-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  border-left: 2px dashed #d1d5db;
  border-right: 2px dashed #d1d5db;
  overflow: hidden;
}

/* Content Header - Fixed */
.content-header {
  flex-shrink: 0;
  padding: 1.5rem 1.5rem 1rem;
  background-color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: relative;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
}

/* Hand-drawn background for content header (always visible) */
.content-header::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100% - 2rem);
  height: calc(100% - 1rem);
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border: 1px solid #3b82f6;
  border-radius: 0.25rem;
  transform: translate(-50%, -50%) rotate(-1deg);
  z-index: 0;
  opacity: 1;
}

.content-title-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

/* Sketched Chapter Badge */
.content-chapter-badge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  border: 3px solid #1c1917;
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, 0.15);
  font-weight: 800;
  font-size: 1.25rem;
  color: #1c1917;
  font-family: var(--font-heading);
  transform: rotate(-5deg);
  z-index: 2;
}

.content-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
  font-family: var(--font-heading);
}

.content-navigation {
  display: flex;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

/* Content Body - Scrollable */
.content-body {
  flex: 1;
  padding: 1.5rem;
}

/* Custom Scrollbar Styling */
.content-body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.content-body::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: #f9fafb;
}

.content-body::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.content-body::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Firefox Scrollbar */
.content-body,
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: #d1d5db #f9fafb;
}

/* Hide sidebars on mobile and tablet */
@media (max-width: 1280px) {
  .sidebar-right {
    display: none;
  }
}

@media (max-width: 1024px) {
  .page-layout {
    flex-direction: column;

    gap: 0;
  }

  .sidebar-left,
  .sidebar-right {
    position: static;
    width: 100%;
    height: auto;
    padding: 1rem 0;
  }

  .sidebar-right,
  .sidebar-left {
    display: none;
  }

  .content {
    max-width: 100%;
    max-width: 100%;
    border-left: none;
    border-right: none;
  }

  /* Simplify content header for mobile */
  .content-header {
    padding: 0rem;
    margin-bottom: 0.25rem;
    margin-top: 0.25rem;
  }

  /* Hide decorative background on mobile */
  .content-header::before {
    display: none;
  }

  .content-title-wrapper {
    gap: 0.75rem;
  }

  .content-chapter-badge {
    width: 2rem;
    height: 2rem;
    font-size: 0.9rem;
    border-width: 2px;
    box-shadow: 2px 2px 0 0 rgba(0, 0, 0, 0.1);
  }

  .content-title {
    font-size: 1.5rem;
  }
}

/* Sketchy Navbar Styling - Enhanced Responsive */
.navbar-container {
  width: 100%;
  position: sticky;
  top: 0;
  background-color: #f9fafb;
  border-bottom: 2px dashed #d1d5db;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.navbar-content {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  text-decoration: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.navbar-brand .icon {
  width: 1.5rem;
  height: 1.5rem;
  stroke-width: 1.5;
}

.navbar-brand::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60%;
  height: 3px;
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  border: 1px solid #1c1917;
  border-radius: 2px;
  transform: rotate(-2deg);
}

.navbar-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 2rem;
  align-items: center;
}

.navbar-links li {
  position: relative;
}

.navbar-links a {
  color: #1e293b;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.navbar-links .icon {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 1.5;
  flex-shrink: 0;
}

.navbar-links a::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border: 1px solid #3b82f6;
  border-radius: 0.25rem;
  transform: translate(-50%, -50%) rotate(-3deg);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.navbar-links a:hover {
  color: #2563eb;
  transform: translateY(-1px);
}

.navbar-links a:hover::before {
  opacity: 1;
}

/* Very small screens - Minimal padding */
@media (max-width: 360px) {
  .navbar-content {
    padding: 0.5rem 0.75rem;
  }

  .navbar-links {
    gap: 0.25rem;
  }

  .navbar-links a {
    padding: 0.375rem;
  }
}

/* Tablet - Stack items but keep horizontal layout */
@media (max-width: 768px) {
  .navbar-content {
    padding: 0.875rem 1rem;
    gap: 0.75rem;
  }

  .navbar-brand {
    font-size: 1.25rem;
  }

  .navbar-brand .icon {
    width: 1.25rem;
    height: 1.25rem;
  }

  .navbar-links {
    gap: 1rem;
  }

  .navbar-links a {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  .navbar-links .icon {
    width: 1.125rem;
    height: 1.125rem;
  }
}

/* Small mobile - Icon only navigation */
@media (max-width: 480px) {
  .navbar-content {
    padding: 0.75rem 1rem;
  }

  .navbar-brand {
    font-size: 1.125rem;
  }

  .navbar-brand span {
    display: none;
  }

  .navbar-brand .icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .navbar-brand::after {
    display: none;
  }

  .navbar-links {
    gap: 0.5rem;
  }

  .navbar-links a span {
    display: none;
  }

  .navbar-links a {
    padding: 0.5rem;
  }

  .navbar-links .icon {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
  }
}

/* Sketchy Footer Styling */
.footer-container {
  display: none; /* Hide footer in fixed layout */
}

.footer-content {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 2rem;
  box-sizing: border-box;
}

.footer-section {
  flex: 1;
  min-width: 200px;
}

.footer-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 1rem;
  position: relative;
}

.footer-section h3::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 40%;
  height: 2px;
  background: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
  border: 1px solid #991b1b;
  border-radius: 1px;
  transform: rotate(2deg);
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.75rem;
  position: relative;
  padding-left: 1.25rem;
}

.footer-links li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #d8b4fe 0%, #c084fc 100%);
  border: 1px solid #7c3aed;
  transform: rotate(10deg);
}

.footer-links a {
  color: #64748b;
  text-decoration: none;
  transition: color 0.2s ease;
  font-size: 0.95rem;
}

.footer-links a:hover {
  color: #2563eb;
}

.footer-bottom {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed #d1d5db;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}

.footer-bottom::before {
  content: "";
  display: block;
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #6ee7b7 0%, #34d399 100%);
  border: 1px solid #059669;
  border-radius: 1px;
  margin: 0 auto 0.5rem auto;
  transform: rotate(-5deg);
}

/* Mobile footer */
@media (max-width: 768px) {
  .footer-container {
    margin-top: 2rem;
    padding: 1rem;
  }

  .footer-content {
    flex-direction: column;
    gap: 1.5rem;
  }

  .footer-section {
    min-width: auto;
  }

  .footer-section h3 {
    font-size: 1.1rem;
  }
}
