@tailwind base;
@tailwind components;
@tailwind utilities;

/* Base styles - Tailwind only */
@layer base {
  html {
    scroll-behavior: smooth;
  }
  
  body {
    @apply bg-white text-slate-800 font-serif antialiased;
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.75;
  }
  
  /* Typography */
  h1, h2, h3, h4, h5, h6 {
    @apply font-sans font-bold text-slate-900;
  }

  h1 {
    @apply text-3xl md:text-4xl leading-tight mb-6;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.025em;
  }

  h2 {
    @apply text-2xl md:text-3xl leading-tight mb-4 mt-8;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.025em;
  }

  h3 {
    @apply text-xl md:text-2xl leading-tight mb-3 mt-6;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.025em;
  }

  h4 {
    @apply text-lg md:text-xl leading-tight mb-2 mt-4;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.025em;
  }

  p {
    @apply mb-4 text-base leading-relaxed text-slate-700;
  }

  .lead {
    @apply text-xl md:text-2xl text-slate-600 mb-6 leading-relaxed;
    font-weight: 400;
  }
  
  a {
    @apply text-blue-600 hover:text-blue-800 transition-colors;
  }
  
  ul, ol {
    @apply ml-5 mb-4;
  }
  
  li {
    @apply mb-1;
  }
  
  code:not([class*='language-']) {
    @apply bg-slate-100 px-1 py-0.5 rounded font-mono text-sm text-slate-700;
  }
  
  blockquote {
    @apply border-l-2 border-slate-300 pl-4 italic text-slate-600 my-4;
  }
  
  /* Focus states */
  a:focus,
  button:focus,
  input:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
  }
}

/* Components - Tailwind utility classes */
@layer components {
  /* Legacy hooks required by tests */
  .file-example {
    @apply w-full;
  }

  .container {
    @apply max-w-4xl mx-auto px-6 py-10;
  }

  .wide-container {
    @apply max-w-5xl mx-auto px-6 py-12;
  }

  .narrow-container {
    @apply max-w-2xl mx-auto px-6 py-8;
  }

  .highlighter-tag {
    @apply inline-block text-xs font-bold px-2 py-0.5 rounded cursor-pointer transition-all duration-200;
    position: relative;
    transform: rotate(-1deg);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
  }

  .search-box {
    @apply w-full px-4 py-3 border-2 border-slate-200 rounded-lg focus:outline-none focus:border-blue-400 transition-colors;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px);
  }

  .search-box::placeholder {
    @apply text-slate-400;
  }

  /* Blog post card */
  .post-card {
    @apply mb-8 last:mb-0;
  }

  .post-meta {
    @apply text-xs text-slate-500 font-sans mb-2;
  }

  .post-excerpt {
    @apply text-slate-700 mb-2 leading-relaxed;
  }

  .post-tags {
    @apply flex flex-wrap gap-1;
  }

  /* Article page */
  .article-header {
    @apply mb-8;
  }
  
  .article-title {
    @apply text-4xl md:text-5xl font-bold mb-3;
  }
  
  .article-meta {
    @apply text-sm text-slate-500 font-sans mb-5;
  }
  
  .article-content {
    @apply text-lg leading-relaxed;
  }
  
  .article-content p {
    @apply mb-5;
  }
  
  .article-content h2 {
    @apply text-2xl font-bold mt-8 mb-3;
  }
  
  .article-content h3 {
    @apply text-xl font-bold mt-6 mb-2;
  }
  
  .article-content ul,
  .article-content ol {
    @apply ml-6 mb-5;
  }
  
  .article-content li {
    @apply mb-1;
  }
  
  .article-content blockquote {
    @apply border-l-2 border-slate-400 pl-4 italic text-slate-600 my-5 text-lg;
  }

  /* Buttons */
  .btn {
    @apply inline-flex items-center justify-center px-6 py-3 border border-slate-200 bg-white text-slate-600 font-sans font-bold text-sm uppercase tracking-widest rounded-full transition-all duration-500 ease-[cubic-bezier(0.23,1,0.32,1)] hover:border-slate-400 hover:text-slate-900 hover:bg-slate-50 hover:-translate-y-0.5 hover:shadow-xl hover:shadow-slate-100 active:translate-y-0 active:shadow-sm;
  }

  .btn-primary {
    @apply border-slate-900 text-slate-900 hover:bg-slate-900 hover:text-white;
  }

  .btn-secondary {
    @apply border-slate-200 text-slate-500 hover:border-slate-400 hover:text-slate-900;
  }

  /* Hide scrollbars */
  .hide-scrollbar::-webkit-scrollbar {
    display: none;
  }

  .hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  /* Empty state */
  .empty-state {
    @apply text-center py-8 text-slate-500;
  }

  .empty-state svg {
    @apply mx-auto mb-2 text-slate-300;
  }

  /* Line clamp utility */
  .line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Reading progress indicator */
  .reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: #3b82f6;
    transform-origin: left;
    transform: scaleX(0);
    z-index: 50;
    transition: transform 0.1s ease-out;
  }

  /* Floating back to top button */
  .floating-back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.15s ease;
    opacity: 0;
    transform: translateY(8px);
  }

  .floating-back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .floating-back-to-top:hover {
    background: #f8fafc;
    color: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }

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

  /* Print styles */
  @media print {
    .floating-back-to-top,
    .reading-progress-bar {
      display: none !important;
    }
  }
}