/* ============================================
   Enhanced Blog Layout Styles
   ============================================ */

/* Main content - allow natural scrolling */
.app-container {
  overflow-y: auto;
}

/* Page Header - Stats + Rotating Question */
.page-header {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(76, 175, 80, 0.05) 100%);
  border-left: 4px solid var(--accent-color, #4CAF50);
  border-radius: 4px;
}

.page-header-stats {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stat-item {
  font-weight: 500;
}

.stat-separator {
  opacity: 0.5;
}

.page-header-question {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--accent-color, #4CAF50);
  font-style: italic;
  line-height: 1.6;
}

@media (max-width: 768px) {
  .page-header {
    padding: 1rem;
  }

  .page-header-question {
    font-size: 1rem;
  }

  .page-header-stats {
    font-size: 0.85rem;
  }
}

/* Sidebar Widgets - scrollable section */
.widgets-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 2rem;
  max-height: 500px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Custom scrollbar for widgets section (webkit browsers) */
.widgets-section::-webkit-scrollbar {
  width: 8px;
}

.widgets-section::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.widgets-section::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.widgets-section::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* For Firefox */
.widgets-section {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.1);
}

.widget {
  margin-bottom: 2rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border-left: 3px solid var(--accent-color, #4CAF50);
}

.widget h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.widget-footer {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  text-align: right;
}

.widget-footer a {
  color: var(--accent-color, #4CAF50);
  text-decoration: none;
}

.widget-footer a:hover {
  text-decoration: underline;
}

/* WakaTime Widget */
.wakatime-widget figure {
  margin: 0;
  padding: 0;
}

.wakatime-widget embed {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 200px;
}

/* Goodreads Widget - hide everything except titles */
.goodreads-widget {
  font-size: 0.9rem;
}

.goodreads-widget a {
  color: inherit;
  text-decoration: none;
}

.goodreads-widget a:hover {
  color: var(--accent-color, #4CAF50);
}

/* Hide book covers, authors, ratings, and tags in Goodreads widget */
.goodreads-widget img {
  display: none !important;
}

/* Hide "Jianni's books" heading and other Goodreads headers */
.goodreads-widget h2,
.goodreads-widget .gr_custom_header_1,
.goodreads-widget [class*="gr_custom_header"],
.goodreads-widget center,
.goodreads-widget .gr_custom_name,
.goodreads-widget .gr_custom_author_1,
.goodreads-widget .gr_custom_author,
.goodreads-widget .gr_custom_rating,
.goodreads-widget .gr_custom_tags,
.goodreads-widget .gr_custom_review,
.goodreads-widget .gr_custom_container_1,
.goodreads-widget .gr_custom_each_container img,
.goodreads-widget [class*="rating"],
.goodreads-widget [class*="author"],
.goodreads-widget [class*="tagged"] {
  display: none !important;
}

/* Show only title links */
.goodreads-widget .gr_custom_title_1,
.goodreads-widget .gr_custom_book_container_1 {
  margin: 0.5rem 0;
  padding: 0;
}

.goodreads-widget .gr_custom_title_1 a {
  display: block;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

/* arXiv Feed Widget */
.arxiv-feed {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.arxiv-item {
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  font-size: 0.85rem;
}

.arxiv-item a {
  color: inherit;
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.arxiv-item a:hover {
  color: var(--accent-color, #4CAF50);
}

.arxiv-date {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

/* Post List Descriptions */
.posts-list-item-summary {
  margin: 0.5rem 0 0 0;
  color: var(--text-color-light, #666);
  font-size: 0.95rem;
  line-height: 1.5;
  font-style: italic;
}

@media (prefers-color-scheme: dark) {
  .posts-list-item-summary {
    color: rgba(255, 255, 255, 0.7);
  }
}

/* Post Metadata Enhancements */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--accent-color, #666);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color, #eee);
}

.post-meta > div {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.post-updated {
  font-style: italic;
  opacity: 0.85;
}

.word-count {
  opacity: 0.75;
}

/* Series Information */
.post-series {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-color, #f0f0f0);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin: 1rem 0;
  font-size: 0.95rem;
  border-left: 4px solid var(--primary-color, #333);
}

/* Table of Contents */
.toc {
  background: var(--background-color, #f8f9fa);
  border: 1px solid var(--border-color, #e1e4e8);
  border-left: 4px solid var(--primary-color, #0366d6);
  border-radius: 6px;
  padding: 1.5rem;
  margin: 2rem 0;
  font-size: 0.95rem;
}

.toc details {
  cursor: pointer;
}

.toc summary {
  user-select: none;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: var(--heading-color, #24292e);
}

.toc summary:hover {
  opacity: 0.8;
}

.toc details[open] summary {
  margin-bottom: 1rem;
}

.toc nav {
  margin-top: 1rem;
}

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

.toc ul ul {
  padding-left: 1.5rem;
  margin-top: 0.5rem;
}

.toc li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.toc a {
  color: var(--text-color, #333);
  text-decoration: none;
  transition: color 0.2s;
}

.toc a:hover {
  color: var(--primary-color, #0366d6);
  text-decoration: underline;
}

/* Enhanced Content Readability */
.post-content {
  font-size: 1.1rem;
  line-height: 1.8;
  max-width: 75ch;
}

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

.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.post-content h2 {
  font-size: 1.8rem;
  border-bottom: 2px solid var(--border-color, #eee);
  padding-bottom: 0.5rem;
}

.post-content h3 {
  font-size: 1.4rem;
}

.post-content h4 {
  font-size: 1.2rem;
}

/* Code Blocks */
.post-content pre {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 2rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.post-content code {
  background: var(--code-background, #f6f8fa);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: 'Courier New', Courier, monospace;
}

.post-content pre code {
  background: transparent;
  padding: 0;
}

/* Blockquotes */
.post-content blockquote {
  border-left: 4px solid var(--primary-color, #0366d6);
  padding-left: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--text-color-light, #586069);
}

/* Lists */
.post-content ul,
.post-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

.post-content li {
  margin: 0.5rem 0;
  line-height: 1.7;
}

/* Images */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin: 2rem 0;
}

/* Footnotes */
.footnotes {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border-color, #eee);
  font-size: 0.9rem;
  color: var(--text-color-light, #586069);
}

.footnotes ol {
  padding-left: 1.5rem;
}

.footnotes li {
  margin: 1rem 0;
}

.footnotes p {
  margin: 0.5rem 0;
}

/* Footnote references in text */
sup {
  line-height: 0;
}

a.footnote-ref {
  text-decoration: none;
  color: var(--primary-color, #0366d6);
  font-weight: 600;
}

/* Series Navigation */
.series-navigation {
  background: var(--background-color, #f8f9fa);
  border: 1px solid var(--border-color, #e1e4e8);
  border-radius: 8px;
  padding: 2rem;
  margin: 3rem 0;
}

.series-navigation h3 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.series-list {
  list-style: decimal;
  padding-left: 2rem;
  margin: 0;
}

.series-list li {
  margin: 0.75rem 0;
  line-height: 1.6;
}

.series-list li.current-post {
  background: var(--highlight-background, #fff3cd);
  padding: 0.5rem;
  border-radius: 4px;
  border-left: 4px solid var(--primary-color, #0366d6);
  margin-left: -0.5rem;
  padding-left: 1rem;
}

.current-indicator {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-color-light, #666);
  font-weight: normal;
}

/* Post Navigation (Previous/Next) */
.post-navigation {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin: 3rem 0 2rem;
  padding: 2rem 0;
  border-top: 2px solid var(--border-color, #eee);
}

.nav-prev,
.nav-next {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-next {
  text-align: right;
  align-items: flex-end;
}

.nav-label {
  font-size: 0.85rem;
  color: var(--text-color-light, #666);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-title {
  font-size: 1.1rem;
  color: var(--primary-color, #0366d6);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
}

.nav-title:hover {
  opacity: 0.7;
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
  .post-meta {
    font-size: 0.85rem;
    gap: 0.75rem;
  }

  .post-content {
    font-size: 1rem;
  }

  .post-content h2 {
    font-size: 1.5rem;
  }

  .post-content h3 {
    font-size: 1.25rem;
  }

  .toc {
    padding: 1rem;
  }

  .post-navigation {
    flex-direction: column;
    gap: 1.5rem;
  }

  .nav-next {
    text-align: left;
    align-items: flex-start;
  }

  .series-navigation {
    padding: 1.5rem;
  }
}

/* Dark Mode Support (if theme supports it) */
@media (prefers-color-scheme: dark) {
  .toc {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .series-navigation {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .series-list li.current-post {
    background: rgba(255, 193, 7, 0.15);
  }

  .post-content code {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* Print Styles */
@media print {
  .post-navigation,
  .series-navigation,
  .toc details summary {
    display: none;
  }

  .toc details {
    display: block;
  }

  .post-content {
    font-size: 12pt;
    line-height: 1.6;
  }
}
