/* ===== Blog Post Layout ===== */

/* 3-column grid: TOC | content | sidenote gutter */
.blog-post {
  display: grid;
  grid-template-columns: 1fr 200px 30px 680px 50px 240px 1fr;
  align-content: start;
  padding-top: 150px; /* generous space above title (nav is ~90px) */
  padding-bottom: 80px;
  min-height: 100vh;
}

/* Header spans content column */
.blog-header {
  grid-column: 4 / 5;
  margin-bottom: 0;
}

.blog-header h1 {
  font-family: Manrope, sans-serif;
  font-size: 2.2em;
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 10px;
  color: #1a1a1a;
}

.blog-subtitle {
  font-size: 1.05em;
  line-height: 1.5;
  color: #555;
  margin: 0;
}

/* Author list in meta bar (full-width line below date/links) */
.blog-meta-authors {
  width: 100%;
  font-family: Manrope, sans-serif;
  font-size: 14px;
  color: #555;
  line-height: 1.5;
  margin-top: 2px;
}

.blog-meta-authors .equal-note {
  font-size: 12px;
  color: #888;
}

/* Cover image at top of blog content */
.blog-cover {
  margin: 0 0 2em;
  text-align: center;
}

.blog-cover img {
  max-width: 100%;
  max-height: 260px;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
}

/* Horizontal dividers: span full page width (Distill-style) */
.blog-divider {
  grid-column: 1 / -1;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 28px 0;
}

/* Meta bar: date + simple text links */
.blog-meta {
  grid-column: 4 / 5;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: Manrope, sans-serif;
  font-size: 14px;
  color: #666;
  padding: 4px 0;
}

.blog-meta-info {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.blog-meta-thumb {
  width: 72px;
  height: auto;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: center;
}

.blog-meta a {
  color: #555;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

.blog-meta a:hover {
  color: #333;
}

.blog-meta-sep {
  color: #bbb;
  margin: 0 2px;
}

/* TOC: sticky left column */
.blog-toc {
  grid-column: 2 / 3;
  grid-row: span 2; /* span content + citation rows */
  position: sticky;
  top: 110px;
  align-self: start;
  padding-top: 32px; /* align with first h2 */
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}

.blog-toc h2 {
  font-family: Manrope, sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin: 0 0 12px;
}

.blog-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.blog-toc li {
  margin-bottom: 6px;
}

.blog-toc a {
  font-family: Manrope, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: #888;
  text-decoration: none;
  display: block;
  padding: 2px 0 2px 10px;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.blog-toc a:hover {
  color: #555;
}

.blog-toc a.active {
  color: #7a3535;
  border-left-color: #7a3535;
  font-weight: 600;
}

/* Mobile TOC toggle button (hidden on desktop) */
.blog-toc-toggle {
  display: none;
}

/* Content column */
.blog-content {
  grid-column: 4 / 5;
  font-family: Manrope, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #333;
}

.blog-content section {
  scroll-margin-top: 110px;
  margin-bottom: 20px;
}

.blog-content h2 {
  font-family: Manrope, sans-serif;
  font-size: 1.5em;
  font-weight: 700;
  margin: 68px 0 24px;
  color: #1a1a1a;
  scroll-margin-top: 110px;
}

.blog-content h2:first-child {
  margin-top: 32px;
}

.blog-content p {
  margin: 0 0 1.1em;
}

/* Ordered/unordered lists */
.blog-content ol,
.blog-content ul {
  margin: 0 0 1.1em;
  padding-left: 1.5em;
}

.blog-content li {
  margin-bottom: 0.6em;
}

/* Blockquotes (Workshop Labs style) */
.blog-content blockquote {
  border-left: 2px solid #7a3535;
  padding-left: 1.25em;
  margin: 1.5em 0;
  font-style: italic;
  opacity: 0.85;
}

.blog-content blockquote p {
  margin: 0;
}

.blog-content strong {
  font-weight: 700;
}

.blog-content em {
  font-style: italic;
}

/* Inline links in content */
.blog-content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(0, 0, 0, 0.35);
  transition: text-decoration-color 0.15s ease;
}

.blog-content a:hover {
  text-decoration-color: rgba(0, 0, 0, 0.8);
}

/* Sidenotes (Tufte-style, float into right gutter) */
.blog-sidenote {
  float: right;
  clear: right;
  width: 240px;
  margin-right: calc(-240px - 50px);
  margin-bottom: 16px;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #777;
}

.blog-sidenote-number {
  font-size: 11px;
  font-weight: 700;
  color: #7a3535;
  vertical-align: super;
  margin-right: 2px;
}

/* Sidenote reference in text */
.blog-sidenote-ref {
  font-size: 11px;
  font-weight: 700;
  color: #7a3535;
  vertical-align: super;
  cursor: default;
}

/* Figures: contained within text column */
.blog-figure {
  margin: 2em 0 2.5em;
  text-align: center;
}

.blog-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
}

/* Lightbox overlay for expanded figures */
.blog-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.blog-lightbox.is-visible {
  opacity: 1;
}

.blog-lightbox-card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
}

.blog-lightbox-card img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

.blog-lightbox-caption {
  margin-top: 14px;
  font-family: Manrope, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 90%;
}

/* Smaller figure variant */
.blog-figure-sm img {
  max-width: 75%;
}

.blog-figure figcaption {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

/* Citation section */
.blog-citation {
  grid-column: 4 / 5;
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  scroll-margin-top: 110px;
}

.blog-citation h2 {
  font-family: Manrope, sans-serif;
  font-size: 1.2em;
  font-weight: 700;
  margin: 0 0 12px;
  color: #1a1a1a;
}

.blog-citation-text {
  font-size: 14px;
  line-height: 1.6;
  color: #555;
  margin-bottom: 16px;
}

/* BibTeX block */
.blog-bibtex-wrapper {
  position: relative;
}

.blog-bibtex {
  background-color: #f0e6d0;
  border-radius: 6px;
  padding: 14px 18px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: #4a3d2e;
  white-space: pre;
  overflow-x: auto;
  margin: 0;
}

.blog-bibtex-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  color: #998675;
  border: none;
  padding: 6px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.blog-bibtex-copy:hover {
  color: #4a3d2e;
  background-color: rgba(0, 0, 0, 0.06);
}

/* ===== Breakpoint: ≤1100px — sidenotes inline ===== */
@media screen and (max-width: 1100px) {
  .blog-post {
    grid-template-columns: 1fr 180px 30px minmax(0, 600px) 1fr;
    padding-top: 140px;
  }

  .blog-header,
  .blog-meta,
  .blog-content,
  .blog-citation {
    grid-column: 4 / 5;
  }

  .blog-toc {
    grid-column: 2 / 3;
  }

  .blog-divider {
    grid-column: 1 / -1;
  }

  /* Sidenotes become inline callout boxes */
  .blog-sidenote {
    float: none;
    width: auto;
    margin: 12px 0 18px;
    padding: 12px 16px;
    background-color: rgba(226, 213, 195, 0.3);
    border-left: 3px solid #e2d5c3;
    border-radius: 0 4px 4px 0;
    font-size: 14px;
    color: #666;
  }
}

/* ===== Breakpoint: ≤767px — single column, TOC hidden ===== */
@media screen and (max-width: 767px) {
  .blog-post {
    display: block;
    padding: 100px 6% 60px;
  }

  .blog-header h1 {
    font-size: 1.8em;
  }

  .blog-meta-thumb {
    width: 56px;
  }

  .blog-content {
    font-size: 15px;
  }

  .blog-content h2 {
    font-size: 1.3em;
    margin-top: 40px;
    scroll-margin-top: 80px;
  }

  .blog-content section {
    scroll-margin-top: 80px;
  }

  .blog-figure-sm img {
    max-width: 100%;
  }

  /* TOC: hidden by default, toggle button shows it */
  .blog-toc {
    position: static;
    max-height: none;
    display: none;
    margin-bottom: 24px;
    padding: 16px;
    background-color: rgba(226, 213, 195, 0.3);
    border-radius: 6px;
  }

  .blog-toc.is-open {
    display: block;
  }

  .blog-toc-toggle {
    display: inline-block;
    margin-bottom: 16px;
    background-color: #e2d5c3;
    color: #4a3d2e;
    border: none;
    border-radius: 4px;
    padding: 6px 14px;
    font-family: Manrope, sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
  }

  .blog-toc-toggle:hover {
    background-color: #d4c4ad;
  }

  /* Sidenotes inline */
  .blog-sidenote {
    float: none;
    width: auto;
    margin: 12px 0 18px;
    padding: 12px 16px;
    background-color: rgba(226, 213, 195, 0.3);
    border-left: 3px solid #e2d5c3;
    border-radius: 0 4px 4px 0;
    font-size: 14px;
    color: #666;
  }

  .blog-citation {
    margin-top: 36px;
    scroll-margin-top: 80px;
  }

  .blog-bibtex {
    font-size: 10px;
    white-space: pre-wrap;
    word-break: break-word;
  }
}

/* ===== Breakpoint: ≤479px — compact ===== */
@media screen and (max-width: 479px) {
  .blog-post {
    padding: 80px 5% 40px;
  }

  .blog-header h1 {
    font-size: 1.5em;
  }

  .blog-meta {
    font-size: 12px;
  }

  .blog-subtitle {
    font-size: 1em;
  }

  .blog-content {
    font-size: 14px;
  }

  .blog-content h2 {
    font-size: 1.2em;
    scroll-margin-top: 60px;
  }

  .blog-content section {
    scroll-margin-top: 60px;
  }

  .blog-citation {
    scroll-margin-top: 60px;
  }

  .blog-bibtex {
    font-size: 9px;
    padding: 10px 12px;
  }
}
