/* =============================================
   CSS Variables — Theme System
   ============================================= */

:root {
  --surface-50: #f6f6f8;
  --surface-100: #ececf0;
  --surface-200: #d5d5de;
  --surface-300: #b1b1c2;
  --surface-400: #8686a1;
  --surface-500: #676786;
  --surface-600: #52526c;
  --surface-700: #434357;
  --surface-800: #3a3a49;
  --surface-900: #1e1e26;
  --surface-950: #0d0d12;
  --grid-line: rgba(255, 255, 255, 0.02);
  --nav-bg: rgba(13, 13, 18, 0.85);
  --scrollbar-track: #0d0d12;
  --scrollbar-thumb: #3a3a49;
  --scrollbar-thumb-hover: #434357;
  --toast-bg: #1e1e26;
  --toast-border: #3a3a49;
}

[data-theme="light"] {
  --surface-50: #011a0d;
  --surface-100: #082916;
  --surface-200: #103d23;
  --surface-300: #1c5634;
  --surface-400: #2e7149;
  --surface-500: #4d9169;
  --surface-600: #62a67e;
  --surface-700: #a6d4b9;
  --surface-800: #cde8d7;
  --surface-900: #e5f2ea;
  --surface-950: #f1f9f4;
  --grid-line: rgba(30, 86, 50, 0.06);
  --nav-bg: rgba(241, 249, 244, 0.85);
  --scrollbar-track: #e5f2ea;
  --scrollbar-thumb: #a6d4b9;
  --scrollbar-thumb-hover: #7ebf98;
  --toast-bg: #ffffff;
  --toast-border: #cde8d7;
}

[data-theme="light"] .noise-overlay {
  opacity: 0.02;
  filter: invert(1);
}

[data-theme="light"] .grid-pattern {
  background-image: 
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
}

[data-theme="light"] .nav-scrolled {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--surface-800);
}

[data-theme="light"] .glitch-text {
  text-shadow:
    0 0 20px rgba(0, 100, 60, 0.2),
    0 0 60px rgba(0, 100, 60, 0.05);
}

[data-theme="light"] .toast {
  background: var(--toast-bg);
  border-color: var(--toast-border);
  box-shadow: 0 20px 25px -5px rgba(0, 60, 30, 0.1);
}

/* Selection */
[data-theme="light"] ::selection {
  background: rgba(0, 168, 95, 0.25);
  color: #011a0d;
}

[data-theme="light"] ::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Noise Overlay */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Grid Pattern */
.grid-pattern {
  background-image: 
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* Glitch Effect */
.glitch-text {
  position: relative;
  display: inline-block;
  text-shadow:
    0 0 20px rgba(0, 230, 138, 0.3),
    0 0 60px rgba(0, 230, 138, 0.1);
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch-text::before {
  color: #ff3e3e;
  animation: glitch-1 3s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
}

.glitch-text::after {
  color: #3ef7ff;
  animation: glitch-2 3s infinite linear alternate-reverse;
  clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
}

@keyframes glitch-1 {
  0%, 90% { transform: translate(0); }
  91% { transform: translate(-2px, 1px); }
  92% { transform: translate(2px, -1px); }
  93% { transform: translate(-1px, 2px); }
  94%, 100% { transform: translate(0); }
}

@keyframes glitch-2 {
  0%, 90% { transform: translate(0); }
  91% { transform: translate(2px, -1px); }
  92% { transform: translate(-2px, 1px); }
  93% { transform: translate(1px, -2px); }
  94%, 100% { transform: translate(0); }
}

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

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

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

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

/* Category Cards */
.category-card {
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(0, 230, 138, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

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

.category-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 230, 138, 0.3);
}

/* Post Cards */
.post-card {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}

.post-card > div {
  min-width: 0;
  overflow-wrap: break-word;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 230, 138, 0.3);
}

.post-card:hover .post-card-image img {
  transform: scale(1.05);
}

.post-card-image {
  overflow: hidden;
}

.post-card-image img {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tag pills */
.tag-pill {
  transition: all 0.2s ease;
}

.tag-pill:hover {
  transform: scale(1.05);
}

.tag-pill.active {
  background: rgba(0, 230, 138, 0.15);
  color: #2bfda3;
  border-color: rgba(0, 230, 138, 0.3);
}

/* Nav scroll state */
.nav-scrolled {
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--surface-800);
}

/* Reading time indicator */
.reading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, #00e68a, #2bfda3);
  z-index: 100;
  transition: width 0.1s linear;
}

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

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out forwards;
}

.animate-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.3s; opacity: 0; }
.animate-delay-4 { animation-delay: 0.4s; opacity: 0; }
.animate-delay-5 { animation-delay: 0.5s; opacity: 0; }

/* Selection */
::selection {
  background: rgba(0, 230, 138, 0.3);
  color: #fff;
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid rgba(0, 230, 138, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Smooth transitions for all interactive elements */
a, button, input {
  transition: all 0.2s ease;
}

/* Pulse dot animation */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-pulse-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 100;
  padding: 12px 24px;
  background: var(--toast-bg);
  border: 1px solid var(--toast-border);
  border-radius: 12px;
  color: var(--surface-200);
  font-size: 14px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}