/* =====================================================
   Tech Research - Redesigned with distinctive aesthetics
   Typography: Space Grotesk + Crimson Pro
   Theme: Light editorial with elegant accents
   ===================================================== */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,500;0,600;1,400&family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
  /* Color Palette - Light editorial theme */
  --bg-deep: #f8f9fa;
  --bg-primary: #ffffff;
  --bg-elevated: #ffffff;
  --bg-surface: #f1f3f5;
  --bg-hover: #e9ecef;

  /* Text colors */
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a5a;
  --text-muted: #8a8a9a;

  /* Accent colors - Deep blue with warm amber complement */
  --accent-primary: #0066cc;
  --accent-primary-dim: rgba(0, 102, 204, 0.1);
  --accent-secondary: #e67e22;
  --accent-tertiary: #8b5cf6;
  --accent-success: #10b981;

  /* Borders and shadows */
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-prominent: rgba(0, 0, 0, 0.15);
  --glow-primary: 0 4px 20px rgba(0, 102, 204, 0.1);
  --glow-hover: 0 8px 30px rgba(0, 102, 204, 0.15);
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Layout */
  --radius: 8px;
  --radius-lg: 16px;
  --max-width: 1200px;
  --sidebar-width: 320px;
  --gap: 32px;

  /* Typography */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Crimson Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-primary);
  background: var(--bg-deep);
  /* Subtle gradient background */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 102, 204, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(139, 92, 246, 0.04) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-primary) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

a:hover {
  color: var(--text-primary);
  text-shadow: 0 0 12px var(--accent-primary);
}

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

/* Container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Site Wrapper */
.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.6s ease-out;
}

/* Header */
.site-header {
  position: relative;
  padding: 80px 0 60px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(0, 102, 204, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-primary) 0%, transparent 100%);
  border-bottom: 1px solid var(--border-subtle);
  animation: fadeIn 0.8s ease-out;
}

.site-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
  opacity: 0.5;
}

.site-title {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: -2px;
  animation: fadeInUp 0.8s ease-out 0.1s both;
}

.site-title a {
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-title a:hover {
  text-shadow: none;
}

.site-description {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-secondary);
  font-weight: 400;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Navigation */
.main-nav {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  animation: fadeIn 0.6s ease-out 0.3s both;
}

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

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-menu a {
  display: block;
  padding: 18px 16px;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  position: relative;
  transition: color 0.2s ease;
}

.nav-menu a::after {
  content: '';
  position: absolute;
  bottom: 12px;
  left: 16px;
  right: 16px;
  height: 2px;
  background: var(--accent-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.nav-menu a:hover {
  color: var(--text-primary);
  text-shadow: none;
}

.nav-menu a:hover::after {
  transform: scaleX(1);
}

.search-container {
  margin-left: auto;
}

#search-input {
  padding: 10px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-primary);
  width: 200px;
  transition: all 0.3s ease;
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  width: 260px;
  box-shadow: 0 0 0 3px var(--accent-primary-dim), var(--glow-primary);
}

/* Main Content */
.site-main {
  flex: 1;
  padding: 48px 0;
}

.content-wrapper {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--gap);
  align-items: start;
}

/* Post List */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.post-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.6s ease-out both;
  box-shadow: var(--shadow-soft);
}

.post-card:nth-child(1) { animation-delay: 0.1s; }
.post-card:nth-child(2) { animation-delay: 0.15s; }
.post-card:nth-child(3) { animation-delay: 0.2s; }
.post-card:nth-child(4) { animation-delay: 0.25s; }
.post-card:nth-child(5) { animation-delay: 0.3s; }
.post-card:nth-child(n+6) { animation-delay: 0.35s; }

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-tertiary));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.post-card:hover {
  border-color: var(--border-prominent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-elevated), var(--glow-primary);
}

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

.post-header {
  margin-bottom: 16px;
}

.post-category {
  display: inline-block;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  border: 1px solid rgba(0, 102, 204, 0.2);
}

.post-title {
  margin: 12px 0 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.post-title a {
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.post-title a:hover {
  color: var(--accent-primary);
  text-shadow: none;
}

.post-excerpt {
  color: var(--text-secondary);
  margin: 16px 0;
  font-size: 1.05rem;
}

.post-excerpt p {
  margin: 0;
}

.post-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.read-more {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.read-more::after {
  content: '→';
  transition: transform 0.3s ease;
}

.read-more:hover::after {
  transform: translateX(4px);
}

/* Single Post */
.post-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 48px;
  animation: fadeInUp 0.7s ease-out 0.1s both;
  box-shadow: var(--shadow-soft);
}

.single-post-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.single-post-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary), transparent);
}

.single-post-title {
  margin: 16px 0 0;
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.single-post-content {
  font-size: 1.1rem;
  line-height: 1.8;
}

.single-post-content h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 56px 0 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  letter-spacing: -0.02em;
}

.single-post-content h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 40px 0 16px;
}

.single-post-content h4 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 32px 0 12px;
}

.single-post-content p {
  margin: 0 0 24px;
  color: var(--text-secondary);
}

.single-post-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.single-post-content ul,
.single-post-content ol {
  margin: 0 0 24px;
  padding-left: 28px;
  color: var(--text-secondary);
}

.single-post-content li {
  margin-bottom: 10px;
}

.single-post-content li::marker {
  color: var(--accent-primary);
}

.single-post-content blockquote {
  margin: 32px 0;
  padding: 24px 28px;
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-left: 4px solid var(--accent-tertiary);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
  font-style: italic;
}

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

/* Inline Code */
.single-post-content code:not(.hljs) {
  background: var(--bg-surface);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent-secondary);
  border: 1px solid var(--border-subtle);
}

/* Code Blocks */
.single-post-content pre {
  background: #282c34;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  overflow-x: auto;
  margin: 28px 0;
  position: relative;
}

.single-post-content pre::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: #21252b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius) var(--radius) 0 0;
}

.single-post-content pre::after {
  content: '• • •';
  position: absolute;
  top: 8px;
  left: 16px;
  font-size: 0.75rem;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.4);
}

.single-post-content pre code {
  background: none !important;
  padding: 0;
  border: none;
  font-size: 0.875rem;
  line-height: 1.7;
  font-family: var(--font-mono);
  display: block;
  margin-top: 16px;
  color: #abb2bf;
}

/* Mermaid diagrams */
.single-post-content .mermaid {
  background: var(--bg-surface);
  padding: 32px;
  border-radius: var(--radius);
  margin: 28px 0;
  text-align: center;
  border: 1px solid var(--border-subtle);
}

/* Tables */
.single-post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-size: 0.95rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.single-post-content th,
.single-post-content td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.single-post-content th {
  background: var(--bg-surface);
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.single-post-content td {
  color: var(--text-secondary);
}

.single-post-content tr:last-child td {
  border-bottom: none;
}

.single-post-content tr:hover td {
  background: rgba(0, 102, 204, 0.03);
}

/* Mermaid Diagrams */
.mermaid-diagram {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 28px;
  margin: 28px 0;
  overflow-x: auto;
  text-align: center;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

/* Single Post Footer */
.single-post-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.back-link {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.back-link::before {
  content: '←';
  transition: transform 0.3s ease;
}

.back-link:hover::before {
  transform: translateX(-4px);
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 100px;
  animation: slideInRight 0.7s ease-out 0.3s both;
}

.widget {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  transition: border-color 0.3s ease;
  box-shadow: var(--shadow-soft);
}

.widget:hover {
  border-color: var(--border-prominent);
}

.widget-title {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent-primary);
}

.recent-posts,
.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-posts li,
.category-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.recent-posts li:last-child,
.category-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.recent-posts li:first-child,
.category-list li:first-child {
  padding-top: 0;
}

.recent-posts a,
.category-list a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  display: block;
}

.recent-posts a:hover,
.category-list a:hover {
  color: var(--accent-primary);
  padding-left: 8px;
  text-shadow: none;
}

/* Footer */
.site-footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
  margin-top: auto;
}

.site-footer p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* Loading & Empty States */
.loading,
.no-posts {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 80px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 992px) {
  .content-wrapper {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    animation-delay: 0.4s;
  }

  .widget {
    margin-bottom: 0;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .site-header {
    padding: 48px 0 36px;
  }

  .site-title {
    font-size: 2.2rem;
    letter-spacing: -1px;
  }

  .site-description {
    font-size: 1rem;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    flex-direction: column;
    gap: 0;
    padding: 0;
    border-top: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-elevated);
    display: none;
  }

  .nav-menu.active {
    display: flex;
  }

  .nav-menu li {
    width: 100%;
    border-bottom: 1px solid var(--border-subtle);
  }

  .nav-menu a {
    padding: 16px 24px;
  }

  .nav-menu a::after {
    display: none;
  }

  .search-container {
    margin-left: 0;
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
  }

  #search-input {
    width: 100%;
  }

  #search-input:focus {
    width: 100%;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .post-card {
    padding: 24px;
  }

  .post-content {
    padding: 28px;
  }

  .single-post-title {
    font-size: 1.8rem;
  }

  .single-post-content h2 {
    font-size: 1.4rem;
    margin-top: 40px;
  }

  .single-post-content h3 {
    font-size: 1.2rem;
  }

  .single-post-content pre {
    padding: 20px 16px;
    padding-top: 44px;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 32px 0;
  }

  .site-title {
    font-size: 1.75rem;
  }

  .site-main {
    padding: 24px 0;
  }

  .post-title {
    font-size: 1.35rem;
  }

  .post-card {
    padding: 20px;
  }

  .single-post-content {
    font-size: 1rem;
  }
}

/* Print Styles */
@media print {
  .main-nav,
  .sidebar,
  .single-post-footer,
  .site-footer {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .content-wrapper {
    display: block;
  }

  .post-content {
    box-shadow: none;
    border: none;
    padding: 0;
    background: white;
  }

  .single-post-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid #ccc;
    background: #f5f5f5;
  }

  .single-post-title,
  .single-post-content h2,
  .single-post-content h3,
  .single-post-content h4 {
    color: black;
  }

  .single-post-content p,
  .single-post-content li,
  .single-post-content td {
    color: #333;
  }
}

/* Syntax Highlighting Overrides - Code blocks stay dark */
.hljs {
  background: transparent !important;
  color: #abb2bf !important;
}

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

::-moz-selection {
  background: var(--accent-primary);
  color: #ffffff;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
  background: #c1c4c9;
  border-radius: 5px;
  border: 2px solid var(--bg-surface);
}

::-webkit-scrollbar-thumb:hover {
  background: #a0a4aa;
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}
