/* Prevent horizontal scroll on mobile */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Blog title hover effect - glitch/cyberpunk style */
header .text-2xl {
  position: relative;
  display: inline-block;
  transition: all 0.3s ease;
}

header .text-2xl:hover {
  animation: glitch 0.3s cubic-bezier(.25, .46, .45, .94) both;
  text-shadow:
    2px 2px 0 #3b82f6,
    -2px -2px 0 #ef4444,
    0 0 20px rgba(59, 130, 246, 0.5);
  transform: scale(1.05);
}

/* Mobile: make Musings title clickable and add subtle glow */
@media (max-width: 768px) {
  header .text-2xl {
    text-shadow: 0 0 4px rgba(59, 130, 246, 0.3);
    cursor: pointer;
  }

  header .text-2xl:active {
    animation: glitch 0.3s cubic-bezier(.25, .46, .45, .94) both;
    text-shadow:
      2px 2px 0 #3b82f6,
      -2px -2px 0 #ef4444,
      0 0 20px rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
  }

}

/* Desktop and mobile dark mode slider */
header .btn-dark {
  width: 60px !important;
  height: 32px !important;
  background: none !important;
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  margin-left: 1rem !important;
}

.dark-mode-slider {
  display: flex !important;
  width: 100%;
  height: 100%;
  position: relative;
}

.slider-track {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  transition: background 0.3s ease;
}

.dark .slider-track {
  background: rgba(255, 255, 255, 0.2);
}

.slider-thumb {
  position: absolute;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.slider-thumb::after {
  content: '☀️';
  font-size: 14px;
}

.dark .slider-thumb {
  background: #000;
  left: 31px;
}

.dark .slider-thumb::after {
  content: '🌙';
}

/* Modern Home link styling */
nav a.home-link {
  position: relative;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.dark nav a.home-link {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

nav a.home-link:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
}

.dark nav a.home-link:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.home-icon {
  font-size: 1.1em;
}

/* Mobile Home link styling */
@media (max-width: 768px) {
  header nav.ml-12 {
    margin-left: auto !important;
    margin-right: 0 !important;
  }

  nav a.home-link {
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    gap: 0.35rem;
    min-width: 48px;
    min-height: 48px;
    justify-content: center;
  }

  .home-text {
    display: none;
  }

  .home-icon {
    font-size: 2em;
  }
}

@keyframes glitch {
  0%, 100% {
    transform: translate(0);
  }
  20% {
    transform: translate(-2px, 2px);
  }
  40% {
    transform: translate(-2px, -2px);
  }
  60% {
    transform: translate(2px, 2px);
  }
  80% {
    transform: translate(2px, -2px);
  }
}

/* Back to Posts animation */
.back-to-posts {
  transition: transform 0.3s ease;
}

.back-to-posts:hover {
  transform: translateX(-4px);
}

/* Custom selection highlighting */
footer a[href^="mailto"]::selection {
  background-color: #3b82f6;
  color: white;
}

footer a[href^="mailto"] *::selection {
  background-color: #3b82f6;
  color: white;
}

/* Email hover glow */
footer a[href^="mailto"] {
  transition: text-shadow 0.3s ease;
}

footer a[href^="mailto"]:hover {
  text-shadow: 0 0 8px #3b82f6, 0 0 16px #3b82f6;
}

/* Post title selection */
h1::selection,
article header h1::selection {
  background-color: #3b82f6;
  color: white;
}

h1 *::selection,
article header h1 *::selection {
  background-color: #3b82f6;
  color: white;
}

/* Post title hover glow */
article header h1,
.post-title,
section h2 {
  transition: text-shadow 0.3s ease;
  cursor: default;
}

article header h1:hover,
.post-title:hover,
section:hover h2 {
  text-shadow: 0 0 8px #3b82f6, 0 0 16px #3b82f6;
}

/* Search Overlay */
.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(0, 0, 0, 0.05);
  margin-left: 1rem;
}

.dark .search-btn {
  background: rgba(255, 255, 255, 0.1);
}

.search-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.98);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-x: hidden;
  box-sizing: border-box;
}

.dark .search-overlay {
  background: rgba(0, 0, 0, 0.95);
}

.search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.search-input-wrapper {
  position: relative;
  width: 90%;
  max-width: 800px;
  margin-bottom: 2rem;
  box-sizing: border-box;
}

.search-input {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.5rem;
  border: none;
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
  background: transparent;
  color: #000;
  outline: none;
  font-family: inherit;
  transition: border-color 0.3s ease;
}

.dark .search-input {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.search-input:focus {
  border-bottom-color: #3b82f6;
}

.search-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.search-close:hover {
  opacity: 1;
}

.search-results {
  width: 90%;
  max-width: 800px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 70vh;
  padding: 1rem;
  box-sizing: border-box;
}

.search-result-item {
  display: block;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s ease;
  border: 1px solid transparent;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.search-result-item:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.05);
}

.dark .search-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.search-result-title {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: #000;
  display: block;
}

.dark .search-result-title {
  color: #fff;
}

.search-result-date {
  font-size: 0.875rem;
  color: #666;
  display: block;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.search-result-date mark {
  background: rgba(59, 130, 246, 0.2);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.dark .search-result-date {
  color: #999;
}

.dark .search-result-date mark {
  background: rgba(59, 130, 246, 0.3);
  color: #fff;
}

.search-no-results {
  text-align: center;
  font-size: 1.2rem;
  color: #666;
  margin-top: 2rem;
}

.dark .search-no-results {
  color: #999;
}

/* Mobile Search Optimizations */
@media (max-width: 768px) {
  /* Adjust search button positioning */
  header .relative.z-50.flex.items-center {
    gap: 0.5rem;
  }

  .search-btn {
    width: 40px;
    height: 40px;
    margin-left: 0.5rem;
  }

  /* Full screen search overlay on mobile */
  .search-overlay {
    padding-top: 1rem;
    background: #fff;
    width: 100vw;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .dark .search-overlay {
    background: #000;
  }

  .search-close {
    top: 1rem;
    right: 1rem;
    padding: 0.5rem;
    font-size: 2rem;
    line-height: 1;
    z-index: 1002;
  }

  .search-input-wrapper {
    width: 100%;
    padding: 0 1rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
    max-width: 100%;
  }

  .search-input {
    font-size: 1.25rem;
    padding: 0.75rem 0;
    width: 100%;
    box-sizing: border-box;
  }

  .search-results {
    width: 100%;
    padding: 0 1rem;
    max-height: calc(100vh - 140px);
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
  }

  .search-result-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: rgba(0,0,0,0.02);
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible;
  }

  .dark .search-result-item {
    background: rgba(255,255,255,0.03);
  }

  .search-result-title {
    font-size: 1.1rem;
    word-break: break-word;
    white-space: normal;
  }

  .search-result-date {
    font-size: 0.8rem;
    line-height: 1.5;
    word-break: break-word !important;
    white-space: normal !important;
    display: block !important;
    width: 100% !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
}
