/* ============================================
   Blog Styles - extends the shared design language
   All colors/spacing come from tokens in ../styles.css
   ============================================ */

/* ----------------------------------------------------------
   Blog Post (Article Pages)
   ---------------------------------------------------------- */
.blog-post {
  max-width: var(--width);
  margin: 0 auto;
  padding: var(--s4) var(--s3) var(--s5);
}

.blog-header {
  margin-bottom: var(--s4);
  padding-bottom: var(--s3);
  border-bottom: 2px solid var(--line);
}

.blog-title {
  font-family: var(--serif);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: var(--s2);
  line-height: 1.3;
}

.post-metadata {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: var(--s1);
}

.post-metadata time {
  font-style: italic;
}

/* ----------------------------------------------------------
   Blog Content Typography
   ---------------------------------------------------------- */
.blog-content {
  line-height: 1.8;
  color: var(--ink);
}

.blog-content h2 {
  margin-top: var(--s4);
  margin-bottom: var(--s2);
  padding-bottom: var(--s1);
  border-bottom: 1px solid var(--line);
  font-size: 1.6rem;
}

.blog-content h3 {
  margin-top: var(--s3);
  margin-bottom: var(--s2);
  font-size: 1.2rem;
  color: var(--navy);
}

.blog-content h4 {
  margin-top: var(--s2);
  margin-bottom: var(--s1);
  font-size: 1.05rem;
}

.blog-content p {
  margin-bottom: var(--s2);
}

/* Code Blocks */
.blog-content pre {
  background: var(--bg-soft);
  border-left: 4px solid var(--teal);
  padding: var(--s2);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: var(--s2) 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.blog-content pre code {
  font-family: 'Monaco', 'Courier New', monospace;
  color: var(--ink);
}

/* Inline Code */
.blog-content code {
  background: var(--bg-soft);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: var(--navy);
}

.blog-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* Code Comparison Sections */
.code-before,
.code-after {
  margin-bottom: var(--s2);
}

.code-label {
  font-weight: 600;
  color: var(--teal);
  margin-bottom: var(--s1);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Callout/Note Boxes */
.callout,
.note-box {
  background: var(--bg-soft);
  border-left: 4px solid var(--navy);
  padding: var(--s2);
  border-radius: var(--radius);
  margin: var(--s3) 0;
}

.callout strong,
.note-box strong {
  color: var(--navy);
}

/* Lists */
.blog-content ul,
.blog-content ol {
  margin-left: var(--s3);
  margin-bottom: var(--s2);
}

.blog-content li {
  margin-bottom: var(--s1);
  line-height: 1.7;
}

.blog-content ul li {
  list-style-type: disc;
}

.blog-content ol li {
  list-style-type: decimal;
}

.blog-content li > code {
  background: var(--bg-soft);
  padding: 0.2rem 0.35rem;
}

/* Emphasis & Highlights */
.highlight-text {
  background: var(--bg-soft);
  padding: 0.2rem 0.4rem;
  border-radius: 2px;
  font-weight: 500;
}

.blog-content strong {
  color: var(--navy);
  font-weight: 600;
}

.blog-content em {
  color: var(--ink-soft);
  font-style: italic;
}

/* Section Spacing */
.blog-section {
  margin-bottom: var(--s4);
}

.blog-section:last-child {
  margin-bottom: var(--s5);
}

/* ----------------------------------------------------------
   Blog Index (List Page)
   ---------------------------------------------------------- */
.blog-index {
  max-width: var(--width);
  margin: 0 auto;
  padding: var(--s4) var(--s3) var(--s5);
}

/* Index Header */
.blog-index-header {
  text-align: center;
  margin-bottom: var(--s4);
  padding-bottom: var(--s4);
  border-bottom: 2px solid var(--line);
}

.blog-index-header h1 {
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: var(--s2);
}

.blog-description {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Articles Section */
.blog-articles {
  margin-bottom: var(--s4);
}

.blog-articles h2 {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--navy);
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 2px solid var(--line);
}

.articles-container {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

/* Article Item */
.article-item {
  background: var(--bg-soft);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.article-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Item Header - Clickable */
.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s3);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.article-item:hover .item-header {
  background-color: rgba(0, 0, 0, 0.02);
}

.header-content {
  flex: 1;
  min-width: 0;
}

.item-header h3 {
  margin: 0 0 var(--s1) 0;
  font-size: 1.25rem;
}

.item-header a {
  color: var(--navy);
  text-decoration: none;
  transition: color 0.2s;
}

.item-header a:hover {
  color: var(--teal);
  text-decoration: underline;
}

.item-header time {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* Toggle Indicator */
.toggle-indicator {
  flex-shrink: 0;
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  margin-left: var(--s3);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  color: var(--teal);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-item[data-expanded="true"] .toggle-indicator {
  transform: rotate(180deg);
}

/* Preview Content - Hidden by Default */
.preview-content {
  max-height: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.01);
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
  padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
  opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  padding: 0 var(--s3);
}

.article-item[data-expanded="true"] .preview-content {
  max-height: 2000px;
  opacity: 1;
  padding: 0 var(--s3) var(--s3) var(--s3);
}

/* Preview Content Typography */
.preview-content > p {
  margin-bottom: var(--s2);
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.7;
}

.preview-content h4 {
  margin: var(--s2) 0 var(--s1);
  color: var(--navy);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-content h3 a {
  color: var(--teal);
  font-weight: 600;
}

.preview-content h3 a:hover {
  color: var(--teal-hover);
}

/* ----------------------------------------------------------
   Responsive Design
   ---------------------------------------------------------- */
@media screen and (max-width: 600px) {
  .blog-post,
  .blog-index {
    padding: var(--s3) var(--s2) var(--s4);
  }

  .blog-title {
    font-size: 1.75rem;
  }

  .blog-index-header h1 {
    font-size: 2rem;
  }

  .blog-content {
    font-size: 0.95rem;
  }

  .blog-content h2 {
    font-size: 1.35rem;
  }

  .blog-content h3 {
    font-size: 1.1rem;
  }

  .blog-content pre {
    padding: var(--s2);
    font-size: 0.8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .item-header {
    padding: var(--s2);
    flex-direction: column;
    align-items: flex-start;
  }

  .header-content {
    width: 100%;
  }

  .item-header h3 {
    font-size: 1.1rem;
  }

  .toggle-indicator {
    margin-left: 0;
    margin-top: var(--s1);
    width: 1.25rem;
    height: 1.25rem;
  }

  .preview-content {
    padding: 0 var(--s2);
  }

  .article-item[data-expanded="true"] .preview-content {
    max-height: 1200px;
    padding: 0 var(--s2) var(--s2) var(--s2);
  }
}
