/**
 * LAYOUT & NAVIGATION SYSTEM
 * Premium modern layout structure
 */

/* ============================================================================
   HEADER & NAVIGATION
   ============================================================================ */

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--neutral-200);
  padding: var(--space-4) 0;
  z-index: var(--z-fixed);
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.95);
  transition: all var(--duration-300) var(--timing-ease-in-out);
}

body.dark-mode header {
  background-color: rgba(9, 9, 11, 0.95);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: transform var(--duration-200) var(--timing-ease);
}

.header-brand:hover {
  transform: scale(1.05);
}

.header-brand svg {
  width: 28px;
  height: 28px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  list-style: none;
}

.header-nav a {
  position: relative;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration-200) var(--timing-ease);
}

.header-nav a::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  transition: width var(--duration-300) var(--timing-ease-in-out);
}

.header-nav a:hover {
  color: var(--brand-primary);
}

.header-nav a:hover::after {
  width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================================================
   THEME TOGGLE
   ============================================================================ */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-200) var(--timing-ease-in-out);
  font-size: var(--text-lg);
}

.theme-toggle:hover {
  background-color: var(--bg-tertiary);
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ============================================================================
   MAIN CONTENT AREA
   ============================================================================ */

main {
  flex: 1;
  width: 100%;
  margin-top: 80px;
}

.hero-section {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(167, 139, 250, 0.08) 100%);
  padding: var(--space-16) var(--space-4);
  text-align: center;
  border-bottom: 1px solid var(--neutral-200);
}

.hero-content {
  max-width: 900px;
  margin: 0 auto;
}

.hero-content h1 {
  font-size: clamp(var(--text-3xl), 8vw, var(--text-6xl));
  margin-bottom: var(--space-4);
}

.hero-content .subtitle {
  font-size: var(--text-xl);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ============================================================================
   CONTENT SECTIONS
   ============================================================================ */

.section {
  padding: var(--space-12) var(--space-4);
  border-bottom: 1px solid var(--neutral-200);
}

.section:last-child {
  border-bottom: none;
}

.section-header {
  text-align: center;
  max-width: 700px;
  margin: 0 auto var(--space-8);
}

.section-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-extrabold);
  margin-bottom: var(--space-4);
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
}

/* ============================================================================
   BLOG LIST SECTION
   ============================================================================ */

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

@media (max-width: 640px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }
}

.blog-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--neutral-200);
  padding: var(--space-6);
  transition: all var(--duration-300) var(--timing-ease-in-out));
  box-shadow: var(--shadow-sm);
}

.blog-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-8px);
}

.blog-card-header {
  margin-bottom: var(--space-4);
}

.blog-card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  transition: color var(--duration-200) var(--timing-ease));
}

.blog-card:hover .blog-card-title {
  color: var(--brand-primary);
}

.blog-card-meta {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-3);
}

.blog-card-excerpt {
  flex: 1;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed));
  margin-bottom: var(--space-4);
}

.blog-card-footer {
  border-top: 1px solid var(--neutral-300);
  padding-top: var(--space-4);
}

.blog-card-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--brand-primary);
  font-weight: var(--font-semibold);
  text-decoration: none;
  transition: all var(--duration-200) var(--timing-ease));
}

.blog-card-link:hover {
  gap: var(--space-3);
  color: var(--brand-secondary);
}

/* ============================================================================
   SINGLE BLOG POST
   ============================================================================ */

.post-header {
  max-width: 900px;
  margin: 0 auto var(--space-8);
  padding: var(--space-12) var(--space-4) var(--space-8);
  border-bottom: 1px solid var(--neutral-200);
}

.post-title {
  font-size: clamp(var(--text-3xl), 6vw, var(--text-5xl));
  font-weight: var(--font-extrabold);
  margin-bottom: var(--space-4);
  line-height: var(--leading-tight));
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.post-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.post-content {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

.post-content h1 {
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}

.post-content h2 {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 2px solid var(--neutral-200);
}

.post-content h3 {
  margin-top: var(--space-8);
}

.post-content p {
  margin-bottom: var(--space-4);
}

.post-content ul,
.post-content ol {
  margin-left: var(--space-6);
  margin-bottom: var(--space-4);
}

.post-content li {
  margin-bottom: var(--space-2);
}

.post-content code {
  background-color: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.post-content pre {
  background-color: var(--bg-secondary);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  overflow-x: auto;
  margin: var(--space-6) 0;
}

.post-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-6) 0;
}

.post-content th,
.post-content td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--neutral-300);
}

.post-content th {
  background-color: var(--bg-secondary);
  font-weight: var(--font-semibold);
}

/* ============================================================================
   FOOTER
   ============================================================================ */

footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--neutral-200);
  padding: var(--space-8) var(--space-4);
  margin-top: var(--space-16);
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}

.footer-section h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-4);
}

.footer-section ul {
  list-style: none;
  margin-left: 0;
}

.footer-section a {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  transition: color var(--duration-200) var(--timing-ease));
}

.footer-section a:hover {
  color: var(--brand-primary);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-6);
  border-top: 1px solid var(--neutral-300);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

@media (max-width: 640px) {
  .footer-bottom {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }
}

/* ============================================================================
   BREADCRUMB NAVIGATION
   ============================================================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
  list-style: none;
}

.breadcrumb li {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.breadcrumb a {
  color: var(--brand-primary);
}

.breadcrumb li:not(:last-child)::after {
  content: '/';
  color: var(--text-tertiary);
}

/* ============================================================================
   BACK TO TOP BUTTON
   ============================================================================ */

.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-300) var(--timing-ease-in-out));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  z-index: var(--z-sticky);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
  .header-nav {
    display: none;
  }
  
  .hero-section {
    padding: var(--space-8) var(--space-4);
  }
  
  .section {
    padding: var(--space-8) var(--space-4);
  }
  
  .post-header {
    padding: var(--space-6) var(--space-4) var(--space-6);
  }
}

@media (max-width: 480px) {
  .back-to-top {
    width: 40px;
    height: 40px;
    font-size: var(--text-base);
  }
}

/* =========================================
   INKWIRE: 全局暗黑模式终极修复补丁
   (Global Dark Mode Fix for Index & Blog)
   ========================================= */

/* 1. 根治“底部露白”：强制 html 和 body 撑满整个屏幕高度 */
html, body {
    height: 100%;
    min-height: 100vh; /* 确保即使内容很少，背景也能铺满全屏 */
    margin: 0;
    padding: 0;
}

/* 2. 强制根元素和 body 在暗黑模式下统一使用背景色变量 */
html[data-theme="dark"],
html[data-theme="dark"] body {
    background-color: var(--bg-primary, #0F0F11) !important;
    color: var(--text-primary, #EAEAEA) !important;
}

/* 3. 扫荡“顽固容器”：强制所有常见的主容器在暗黑模式下变黑 */
html[data-theme="dark"] main,
html[data-theme="dark"] .container,
html[data-theme="dark"] .wrapper,
html[data-theme="dark"] .content,
html[data-theme="dark"] .post-content,
html[data-theme="dark"] .article-body,
html[data-theme="dark"] section {
    background-color: var(--bg-primary, #0F0F11) !important;
    color: var(--text-primary, #EAEAEA) !important;
}

/* 4. 修复卡片和代码块在暗黑模式下的对比度 */
html[data-theme="dark"] .card,
html[data-theme="dark"] .post-item,
html[data-theme="dark"] pre,
html[data-theme="dark"] code {
    background-color: var(--bg-secondary, #1A1A1D) !important;
    border-color: var(--border-color, #333336) !important;
    color: var(--text-primary, #EAEAEA) !important;
}
