/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  /* font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; */
  font-family: 'Nunito Sans', sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-variation-settings:
    'wdth' 100,
    'YTLC' 500;
  color: #1a1a1a;
  background: #fff;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Homepage ---- */
.home {
  background: #000;
  overflow: hidden;
}

.home-bg {
  position: fixed;
  z-index: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.85;
}

/* ---- Site Header ---- */
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 0;
}

.home .site-header {
  max-width: none;
  padding: 2rem 2.5rem 0;
}

.home .site-header .site-title {
  /* color: #fff; */
  /* text-shadow: 0 1px 6px rgba(0,0,0,0.5); */
}

.home .site-header nav a {
  /* color: #fff; */
  /* text-shadow: 0 1px 6px rgba(0,0,0,0.5); */
}

.home .site-header nav a:hover {
  /* opacity: 0.7; */
}

.site-header .site-title {
  font-size: 0.9rem;
  font-weight: 400;
  color: #1a1a1a;
  text-decoration: none;
  letter-spacing: 0.06em;
}

.site-header nav {
  display: flex;
  gap: 2rem;
}

.site-header nav a {
  font-size: 0.9rem;
  color: #555;
  text-decoration: none;
  letter-spacing: 0.04em;
}

.site-header nav a:hover {
  color: #1a1a1a;
}

/* ---- Page Content (Writing index) ---- */
.page-content {
  max-width: 980px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.post-list {
  list-style: none;
  margin-top: 1rem;
}

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #eee;
}

.post-list li:last-child {
  border-bottom: none;
}

.post-list time {
  font-size: 0.78rem;
  color: #999;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.post-list a {
  font-size: 1rem;
  color: #1a1a1a;
  text-decoration: none;
}

.post-list a:hover {
  text-decoration: underline;
}

/* ---- Post ---- */
.post {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.post-header {
  margin-bottom: 2.5rem;
}

.post-header h1 {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1.3;
  color: #1a1a1a;
  margin-bottom: 0.4rem;
}

.post-header time {
  font-size: 0.82rem;
  color: #999;
}

/* ---- Project Archived Banner ---- */
.project-archived {
  display: flex;
  height: 50px;
  align-items: center; 
  font-size: 0.85rem;
  color: #d86500;
  background: #ffe6cf;
  border-left: 3px solid #d86500;
  padding: 0.6rem 1rem;
  margin-bottom: 2rem;
}

/* ---- Post Content Typography ---- */
.post-content h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 2.4rem;
  margin-bottom: 0.8rem;
  color: #1a1a1a;
}

.post-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  color: #1a1a1a;
}

.post-content p {
  margin-bottom: 1.2rem;
}

.post-content a {
  color: #1a1a1a;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover {
  color: #555;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.2rem;
  padding-left: 1.6rem;
}

.post-content li {
  margin-bottom: 0.3rem;
}

.post-content li > ul,
.post-content li > ol {
  margin-bottom: 0;
  margin-top: 0.3rem;
}

.post-content blockquote {
  border-left: 3px solid #ddd;
  padding-left: 1rem;
  color: #555;
  margin: 1.4rem 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 2rem 0;
}

.post-content code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: #f5f5f5;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.post-content pre {
  background: #f5f5f5;
  padding: 1.2rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.4rem;
  line-height: 1.5;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
}

.post-content strong {
  font-weight: 600;
}

.post-content img {
  display: block;
  margin: 1rem auto;
  max-width: 100%;  
  /* height: auto;
  border-radius: 4px; */
}

/* ---- Table of Contents ---- */
.toc-sidebar {
  margin-bottom: 1.5rem;
}

.toc-toggle {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  color: #888;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
}

.toc-toggle:hover {
  color: #1a1a1a;
  border-color: #ddd;
}

.toc {
  display: none;
  padding: 0.8rem 1rem 0;
}

.toc-sidebar.open .toc {
  display: block;
}

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

.toc li {
  margin-bottom: 0.35rem;
}

.toc li.toc-h3 {
  padding-left: 0.9rem;
}

.toc a {
  font-size: 0.75rem;
  color: #999;
  text-decoration: none;
  line-height: 1.5;
  display: block;
  transition: color 0.15s;
}

.toc a:hover {
  color: #1a1a1a;
}

.toc a.active {
  color: #1a1a1a;
}

/* Desktop TOC sidebar */
@media (min-width: 1100px) {
  .post.has-toc {
    max-width: 980px;
  }

  .post.has-toc article {
    display: grid;
    grid-template-columns: 700px 200px;
    column-gap: 3rem;
  }

  .post.has-toc .post-header {
    grid-column: 1;
    /* grid-row: 1; */
  }

  .post.has-toc .project-archived {
    grid-column: 1;
    grid-row: 2;
    margin-top: -30px;
  }

  .post.has-toc .post-content {
    grid-column: 1;
    grid-row: 2;
  }

  .post.has-toc .toc-sidebar {
    grid-column: 2;
    grid-row: 2;
    /* grid-row: 1 / -1; */
    position: sticky;
    top: 2rem;
    align-self: start;
    margin-bottom: 0;
    /* padding-top: 5rem; */
  }

  .toc-toggle {
    display: none;
  }

  .toc {
    display: block;
    padding: 0;
    border-left: 1px solid #eee;
    padding-left: 1rem;
  }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .site-header {
    padding: 1.5rem 1rem 0;
  }

  .post,
  .page-content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }

  .post-list li {
    flex-direction: column;
    gap: 0.2rem;
  }
}
