/* Custom styles to complement Tailwind CSS */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@300;400;500;600;700&family=Montserrat:wght@200;300;400;500;600&display=swap');

/* Global font smoothing */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Custom font settings */
h1, h2, h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
}

body {
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
}

/* Magazine specific styles */
.magazine-headline {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.magazine-story {
    position: relative;
    padding-left: 1rem;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.magazine-story:hover {
    border-left-color: #F59E0B;
    padding-left: 1.5rem;
}

.story-number {
    font-family: 'Montserrat', sans-serif;
    font-weight: 200;
    letter-spacing: 0.2em;
}

.story-divider {
    letter-spacing: 0.5em;
    font-family: 'Cormorant Garamond', serif;
}

/* Logo styles */
.logo-container {
    position: relative;
}

.logo-container img {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
    transition: all 0.5s ease;
}

.logo-container:after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.5), transparent);
}

/* Typography refinements */
.text-xl, .text-2xl, .text-3xl, .text-4xl, .text-5xl, .text-6xl {
    font-family: 'Cormorant Garamond', serif;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom animations */
.hover\:scale-up:hover {
    transform: scale(1.02);
    transition: transform 0.2s ease-in-out;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Article card hover effects */
.article-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* Category filter active state */
.category-filter.active {
    background-color: #2563eb;
    color: white;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

.category-filter {
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Article date style */
.article-date {
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    font-size: 0.875rem;
    color: #6B7280;
    letter-spacing: 0.02em;
}

/* Header spacing fix - ensures proper spacing between sticky header and content */
.header-spacing {
    padding-top: 120px; /* Increased padding for better spacing */
}

/* Responsive header spacing */
@media (max-width: 1024px) {
    .header-spacing {
        padding-top: 100px; /* Increased padding for mobile */
    }
}

/* Specific spacing for different page layouts */
.main-content-with-header {
    padding-top: 120px !important; /* Added !important to override other styles */
}

@media (max-width: 1024px) {
    .main-content-with-header {
        padding-top: 80px !important; /* Optimized padding for mobile header clearance */
    }
}

/* Additional mobile spacing adjustments */
@media (max-width: 768px) {
    .main-content-with-header {
        padding-top: 70px !important; /* Reduced padding for smaller mobile screens */
    }
}

@media (max-width: 640px) {
    .main-content-with-header {
        padding-top: 65px !important; /* Further optimized for small mobile screens */
    }
    
    /* Reduce excessive spacing in index.html featured section */
    #featured.mb-6 {
        margin-bottom: 1rem !important; /* Reduced from 1.5rem (mb-6) */
    }
}

/* Additional mobile spacing optimizations for index.html */
@media (max-width: 768px) {
    #featured.mb-6 {
        margin-bottom: 1.25rem !important; /* Slightly reduced spacing for medium mobile */
    }
    
    /* Fix excessive spacing on category pages */
    .main-content-with-header section.mb-8 {
        margin-bottom: 1.5rem !important; /* Reduced from 2rem (mb-8) */
    }
}

/* Category page spacing optimizations for smaller mobile screens */
@media (max-width: 640px) {
    .main-content-with-header section.mb-8 {
        margin-bottom: 1rem !important; /* Further reduced for small screens */
    }
    
    /* Additional hero section fixes for small mobile screens */
    .w-full.lg\:w-1\/2.lg\:fixed {
        padding-top: 70px !important;
    }
    
    .w-full.lg\:w-1\/2.lg\:fixed .absolute.inset-0 {
        top: 70px !important;
    }
}    
    /* Fix excessive spacing on category pages */
    main .mb-8:first-child {
        margin-bottom: 1.5rem !important; /* Reduced from 2rem (mb-8) */
    }
}

/* Category page spacing optimizations for smaller mobile screens */
@media (max-width: 640px) {
    /* Further reduce spacing on category pages */
    main .mb-8:first-child {
        margin-bottom: 1rem !important; /* Further reduced for small mobile */
    }
    
    /* Optimize page header spacing */
    main section:first-child h1 {
        margin-bottom: 0.75rem !important; /* Reduced h1 bottom margin */
    }
}

/* Loading animation */
.loading-skeleton {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

/* Mobile menu */
#mobileMenu {
    transition: max-height 0.3s ease-in-out;
    max-height: 0;
    overflow: hidden;
}

#mobileMenu.active {
    max-height: 300px;
}

/* Responsive adjustments */
@media (max-width: 1280px) {
    .logo-container {
        width: 600px !important;
    }
    
    .magazine-headline {
        font-size: 3rem;
    }
}

@media (max-width: 1024px) {
    .logo-container {
        width: 500px !important;
    }
    
    .magazine-headline {
        font-size: 2.5rem;
    }
    
    .magazine-story h3 {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .logo-container {
        width: 400px !important;
        top: 4rem !important;
    }
    
    /* Fix hero section overlap with header on mobile */
    .w-full.lg\:w-1\/2.lg\:fixed {
        padding-top: 80px !important;
    }
    
    /* Adjust hero content positioning */
    .w-full.lg\:w-1\/2.lg\:fixed .absolute.inset-0 {
        top: 80px !important;
    }
    
    .magazine-headline {
        font-size: 2rem;
    }
    
    .magazine-stories {
        margin-top: 2rem;
    }
    
    .magazine-story {
        padding-left: 0.75rem;
    }
    
    .magazine-story h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 640px) {
    h1 {
        font-size: 2rem;
    }
    
    .article-card {
        margin-bottom: 0.75rem;
        min-height: 44px;
        padding: 0.25rem !important;
    }
    
    .article-card .p-6 {
        padding: 1rem !important;
    }
    
    .article-card img {
        aspect-ratio: 4/3 !important;
        height: auto !important;
    }
    
    .article-card img.aspect-square {
        aspect-ratio: 4/3 !important;
    }
    
    .article-card h3 {
        font-size: 1rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.75rem !important;
    }
    
    .article-card .text-lg {
        font-size: 1rem !important;
    }
    
    .article-card .text-xl {
        font-size: 1rem !important;
    }
    
    .magazine-title {
        font-size: 1.75rem;
    }
    
    /* Better spacing for mobile */
    .article-card .mb-4 {
        margin-bottom: 0.5rem !important;
    }
    
    /* Improved touch targets and spacing */
    .article-card .px-3 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    .article-card .py-1 {
         padding-top: 0.375rem !important;
         padding-bottom: 0.375rem !important;
     }
     
     /* Enhanced content hierarchy for mobile */
     .article-card .text-xs {
         font-size: 0.75rem !important;
     }
     
     .article-card .text-sm {
         font-size: 0.875rem !important;
     }
     
     /* Better visual balance */
     .article-card .rounded-xl {
         border-radius: 0.5rem !important;
     }
     
     /* Improved button and link targets */
     .article-card .fas,
     .article-card .far {
         font-size: 1rem !important;
         padding: 0.25rem;
     }
 }

/* Additional mobile optimizations for larger phones */
@media (max-width: 768px) {
    .article-card {
        margin-bottom: 1rem;
    }
    
    .article-card .p-6 {
        padding: 1.25rem !important;
    }
    
    .article-card img {
        aspect-ratio: 4/3 !important;
        height: auto !important;
    }
    
    .article-card h3 {
        font-size: 1.125rem !important;
        line-height: 1.4 !important;
    }
    
    /* Override Tailwind aspect-square */
    .article-card img.aspect-square {
        aspect-ratio: 4/3 !important;
    }
    
    /* Better content spacing */
    .article-card .mb-4 {
        margin-bottom: 0.75rem !important;
    }
    
    /* Improved typography hierarchy */
     .article-card .text-lg {
         font-size: 1.125rem !important;
     }
     
     .article-card .text-xl {
         font-size: 1.125rem !important;
     }
     
     /* Mobile grid optimizations */
     .grid {
         gap: 1rem !important;
     }
     
     /* Enhanced readability */
     .article-card .text-gray-500 {
         font-size: 0.875rem !important;
     }
     
     .article-card .font-medium {
         font-weight: 500 !important;
     }
 }

/* Mobile logo visibility fix */
.mobile-logo {
    filter: brightness(0) saturate(100%);
}

/* ===== ARTICLE LAYOUT IMPROVEMENTS ===== */

/* 1. PROPER HEADING HIERARCHY */
/* Article title (h1) styling */
article h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: #1f2937;
    letter-spacing: -0.02em;
}

/* Article section headings (h2) */
article h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    color: #374151;
    letter-spacing: -0.01em;
}

/* Article subsection headings (h3) */
article h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #4b5563;
}

/* Article minor headings (h4) */
article h4 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.4;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #1f2937;
}

/* 2. OPTIMAL LINE LENGTH AND PROSE IMPROVEMENTS */
/* Replace max-w-none with optimal reading width */
.prose.prose-lg {
    max-width: 65ch !important; /* Optimal reading line length */
    margin: 0 auto;
    font-size: 1.125rem;
    line-height: 1.7;
    text-align: justify;
    color: #1f2937 !important;
}

/* Ensure all text elements in articles have dark color */
.prose.prose-lg p,
.prose.prose-lg span,
.prose.prose-lg div {
    color: #1f2937 !important;
}

/* Explicit heading typography inside .prose wrappers
   Tailwind Preflight resets heading font-sizes to inherit,
   so define clear, larger sizes for headings here */
.prose h1 {
    font-size: 2rem;
    line-height: 1.3;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #111827;
}

.prose h2 {
    font-size: 1.75rem; /* Larger than body (1.125rem) */
    line-height: 1.35;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: #1f2937;
}

.prose h3 {
    font-size: 1.375rem;
    line-height: 1.4;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #374151;
}

.prose h4 {
    font-size: 1.25rem;
    line-height: 1.4;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: #374151;
}

/* Reduce top margin for first paragraph after headings inside .prose */
.prose h1 + p,
.prose h2 + p,
.prose h3 + p,
.prose h4 + p {
    margin-top: 0;
}

/* Responsive adjustments for .prose headings */
@media (max-width: 768px) {
    .prose h1 { font-size: 1.75rem; }
    .prose h2 { font-size: 1.5rem; }
    .prose h3 { font-size: 1.25rem; }
    .prose h4 { font-size: 1.125rem; }
}

/* 3. PARAGRAPH SPACING IMPROVEMENTS */
/* Consistent paragraph margins */
article p {
    margin-bottom: 1.5rem;
    line-height: 1.7;
    color: #1f2937;
}

/* Remove custom data-spacing attributes effect */
article p[data-spacing] {
    margin-bottom: 1.5rem !important;
}

/* First paragraph after heading gets reduced top margin */
article h1 + p,
article h2 + p,
article h3 + p,
article h4 + p {
    margin-top: 0;
}

/* 4. IMAGE STYLING IMPROVEMENTS */
/* Article images with proper spacing and responsive behavior */
article img {
    margin: 2rem auto;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    height: auto;
    display: block;
}

/* Larger images get more spacing */
article img[width="1024"] {
    margin: 2.5rem auto;
}

/* RESPONSIVE TYPOGRAPHY */
@media (max-width: 768px) {
    article h1 {
        font-size: 2rem;
        margin-bottom: 1.25rem;
    }
    
    article h2 {
        font-size: 1.75rem;
        margin-top: 2rem;
        margin-bottom: 1rem;
    }
    
    article h3 {
        font-size: 1.375rem;
        margin-top: 1.5rem;
        margin-bottom: 0.875rem;
    }
    
    article h4 {
        font-size: 1.25rem;
        margin-top: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    .prose.prose-lg {
        font-size: 1rem;
        line-height: 1.6;
        max-width: 100% !important;
        padding: 0 1rem;
    }
    
    article p {
        margin-bottom: 1.25rem;
    }
    
    article img {
        margin: 1.5rem auto;
    }
}

@media (max-width: 640px) {
    article h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    article h2 {
        font-size: 1.5rem;
    }
    
    article h3 {
        font-size: 1.25rem;
    }
    
    article h4 {
        font-size: 1.125rem;
    }
    
    .prose.prose-lg {
        font-size: 0.95rem;
        padding: 0 0.75rem;
    }
}

/* ENHANCED READABILITY */
/* Better text contrast and spacing */
article {
    color: #374151;
}

/* Strong text styling */
article strong {
    font-weight: 600;
    color: #1f2937;
}

/* Link styling within articles */
article a {
    color: #2563eb;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

article a:hover {
    color: #1d4ed8;
}

/* ===== END ARTICLE IMPROVEMENTS ===== */

/* Fixed header adjustments for split screen */
@media (min-width: 1024px) {
  #header-placeholder {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    z-index: 50;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  main {
    padding-top: 5rem; /* Adjust based on header height */
  }
}

/* You Might Also Like Section Styles */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Ensure consistent card heights in grid */
#you-might-also-like-container .grid > div {
    display: flex;
    flex-direction: column;
}

#you-might-also-like-container .grid > div > a {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#you-might-also-like-container .grid > div > a > div:last-child {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
