/* CSS Custom Properties */
:root {
  /* Color Palette */
  --color-primary: #2c3e50;
  --color-primary-dark: #34495e;
  --color-accent: #3498db;
  --color-text: #333;
  --color-text-light: #666;
  --color-white: #fff;
  --color-bg-light: #f4f4f4;
  --color-bg-lighter: #ecf0f1;
  --color-border: #eee;

  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography Scale */
  --font-size-base: 1rem;
  --font-size-sm: 0.875rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.75rem;
  --font-size-3xl: 2.25rem;

  /* Line Heights */
  --line-height-tight: 1.4;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;

  /* Container */
  --container-max-width: 800px;
  --container-padding: 1.25rem;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* Header */
.site-header {
  background-color: var(--color-primary);
  color: var(--color-white);
  padding: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title a {
  color: var(--color-white);
  text-decoration: none;
  font-size: var(--font-size-xl);
  font-weight: bold;
  transition: opacity 0.2s;
}

.site-title a:hover {
  opacity: 0.8;
}

.site-nav {
  display: flex;
  gap: var(--space-md);
}

.site-nav a {
  color: var(--color-white);
  text-decoration: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: 4px;
  transition:
    opacity 0.2s,
    background-color 0.2s;
  white-space: nowrap;
}

.site-nav a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  opacity: 0.9;
}

/* Main Content */
main {
  flex: 1;
}

/* Page and Post Styles */
.page,
.post {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.page-header,
.post-header {
  padding: 16px 0;
}

.page-header h1,
.post-header h1 {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-sm);
  color: var(--color-primary);
}

.page-description {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
}

.post-meta {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

/* Content Styles */
.page-content,
.post-content {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
}

.page-content h2,
.post-content h2 {
  font-size: var(--font-size-2xl);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  color: var(--color-primary);
}

.page-content h3,
.post-content h3 {
  font-size: var(--font-size-xl);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
  color: var(--color-primary-dark);
}

.page-content p,
.post-content p {
  margin-bottom: var(--space-md);
}

.page-content ul,
.post-content ul,
.page-content ol,
.post-content ol {
  margin-left: var(--space-xl);
  margin-bottom: var(--space-md);
}

.page-content li,
.post-content li {
  margin-bottom: var(--space-sm);
}

.page-content code,
.post-content code {
  background-color: var(--color-bg-light);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 3px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
}

.page-content pre,
.post-content pre {
  background-color: var(--color-bg-light);
  padding: var(--space-md);
  border-radius: 5px;
  overflow-x: auto;
  margin-bottom: var(--space-md);
}

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

.page-content img,
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--space-xl) auto;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Video Embeds */
.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin: var(--space-xl) auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

/* Tables */
.page-content,
.post-content {
  overflow-x: visible;
}

.page-content table,
.post-content table {
  border-collapse: collapse;
  margin-bottom: var(--space-xl);
  width: 100%;
  table-layout: auto;
  display: table;
}

/* Wrapper styling - tables need a wrapper on render */
.page-content > table,
.post-content > table,
.page-content > div > table,
.post-content > div > table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.page-content > table > thead,
.post-content > table > thead,
.page-content > table > tbody,
.post-content > table > tbody,
.page-content > div > table > thead,
.post-content > div > table > thead,
.page-content > div > table > tbody,
.post-content > div > table > tbody {
  display: table-header-group;
}

.page-content > table > tbody,
.post-content > table > tbody,
.page-content > div > table > tbody,
.post-content > div > table > tbody {
  display: table-row-group;
}

.page-content tr,
.post-content tr {
  display: table-row;
}

.page-content th,
.post-content th,
.page-content td,
.post-content td {
  display: table-cell;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

.page-content th,
.post-content th {
  background-color: var(--color-bg-lighter);
  font-weight: bold;
  color: var(--color-primary);
}

.page-content td,
.post-content td {
  vertical-align: top;
}

.page-content table img,
.post-content table img {
  margin: var(--space-sm) auto;
  max-height: 300px;
  width: auto;
  object-fit: contain;
}

.page-content blockquote,
.post-content blockquote {
  border-left: 4px solid var(--color-primary);
  padding-left: var(--space-md);
  margin-left: 0;
  margin-bottom: var(--space-md);
  color: var(--color-text-light);
  font-style: italic;
}

/* Post Tags */
.post-tags {
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.tag {
  display: inline-block;
  background-color: var(--color-bg-lighter);
  color: var(--color-primary);
  padding: var(--space-xs) var(--space-sm);
  margin-right: var(--space-sm);
  margin-bottom: var(--space-sm);
  border-radius: 3px;
  font-size: var(--font-size-sm);
  transition: background-color 0.2s;
}

.tag:hover {
  background-color: var(--color-primary);
  color: var(--color-white);
}

/* Blog Index */
section h2 {
  margin-bottom: var(--space-lg);
}

.post-list {
  list-style: none;
  margin-left: 0;
}

.post-item {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

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

.post-item h2 {
  margin-bottom: var(--space-sm);
}

.post-item h2 a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s;
}

.post-item h2 a:hover {
  color: var(--color-accent);
}

.post-excerpt {
  color: var(--color-text-light);
  margin-top: var(--space-sm);
}

/* Blog Page - Card Grid Layout */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-2xl);
  margin-top: 16px;
}

.post-card {
  background-color: var(--color-white);
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 1px 2px rgba(0, 0, 0, 0.1);
  height: 100%;
}

.post-card-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background-color: var(--color-bg-light);
}

.post-card-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  margin: 0;
  box-shadow: none;
  border-radius: 0;
}

.post-card:hover .post-card-image img {
  transform: scale(1.05);
}

.post-card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.08),
    0 4px 8px rgba(0, 0, 0, 0.06);
  border-color: var(--color-accent);
}

.post-card-content {
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: var(--space-md);
}

.post-card h2 {
  font-size: 1.375rem;
  margin: 0;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.post-card h2 a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
  background-image: linear-gradient(
    to right,
    var(--color-accent) 0%,
    var(--color-accent) 100%
  );
  background-size: 0 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition:
    color 0.2s ease,
    background-size 0.3s ease;
}

.post-card h2 a:hover {
  color: var(--color-accent);
  background-size: 100% 2px;
}

.post-card .post-meta {
  color: var(--color-text-light);
  font-size: 0.875rem;
  margin: 0;
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--color-bg-light);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.post-card .post-meta time {
  display: inline-block;
}

.post-card .post-excerpt {
  color: var(--color-text-light);
  line-height: 1.65;
  margin: 0;
  flex-grow: 1;
  font-size: 0.95rem;
}

.post-card .read-more {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  transition:
    color 0.2s ease,
    transform 0.2s ease;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-card .read-more:hover {
  color: var(--color-primary);
  transform: translateX(4px);
}

/* Responsive adjustments for card grid */
@media (max-width: 768px) {
  .post-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .post-card-content {
    padding: var(--space-xl);
  }

  .post-card h2 {
    font-size: 1.25rem;
  }
}

/* Home Page */
.home-intro {
  text-align: center;
  padding: var(--space-2xl) 0;
}

.home-intro h1 {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-md);
  color: var(--color-primary);
}

.home-intro p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
  max-width: 600px;
  margin: 0 auto;
}

/* Social Links */
.social-links {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  flex-wrap: wrap;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--color-primary);
  background-color: var(--color-bg-lighter);
  border-radius: 50%;
  transition:
    transform 0.3s ease,
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.social-links a:hover {
  transform: translateY(-4px);
  background-color: var(--color-accent);
  color: var(--color-white);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.social-links svg {
  width: 24px;
  height: 24px;
}

.social-links a:hover svg {
  stroke: var(--color-white);
}

/* See All Posts Link */
.see-all-posts {
  text-align: center;
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.view-all-link {
  display: inline-block;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--font-size-lg);
  padding: var(--space-md) var(--space-2xl);
  border: 2px solid var(--color-accent);
  border-radius: 8px;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    transform 0.2s ease;
}

.view-all-link:hover {
  background-color: var(--color-accent);
  color: var(--color-white);
  transform: translateY(-2px);
}

/* Breadcrumb Navigation */
.breadcrumb {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--space-lg) var(--container-padding);
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.breadcrumb-link {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s;
  font-weight: 500;
}

.breadcrumb-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.breadcrumb-separator {
  margin: 0 var(--space-sm);
  color: var(--color-text-light);
}

.breadcrumb-current {
  color: var(--color-text);
  font-weight: 500;
}

/* Post Navigation */
.post-navigation {
  margin-top: var(--space-lg);
  padding-top: var(--space-xl);
  border-top: 2px solid var(--color-border);
  text-align: center;
}

.back-to-blog {
  display: inline-block;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  padding: var(--space-md) var(--space-xl);
  border: 2px solid var(--color-accent);
  border-radius: 8px;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    transform 0.2s ease;
}

.back-to-blog:hover {
  background-color: var(--color-accent);
  color: var(--color-white);
  transform: translateY(-2px);
}

/* Footer */
.site-footer {
  background-color: var(--color-primary);
  color: var(--color-white);
  padding: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: var(--space-xl);
}

.site-footer p {
  margin-bottom: var(--space-sm);
}

.site-footer a {
  color: var(--color-white);
  text-decoration: underline;
  transition: opacity 0.2s;
}

.site-footer a:hover {
  opacity: 0.8;
}

/* KaTeX Styles */
.katex {
  font-size: 1.1em;
}

.katex-display {
  margin: var(--space-lg) 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Responsive Design */
@media (max-width: 768px) {
  .site-header .container {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .site-title {
    flex: 0 0 100%;
    text-align: center;
  }

  .site-title a {
    font-size: var(--font-size-xl);
  }

  .site-nav {
    flex: 0 0 100%;
    justify-content: flex-start;
    gap: var(--space-sm);
  }

  .site-nav a {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm);
  }

  .breadcrumb {
    padding: var(--space-md) var(--container-padding);
    font-size: 0.8rem;
  }

  .breadcrumb-current {
    display: block;
    margin-top: var(--space-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-intro h1 {
    font-size: var(--font-size-2xl);
  }

  .home-intro p {
    font-size: var(--font-size-base);
  }

  .page-header h1,
  .post-header h1 {
    font-size: var(--font-size-2xl);
  }

  .page-content,
  .post-content {
    font-size: 0.95rem;
  }

  .page-content h2,
  .post-content h2 {
    font-size: var(--font-size-xl);
  }

  .page-content h3,
  .post-content h3 {
    font-size: var(--font-size-lg);
  }

  .page-content table,
  .post-content table {
    font-size: 0.85rem;
  }

  .page-content table img,
  .post-content table img {
    max-height: 200px;
  }

  .page-content th,
  .post-content th,
  .page-content td,
  .post-content td {
    padding: var(--space-xs) var(--space-sm);
    min-width: 80px;
  }

  .post-card h2 {
    font-size: 1.125rem;
  }
}
