/* Article/Prose Typography Styles */

.prose {
  max-width: 720px;
  margin: 0 auto;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  color: var(--text-light);
  line-height: 1.3;
  margin-top: 2em;
  /*margin-bottom: 0.75em;*/
}

.prose h1 {
  /*font-size: clamp(1.75rem, 4vw, 2.5rem);*/
  margin-top: 0;
}

.prose h2 {
  font-size: clamp(1.4rem, 3vw, 1.875rem);
}

.prose h3 {
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
}

.prose p {
  margin-bottom: 1.5em;
  line-height: 1.8;
  color: var(--text-muted);
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  transition: color 0.2s ease;
}

.prose a:hover {
  color: var(--text-light);
}

.prose strong {
  color: var(--text-light);
  font-weight: 600;
}

.prose em {
  color: var(--text-light);
  font-style: italic;
}

.prose blockquote {
  margin: 2em 0;
  padding: 1em 1.5em;
  border-left: 3px solid var(--accent-glow);
  background: var(--surface-dark-subtle);
  border-radius: 0 8px 8px 0;
}

.prose blockquote p {
  margin-bottom: 0;
  color: var(--text-strong);
}

.prose ul,
.prose ol {
  margin: 1.5em 0;
  padding-left: 1.5em;
  color: var(--text-muted);
}

.prose li {
  margin-bottom: 0.5em;
  line-height: 1.7;
}

.prose ul li::marker {
  color: var(--accent);
}

.prose ol li::marker {
  color: var(--accent);
  font-weight: 600;
}

.prose code {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--surface-dark-subtle);
  border-radius: 4px;
  color: var(--accent);
  word-break: break-word;
}

.prose pre {
  margin: 2em 0;
  padding: 1.25em 1.5em;
  background: rgba(16, 16, 24, 0.8);
  border: 1px solid var(--accent-glow);
  border-radius: 12px;
  overflow-x: auto;
}

.prose pre code {
  padding: 0;
  background: transparent;
  color: var(--text-light);
  font-size: 0.875em;
  line-height: 1.6;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 2em 0;
}

.prose hr {
  margin: 3em 0;
  border: none;
  height: 1px;
  background: var(--accent-glow);
}

/* Tables */
.prose table {
  width: 100%;
  margin: 2em 0;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--accent-glow);
  border-radius: 12px;  
}

.prose th,
.prose td {
  padding: 0.75em 1em;
  text-align: left;
  border-bottom: 1px solid var(--accent-faint);
}

.prose th {
  color: var(--text-light);
  font-weight: 600;
  background: var(--surface-dark-subtle);
}

.prose td {
  color: var(--text-muted);
}

.prose tr:hover td {
  background: rgba(234, 160, 28, 0.05);
}

/* Keyboard shortcuts */
.prose kbd {
  display: inline-block;
  padding: 0.2em 0.5em;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.85em;
  color: var(--text-light);
  background: var(--surface-medium);
  border: 1px solid var(--accent-faint);
  border-radius: 4px;
  box-shadow: 0 2px 0 var(--shadow-soft);
}

/* Definition lists */
.prose dl {
  margin: 2em 0;
}

.prose dt {
  color: var(--text-light);
  font-weight: 600;
  margin-top: 1.5em;
}

.prose dt:first-child {
  margin-top: 0;
}

.prose dd {
  margin: 0.5em 0 0 1.5em;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Post header styles */
.post-header {
  margin-bottom: 3em;
  padding-bottom: 2em;
  border-bottom: 1px solid var(--accent-glow);
}

.post-title {
  margin-bottom: 0.5em;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em 1.5em;
  font-size: 0.9rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.post-date,
.post-author,
.post-reading-time {
  display: inline-flex;
  align-items: center;
}

.post-date::before,
.post-updated::before,
.post-reading-time::before {
  content: "\00B7";
  margin-right: 1.5em;
  color: var(--accent);
}

.post-updated {
  display: inline-flex;
  align-items: center;
  color: var(--text-faint);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 1.2em;
  margin-bottom: 1.2em;
}

.post-tag {
  display: inline-block;
  padding: 0.25em 1.25em;
  font-size: 0.75rem;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-strong);
  background: var(--surface-dark-subtle);
  border: 1px solid var(--accent-faint);
  border-radius: 20px;
  transition: all 0.2s ease;
}

.post-tag--ai {
  color: var(--accent);
  border-color: var(--accent-glow);
}

.post-tag--engineering {
  color: #98c379;
  border-color: rgba(152, 195, 121, 0.35);
}

.post-tag--formal-methods {
  color: #c678dd;
  border-color: rgba(198, 120, 221, 0.35);
}

.post-tag--announcement {
  color: #61afef;
  border-color: rgba(97, 175, 239, 0.35);
}

.post-excerpt {
  margin-top: 1.25em;
  font-size: 1em !important;
  line-height: 1.7;
  color: var(--text-muted);
  font-style: italic;
}

/* Heading wrappers (for clickable headings) */
.heading-wrapper {
  cursor: pointer;
}

.heading-wrapper h2,
.heading-wrapper h3,
.heading-wrapper h4 {
  margin-top: 0;
}

/* Hide anchor visually but keep for accessibility */
.heading-anchor {
  display: none;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==================== */
/* Post Layout with TOC */
/* ==================== */

.post-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 1200px;
  padding: 0.85rem 1.75rem;
  margin: 0 auto;
  overflow: visible;
}

@media (min-width: 1100px) {
  .post-layout {
    grid-template-columns: 280px 1fr;
    gap: 3rem;
  }
}

.post-main {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.post-content {
  overflow-x: hidden;
  max-width: 100%;
}

/* TOC Sidebar (Desktop) */
.toc-sidebar {
  display: none;
}

@media (min-width: 1100px) {
  .toc-sidebar {
    display: block;
    position: sticky;
    top: 2rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
  }

  .toc-sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .toc-sidebar::-webkit-scrollbar-track {
    background: transparent;
  }

  .toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-faint);
    border-radius: 2px;
  }

  .toc-wrapper {
    padding-right: 1rem;
  }
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-faint);
  margin: 0 0 1em;
  padding-bottom: 0.75em;
  border-bottom: 1px solid var(--accent-faint);
}

/* TOC nav styles */
.toc {
  font-size: 0.85rem;
  line-height: 1.5;
}

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

.toc li {
  margin: 0;
}

.toc > ul > li {
  margin-bottom: 0.5em;
}

.toc a {
  display: block;
  padding: 0.35em 0;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 0.75em;
  transition: all 0.2s ease;
}

.toc a:hover {
  color: var(--text-light);
  border-left-color: var(--accent-glow);
}

.toc a[data-active="true"] {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Nested TOC (h3 items) */
.toc ul ul {
  margin-left: 0.75em;
}

.toc ul ul a {
  font-size: 0.9em;
  color: var(--text-faint);
}

.toc ul ul a:hover {
  color: var(--text-muted);
}

.toc ul ul a[data-active="true"] {
  color: var(--accent-soft);
}

/* Mobile TOC */
.toc-mobile {
  display: block;
  margin-bottom: 2em;
  border: 1px solid var(--accent-faint);
  border-radius: 8px;
  background: var(--surface-dark-subtle);
}

@media (min-width: 1100px) {
  .toc-mobile {
    display: none;
  }
}

.toc-mobile__toggle {
  display: flex;
  align-items: center;
  gap: 0.5em;
  width: 100%;
  padding: 0.85em 1em;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  list-style: none;
}

.toc-mobile__toggle::-webkit-details-marker {
  display: none;
}

.toc-mobile__icon {
  display: flex;
  color: var(--accent);
}

.toc-mobile__chevron {
  display: flex;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.toc-mobile[open] .toc-mobile__chevron {
  transform: rotate(180deg);
}

.toc-mobile__content {
  padding: 0 1em 1em;
}

.toc-mobile__content .toc a {
  padding: 0.5em 0.75em;
}

/* Featured image in post */
.post-featured-image {
  margin: 0 0 2rem;
}

.post-featured-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0 !important;
}

.post-featured-image figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-faint);
  text-align: center;
}

/* Inline Spline embed */
.spline-embed {
  margin: 2em 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--accent-glow);
  background: var(--surface-dark-subtle);
}

.spline-embed spline-viewer {
  display: block;
  width: 100%;
  height: 100%;
}

/* Featured Spline */
.post-featured-spline {
  margin: 0 0 2rem;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--accent-glow);
  background: var(--surface-dark-subtle);
}

.post-featured-spline spline-viewer {
  display: block;
  width: 100%;
  height: 100%;
}

.post-featured-spline figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-faint);
  text-align: center;
}

/* Blog listing 3D badge */
.blog-list__image-link--3d {
  position: relative;
}

.blog-list__3d-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25em 0.6em;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  background: rgba(234, 160, 28, 0.9);
  border-radius: 4px;
}

/* Blog index styles */
.blog-list {
  list-style: none;
  padding: 0;
  margin: 2em 0;
}

.blog-list__item {
  margin-bottom: 2em;
  padding-bottom: 2em;
  border-bottom: 1px solid var(--accent-faint);
}

.blog-list__item:last-child {
  border-bottom: none;
}

/* Blog listing with images */
.blog-list__item.has-image {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .blog-list__item.has-image {
    grid-template-columns: 280px 1fr;
  }
}

.blog-list__image-link {
  display: block;
  border: 1px solid var(--accent-glow);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  background: var(--surface-dark-subtle);
}

.blog-list__image-link picture {
  display: block;
  width: 100%;
  height: 100%;
}

.blog-list__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.blog-list__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.blog-list__content {
  min-width: 0;
}

.blog-list__title {
  margin: 0 0 0.5em;
  font-size: 1.35rem;
}

.blog-list__title a {
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.2s ease;
}

.blog-list__title a:hover {
  color: var(--accent);
}

.blog-list__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em 1em;
  font-size: 0.9rem;
  color: var(--text-faint);
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;

}

.blog-list__author::after,
.blog-list__reading-time::before {
  content: "\00B7";
  margin-left: 1em;
  color: var(--accent);
}

.blog-list__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em;
}

@media (max-width: 768px) {
  .blog-list__tags {
    margin-top: 0.75em;
  }
}

.blog-list__excerpt {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

/* Optimized images (picture element) */
.prose picture {
  display: block;
}

.prose picture img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--accent-glow);
}

/* Related posts section */
.related-posts {
  margin-top: 4em;
  padding-top: 2em;
  border-top: 1px solid var(--accent-glow);
}

.related-posts__title {
  font-size: 1.1rem !important;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 1em;
}

.related-posts__list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 1em;
}

.related-posts__item a {
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.2s;
}

.related-posts__item a:hover {
  color: var(--accent);
}

.related-posts__item time {
  display: block;
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* Blog header with search */
.blog-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5em;
  margin-bottom: 2em;
}

.blog-header__text {
  flex: 1 1 auto;
}

.blog-header__text .section-heading {
  margin-bottom: 0.5em;
}

.blog-header__text .section-intro {
  margin-bottom: 0;
}

/* Blog search */
.blog-search {
  position: relative;
  flex: 0 1 280px;
}

.blog-search input {
  width: 100%;
  padding: 0.65em 1em;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-light);
  background: var(--surface-dark-subtle);
  border: 1px solid var(--accent-faint);
  border-radius: 20px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.blog-search input::placeholder {
  color: var(--text-faint);
}

.blog-search input:focus {
  border-color: var(--accent-glow);
  box-shadow: 0 0 0 3px rgba(234, 160, 28, 0.1);
}

.search-results {
  position: absolute;
  top: calc(100% + 0.5em);
  left: 0;
  right: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--accent-glow);
  border-radius: 12px;
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 100;
}

.search-results.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.search-results__item {
  display: block;
  padding: 0.75em 1em;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-faint);
  transition: background 0.2s;
}

.search-results__item:last-child {
  border-bottom: none;
}

.search-results__item:hover {
  background: rgba(234, 160, 28, 0.1);
}

.search-results__title {
  display: block;
  color: var(--text-light);
  font-size: 0.9rem;
  font-weight: 500;
}

.search-results__tags {
  display: block;
  color: var(--text-faint);
  font-size: 0.75rem;
  margin-top: 0.25em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-results__empty {
  padding: 1em;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .blog-header {
    flex-direction: column;
  }

  .blog-search {
    width: 100%;
    flex: 1 1 100%;
  }
}

/* Print styles */
@media print {
  /* Hide non-essential elements */
  .site-header,
  .site-footer,
  .toc-sidebar,
  .toc-mobile,
  .blog-search,
  .search-results,
  .related-posts,
  .post-tags,
  .heading-anchor {
    display: none !important;
  }

  /* Reset backgrounds and colors for print */
  body {
    background: white !important;
    color: black !important;
  }

  .page-shell,
  .content-section,
  .prose,
  .post-main,
  .post-content {
    background: transparent !important;
    color: black !important;
  }

  /* Typography optimizations */
  .prose {
    max-width: 100%;
    font-size: 12pt;
    line-height: 1.5;
  }

  .prose h1,
  .prose h2,
  .prose h3,
  .prose h4,
  .prose h5,
  .prose h6,
  .post-title {
    color: black !important;
    page-break-after: avoid;
  }

  .prose p,
  .prose li {
    color: #333 !important;
    orphans: 3;
    widows: 3;
  }

  /* Show URLs inline for links */
  .prose a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #666;
    word-break: break-all;
  }

  /* Don't show URL for internal/anchor links */
  .prose a[href^="#"]::after,
  .prose a[href^="/"]::after {
    content: "";
  }

  /* Code blocks */
  .prose pre {
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    page-break-inside: avoid;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .prose code {
    background: #f5f5f5 !important;
    color: #333 !important;
  }

  /* Images */
  .prose img,
  .prose picture,
  .post-featured-image {
    max-width: 100%;
    page-break-inside: avoid;
  }

  /* Post meta */
  .post-meta {
    color: #666 !important;
  }

  /* Blockquotes */
  .prose blockquote {
    border-left-color: #333 !important;
    background: transparent !important;
    page-break-inside: avoid;
  }

  /* Tables */
  .prose table {
    border-color: #333 !important;
  }

  .prose th,
  .prose td {
    border-color: #ddd !important;
    color: black !important;
  }

  .prose th {
    background: #f5f5f5 !important;
  }
}
