@import './highlight-github.css';
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --foreground-rgb: 0, 0, 0;
  --background-rgb: 255, 255, 255;
}

body {
  color: rgb(var(--foreground-rgb));
  background: rgb(var(--background-rgb));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;
}

/* Mobile-first responsive typography */
html {
  font-size: 16px;
  /* Improve mobile scrolling */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  html {
    font-size: 16px; /* Keep 16px on mobile to prevent zoom */
  }
}

/* Enhanced prose styles for mobile reading */
.prose {
  max-width: none;
  color: #374151;
}

.prose img {
  margin: 1.5rem auto;
  border-radius: 0.5rem;
  max-width: 100%;
  height: auto;
}

.prose a {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.prose a:hover {
  color: #1d4ed8;
  text-decoration-thickness: 2px;
}

/* Enhanced anchor link styles */
.prose a[href^="#"] {
  color: #059669; /* Green color for anchor links */
  font-weight: 500;
  transition: all 0.2s ease;
}

.prose a[href^="#"]:hover {
  color: #047857;
  text-decoration-thickness: 2px;
  background-color: #f0fdf4;
  padding: 2px 4px;
  border-radius: 4px;
}

/* Add subtle visual indicator for headings that have anchor links */
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  position: relative;
}

.prose h1:hover::before,
.prose h2:hover::before,
.prose h3:hover::before,
.prose h4:hover::before,
.prose h5:hover::before,
.prose h6:hover::before {
  content: "🔗";
  position: absolute;
  left: -1.5rem;
  opacity: 0.6;
  font-size: 0.8em;
  cursor: pointer;
}

/* Ensure proper spacing for anchor link indicators */
@media (min-width: 641px) {
  .prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    padding-left: 0.5rem;
  }
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  color: #111827;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.prose h1 {
  font-size: 1.875rem;
  margin-top: 0;
}

.prose h2 {
  font-size: 1.5rem;
}

.prose h3 {
  font-size: 1.25rem;
}

.prose p {
  margin-bottom: 1.25rem;
  line-height: 1.75;
}

.prose ul, .prose ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose blockquote {
  border-left: 4px solid #e5e7eb;
  padding-left: 1rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: #6b7280;
}

.prose code {
  background-color: #f3f4f6;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  color: #dc2626;
}

/* Ensure highlight.js styles override Tailwind prose for code blocks */
.prose pre code.hljs {
  background: inherit !important;
  color: inherit !important;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

.prose pre {
  background: #292d3e !important;
  color: #fff !important;
  border-radius: 0.5rem;
  overflow-x: auto;
  padding: 1rem;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Mobile-specific prose adjustments for optimal reading */
@media (max-width: 640px) {
  .prose {
    font-size: 1rem; /* Larger base font for mobile reading */
    line-height: 1.7; /* Better line spacing for mobile */
  }
  
  .prose h1 {
    font-size: 1.75rem;
    line-height: 1.3;
    scroll-margin-top: 100px; /* Account for sticky header */
  }
  
  .prose h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    scroll-margin-top: 100px;
  }
  
  .prose h3 {
    font-size: 1.25rem;
    line-height: 1.3;
    scroll-margin-top: 100px;
  }
  
  .prose h4, .prose h5, .prose h6 {
    scroll-margin-top: 100px;
  }
  
  .prose p {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
  }
  
  .prose pre {
    font-size: 0.875rem;
    padding: 0.75rem;
    margin: 1rem 0;
  }
  
  .prose img {
    margin: 1.5rem auto;
  }
  
  /* Better mobile paragraph spacing */
  .prose p + p {
    margin-top: 1.5rem;
  }
  
  /* Improved mobile list spacing */
  .prose ul, .prose ol {
    margin: 1.5rem 0;
    padding-left: 1.25rem;
  }
  
  .prose li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
  }
  
  /* Better mobile blockquote */
  .prose blockquote {
    margin: 1.5rem 0;
    padding: 1rem 0 1rem 1rem;
    font-size: 1rem;
    line-height: 1.6;
  }
}

/* Desktop prose optimizations */
@media (min-width: 641px) {
  .prose {
    font-size: 1.125rem;
    line-height: 1.8;
  }
  
  .prose h1 {
    font-size: 2.25rem;
    line-height: 1.2;
    scroll-margin-top: 120px; /* Account for sticky header */
  }
  
  .prose h2 {
    font-size: 1.875rem;
    line-height: 1.3;
    scroll-margin-top: 120px;
  }
  
  .prose h3 {
    font-size: 1.5rem;
    line-height: 1.4;
    scroll-margin-top: 120px;
  }
  
  .prose h4, .prose h5, .prose h6 {
    scroll-margin-top: 120px;
  }
  
  .prose p {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
  }
}

/* Touch-friendly focus states and buttons */
button:focus, 
a:focus, 
input:focus, 
textarea:focus, 
select:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Mobile touch targets - minimum 44px for accessibility */
@media (max-width: 640px) {
  button, 
  a[role="button"], 
  input[type="button"], 
  input[type="submit"], 
  input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Improve touch scrolling */
  .overflow-auto,
  .overflow-scroll {
    -webkit-overflow-scrolling: touch;
  }
}

/* Mobile-friendly table styles */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.prose th,
.prose td {
  border: 1px solid #e5e7eb;
  padding: 0.5rem;
  text-align: left;
}

.prose th {
  background-color: #f9fafb;
  font-weight: 600;
}

@media (max-width: 640px) {
  .prose table {
    font-size: 0.875rem;
  }
  
  .prose th,
  .prose td {
    padding: 0.5rem 0.25rem;
  }
  
  /* Make tables scrollable on mobile */
  .prose table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Mobile-specific animations */
@media (max-width: 640px) {
  /* Reduce motion for mobile performance */
  @media (prefers-reduced-motion: no-preference) {
    .animate-spin {
      animation-duration: 1.5s;
    }
    
    .animate-spin-reverse {
      animation-duration: 1.5s;
    }
  }
}

/* Mobile-specific container adjustments */
@media (max-width: 640px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Mobile-specific form improvements */
@media (max-width: 640px) {
  input, 
  textarea, 
  select {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
  
  /* Improve mobile form spacing */
  form > * + * {
    margin-top: 1rem;
  }
}

/* Mobile-specific modal improvements */
@media (max-width: 640px) {
  .fixed.inset-0 {
    padding: 1rem;
  }
  
  /* Ensure modals are properly sized on mobile */
  .fixed.inset-0 > div {
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

/* Mobile-specific grid improvements */
@media (max-width: 640px) {
  .grid {
    gap: 0.75rem;
  }
  
  /* Ensure cards don't overflow on mobile */
  .bg-white {
    word-break: break-word;
  }
}

/* Mobile-specific badge improvements */
@media (max-width: 640px) {
  img[src*="shields.io"] {
    max-width: 100%;
    height: auto;
  }
}

/* Mobile reading optimizations */
@media (max-width: 640px) {
  /* Better text rendering for mobile */
  .prose {
    text-rendering: optimizeLegibility;
    -webkit-font-feature-settings: "kern" 1;
    font-feature-settings: "kern" 1;
  }
  
  /* Improved mobile paragraph readability */
  .prose p {
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
  }
  
  /* Better mobile heading spacing */
  .prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
  }
  
  /* Mobile-specific code block improvements */
  .prose pre {
    border-radius: 0.375rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  }
  
  /* Mobile-specific link improvements */
  .prose a {
    word-break: break-word;
  }
}

.custom-tag {
  padding: 1rem;
  border-radius: 6px;
  margin: 1rem 0;
  font-weight: 500;
}
.custom-tag.warning { background: #fff3cd; border: 1px solid #ffeaa7; color: #856404; }
.custom-tag.info { background: #d1ecf1; border: 1px solid #bee5eb; color: #0c5460; }
.custom-tag.success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.custom-tag.error { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }
.custom-tag.mytag { background: #e3e3ff; border: 1px solid #b3b3ff; color: #333366; } 