/* Basic Reset & Body */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol";
  background-color: #fff;
  color: #171717;
  line-height: 1.6;
  font-size: 16px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 4px 4px;
}

.skip-link:focus {
  top: 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

/* Container */
.container {
  width: 100%;
  max-width: 96rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
  box-sizing: border-box;
}

/* Header */
.site-header {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #171717;
}
.site-header .logo:hover {
  color: #404040;
}

.header-nav .search-link {
  font-size: 0.875rem;
  color: #525252;
}
.header-nav .search-link:hover {
  color: #171717;
}

/* Main Content Area */
.main-layout {
  display: flex;
  padding-top: 2rem;
  padding-bottom: 2rem;
  gap: 2rem;
}

.year-nav {
  width: 4rem;
  flex-shrink: 0;
  position: sticky;
  top: 2rem;
  align-self: flex-start;
}

.year-nav-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #a3a3a3;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.year-nav .year-item {
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
  color: #a3a3a3;
  cursor: pointer;
  transition: color 0.2s ease-in-out;
  padding: 0.25rem 0;
  border-radius: 3px;
}
.year-nav .year-item:hover {
  color: #737373;
}
.year-nav .year-item.current-year {
  font-weight: 600;
  color: #171717;
}

.post-list-main {
  flex: 1;
  min-width: 0;
}

/* Loading and Error States */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #737373;
  font-size: 0.875rem;
}

.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid #e5e5e5;
  border-top-color: #737373;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message {
  text-align: center;
  padding: 2rem;
  color: #dc2626;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  margin: 1rem 0;
}

.no-posts {
  text-align: center;
  padding: 2rem;
  color: #737373;
}

/* Post List Items */
.post-list-item {
  display: block;
  margin-bottom: 2.5rem;
  transition: transform 0.1s ease-in-out;
}

.post-list-item:hover {
  transform: translateY(-1px);
}

.post-list-item .post-item-content {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.post-list-item .post-date-short {
  width: 3.5rem;
  font-size: 0.875rem;
  color: #737373;
  flex-shrink: 0;
  line-height: 1.4;
  /*padding-top: 0.125rem; /* Align with title baseline */
}

.post-list-item .post-details {
  flex: 1;
  min-width: 0;
}

.post-list-item .post-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #171717;
  margin-bottom: 0.25rem;
  line-height: 1.4;
  margin-top: 0;
}
.post-list-item:hover .post-title {
  text-decoration: underline;
}

.post-list-item .post-description {
  font-size: 0.875rem;
  color: #737373;
  line-height: 1.625;
}

/* Featured badge */
.featured-badge {
  color: #f59e0b;
  font-size: 0.875rem;
  margin-left: 0.25rem;
}

/* Post tags */
.post-tags {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.post-tags .tag {
  background-color: #f3f4f6;
  color: #6b7280;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Post Page Specific Styles */
.back-link-container {
  margin-bottom: 2rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.875rem;
  color: #737373;
  transition: all 0.2s ease-in-out;
}
.back-link:hover {
  color: #404040;
}
.back-link .chevron {
  margin-right: 0.25rem;
  transition: transform 0.2s ease-in-out;
}
.back-link:hover .chevron {
  transform: translateX(-2px);
}

.post-article {
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

.post-article .post-date-full {
  font-size: 0.875rem;
  color: #737373;
  margin-bottom: 0.5rem;
}

.post-article .post-title-main {
  font-size: 1.75rem;
  font-weight: 700;
  color: #171717;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.post-article .post-description-main {
  font-size: 1rem;
  color: #525252;
  margin-bottom: 2rem;
  line-height: 1.75;
}

/* Post meta styles */
.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e5e5;
  font-size: 0.875rem;
  color: #737373;
}

.reading-time::before {
  content: "📖 ";
}

.post-meta .post-tags {
  margin-top: 0;
}

/* Markdown Content Styling */
.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4,
.post-body h5,
.post-body h6 {
  font-weight: 600;
  color: #171717;
  margin-top: 2em;
  margin-bottom: 0.5em;
  line-height: 1.25;
}

.post-body h1 { font-size: 1.875rem; }
.post-body h2 { font-size: 1.5rem; }
.post-body h3 { font-size: 1.25rem; }
.post-body h4 { font-size: 1.125rem; }

.post-body p {
  margin-bottom: 1.25em;
  line-height: 1.75;
}

.post-body ul,
.post-body ol {
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}

.post-body li {
  margin-bottom: 0.5em;
  line-height: 1.625;
}

.post-body blockquote {
  border-left: 4px solid #e5e5e5;
  padding-left: 1em;
  margin: 1.5em 0;
  font-style: italic;
  color: #525252;
}

.post-body hr {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 2em 0;
}

/* Links in post content */
.post-body a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.post-body a:hover {
  color: #1d4ed8;
}

/* Images */
.post-body img {
  max-width: 100%;
  height: auto;
  margin: 1.5em 0;
  border-radius: 6px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Code Styling */
.post-body code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 0.875em;
}

.post-body p > code,
.post-body li > code,
.post-body h1 > code,
.post-body h2 > code,
.post-body h3 > code,
.post-body h4 > code {
  background-color: #f5f5f5;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  border: 1px solid #e5e5e5;
}

.post-body pre {
  background-color: #f8f9fa;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 1.25em;
  overflow-x: auto;
  margin: 1.5em 0;
  line-height: 1.45;
  font-size: 0.875em;
}

.post-body pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  border: none;
  font-size: inherit;
}

/* Tables */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.post-body th,
.post-body td {
  border: 1px solid #e5e5e5;
  padding: 0.75em;
  text-align: left;
}

.post-body th {
  background-color: #f8f9fa;
  font-weight: 600;
}

/* Table of contents styles */
.table-of-contents {
  background-color: #f8f9fa;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 1.5rem;
  margin: 2rem 0;
}

.table-of-contents h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1rem;
  color: #171717;
}

.table-of-contents ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.table-of-contents li {
  margin-bottom: 0.5rem;
}

.table-of-contents a {
  color: #525252;
  text-decoration: none;
  font-size: 0.875rem;
}

.table-of-contents a:hover {
  color: #171717;
  text-decoration: underline;
}

.toc-h3 {
  padding-left: 1rem;
}

.toc-h4 {
  padding-left: 2rem;
}

/* Social sharing styles */
.social-share {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #e5e5e5;
}

.social-share h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: #525252;
}

.share-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-button {
  padding: 0.5rem 1rem;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #525252;
  transition: all 0.2s ease-in-out;
  text-decoration: none;
}

.share-button:hover {
  border-color: #171717;
  color: #171717;
}

/* Post navigation */
.post-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #e5e5e5;
}

.post-navigation {
  margin-bottom: 2rem;
}

.nav-link {
  color: #737373;
  font-size: 0.875rem;
  text-decoration: none;
}

.nav-link:hover {
  color: #171717;
  text-decoration: underline;
}

/* Footer */
.site-footer {
  padding-top: 2rem;
  padding-bottom: 2rem;
  margin-top: 3rem;
  border-top: 1px solid #e5e5e5;
  text-align: center;
  font-size: 0.875rem;
  color: #737373;
}

/* Layout */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.content-wrapper {
  flex-grow: 1;
}

/* Loading skeleton styles */
.loading-skeleton {
  animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-date {
  height: 16px;
  width: 80px;
  background-color: #e5e5e5;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 32px;
  width: 70%;
  background-color: #e5e5e5;
  border-radius: 4px;
  margin-bottom: 12px;
}

.skeleton-description {
  height: 20px;
  width: 90%;
  background-color: #e5e5e5;
  border-radius: 4px;
  margin-bottom: 24px;
}

.skeleton-content {
  height: 200px;
  width: 100%;
  background-color: #e5e5e5;
  border-radius: 4px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Responsive Design */
@media (min-width: 640px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  .year-nav {
    width: 5rem;
  }
  .post-article .post-title-main {
    font-size: 1.875rem;
  }
}

@media (min-width: 768px) {
  .post-list-item {
    margin-bottom: 3rem;
  }
  .post-list-item .post-title {
    font-size: 1.25rem;
  }
  .post-article .post-title-main {
    font-size: 2.25rem;
  }
  .post-article .post-description-main {
    font-size: 1.125rem;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Mobile Responsive */
@media (max-width: 767px) {
  .main-layout {
    flex-direction: column;
    padding-top: 1rem;
    gap: 1rem;
  }

  .year-nav {
    position: static;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
  }

  .year-nav-title {
    margin-bottom: 0;
    margin-right: 0.5rem;
  }

  .year-nav .year-item {
    margin-bottom: 0;
  }

  .post-list-item .post-date-short {
    width: auto;
    margin-right: 0.5rem;
  }

  .post-list-item .post-title {
    font-size: 1.05rem;
  }
  .post-list-item .post-description {
    font-size: 0.825rem;
  }

  .post-article .post-title-main {
    font-size: 1.6rem;
  }
  .post-article .post-description-main {
    font-size: 0.95rem;
  }

  .site-header {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  .site-header .logo {
    font-size: 1.1rem;
  }
  .header-nav .search-link {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  .post-article .post-title-main {
    font-size: 1.4rem;
  }
  .post-article .post-description-main {
    font-size: 0.9rem;
  }
  .post-body pre {
    font-size: 0.8em;
    padding: 1em;
  }
}

/* Print Styles */
@media print {
  .year-nav,
  .back-link-container,
  .site-header,
  .site-footer,
  .social-share {
    display: none;
  }
  
  .post-article {
    max-width: none;
  }
  
  .post-body a {
    color: #000;
    text-decoration: none;
  }
  
  .post-body a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}