/* ========================================
   Modern Blog - Two Column Layout
   ======================================== */

/* CSS Custom Properties */
:root {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text: #2c3e50;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 300px;
  --max-content-width: 820px;
  --transition: 0.2s ease;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Menlo, monospace;
}

/* Dark mode */
body.dark {
  --bg: #111827;
  --bg-card: #1f2937;
  --bg-sidebar: #1f2937;
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border: #374151;
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --accent-light: #1e3a5f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body.default {
  background-image: url('https://blog.shenmo.tech/img/Icey-wall.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: scroll;
}

body.default::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(240, 242, 245, 0.92);
  z-index: -1;
  pointer-events: none;
}

body.dark.default::before {
  background: rgba(17, 24, 39, 0.92);
}

a {
  color: inherit !important;
  text-decoration: none;
  transition: background var(--transition);
  border-radius: 3px;
  padding: 1px 3px;
  margin: -1px -3px;
}

a:hover {
  color: inherit !important;
  text-decoration: none;
  background: rgba(59, 130, 246, 0.12);
}

img {
  max-width: 100%;
  height: auto;
}

/* ===== Layout: Two Column ===== */
.blog-layout {
  display: flex;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px;
  gap: 24px;
  min-height: 100vh;
}

/* ===== Left Sidebar ===== */
.blog-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 24px;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Sidebar Cards */
.sidebar-card {
  background: var(--bg-sidebar);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* Profile Section */
.profile-section {
  text-align: center;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-light);
  margin-bottom: 16px;
  transition: transform var(--transition);
  box-shadow: var(--shadow-md);
}

.profile-avatar:hover {
  transform: scale(1.05);
}

.profile-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.profile-motto {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 12px;
}

.profile-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Sidebar Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a,
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: background var(--transition);
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar-nav a:hover,
.sidebar-nav button:hover,
.sidebar-nav a.active {
  background: var(--accent-light);
}

.sidebar-nav a.active {
  font-weight: 600;
  color: var(--accent);
}

.sidebar-nav i,
.sidebar-nav svg {
  width: 20px;
  height: 20px;
  font-size: 1rem;
  flex-shrink: 0;
}

/* Social Icons in Sidebar */
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-secondary);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border);
}

.social-links a:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Friend Links in Sidebar */
.friend-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.friend-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  background: var(--bg);
  border: 1px solid transparent;
}

.friend-link-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  transform: translateX(3px);
}

.friend-link-item img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.friend-link-info {
  min-width: 0;
}

.friend-link-info a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  line-height: 1.3;
}

.friend-link-info a:hover {
  background: var(--accent-light);
}

.friend-link-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.sidebar-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ===== Right Content Area ===== */
.blog-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Top Nav */
.blog-topnav {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 24px;
  z-index: 100;
}

.blog-topnav .nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.blog-topnav .nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.blog-topnav .nav-links a,
.blog-topnav .nav-links button {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition);
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.blog-topnav .nav-links a:hover,
.blog-topnav .nav-links button:hover {
  background: var(--accent-light);
}

/* Dark mode & search toggle */
.dark-toggle,
.search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
  font-size: 1.1rem;
  font-family: inherit;
}

.dark-toggle:hover,
.search-toggle:hover {
  border-color: var(--accent);
}

/* Content Card */
.content-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 36px 40px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

/* Post List (home page) */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-list-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

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

.post-list-item h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}

.post-list-item h2 a {
  color: var(--text);
  transition: background var(--transition);
  border-radius: 3px;
  padding: 1px 3px;
  margin: -1px -3px;
  display: inline;
}

.post-list-item h2 a:hover {
  background: var(--accent-light);
}

.post-list-item .post-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.post-list-item .post-summary {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ===== Single Post ===== */
.post-header {
  margin-bottom: 28px;
}

.post-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 12px;
}

.post-header .post-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.post-header .post-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.post-cover {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

/* Article Content */
.article-content {
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--text);
}

.article-content h1 { font-size: 1.7rem; font-weight: 700; margin: 1.8em 0 0.6em; }
.article-content h2 { font-size: 1.4rem; font-weight: 700; margin: 1.6em 0 0.5em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.article-content h3 { font-size: 1.2rem; font-weight: 600; margin: 1.4em 0 0.4em; }
.article-content h4 { font-size: 1.05rem; font-weight: 600; margin: 1.3em 0 0.3em; }

.article-content p {
  margin-bottom: 1em;
}

.article-content ul, .article-content ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.article-content li {
  margin-bottom: 0.3em;
}

.article-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 12px 20px;
  margin: 1.2em 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.article-content pre {
  background: #1e293b;
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 1.2em 0;
  border: 1px solid var(--border);
}

.article-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.88rem;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.9rem;
}

.article-content th, .article-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-content th {
  background: var(--bg);
  font-weight: 600;
}

.article-content hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 2em 0;
}

.article-content img {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* TOC */
.toc-section {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

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

.toc-section nav ul li {
  margin-bottom: 4px;
}

.toc-section nav ul li a {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toc-section nav ul li a:hover {
  color: var(--accent);
}

.toc-section nav ul ul {
  padding-left: 16px;
}

/* Comments */
.comments-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 36px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

/* Footer */
.blog-footer {
  text-align: center;
  padding: 24px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.8;
}

.blog-footer a {
  color: var(--text-secondary);
}

.blog-footer a:hover {
  color: var(--accent);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.pagination a:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination .active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .blog-layout {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }

  .blog-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease, opacity 0.25s ease;
    will-change: transform;
    padding: 20px 16px;
    background: var(--bg-sidebar);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
  }

  .blog-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
  }

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

  .mobile-menu-btn {
    display: block;
  }

  .blog-topnav {
    position: sticky;
    top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .content-card {
    padding: 24px 20px;
  }

  .article-content pre {
    margin-left: -20px;
    margin-right: -20px;
    border-radius: 0;
  }

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

@media (max-width: 480px) {
  .blog-topnav .nav-links a span {
    display: none;
  }

  .nav-brand {
    font-size: 1rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection */
::selection {
  background: var(--accent);
  color: #fff;
}

/* Old Semantic UI compatibility helpers */
.ui.segment {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

.ui.relaxed.grid {
  margin: 0;
}

/* Hide old theme elements */
body.default > .flip-container {
  display: none !important;
}
