/* =============================================================================
   TUFTE CSS BASE STYLES
   ============================================================================= */

html {
  font-size: 15px;
}

body {
  width: 87.5%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 12.5%;
  font-family: et-book, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
  background-color: #fffff8;
  color: #111;
  max-width: 1400px;
  counter-reset: sidenote-counter;
}

/* Headers */
h1, h2, h3 {
  font-weight: 400;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
  line-height: 1;
}

h1 { 
  margin-top: 5rem; 
}

/* Main content */
#quarto-content {
  padding-left: 0;
  padding-right: 0;
}

p {
  margin-top: 1.4rem;
  margin-bottom: 1.4rem;
  padding-right: 0;
  vertical-align: baseline;
}

/* =============================================================================
   SIDENOTES AND MARGIN NOTES
   ============================================================================= */

.sidenote,
.marginnote,
.column-margin,
.no-row-height.column-margin {
  float: right;
  clear: right;
  margin-right: -70%;
  width: 300px;
  margin-top: 0.3rem;
  margin-bottom: 0;
  font-size: 0.9rem;
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;
}

.sidenote-number {
  counter-increment: sidenote-counter;
}

.sidenote-number:after,
.sidenote:before {
  font-family: et-book-roman-old-style;
  position: relative;
  vertical-align: baseline;
}

.sidenote-number:after {
  content: counter(sidenote-counter);
  font-size: 1rem;
  top: -0.5rem;
  left: 0.1rem;
}

.sidenote:before {
  content: counter(sidenote-counter) " ";
  font-size: 1rem;
  top: -0.5rem;
}

/* Footnotes as sidenotes */
.footnote-ref {
  text-decoration: none;
  background: none;
  color: inherit;
  vertical-align: super;
  font-size: 0.8em;
}

/* =============================================================================
   QUARTO SIDEBAR POSITIONING (Desktop only)
   ============================================================================= */

@media (min-width: 769px) {
  body {
    margin-left: 150px;
  }

  #quarto-sidebar,
  #quarto-margin-sidebar {
    position: fixed !important;
    left: 20px !important;
    top: 5rem !important;
    width: 240px !important;
    max-height: calc(100vh - 5rem) !important;
    background: #fffff8 !important;
    border: none !important;
    padding: 1rem !important;
    z-index: 1000 !important;
  }

  #quarto-margin-sidebar {
    left: 150px !important;
  }

  /* Adjust main content positioning for desktop */
  main.content.page-columns.page-full {
    margin-left: 30px;
    padding-left: 0;
    padding-right: 30px;
    max-width: 900px;
  }

  #quarto-document-content {
    margin-left: -6em;
  }
}

/* Hide duplicate "On this page" TOC toggle dropdown */
#quarto-toc-toggle {
  display: none !important;
}

/* =============================================================================
   QUARTO-SPECIFIC FIXES
   ============================================================================= */

.quarto-title-block {
  margin-bottom: 3rem;
}

.listing-container {
  margin-top: 2rem;
}

/* Hide author in listings */
.listing-item .listing-author,
.quarto-listing .listing-author {
  display: none;
}

/* =============================================================================
   GISCUS COMMENTS STYLING
   ============================================================================= */

.giscus {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid #ccc;
}

.giscus-frame {
  border: none;
  width: 100%;
  background: transparent;
}

/* Ensure comments don't interfere with sidenotes on desktop */
@media (min-width: 769px) {
  .giscus {
    padding-right: 12.5%;
  }
}

/* =============================================================================
   MOBILE RESPONSIVE DESIGN (Mobile First Approach)
   ============================================================================= */

@media (max-width: 768px) {
  /* Reset body margins and padding for mobile */
  body {
    width: 95%;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 2.5%;
    padding-right: 2.5%;
    max-width: none;
    font-size: 16px;
    line-height: 1.5;
  }
  
  /* Reset main content margins */
  #quarto-content,
  #quarto-document-content,
  main.content.page-columns.page-full {
    margin: 0 !important;
    margin-left: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  /* Stack sidenotes as blocks on mobile */
  .sidenote,
  .marginnote,
  .column-margin,
  .no-row-height.column-margin {
    float: none !important;
    width: 100% !important;
    margin: 1rem 0 !important;
    margin-right: 0 !important;
    padding: 1rem !important;
    background: #f8f8f8;
    border-left: 3px solid #ccc;
    font-size: 0.9rem;
    display: block !important;
    position: static !important;
  }
  
  /* Hide sidebar TOC on mobile */
  .sidebar-toc,
  #quarto-sidebar,
  #quarto-margin-sidebar,
  #quarto-sidebar-toc-left {
    display: none !important;
  }
  
  /* Adjust headers for mobile */
  h1 { 
    font-size: 1.8rem; 
    margin-top: 2rem;
  }
  h2 { 
    font-size: 1.4rem; 
    margin-top: 1.5rem;
  }
  h3 { 
    font-size: 1.2rem; 
    margin-top: 1rem;
  }
  
  /* Better navigation on mobile */
  .navbar-nav {
    text-align: center;
  }
  
  /* Ensure tables are responsive */
  table {
    font-size: 0.8rem;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
  }

  /* Reset any column margins that might affect mobile */
  .no-row-height.column-margin.column-container {
    margin-left: 0 !important;
  }

  /* Ensure content spans full width on mobile */
  .page-columns {
    display: block !important;
    width: 100% !important;
  }

  /* Fix Giscus comments on mobile */
  .giscus {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
}

/* =============================================================================
   TABLET ADJUSTMENTS
   ============================================================================= */

@media (min-width: 769px) and (max-width: 1024px) {
  body {
    width: 90%;
    padding-left: 5%;
    margin-left: 100px; /* Reduced from 150px for tablets */
  }
  
  .sidenote,
  .marginnote,
  .column-margin {
    width: 35%;
    margin-right: -40%;
  }

  /* Adjust sidebar width for tablets */
  #quarto-sidebar,
  #quarto-margin-sidebar {
    width: 200px !important;
  }

  main.content.page-columns.page-full {
    margin-left: 20px;
    max-width: 800px;
  }
}/* Tufte CSS - simplified version */
html {
  font-size: 15px;
}

body {
  width: 87.5%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 12.5%;
  font-family: et-book, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
  background-color: #fffff8;
  color: #111;
  max-width: 1400px;
  counter-reset: sidenote-counter;
}

/* Headers */
h1, h2, h3 {
  font-weight: 400;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
  line-height: 1;
}

h1 { margin-top: 5rem; }

/* Main content */
#quarto-content {
  padding-left: 0;
  padding-right: 0;
}

/* TOC styling */
.sidebar-toc {
  position: fixed;
  left: 0;
  top: 0;
  width: 250px;
  height: 100vh;
  overflow-y: auto;
  background: #fefefe;
  padding: 2rem 1rem;
  border-right: 1px solid #ccc;
}

/* Sidenotes and margin notes */
.sidenote,
.marginnote {
  float: right;
  clear: right;
  margin-right: -60%;
  width: 50%;
  margin-top: 0.3rem;
  margin-bottom: 0;
  font-size: 1.1rem;
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;
}

.sidenote-number {
  counter-increment: sidenote-counter;
}

.sidenote-number:after,
.sidenote:before {
  font-family: et-book-roman-old-style;
  position: relative;
  vertical-align: baseline;
}

.sidenote-number:after {
  content: counter(sidenote-counter);
  font-size: 1rem;
  top: -0.5rem;
  left: 0.1rem;
}

.sidenote:before {
  content: counter(sidenote-counter) " ";
  font-size: 1rem;
  top: -0.5rem;
}

/* Footnotes as sidenotes */
.footnote-ref {
  text-decoration: none;
  background: none;
  color: inherit;
  vertical-align: super;
  font-size: 0.8em;
}

/* Responsive - Mobile First */
@media (max-width: 768px) {
  body {
    width: 95%;
    padding: 0 2.5%;
    max-width: none;
    font-size: 16px;
    line-height: 1.5;
  }
  
  /* Reset main content margins */
  #quarto-content {
    margin: 0;
    padding: 1rem;
  }
  
  /* Hide/stack sidenotes */
  .sidenote,
  .marginnote {
    float: none;
    width: 100%;
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f8f8;
    border-left: 3px solid #ccc;
    font-size: 0.9rem;
  }
  
  /* Hide sidebar TOC on mobile */
  .sidebar-toc,
  #quarto-sidebar-toc-left {
    display: none !important;
  }
  
  /* Adjust headers for mobile */
  h1 { 
    font-size: 1.8rem; 
    margin-top: 2rem;
  }
  h2 { 
    font-size: 1.4rem; 
    margin-top: 1.5rem;
  }
  h3 { 
    font-size: 1.2rem; 
    margin-top: 1rem;
  }
  
  /* Better navigation on mobile */
  .navbar-nav {
    text-align: center;
  }
  
  /* Ensure tables are responsive */
  table {
    font-size: 0.8rem;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    width: 90%;
    padding-left: 5%;
  }
  
  .sidenote,
  .marginnote {
    width: 35%;
    margin-right: -40%;
  }
}

/* Fix Quarto-specific elements */
.quarto-title-block {
  margin-bottom: 3rem;
}

.listing-container {
  margin-top: 2rem;
}

p {
  margin-top: 1.4rem;
  margin-bottom: 1.4rem;
  padding-right: 0;
  vertical-align: baseline;
}/* =============================================================================
   TUFTE CSS BASE STYLES
   ============================================================================= */

html {
  font-size: 15px;
}

body {
  width: 87.5%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 12.5%;
  font-family: et-book, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
  background-color: #fffff8;
  color: #111;
  max-width: 1400px;
  counter-reset: sidenote-counter;
}

/* Headers */
h1, h2, h3 {
  font-weight: 400;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
  line-height: 1;
}

h1 { 
  margin-top: 5rem; 
}

/* Main content */
#quarto-content {
  padding-left: 0;
  padding-right: 0;
}

p {
  margin-top: 1.4rem;
  margin-bottom: 1.4rem;
  padding-right: 0;
  vertical-align: baseline;
}

/* =============================================================================
   SIDENOTES AND MARGIN NOTES
   ============================================================================= */

.sidenote,
.marginnote,
.column-margin,
.no-row-height.column-margin {
  float: right;
  clear: right;
  margin-right: -70%;
  width: 300px; /* Fixed width of 300px as requested */
  margin-top: 0.3rem;
  margin-bottom: 0;
  font-size: 0.9rem; /* Smaller than main text */
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;
}

.sidenote-number {
  counter-increment: sidenote-counter;
}

.sidenote-number:after,
.sidenote:before {
  font-family: et-book-roman-old-style;
  position: relative;
  vertical-align: baseline;
}

.sidenote-number:after {
  content: counter(sidenote-counter);
  font-size: 1rem;
  top: -0.5rem;
  left: 0.1rem;
}

.sidenote:before {
  content: counter(sidenote-counter) " ";
  font-size: 1rem;
  top: -0.5rem;
}

/* Footnotes as sidenotes */
.footnote-ref {
  text-decoration: none;
  background: none;
  color: inherit;
  vertical-align: super;
  font-size: 0.8em;
}

/* =============================================================================
   QUARTO SIDEBAR POSITIONING (for TOC and "Other Formats")
   ============================================================================= */

#quarto-sidebar,
#quarto-margin-sidebar {
  position: fixed !important;
  left: 20px !important;
  top: 5rem !important;
  width: 240px !important;
  max-height: calc(100vh - 5rem) !important;
  background: #fffff8 !important;
  border: none !important;
  padding: 1rem !important;
  z-index: 1000 !important;
}

/* Hide duplicate "On this page" TOC toggle dropdown */
#quarto-toc-toggle {
  display: none !important;
}

/* Adjust main content positioning and spacing - CORRECTED */
main.content.page-columns.page-full {
  margin-left: 30px;   /* Move content AWAY from right, closer to left */
  padding-left: -20px; /* Reduce left padding */
  padding-right: 30px;
  max-width: 900px;    /* Constrain content width */
}

/* Adjust body margin to make room for left sidebar */
body {
  margin-left: 150px;
}

#quarto-margin-sidebar{
    left:150px !important;
}

no-row-height column-margin column-container {
    margin-left: 30px;
}

/* =============================================================================
   QUARTO-SPECIFIC FIXES
   ============================================================================= */

.quarto-title-block {
  margin-bottom: 3rem;
}

.listing-container {
  margin-top: 2rem;
}

/* Hide author in listings */
.listing-item .listing-author,
.quarto-listing .listing-author {
  display: none;
}

#quarto-document-content {
    margin-left: -6em;
}

/* =============================================================================
   GISCUS COMMENTS STYLING
   ============================================================================= */

.giscus {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid #ccc;
}

.giscus-frame {
  border: none;
  width: 100%;
  background: transparent;
}

/* Ensure comments don't interfere with sidenotes */
@media (min-width: 760px) {
  .giscus {
    padding-right: 12.5%;
  }
}

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

@media (max-width: 760px) {
  body {
    width: 84%;
    margin-left: auto;
    padding-left: 8%;
    padding-right: 8%;
  }
  
  .sidenote,
  .marginnote,
  .column-margin,
  .no-row-height.column-margin {
    display: none;
  }
  
  .margin-toggle:checked + .sidenote,
  .margin-toggle:checked + .marginnote {
    display: block;
    float: left;
    left: 1rem;
    clear: both;
    width: 95%;
    margin: 1rem 2.5%;
    vertical-align: baseline;
    position: relative;
  }
  
  .giscus {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
}
