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

:root {
  --neon-cyan: #00f0ff;
  --neon-purple: #b44aff;
  --neon-pink: #ff2d95;
  --neon-green: #39ff14;
  --neon-yellow: #ffe600;
  --bg-deep: #0a0e17;
  --bg-card: #111827;
  --bg-sidebar: #0d1220;
  --border-glow: rgba(0, 240, 255, 0.15);
  --text: #e2e8f0;
  --text-dim: #8892a4;
  --sidebar-width: 260px;
  --radius: 12px;
  --glow-cyan: 0 0 20px rgba(0, 240, 255, 0.3);
  --glow-purple: 0 0 20px rgba(180, 74, 255, 0.3);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Consolas, 'Noto Sans SC', monospace;
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0, 240, 255, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(180, 74, 255, 0.03) 0%, transparent 50%);
}

a { color: var(--neon-cyan); text-decoration: none; transition: all 0.3s; }
a:hover { color: var(--neon-pink); text-shadow: 0 0 8px rgba(255, 45, 149, 0.5); }

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

::selection {
  background: rgba(0, 240, 255, 0.25);
  color: #fff;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--neon-cyan), var(--neon-purple));
  border-radius: 3px;
}

/* ========== Layout ========== */
.layout {
  display: flex;
  min-height: 100vh;
}

.layout .main-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
}

/* ========== Sidebar ========== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-glow);
  flex-shrink: 0;
  position: relative;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, var(--neon-cyan), transparent 30%, transparent 70%, var(--neon-purple));
  opacity: 0.6;
}

.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.site-author { text-align: center; margin-bottom: 28px; }

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  position: relative;
  transition: transform 0.6s ease, box-shadow 0.6s ease;
  box-shadow: 0 0 0 3px var(--neon-cyan), 0 0 15px rgba(0, 240, 255, 0.4), 0 0 30px rgba(0, 240, 255, 0.1);
  animation: robot-pulse 3s ease-in-out infinite;
}

.avatar:hover {
  transform: rotate(360deg) scale(1.05);
  box-shadow: 0 0 0 3px var(--neon-pink), 0 0 25px rgba(255, 45, 149, 0.6), 0 0 50px rgba(255, 45, 149, 0.2);
}

@keyframes robot-pulse {
  0%, 100% {
    box-shadow: 0 0 0 3px var(--neon-cyan), 0 0 15px rgba(0, 240, 255, 0.4), 0 0 30px rgba(0, 240, 255, 0.1);
  }
  33% {
    box-shadow: 0 0 0 3px var(--neon-purple), 0 0 15px rgba(180, 74, 255, 0.4), 0 0 30px rgba(180, 74, 255, 0.1);
  }
  66% {
    box-shadow: 0 0 0 3px var(--neon-pink), 0 0 15px rgba(255, 45, 149, 0.4), 0 0 30px rgba(255, 45, 149, 0.1);
  }
}

.author-name {
  font-size: 1.1rem;
  margin-top: 14px;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  letter-spacing: 1px;
}

.site-subtitle {
  min-height: 1.6em;
  line-height: 1.6em;
  font-size: 0.8rem;
  color: var(--neon-green);
  margin-top: 6px;
  font-family: 'Fira Code', monospace;
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.3);
}

/* ========== Navigation ========== */
.site-nav {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.9rem;
  transition: all 0.3s ease;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--neon-cyan);
  opacity: 0;
  transition: opacity 0.3s;
}

.nav-item:hover {
  background: rgba(0, 240, 255, 0.05);
  border-color: rgba(0, 240, 255, 0.2);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  transform: translateX(4px);
}

.nav-item:hover::before { opacity: 1; }

.nav-item.active {
  background: rgba(0, 240, 255, 0.1);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
  box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.05), var(--glow-cyan);
}

.nav-item.active::before { opacity: 1; }

.nav-icon { font-size: 1.1rem; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
}

.github-link {
  font-size: 0.8rem;
  color: var(--text-dim);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.3s;
}

.github-link:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ========== Reading Progress ========== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
  z-index: 9999;
  transition: width 0.1s;
  box-shadow: 0 0 10px var(--neon-cyan), 0 0 20px rgba(0, 240, 255, 0.3);
}

/* ========== Post Card ========== */
.post-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 20px;
  border: 1px solid var(--border-glow);
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
  transition: left 0.6s ease;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.08), 0 8px 32px rgba(0, 0, 0, 0.3);
}

.post-card:hover::before { left: 100%; }

.post-title {
  font-size: 1.25rem;
  margin-bottom: 10px;
  line-height: 1.4;
}

.post-title a {
  color: var(--text);
  transition: all 0.3s;
}

.post-title a:hover {
  color: var(--neon-cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}

.post-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-family: 'Fira Code', monospace;
}

.post-tags { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  font-size: 0.75rem;
  color: var(--neon-purple);
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid rgba(180, 74, 255, 0.3);
  background: rgba(180, 74, 255, 0.08);
  transition: all 0.3s;
  font-family: 'Fira Code', monospace;
}

.tag:hover {
  background: rgba(180, 74, 255, 0.2);
  border-color: var(--neon-purple);
  color: #fff;
  box-shadow: var(--glow-purple);
  transform: scale(1.05);
}

.post-excerpt {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.6;
}

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

.pagination a, .pagination span {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: 'Fira Code', monospace;
}

.pagination a {
  background: var(--bg-card);
  color: var(--neon-cyan);
  border: 1px solid var(--border-glow);
  transition: all 0.3s;
}

.pagination a:hover {
  border-color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
  transform: translateY(-2px);
}

.pagination .current {
  background: rgba(0, 240, 255, 0.1);
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

/* ========== Post Detail ========== */
.post-detail {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px 48px;
  border: 1px solid var(--border-glow);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
}

.post-detail .post-header { margin-bottom: 32px; }

.post-detail .post-title {
  font-size: 1.7rem;
  margin-bottom: 12px;
}

.post-detail .post-title {
  color: var(--neon-cyan);
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.post-body {
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--text);
}

.post-body h2 {
  font-size: 1.35rem;
  margin: 2em 0 0.8em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-glow);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
  position: relative;
}

.post-body h2::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), transparent);
  box-shadow: 0 0 8px var(--neon-cyan);
}

.post-body h3 {
  font-size: 1.15rem;
  margin: 1.5em 0 0.6em;
  color: var(--neon-purple);
  text-shadow: 0 0 6px rgba(180, 74, 255, 0.2);
}

.post-body p { margin: 0.8em 0; }

.post-body blockquote {
  border-left: 3px solid var(--neon-cyan);
  padding: 12px 20px;
  margin: 1.2em 0;
  background: rgba(0, 240, 255, 0.03);
  border-radius: 0 8px 8px 0;
  color: var(--text-dim);
  font-style: italic;
  box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.02);
}

.post-body pre {
  border-radius: 10px;
  padding: 20px;
  margin: 1.2em 0;
  overflow-x: auto;
  border: 1px solid var(--border-glow);
  position: relative;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.post-body pre:hover {
  border-color: rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.05);
}

.post-body code {
  font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.88em;
}

.post-body :not(pre) > code {
  background: rgba(0, 240, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 240, 255, 0.15);
}

.post-body a {
  position: relative;
  color: var(--neon-cyan);
}

.post-body a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 1px;
  bottom: -2px;
  left: 0;
  background: var(--neon-cyan);
  box-shadow: 0 0 6px var(--neon-cyan);
  transition: width 0.3s;
}

.post-body a:hover::after { width: 100%; }

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

.post-body li { margin: 0.3em 0; }

.post-body li::marker { color: var(--neon-cyan); }

/* ========== Back to Top ========== */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--neon-cyan);
  background: var(--bg-card);
  color: var(--neon-cyan);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  z-index: 999;
  box-shadow: var(--glow-cyan);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  transform: translateY(-4px);
  background: rgba(0, 240, 255, 0.1);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.5);
}

/* ========== Footer ========== */
.site-footer {
  margin-top: 48px;
  padding: 24px 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-glow);
}

.footer-inner {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.heart {
  animation: heartbeat 1.2s ease-in-out infinite;
  display: inline-block;
  filter: hue-rotate(160deg);
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.3); }
  28% { transform: scale(1); }
  42% { transform: scale(1.3); }
  70% { transform: scale(1); }
}

.visitor-stats {
  margin-top: 8px;
  font-size: 0.75rem;
  display: flex;
  justify-content: center;
  gap: 16px;
  font-family: 'Fira Code', monospace;
  color: var(--text-dim);
}

/* ========== Page Title ========== */
.page-title {
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: var(--neon-cyan);
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
  letter-spacing: 1px;
}

/* ========== Tags Page ========== */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 32px;
}

.tag-cloud .tag {
  font-size: 0.85rem;
  padding: 6px 14px;
}

/* ========== Archives ========== */
.archive-year {
  font-size: 1.2rem;
  margin: 28px 0 12px;
  color: var(--neon-purple);
  text-shadow: 0 0 8px rgba(180, 74, 255, 0.3);
  font-family: 'Fira Code', monospace;
}

.archive-list { list-style: none; }

.archive-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 240, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 12px;
}

.archive-item time {
  font-size: 0.8rem;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 80px;
  font-family: 'Fira Code', monospace;
}

.archive-item a {
  font-size: 0.9rem;
  color: var(--text);
  transition: all 0.3s;
}

.archive-item a:hover {
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  transform: translateX(4px);
  display: inline-block;
}

/* ========== Search ========== */
.search-box { margin-bottom: 24px; }

.search-input {
  width: 100%;
  padding: 12px 20px;
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s;
  background: var(--bg-card);
  color: var(--text);
  font-family: 'Fira Code', monospace;
}

.search-input::placeholder { color: var(--text-dim); }

.search-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-glow);
  }
  .sidebar::after { display: none; }
  .sidebar-inner {
    position: relative;
    height: auto;
    padding: 20px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  .site-author { margin-bottom: 0; }
  .avatar { width: 60px; height: 60px; }
  .site-nav { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .nav-item::before { display: none; }
  .sidebar-footer { display: none; }
  .main-content { padding: 20px 16px; }
  .post-detail { padding: 24px 20px; }
}

/* ========== Ambient Grid Background ========== */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: -1;
}
