/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

@import "tailwindcss";

/* Custom animations */
.animated-border {
  position: relative;
}

.animated-border::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 2px;
  background-color: #3b82f6; /* blue-500 */
  transition: width 0.3s ease-in-out;
}

.animated-border:hover::after {
  width: 100%;
  right: auto;
  left: 0;
}

/* Markdown Content Styles */
.markdown-content {
  color: #374151;
  line-height: 1.75;
}

.markdown-content h1 {
  font-size: 2.25rem;
  font-weight: 800;
  margin-top: 0;
  margin-bottom: 1rem;
  line-height: 1.2;
  color: #111827;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.markdown-content h2 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  color: #111827;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.markdown-content h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.4;
  color: #1f2937;
}

.markdown-content h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.5;
  color: #1f2937;
}

.markdown-content h5 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.5;
  color: #374151;
}

.markdown-content h6 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  line-height: 1.5;
  color: #374151;
}

.markdown-content p {
  margin-top: 0;
  margin-bottom: 1rem;
}

.markdown-content a {
  color: #3b82f6;
  text-decoration: underline;
  font-weight: 500;
}

.markdown-content a:hover {
  color: #2563eb;
}

.markdown-content strong {
  font-weight: 700;
  color: #111827;
}

.markdown-content em {
  font-style: italic;
}

.markdown-content code {
  background-color: #f3f4f6;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #dc2626;
  font-weight: 500;
}

.markdown-content pre {
  background-color: #1f2937;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-top: 0;
  margin-bottom: 1rem;
}

.markdown-content pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.875rem;
  font-weight: normal;
}

.markdown-content blockquote {
  border-left: 4px solid #3b82f6;
  padding-left: 1rem;
  margin-left: 0;
  margin-right: 0;
  margin-top: 1rem;
  margin-bottom: 1rem;
  color: #6b7280;
  font-style: italic;
}

.markdown-content ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

.markdown-content ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

.markdown-content li {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.markdown-content li > p {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.markdown-content ul ul,
.markdown-content ul ol,
.markdown-content ol ul,
.markdown-content ol ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.markdown-content hr {
  border: 0;
  border-top: 2px solid #e5e7eb;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.markdown-content th {
  background-color: #f3f4f6;
  font-weight: 600;
  text-align: left;
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
}

.markdown-content td {
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
}

.markdown-content tbody tr:hover {
  background-color: #f9fafb;
}

.markdown-content img {
  width: calc(100% + 6rem);
  max-width: none;
  margin-left: -3rem;
  height: auto;
  border-radius: 0.75rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
}

@media (max-width: 640px) {
  .markdown-content img {
    width: 100%;
    margin-left: 0;
    max-width: 100%;
  }
}

.markdown-content > *:first-child {
  margin-top: 0;
}

.markdown-content > *:last-child {
  margin-bottom: 0;
}

/* Lightbox transitions */
.lightbox-image {
  transition: opacity 0.2s ease-in-out;
}

/* ============================================
   View Transitions (Turbo 8 native support)
   ============================================ */

/* Keep header and footer stable during navigation */
::view-transition-group(site-header),
::view-transition-group(site-footer) {
  animation: none;
}

/* Main content: only animate the new content in, hide old instantly */
@keyframes fade-in {
  from {
    opacity: 0;
  }
}

::view-transition-old(main-content) {
  animation: none;
  display: none;
}

::view-transition-new(main-content) {
  animation: fade-in 300ms ease-out;
}

/* ============================================
   Article card hover lift effect
   ============================================ */

.article-card {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* ============================================
   Staggered fade-in for article cards
   ============================================ */

@keyframes card-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@supports not (view-transition-name: test) {
  .article-card-animated {
    animation: card-fade-in 400ms ease-out backwards;
  }

  .article-card-animated:nth-child(1) { animation-delay: 0ms; }
  .article-card-animated:nth-child(2) { animation-delay: 100ms; }
  .article-card-animated:nth-child(3) { animation-delay: 200ms; }
  .article-card-animated:nth-child(4) { animation-delay: 300ms; }
  .article-card-animated:nth-child(5) { animation-delay: 400ms; }
  .article-card-animated:nth-child(6) { animation-delay: 500ms; }
  .article-card-animated:nth-child(n+7) { animation-delay: 600ms; }
}

/* ============================================
   Article detail page entrance animation
   (fallback for browsers without View Transitions)
   ============================================ */

@keyframes article-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@supports not (view-transition-name: test) {
  .article-detail-enter {
    animation: article-enter 300ms ease-out backwards;
  }

  .article-detail-content {
    animation: article-enter 300ms ease-out 100ms backwards;
  }
}

/* ============================================
   Accessibility: respect reduced motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .article-card-animated,
  .article-detail-enter,
  .article-detail-content {
    animation: none !important;
  }

  .article-card {
    transition: none !important;
  }
}
