/* ========================================
   LAYOUT & STRUCTURE
   ======================================== */

/* Content width optimization */
#quarto-document-content,
main.content {
  max-width: 75ch !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Clean top navbar */
#quarto-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
  background-color: #ffffff !important;
  box-shadow: none !important;
}

.quarto-secondary-nav {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Pixel animations at top */
.pixel-scene {
  margin: 2rem auto 1rem;
  max-width: 75ch;
}

/* Page title styling */
#title-block-header {
  margin-top: 1.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 2px solid #000000;
  padding-bottom: 1.5rem;
}

#title-block-header .title {
  font-family: 'ITC Garamond Std Light Narrow', serif !important;
  font-weight: 400 !important;
  letter-spacing: -0.02em !important;
  margin-bottom: 0.5rem !important;
}

#title-block-header .subtitle {
  font-family: 'Geist', sans-serif !important;
  color: #738a94 !important;
  font-size: 1.125rem !important;
  font-weight: 400 !important;
  margin-top: 0 !important;
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */

.sidebar.sidebar-navigation {
  border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
  background-color: #ffffff !important;
  padding: 1.5rem 0 !important;
}

/* Sidebar items spacing and hierarchy */
.sidebar-item {
  margin-bottom: 0.25rem;
}

.sidebar-item a,
.sidebar-item-text {
  padding: 0.75rem 1.5rem !important;
  display: block;
  transition: all 150ms ease;
  border-left: 3px solid transparent;
  font-size: 0.9375rem;
}

/* Active state */
.sidebar-item.active > .sidebar-item-container > a,
.sidebar-item > .sidebar-item-container > a.active {
  border-left-color: #3eb0ef !important;
  background-color: rgba(62, 176, 239, 0.05) !important;
  font-weight: 500;
  color: #15171a !important;
}

/* Hover state */
.sidebar-item:hover > .sidebar-item-container > a {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Section headers (Patterns) */
.sidebar-item-section > .sidebar-item-container {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.sidebar-item-section > .sidebar-item-container > a {
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #738a94;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* Nested items (pattern list) */
.sidebar-section .sidebar-item a {
  padding-left: 2rem !important;
}

/* ========================================
   TYPOGRAPHY & CONTENT
   ======================================== */

/* Headings with Garamond */
#quarto-document-content h1,
#quarto-document-content h2,
#quarto-document-content h3,
#quarto-document-content h4,
#quarto-document-content h5,
#quarto-document-content h6 {
  font-family: 'ITC Garamond Std Light Narrow', serif !important;
  font-weight: 400 !important;
  letter-spacing: -0.02em !important;
  margin-top: 2rem !important;
  margin-bottom: 1rem !important;
}

#quarto-document-content h2 {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 0.5rem;
}

/* Better paragraph spacing */
#quarto-document-content p {
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

/* Blockquotes */
#quarto-document-content blockquote {
  border-left: 3px solid #3eb0ef;
  padding-left: 1.5rem;
  margin-left: 0;
  margin-right: 0;
  color: #738a94;
  font-style: italic;
}

/* Lists */
#quarto-document-content ul,
#quarto-document-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

#quarto-document-content li {
  margin-bottom: 0.5rem;
}

/* Strong emphasis */
#quarto-document-content strong {
  font-weight: 600;
  color: #15171a;
}

/* Links - subtle underline */
#quarto-document-content a:not(.nav-button):not(.sidebar-link):not(.btn) {
  color: #3eb0ef;
  text-decoration: none;
  border-bottom: 1px solid rgba(62, 176, 239, 0.3);
  transition: all 150ms ease;
}

#quarto-document-content a:not(.nav-button):not(.sidebar-link):not(.btn):hover {
  color: #2a9bd6;
  border-bottom-color: #3eb0ef;
}

/* External link indicators - helps users know when leaving the site */
#quarto-document-content a[href^="http"]:not([href*="localhost"]):not(.nav-button):not(.sidebar-link):not(.btn):after {
  content: " ↗";
  font-size: 0.875em;
  opacity: 0.7;
  display: inline-block;
  margin-left: 0.125rem;
}

/* Focus indicators for accessibility (WCAG 2.1 AA) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #3eb0ef !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 3px rgba(62, 176, 239, 0.2) !important;
}

/* Sidebar link focus states */
.sidebar-item a:focus-visible {
  background-color: rgba(62, 176, 239, 0.1) !important;
  border-left-color: #3eb0ef !important;
}

/* Navigation button focus states */
.nav-button:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px #000000, 0 0 0 3px rgba(62, 176, 239, 0.3) !important;
}

/* TOC link focus states */
#TOC a:focus-visible {
  color: #3eb0ef !important;
  font-weight: 500;
}

/* Code blocks - clean but defined with improved contrast */
#quarto-document-content pre,
#quarto-document-content div.sourceCode {
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  border-left: 3px solid #3eb0ef !important;
  border-radius: 0 !important;
  background-color: #f4f5f6 !important;
  padding: 1rem !important;
  margin: 1.5rem 0 !important;
}

/* Inline code - subtle */
#quarto-document-content code:not(.sourceCode) {
  background-color: rgba(0, 0, 0, 0.05) !important;
  border-radius: 2px !important;
  padding: 0.125rem 0.375rem !important;
  font-size: 0.9em !important;
}

/* ========================================
   NAVIGATION BUTTONS
   ======================================== */

.page-navigation {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.nav-wrapper {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border: 2px solid #000000 !important;
  background-color: #ffffff;
  box-shadow: 3px 3px 0px #000000;
  transition: all 150ms ease;
  flex: 0 1 auto;
  max-width: 300px;
  text-decoration: none !important;
  border-radius: 0 !important;
}

.nav-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px #000000;
  background-color: rgba(62, 176, 239, 0.05);
  color: inherit !important;
}

.nav-button:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0px #000000;
}

.nav-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.nav-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  color: #738a94;
  letter-spacing: 0.05em;
}

.nav-title {
  font-family: 'ITC Garamond Std Light Narrow', serif;
  font-size: 1.125rem;
  color: #15171a;
}

.nav-prev {
  margin-right: auto;
}

.nav-next {
  margin-left: auto;
}

/* Progress Indicator */
.progress-indicator {
  position: relative;
  height: 6px;
  background-color: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  overflow: hidden;
  border-radius: 0;
}

.progress-bar {
  height: 100%;
  background-color: #3eb0ef;
  transition: width 300ms ease;
}

.progress-label {
  position: absolute;
  right: 0.5rem;
  top: -1.75rem;
  font-family: 'Geist Mono', monospace;
  font-size: 0.75rem;
  color: #738a94;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ========================================
   RIGHT SIDEBAR TOC
   ======================================== */

#TOC {
  border-left: 3px solid #3eb0ef !important;
  border-top: none !important;
  border-right: none !important;
  border-bottom: none !important;
  padding: 1.5rem !important;
  background-color: transparent !important;
}

#TOC .toc-actions {
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

#TOC ul {
  list-style: none !important;
  padding-left: 0 !important;
}

#TOC ul ul {
  padding-left: 1rem !important;
  margin-top: 0.5rem;
}

#TOC li {
  margin-bottom: 0.5rem;
}

#TOC a {
  color: #738a94;
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 150ms ease;
  display: block;
  padding: 0.25rem 0;
  border-bottom: none !important;
}

#TOC a:hover {
  color: #3eb0ef !important;
  border-bottom: none !important;
}

#TOC a.active {
  color: #3eb0ef !important;
  font-weight: 500;
}

/* ========================================
   BUTTONS & INTERACTIVE ELEMENTS
   ======================================== */

/* Code fold buttons */
.code-tools-button,
.code-copy-button {
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  background-color: #ffffff !important;
  border-radius: 0 !important;
  transition: all 150ms ease !important;
}

.code-tools-button:hover,
.code-copy-button:hover {
  border-color: #3eb0ef !important;
  background-color: rgba(62, 176, 239, 0.05) !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Responsive adjustments */
@media (max-width: 768px) {
  /* Hide code button on mobile */
  .code-tools-button {
    display: none !important;
  }

  /* Better navbar positioning */
  #quarto-header {
    padding: 0.5rem 1rem !important;
  }

  .navbar-brand {
    font-size: 1rem !important;
  }

  /* Restore mobile navigation - allow hamburger menu and sidebar toggle */
  /* Previously hidden for design reasons, but needed for accessibility */
  /* If you want to hide these, implement an alternative mobile navigation */
  /* .navbar-toggler {
    display: none !important;
  }

  .quarto-btn-toggle {
    display: none !important;
  } */

  /* Navigation buttons stack vertically */
  .nav-wrapper {
    flex-direction: column;
  }

  .nav-button {
    max-width: 100%;
  }

  .nav-prev,
  .nav-next {
    margin: 0;
  }

  /* Pixel animations smaller on mobile */
  .pixel-scene {
    height: 24px;
    margin: 1rem 0;
  }

  .pixel-decoration {
    width: 6px;
    height: 6px;
  }

  /* Title block more compact */
  #title-block-header {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  #title-block-header .title {
    font-size: 2rem !important;
  }

  #title-block-header .subtitle {
    font-size: 1rem !important;
  }

  /* Content width on mobile */
  #quarto-document-content,
  main.content {
    padding: 0 1rem !important;
  }

  /* Minimum touch targets for accessibility (44x44px) */
  .sidebar-item a,
  .sidebar-item-text {
    padding: 0.875rem 1.5rem !important;
    min-height: 44px !important;
  }

  #TOC a {
    padding: 0.75rem 0 !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
  }

  .nav-button {
    min-height: 44px !important;
    padding: 1rem 1.5rem !important;
  }
}
