/* ============================================
   ECHARTS DASHBOARD STYLE - Blog Archive
   Data Visualization Inspired Design (Light Theme)
   ============================================ */

/* === CSS Variables - ECharts Light Theme === */
:root {
  /* ECharts Color Palette - Light */
  --echarts-bg: #F8FAFC;
  --echarts-surface: #FFFFFF;
  --echarts-surface-elevated: #F1F5F9;
  --echarts-border: #E2E8F0;
  --echarts-border-light: #CBD5E1;

  /* Primary Colors - Blue Series */
  --echarts-primary: #1E40AF;
  --echarts-primary-light: #3B82F6;
  --echarts-primary-glow: rgba(59, 130, 246, 0.15);

  /* Accent Colors */
  --echarts-accent: #F59E0B;
  --echarts-accent-light: #FBBF24;
  --echarts-success: #10B981;
  --echarts-danger: #EF4444;

  /* Text Colors */
  --echarts-text: #1E293B;
  --echarts-text-muted: #64748B;
  --echarts-text-dim: #94A3B8;

  /* Gradients */
  --echarts-gradient-primary: linear-gradient(135deg, #1E40AF 0%, #3B82F6 100%);
  --echarts-gradient-accent: linear-gradient(135deg, #F59E0B 0%, #FBBF24 100%);
  --echarts-gradient-bg: radial-gradient(ellipse at top, #FFFFFF 0%, #F8FAFC 100%);

  /* Shadows */
  --echarts-shadow-sm: 0 2px 8px rgba(30, 64, 175, 0.08);
  --echarts-shadow-md: 0 4px 16px rgba(30, 64, 175, 0.12);
  --echarts-shadow-lg: 0 8px 32px rgba(30, 64, 175, 0.15);
  --echarts-shadow-glow: 0 0 30px rgba(59, 130, 246, 0.1);
  --echarts-shadow-accent-glow: 0 0 30px rgba(245, 158, 11, 0.1);

  /* Typography */
  --echarts-font-heading: 'Fira Code', 'JetBrains Mono', monospace;
  --echarts-font-body: 'Fira Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --echarts-space-1: 8px;
  --echarts-space-2: 16px;
  --echarts-space-3: 24px;
  --echarts-space-4: 32px;
  --echarts-space-6: 48px;
  --echarts-space-8: 64px;

  /* Border Radius */
  --echarts-radius-sm: 4px;
  --echarts-radius-md: 8px;
  --echarts-radius-lg: 12px;
  --echarts-radius-xl: 16px;

  /* Transitions */
  --echarts-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --echarts-duration: 250ms;
}

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

/* === Base Styles === */
#archive {
  font-family: var(--echarts-font-body);
  background: var(--echarts-bg);
  color: var(--echarts-text);
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient background effect */
#archive::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(30, 64, 175, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(245, 158, 11, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle grid pattern */
#archive::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(203, 213, 225, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(203, 213, 225, 0.5) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* === Layout Container === */
.archive-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--echarts-space-6) var(--echarts-space-3);
}

/* === Stats Dashboard === */
.archive-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--echarts-space-3);
  margin-bottom: var(--echarts-space-6);
  animation: fadeInUp 0.6s var(--echarts-ease) backwards;
}

.stat-card {
  background: var(--echarts-surface);
  border: 1px solid var(--echarts-border);
  border-radius: var(--echarts-radius-lg);
  padding: var(--echarts-space-3);
  position: relative;
  overflow: hidden;
  transition: all var(--echarts-duration) var(--echarts-ease);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--echarts-gradient-primary);
  opacity: 0;
  transition: opacity var(--echarts-duration) var(--echarts-ease);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--echarts-primary-light);
  box-shadow: var(--echarts-shadow-glow);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card.accent::before {
  background: var(--echarts-gradient-accent);
}

.stat-label {
  font-family: var(--echarts-font-heading);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--echarts-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--echarts-space-1);
}

.stat-value {
  font-family: var(--echarts-font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--echarts-text);
  line-height: 1.2;
}

.stat-value.primary {
  color: var(--echarts-primary-light);
}

.stat-value.accent {
  color: var(--echarts-accent);
}

.stat-change {
  font-family: var(--echarts-font-heading);
  font-size: 0.6875rem;
  color: var(--echarts-success);
  margin-top: var(--echarts-space-1);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* === Main Content Grid === */
.archive-content {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--echarts-space-4);
  position: relative;
  z-index: 1;
}

/* === Timeline Sidebar === */
.archive-timeline {
  position: sticky;
  top: var(--echarts-space-4);
  height: fit-content;
  background: var(--echarts-surface);
  border: 1px solid var(--echarts-border);
  border-radius: var(--echarts-radius-lg);
  padding: var(--echarts-space-3);
  animation: fadeInLeft 0.6s var(--echarts-ease) 0.1s backwards;
}

.timeline-header {
  margin-bottom: var(--echarts-space-3);
  padding-bottom: var(--echarts-space-2);
  border-bottom: 1px solid var(--echarts-border);
}

.timeline-title {
  font-family: var(--echarts-font-heading);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--echarts-text-muted);
  margin: 0;
}

.timeline-subtitle {
  font-family: var(--echarts-font-heading);
  font-size: 0.5625rem;
  color: var(--echarts-text-dim);
  letter-spacing: 0.1em;
  margin: var(--echarts-space-1) 0 0 0;
}

.timeline-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: var(--echarts-space-1);
}

/* Custom scrollbar */
.timeline-nav::-webkit-scrollbar {
  width: 4px;
}

.timeline-nav::-webkit-scrollbar-track {
  background: transparent;
}

.timeline-nav::-webkit-scrollbar-thumb {
  background: var(--echarts-border);
  border-radius: 4px;
}

.timeline-nav::-webkit-scrollbar-thumb:hover {
  background: var(--echarts-primary);
}

/* Timeline links */
.timeline-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--echarts-space-1) var(--echarts-space-2);
  text-decoration: none;
  color: var(--echarts-text-muted);
  font-family: var(--echarts-font-heading);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--echarts-radius-sm);
  transition: all var(--echarts-duration) var(--echarts-ease);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
}

.timeline-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--echarts-gradient-primary);
  transform: scaleY(0);
  transition: transform var(--echarts-duration) var(--echarts-ease);
}

.timeline-link:hover {
  color: var(--echarts-text);
  background: rgba(30, 64, 175, 0.15);
  border-color: var(--echarts-border);
  transform: translateX(4px);
}

.timeline-link:hover::before {
  transform: scaleY(1);
}

.timeline-link.active {
  color: var(--echarts-primary-light);
  background: rgba(30, 64, 175, 0.2);
  border-color: var(--echarts-primary);
}

.timeline-link.active::before {
  transform: scaleY(1);
}

.timeline-year {
  font-variant-numeric: tabular-nums;
}

.timeline-count {
  font-family: var(--echarts-font-heading);
  font-size: 0.5625rem;
  color: var(--echarts-text-dim);
  padding: 2px 8px;
  background: var(--echarts-surface-elevated);
  border-radius: 99px;
  font-weight: 600;
  transition: all var(--echarts-duration) var(--echarts-ease);
}

.timeline-link:hover .timeline-count,
.timeline-link.active .timeline-count {
  background: var(--echarts-primary);
  color: white;
}

/* === Article List Area === */
.archive-articles {
  position: relative;
}

/* === Year Section === */
.article-sort-item.year {
  display: block !important;
  position: relative;
  margin: var(--echarts-space-8) 0 var(--echarts-space-4) 0;
  animation: fadeInUp 0.6s var(--echarts-ease) backwards;
}

/* Year header with ECharts style */
.archive-year-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--echarts-space-3);
  padding: var(--echarts-space-3) var(--echarts-space-4);
  background: var(--echarts-surface);
  border: 1px solid var(--echarts-border);
  border-radius: var(--echarts-radius-lg);
  cursor: pointer;
  transition: all var(--echarts-duration) var(--echarts-ease);
}

.archive-year-header::before {
  content: attr(data-year);
  position: absolute;
  right: var(--echarts-space-4);
  font-family: var(--echarts-font-heading);
  font-size: clamp(60px, 10vw, 100px);
  font-weight: 700;
  color: var(--echarts-border);
  line-height: 1;
  pointer-events: none;
  opacity: 0.5;
}

.archive-year-header:hover {
  border-color: var(--echarts-primary-light);
  box-shadow: var(--echarts-shadow-glow);
}

.year-marker {
  display: flex;
  align-items: center;
  gap: var(--echarts-space-2);
  flex-shrink: 0;
}

.year-dot {
  width: 12px;
  height: 12px;
  background: var(--echarts-gradient-primary);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--echarts-primary-glow);
  transition: all var(--echarts-duration) var(--echarts-ease);
}

.archive-year-header:hover .year-dot {
  transform: scale(1.2);
  box-shadow: 0 0 20px var(--echarts-primary-glow);
}

.year-title {
  font-family: var(--echarts-font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--echarts-text);
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}

.year-count {
  font-family: var(--echarts-font-heading);
  font-size: 0.6875rem;
  color: var(--echarts-text-muted);
  padding: 4px 12px;
  background: var(--echarts-surface-elevated);
  border: 1px solid var(--echarts-border);
  border-radius: 99px;
  font-weight: 600;
}

/* Toggle button */
.year-toggle {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--echarts-surface-elevated);
  border: 1px solid var(--echarts-border);
  border-radius: var(--echarts-radius-md);
  cursor: pointer;
  transition: all var(--echarts-duration) var(--echarts-ease);
  color: var(--echarts-text-muted);
  flex-shrink: 0;
}

.year-toggle:hover {
  background: var(--echarts-primary);
  border-color: var(--echarts-primary);
  color: white;
  transform: scale(1.05);
}

.year-toggle svg {
  transition: transform 0.4s var(--echarts-ease);
}

.year-toggle.rotated svg {
  transform: rotate(180deg);
}

/* Year content (articles) */
.year-content {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.4s var(--echarts-ease);
  padding-left: var(--echarts-space-4);
}

.year-content.collapsed {
  grid-template-rows: 0fr;
}

.year-content > * {
  overflow: hidden;
  transition: opacity 0.3s var(--echarts-ease);
}

.year-content.collapsed > * {
  opacity: 0;
}

/* === Article Cards === */
.article-sort-item:not(.year) {
  position: relative;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--echarts-space-3);
  padding: var(--echarts-space-3);
  background: var(--echarts-surface);
  border: 1px solid var(--echarts-border);
  border-radius: var(--echarts-radius-md);
  margin-bottom: var(--echarts-space-2);
  transition: all var(--echarts-duration) var(--echarts-ease);
  opacity: 0;
  transform: translateY(10px);
}

.article-sort-item:not(.year).in-view {
  opacity: 1;
  transform: translateY(0);
}

.article-sort-item:not(.year):hover {
  border-color: var(--echarts-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--echarts-shadow-glow);
}

/* Cover image */
.article-sort-item-img {
  display: block;
}

.article-sort-item-img a {
  display: block;
  width: 100px;
  height: 75px;
  border-radius: var(--echarts-radius-sm);
  overflow: hidden;
  position: relative;
}

.article-sort-item-img a::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.3) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--echarts-duration) var(--echarts-ease);
}

.article-sort-item:not(.year):hover .article-sort-item-img a::after {
  opacity: 1;
}

.article-sort-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--echarts-duration) var(--echarts-ease);
}

.article-sort-item:not(.year):hover .article-sort-item-img img {
  transform: scale(1.05);
}

/* Article info */
.article-sort-item-info {
  display: flex;
  flex-direction: column;
  gap: var(--echarts-space-1);
  justify-content: center;
}

.article-sort-item-time {
  font-family: var(--echarts-font-heading);
  font-size: 0.6875rem;
  color: var(--echarts-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: var(--echarts-space-1);
}

.article-sort-item-time::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--echarts-primary-light);
  border-radius: 50%;
}

.article-sort-item-title {
  font-family: var(--echarts-font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--echarts-text);
  text-decoration: none;
  transition: color var(--echarts-duration) var(--echarts-ease);
}

.article-sort-item-title:hover {
  color: var(--echarts-primary-light);
}

/* Article tags */
.article-sort-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--echarts-space-1);
}

.article-tag {
  font-family: var(--echarts-font-heading);
  font-size: 0.5625rem;
  color: var(--echarts-text-muted);
  padding: 2px 8px;
  background: var(--echarts-surface-elevated);
  border: 1px solid var(--echarts-border);
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all var(--echarts-duration) var(--echarts-ease);
}

.article-sort-item:not(.year):hover .article-tag {
  border-color: var(--echarts-primary);
  color: var(--echarts-primary-light);
}

/* === Animations === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Staggered animation for year sections */
.article-sort-item.year:nth-child(1) { animation-delay: 0s; }
.article-sort-item.year:nth-child(2) { animation-delay: 0.1s; }
.article-sort-item.year:nth-child(3) { animation-delay: 0.15s; }
.article-sort-item.year:nth-child(4) { animation-delay: 0.2s; }
.article-sort-item.year:nth-child(5) { animation-delay: 0.25s; }

/* === Responsive Design === */
@media (max-width: 1024px) {
  .archive-content {
    grid-template-columns: 1fr;
  }

  .archive-timeline {
    position: static;
  }

  .timeline-nav {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    padding-bottom: var(--echarts-space-2);
    gap: var(--echarts-space-1);
  }

  .archive-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .archive-container {
    padding: var(--echarts-space-4) var(--echarts-space-2);
  }

  .archive-stats {
    grid-template-columns: 1fr 1fr;
    gap: var(--echarts-space-2);
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .archive-year-header::before {
    display: none;
  }

  .year-title {
    font-size: 1.25rem;
  }

  .article-sort-item:not(.year) {
    grid-template-columns: 80px 1fr;
  }

  .article-sort-item-img a {
    width: 80px;
    height: 60px;
  }

  .article-sort-item-title {
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .archive-stats {
    grid-template-columns: 1fr;
  }

  .article-sort-item:not(.year) {
    grid-template-columns: 1fr;
  }

  .article-sort-item-img {
    display: none;
  }
}

/* === Focus States === */
.timeline-link:focus-visible,
.year-toggle:focus-visible,
.article-sort-item-title:focus-visible {
  outline: 2px solid var(--echarts-primary-light);
  outline-offset: 2px;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === Title Styling Override === */
.article-sort-title {
  font-family: var(--echarts-font-heading);
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--echarts-text);
  margin-bottom: var(--echarts-space-6);
  position: relative;
  z-index: 1;
}

.article-sort-title span {
  color: var(--echarts-primary-light);
}
