/* ==========================================================================
   CSS Variables
   ========================================================================== */
   :root {
    /* Colors */
    --color-text: rgb(22, 23, 26);
    --color-background: #fff;
    --color-link: #000;
    --color-link-hover: #0073e6;
    --color-code-bg: rgb(236, 237, 238);
    --color-border: #edf2f7;
    --color-hr: #000;
    --color-blockquote-border: #ececec;
    --color-pagination-bg: #f0f0f0;
    --color-pagination-hover: #e0e0e0;
    --color-secondary-text: #666;
  
    /* Typography */
    --font-family-base: system-ui, sans-serif;
    --font-size-base: 1.125rem;
    --line-height-base: 1.6;
  }
  
  /* Dark mode overrides */
  @media (prefers-color-scheme: dark) {
    :root {
      --color-text: #e0e0e0;
      --color-background: #121212;
      --color-link: #8ab4f8;
      --color-hr: #444;
      --color-blockquote-border: #333;
      --color-code-bg: #333;
      --color-pagination-bg: #222;
      --color-pagination-hover: #333;
    }
  }
  
  /* ==========================================================================
     Reset and Base Styles
     ========================================================================== */
  
  /* Universal box-sizing and reset */
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    background-color: inherit;
    color: inherit;
    margin: 0;
    padding: 0;
  }
  
  /* Base typography and body styles */
  body {
    font-family: var(--font-family-base);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-background);
  }
  
  a {
    color: var(--color-link);
    text-decoration: underline;
    text-decoration-skip-ink: auto;
  }
  
  h1, h2, h3, h4, h5 {
    line-height: 1;
    margin: 1rem 0;
    font-weight: 600;
  }
  
  strong, b {
    font-weight: bold;
  }
  
  img {
    max-width: 100%;
  }
  
  hr {
    background: var(--color-hr);
    height: 1px;
    border: 0;
  }
  
  blockquote {
    font-style: italic;
    border-left: 5px solid var(--color-blockquote-border);
    padding-left: 1rem;
  }
  
  /* ==========================================================================
     Layout Components
     ========================================================================== */
  
  /* Header and Section */
  header,
  section {
    padding: 1rem;
  }
  
  header {
    flex-basis: 10rem;
    flex-grow: 1;
    position: relative;
  }
  
  header a {
    text-decoration: none;
  }
  
  header li {
    margin: 0.2rem 2rem 0 0;
    text-align: right;
  }
  
  header a.active {
    font-weight: bold;
  }
  
  /* Navigation and Lists */
  nav ul,
  .posts ul,
  header ul {
    list-style: none;
  }
  
  ul, ol {
    padding-left: 1em; /* Restore default indentation */
    list-style: disc;
  }
  
  /* Post and Project Elements */
  .post p {
    margin: 0.5rem 0;
  }
  
  .post h2:first-child,
  .project h2:first-child,
  .photo h2:first-child {
    margin-top: 0;
  }
  
  .meta {
    margin: 2rem 0;
  }
  
  /* Code Blocks */
  code {
    padding: 0.1rem;
    background: var(--color-code-bg);
  }
  
  pre {
    margin: 0.5rem 0;
    padding: 1rem;
    background: var(--color-code-bg);
    overflow-x: auto;
  }
  
  pre code {
    border: none;
  }
  
  /* Photos and Pictures */
  .photos ul {
    list-style: none;
    margin-top: 0.5rem;
  }
  
  .photos li {
    margin-bottom: 1.5rem;
  }
  
  .photo picture,
  .project picture {
    margin-bottom: 0.5rem;
  }
  
  /* Post list items */
  .posts li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    max-width: 90%;
  }
  
  .posts li a,
  .posts li div,
  .projects li a {
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .posts li time,
  .projects li time {
    padding-left: 1rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  
  .post ul,
  .project ul,
  .post ol {
    list-style-position: inside;
  }
  
  /* Main layout */
  main {
    display: flex;
    flex-wrap: wrap;
    max-width: 60rem;
    margin: 2rem auto;
    padding: 1rem;
  }
  
  section {
    flex-basis: 0;
    flex-grow: 999;
    min-width: 70%;
    display: flex;
    flex-direction: column;
  }
  
  figcaption {
    font-size: smaller;
  }
  
  /* ==========================================================================
     Recent sections (Publications / Notes)
     ========================================================================== */
  
  /* Container for both sections side-by-side on larger screens */
  .recent-sections {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    /* If you want them centered, uncomment:
       justify-content: center;
    */
  }
  
  /* Each column (publications or notes) shares the same max width */
  .recent-publications,
  .recent-notes {
    flex: 1;
    max-width: 300px; /* Adjust as needed for your layout */
  }
  
  /* Remove default list styling */
  .recent-publications ul,
  .recent-notes ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  /* Each item is stacked: date on top, title below */
  .recent-publications li,
  .recent-notes li {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem; /* spacing between items */
  }
  
  /* Date styling */
  .recent-publications li time,
  .recent-notes li time {
    display: block;         /* ensures the date is on its own line */
    margin-bottom: 0.25rem; /* small spacing before the title */
    font-size: 0.9em;
    color: var(--color-secondary-text);
  }
  
  /* Single-line truncation for titles on larger screens */
  .recent-publications li a,
  .recent-notes li a {
    display: inline-block;   /* required for text-overflow */
    width: 100%;
    white-space: nowrap;     /* prevents line wrapping */
    overflow: hidden;        /* hides overflow text */
    text-overflow: ellipsis; /* shows ellipsis when truncated */
  }
  
  /* Hover states */
  .recent-sections a {
    text-decoration: none;
    color: var(--color-link);
  }
  .recent-sections a:hover {
    text-decoration: underline;
  }
  
  /* ==========================================================================
     Pagination
     ========================================================================== */
  .pagination-links {
    display: flex;
    width: 100%;
    max-width: 90%;
    padding-top: 1.5rem;
    margin-top: 1rem;
  }
  
  .pagination-links a {
    text-decoration: none;
    padding: 0.25rem 0.55rem;
    background-color: var(--color-pagination-bg);
    border-radius: 6px;
  }
  
  .pagination-links a:hover {
    background-color: var(--color-pagination-hover);
  }
  
  .prev-link {
    margin-left: 0;
    text-align: left;
  }
  
  .next-link {
    margin-left: auto;
    text-align: right;
  }
  
  /* ==========================================================================
     Print Styles
     ========================================================================== */
  @media print {
    .no-print,
    .no-print * {
      display: none !important;
    }
  }
  
  /* ==========================================================================
     Additional Layout Components
     ========================================================================== */
  
  .search {
    margin-top: 20px;
  }
  
  .headshot {
    width: 172px;
    height: 200px;
    border-radius: 10%;
    object-fit: cover;
    margin: 0 auto;
  }
  
  .row {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: center;
    justify-content: center;
  }
  
  .photo-container {
    flex: 0 0 172px;
  }
  
  .text-container {
    flex: 1;
    min-width: 300px;
    text-align: left;
  }
  
  .card {
    padding: 20px;
  }
  
  .links {
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  
  /* ==========================================================================
     Responsive Styles
     ========================================================================== */
  
  /* For viewports up to 768px */
  @media (max-width: 768px) {
    h1 {
      font-size: 2rem;
    }
    h2 {
      font-size: 1.75rem;
    }
    h3 {
      font-size: 1.5rem;
    }
  
    /* Stack the recent-sections vertically */
    .recent-sections {
      flex-direction: column;
    }
    /* Let each section fill the width on mobile */
    .recent-publications,
    .recent-notes {
      max-width: 100%;
    }
    /* Remove single-line truncation so titles show fully on smaller screens */
    .recent-publications li a,
    .recent-notes li a {
      white-space: normal;
      overflow: visible;
      text-overflow: clip;
    }
  
    .row {
      flex-direction: column;
      text-align: center;
    }
  
    .headshot {
      margin-bottom: 20px;
    }
  
    .text-container {
      min-width: auto;
      width: 100%;
      text-align: center;
    }
  
    .links {
      align-items: center;
    }
  }
  
  /* For viewports up to 45rem (~720px) */
  @media screen and (max-width: 45rem) {
    header li {
      display: inline;
      margin-right: 1rem;
    }
  
    .logo {
      padding-bottom: 1rem;
    }
  
    header ul {
      border-right: 0;
      border-bottom: 1px solid var(--color-border);
      padding-bottom: 2rem;
    }
  
    nav ul {
      border-right: 0;
    }
  
    main {
      margin: 1rem auto;
      padding: 0.5rem;
    }
  
    header {
      flex-basis: 100%;
      padding: 0.5rem;
    }
  
    .posts li {
      flex-direction: column;
      align-items: flex-start;
      margin-bottom: 1rem;
    }
  
    .posts li time {
      padding-left: 0;
      padding-top: 0.25rem;
      order: -1;
      margin-bottom: 0.25rem;
    }
  
    .posts li a,
    .posts li div,
    .projects li a {
      white-space: normal;
      overflow-wrap: break-word;
      word-break: break-word;
      width: 100%;
    }
  }
  
  /* ==========================================================================
     Table of Contents Styles
     ========================================================================== */
  details.toc {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
    /* Optional: subtle shadow for depth */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  
  details.toc summary {
    padding: 0.5rem 0.75rem; /* Reduced padding */
    background-color: var(--color-code-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    list-style: none; /* Remove default marker */
    font-weight: bold;
  }
  
  /* Remove default disclosure triangle in WebKit */
  details.toc summary::-webkit-details-marker {
    display: none;
  }
  
  /* Arrow before the summary text */
  details.toc summary::before {
    content: '▶';
    margin-right: 0.5rem;
    transition: transform 0.3s ease;
  }
  
  /* Rotate arrow when open */
  details.toc[open] summary::before {
    transform: rotate(90deg);
  }
  
  details.toc .toc-content {
    padding: 0.75rem; /* Slightly less padding */
    background: var(--color-background);
    animation: fadeIn 0.3s ease-in;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  