/* Mobile-First Design System - Unified Tokens */
:root {
  /* ===== INHERITS DESIGN SYSTEM FROM MAIN STYLE.CSS ===== */
  /* All color, typography, spacing, radius, and animation tokens are inherited */
  
  /* Mobile-specific overrides only when needed */
  --mobile-header-height: 60px;
  --mobile-nav-height: 50px;
  --mobile-padding: var(--space-4);
  
  /* Mobile-optimized typography scale */
  --mobile-text-xs: 0.75rem;    /* 12px */
  --mobile-text-sm: 0.875rem;   /* 14px */
  --mobile-text-base: 1rem;     /* 16px */
  --mobile-text-lg: 1.125rem;   /* 18px */
  --mobile-text-xl: 1.25rem;    /* 20px */
  --mobile-text-2xl: 1.375rem;  /* 22px */
  --mobile-text-3xl: 1.5rem;    /* 24px */
  
  /* Mobile-specific radius (slightly smaller) */
  --mobile-radius-sm: 0.25rem;   /* 4px */
  --mobile-radius-md: 0.375rem;  /* 6px */
  --mobile-radius-lg: 0.5rem;    /* 8px */
  --mobile-radius-xl: 0.75rem;   /* 12px */
  --mobile-radius-2xl: 1rem;     /* 16px */
}

/* Dark mode inherits from main CSS - no overrides needed */

/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  font-size: 16px;
  overflow-x: hidden;
}

/* Enhanced Mobile Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 { 
  font-size: clamp(2rem, 6vw, 2.5rem);
  font-weight: 700;
  line-height: 1.1;
}
h2 { 
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 600;
}
h3 { 
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 600;
}

p {
  line-height: 1.6;
  color: var(--fg-muted);
  margin: 0;
}

/* Mobile Header */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.9) 0%, 
    rgba(255, 255, 255, 0.7) 100%);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  height: 60px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .mobile-header {
  background: linear-gradient(135deg, 
    rgba(0, 0, 0, 0.9) 0%, 
    rgba(25, 25, 25, 0.8) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.3);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-4);
  height: 100%;
  max-width: 100vw;
  overflow: hidden;
}

.logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--fg);
  flex-shrink: 0;
}

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

.theme-toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-subtle);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}

.theme-toggle:hover {
  background: var(--bg-elevated);
  transform: scale(1.05);
}

.theme-icon {
  width: 16px;
  height: 16px;
  background: var(--fg);
  mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg>') no-repeat center;
  mask-size: contain;
  -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg>') no-repeat center;
  -webkit-mask-size: contain;
}

[data-theme="dark"] .theme-icon {
  mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/></svg>') no-repeat center;
  mask-size: contain;
  -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/></svg>') no-repeat center;
  -webkit-mask-size: contain;
}

.menu-toggle {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: var(--space-2);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-toggle span {
  width: 24px;
  height: 2px;
  background: var(--fg);
  transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

.mobile-nav {
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.95) 0%, 
    rgba(255, 255, 255, 0.9) 100%);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav.active {
  max-height: 600px; /* Increased to ensure all content fits comfortably */
  padding: var(--space-2) 0 var(--space-6) 0; /* Add proper padding */
}

[data-theme="dark"] .mobile-nav {
  background: linear-gradient(135deg, 
    rgba(0, 0, 0, 0.95) 0%, 
    rgba(25, 25, 25, 0.9) 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.nav-link {
  display: block;
  padding: var(--space-4);
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.nav-link:hover {
  background: var(--bg-subtle);
}

/* Mobile Hero */
.mobile-hero {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4) var(--space-4) var(--space-6);
  margin-top: 60px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.1) 0%, 
    rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  padding: var(--space-2) var(--space-3);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: var(--space-3);
}

[data-theme="dark"] .hero-badge {
  background: linear-gradient(135deg, 
    rgba(25, 25, 25, 0.8) 0%, 
    rgba(35, 35, 35, 0.6) 100%);
  border-color: rgba(255, 255, 255, 0.05);
}

.hero-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--fg);
  line-height: 1.2;
}

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

.hero-description {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.profile-image {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto var(--space-4);
  border: 3px solid transparent;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.profile-image:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
  /* Optimized for PNG with transparency */
  image-rendering: auto;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}

.title {
  font-size: 1.25rem;
  color: var(--link);
  margin-bottom: var(--space-1);
}

.location {
  color: var(--fg-muted);
  margin-bottom: var(--space-6);
}

.quick-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-top: var(--space-6);
}

.stat {
  text-align: center;
}

.stat .number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--link);
}

.stat .label {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

/* Mobile Sections */
.mobile-section {
  padding: var(--space-8) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.section-content h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-4);
  color: var(--fg);
}

.section-content p {
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
  line-height: 1.6;
}

/* About Section */
.key-points {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.point {
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.7) 0%, 
    rgba(255, 255, 255, 0.5) 100%);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  padding: var(--space-3);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .point {
  background: linear-gradient(135deg, 
    rgba(25, 25, 25, 0.8) 0%, 
    rgba(35, 35, 35, 0.6) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Work Cards */
.work-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.work-card {
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.8) 0%, 
    rgba(255, 255, 255, 0.6) 100%);
  backdrop-filter: blur(15px) saturate(180%);
  -webkit-backdrop-filter: blur(15px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.work-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .work-card {
  background: linear-gradient(135deg, 
    rgba(25, 25, 25, 0.9) 0%, 
    rgba(35, 35, 35, 0.7) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .work-card:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

.company {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--link);
  margin-bottom: var(--space-1);
}

.role {
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.period {
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-bottom: var(--space-3);
}

.work-card p {
  color: var(--fg);
  margin-bottom: var(--space-3);
}

.impact {
  display: flex;
  gap: var(--space-4);
  font-size: 0.875rem;
}

.impact span {
  background: rgba(0, 153, 255, 0.1);
  color: var(--link);
  padding: var(--space-1) var(--space-2);
  border-radius: 6px;
  border: 1px solid rgba(0, 153, 255, 0.2);
}

/* Mobile Posts */
.mobile-posts {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.mobile-post {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-post:hover {
  border-color: var(--link);
  transform: translateY(-2px);
}

.post-date {
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-bottom: var(--space-2);
}

.post-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--fg);
}

.post-summary {
  color: var(--fg-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: var(--space-2);
}

.post-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.view-all-btn {
  display: inline-block;
  background: var(--link);
  color: white;
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius);
  text-decoration: none;
  text-align: center;
  font-weight: 500;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-all-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* Contact Section */
.contact-methods {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.contact-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: all 0.2s ease;
}

.contact-btn:hover {
  border-color: var(--link);
  transform: translateY(-2px);
}

.contact-btn.primary {
  background: var(--link);
  border-color: var(--link);
  color: white;
}

.contact-btn.primary:hover {
  background: var(--accent-hover);
}

.contact-btn .icon {
  font-size: 1.25rem;
}

/* Newsletter */
.newsletter-mobile {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  text-align: center;
}

.newsletter-mobile h3 {
  margin-bottom: var(--space-2);
  color: var(--fg);
}

.newsletter-mobile p {
  margin-bottom: var(--space-4);
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.newsletter-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
}

.newsletter-input {
  flex: 1;
  padding: var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 1rem;
}

.newsletter-input:focus {
  outline: none;
  border-color: var(--link);
}

.newsletter-btn {
  padding: var(--space-3) var(--space-4);
  background: var(--link);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

/* Footer */
.mobile-footer {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.footer-content p {
  color: var(--fg-muted);
  margin-bottom: var(--space-2);
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.footer-links a {
  color: var(--link);
  text-decoration: none;
  font-size: 0.9rem;
}

.footer-links span {
  color: var(--fg-muted);
}

/* Optimized smooth scrolling for mobile */
html {
  scroll-behavior: smooth;
}

/* Prefer reduced motion support */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Mobile performance optimizations */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection where needed */
p, h1, h2, h3, h4, h5, h6, span, div.post-content, div.work-content {
  -webkit-user-select: text;
  user-select: text;
}

/* Hardware acceleration for common elements */
.mobile-section,
.work-card,
.mobile-post,
.mobile-header {
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

/* ===== OPTIMIZED MOBILE ANIMATIONS ===== */

/* Hardware-accelerated keyframes for smooth mobile performance */
@keyframes mobileSlideUp {
  0% { 
    opacity: 0; 
    transform: translate3d(0, 30px, 0) scale(0.98);
  }
  100% { 
    opacity: 1; 
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes mobileSlideInLeft {
  0% { 
    opacity: 0; 
    transform: translate3d(-20px, 0, 0);
  }
  100% { 
    opacity: 1; 
    transform: translate3d(0, 0, 0);
  }
}

@keyframes mobileSlideInRight {
  0% { 
    opacity: 0; 
    transform: translate3d(20px, 0, 0);
  }
  100% { 
    opacity: 1; 
    transform: translate3d(0, 0, 0);
  }
}

@keyframes mobileFadeIn {
  0% { 
    opacity: 0; 
    transform: translate3d(0, 0, 0) scale(0.95);
  }
  100% { 
    opacity: 1; 
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* Optimized animation classes with hardware acceleration */
.mobile-reveal {
  opacity: 0;
  will-change: transform, opacity;
  transform: translate3d(0, 30px, 0) scale(0.98);
  transition: none;
  backface-visibility: hidden;
  perspective: 1000px;
  contain: layout style;
}

.mobile-reveal.animated {
  animation: mobileSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-fill-mode: both;
}

.mobile-reveal-left {
  opacity: 0;
  will-change: transform, opacity;
  transform: translate3d(-20px, 0, 0);
  transition: none;
  backface-visibility: hidden;
  perspective: 1000px;
  contain: layout style;
}

.mobile-reveal-left.animated {
  animation: mobileSlideInLeft 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-fill-mode: both;
}

.mobile-reveal-right {
  opacity: 0;
  will-change: transform, opacity;
  transform: translate3d(20px, 0, 0);
  transition: none;
  backface-visibility: hidden;
  perspective: 1000px;
  contain: layout style;
}

.mobile-reveal-right.animated {
  animation: mobileSlideInRight 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-fill-mode: both;
}

.mobile-fade {
  opacity: 0;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0) scale(0.95);
  transition: none;
  backface-visibility: hidden;
  perspective: 1000px;
  contain: layout style;
}

.mobile-fade.animated {
  animation: mobileFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-fill-mode: both;
}

/* Remove will-change after animation completes to save resources */
.mobile-reveal.animation-complete,
.mobile-reveal-left.animation-complete,
.mobile-reveal-right.animation-complete,
.mobile-fade.animation-complete {
  will-change: auto;
  contain: none;
}

/* Legacy fade-in support */
.fade-in {
  animation: mobileSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
  backface-visibility: hidden;
  animation-fill-mode: both;
}

/* Responsive adjustments */
@media (max-width: 375px) {
  .hero-content h1 {
    font-size: 2rem;
  }
  
  .quick-stats {
    gap: var(--space-4);
  }
  
  .newsletter-form {
    flex-direction: column;
  }
  
  .newsletter-btn {
    padding: var(--space-3);
  }
}

/* ===== MOBILE SEARCH FUNCTIONALITY ===== */

/* Search toggle button in header */
.search-toggle {
  background: rgba(var(--bg-rgb), 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.search-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.6s ease;
}

.search-toggle:hover::before {
  left: 100%;
}

.search-toggle:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.2);
}

.search-toggle:active {
  transform: translateY(0) scale(1.02);
  transition: all 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Search Modal */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  backdrop-filter: blur(0px);
}

.search-modal.active {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(10px) saturate(180%);
}

.search-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.search-container {
  position: relative;
  width: 95%;
  max-width: 500px;
  margin: var(--space-16) auto;
  background: linear-gradient(135deg, 
    rgba(var(--bg-rgb), 0.95) 0%, 
    rgba(var(--bg-rgb), 0.85) 50%,
    rgba(var(--bg-rgb), 0.95) 100%);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border: 1px solid rgba(var(--border-rgb), 0.3);
  border-radius: var(--mobile-radius-2xl);
  box-shadow: 
    0 32px 64px rgba(0, 0, 0, 0.12),
    0 8px 32px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
  transform: translateY(-20px) scale(0.9);
  transition: all var(--duration-normal) var(--ease-bounce);
}

.search-modal.active .search-container {
  transform: translateY(0) scale(1);
}

[data-theme="dark"] .search-container {
  background: linear-gradient(135deg, 
    rgba(15, 15, 15, 0.95) 0%, 
    rgba(25, 25, 25, 0.85) 50%,
    rgba(20, 20, 20, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 32px 64px rgba(0, 0, 0, 0.6),
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Search Header */
.search-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid rgba(var(--border-rgb), 0.5);
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.1) 0%, 
    rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(10px);
}

.search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.search-icon {
  color: var(--fg-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  font-size: var(--mobile-text-lg);
  color: var(--fg);
  outline: none;
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.search-input::placeholder {
  color: var(--fg-muted);
}

.search-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--mobile-radius-md);
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-close:hover {
  background: rgba(var(--error-rgb), 0.1);
  color: var(--error);
}

/* Search Results */
.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--space-2);
}

.search-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
  color: var(--fg-muted);
}

.search-placeholder svg {
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.search-placeholder p {
  font-size: var(--mobile-text-base);
  margin: 0;
}

.search-result {
  display: block;
  padding: var(--space-4);
  border-radius: var(--mobile-radius-lg);
  text-decoration: none;
  color: inherit;
  margin-bottom: var(--space-2);
  background: rgba(var(--bg-rgb), 0.5);
  border: 1px solid transparent;
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
}

.search-result:hover {
  background: rgba(var(--accent-rgb), 0.05);
  border-color: rgba(var(--accent-rgb), 0.2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.1);
}

.search-result:active {
  transform: translateY(0);
  transition: all 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.search-result-title {
  font-size: var(--mobile-text-lg);
  font-weight: 600;
  color: var(--fg);
  margin-bottom: var(--space-2);
  line-height: 1.3;
}

.search-result-summary {
  font-size: var(--mobile-text-sm);
  color: var(--fg-secondary);
  margin-bottom: var(--space-3);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--mobile-text-xs);
  color: var(--fg-muted);
  flex-wrap: wrap;
}

.search-result-tag {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent-dark);
  padding: 2px var(--space-2);
  border-radius: var(--mobile-radius-sm);
  font-size: var(--mobile-text-xs);
  font-weight: 500;
}

.search-no-results {
  text-align: center;
  padding: var(--space-8);
  color: var(--fg-muted);
}

.search-no-results h3 {
  margin-bottom: var(--space-2);
  color: var(--fg-secondary);
}

/* Search Footer */
.search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(var(--border-rgb), 0.5);
  background: rgba(var(--bg-rgb), 0.5);
  backdrop-filter: blur(10px);
}

.search-stats {
  font-size: var(--mobile-text-xs);
  color: var(--fg-muted);
  font-weight: 500;
}

.search-shortcuts {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--mobile-text-xs);
  color: var(--fg-muted);
}

.search-shortcuts kbd {
  background: rgba(var(--fg-rgb), 0.1);
  border: 1px solid rgba(var(--border-rgb), 0.5);
  border-radius: var(--mobile-radius-sm);
  padding: 2px var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--mobile-text-xs);
  font-weight: 500;
  color: var(--fg-secondary);
}

/* Highlighted search terms */
.search-result mark {
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--accent-dark);
  padding: 0.1em 0.2em;
  border-radius: 2px;
  font-weight: 600;
}

[data-theme="dark"] .search-result mark {
  background: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
}

/* Mobile-specific responsive adjustments */
@media (max-width: 375px) {
  .search-container {
    width: 98%;
    margin: var(--space-12) auto;
  }
  
  .search-header {
    padding: var(--space-3);
  }
  
  .search-input {
    font-size: var(--mobile-text-base);
  }
  
  .search-result {
    padding: var(--space-3);
  }
  
  .search-result-title {
    font-size: var(--mobile-text-base);
  }
}
