/**
 * Blog Public Frontend CSS
 * Matches 25i Agricultural Chemical website design system
 * Agricultural green theme with responsive layouts
 */

/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #374151;
}

/* ==================== AGRICULTURAL GREEN THEME ==================== */
:root {
    --agricultural-green: #2ab939;
    --agricultural-green-dark: #22a32f;
    --agricultural-green-light: #3dd84e;
    --gradient-start: #065f46;
    --gradient-end: #047857;
}

.agricultural-green {
    color: var(--agricultural-green);
}

.agricultural-green-bg {
    background-color: var(--agricultural-green);
}

.hero-bg {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
}

/* ==================== BLOG CARD STYLES ==================== */
.blog-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: rgba(99, 99, 99, 0.3) 0px 8px 16px 0px;
}

.blog-card img {
    transition: transform 0.3s ease;
}

.blog-card:hover img {
    transform: scale(1.05);
}

/* ==================== TEXT TRUNCATION ==================== */
.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;
}

/* ==================== CUSTOM SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==================== LOADING ANIMATIONS ==================== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ==================== FOCUS STYLES ==================== */
input:focus,
select:focus,
button:focus {
    outline: none;
    ring: 2px;
    ring-color: var(--agricultural-green);
}

/* ==================== RESPONSIVE UTILITIES ==================== */
@media (max-width: 768px) {
    .hero-bg h1 {
        font-size: 2rem;
    }
    
    .hero-bg p {
        font-size: 1rem;
    }
    
    #postsGrid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    #postsGrid {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* ==================== CATEGORY & TAG LINKS ==================== */
.category-link,
.tag-link {
    transition: all 0.2s ease;
}

.category-link:hover,
.tag-link:hover {
    background-color: rgba(42, 185, 57, 0.1);
    color: var(--agricultural-green);
}

/* ==================== PAGINATION STYLES ==================== */
#pagination button {
    transition: all 0.2s ease;
    min-width: 40px;
}

#pagination button:not(:disabled):hover {
    background-color: rgba(42, 185, 57, 0.1);
    border-color: var(--agricultural-green);
    color: var(--agricultural-green);
}

#pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#pagination .bg-green-600 {
    background-color: var(--agricultural-green);
}

#pagination .bg-green-600:hover {
    background-color: var(--agricultural-green-dark);
}

/* ==================== SIDEBAR STYLES ==================== */
aside .bg-white {
    position: sticky;
    top: 100px;
}

aside h3 {
    border-bottom: 2px solid var(--agricultural-green);
    padding-bottom: 0.5rem;
}

/* ==================== SEARCH BOX ==================== */
#searchInput {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#searchInput:focus {
    border-color: var(--agricultural-green);
    box-shadow: 0 0 0 3px rgba(42, 185, 57, 0.1);
}

#searchBtn {
    transition: color 0.2s ease;
}

#searchBtn:hover {
    color: var(--agricultural-green);
}

/* ==================== FILTER & SORT CONTROLS ==================== */
#categoryFilter,
#sortOrder {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#categoryFilter:focus,
#sortOrder:focus {
    border-color: var(--agricultural-green);
    box-shadow: 0 0 0 3px rgba(42, 185, 57, 0.1);
}

/* ==================== EMPTY STATE ==================== */
#postsEmpty {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== POST CARD DETAILS ==================== */
.blog-card h2 {
    transition: color 0.2s ease;
}

.blog-card h2:hover {
    color: var(--agricultural-green);
}

.blog-card .fa-arrow-right {
    transition: transform 0.2s ease;
}

.blog-card:hover .fa-arrow-right {
    transform: translateX(4px);
}

/* ==================== CATEGORY BADGES ==================== */
.blog-card .bg-green-600 {
    background-color: var(--agricultural-green);
}

/* ==================== TAG CLOUD ==================== */
#tagCloud a {
    transition: all 0.2s ease;
}

#tagCloud a:hover {
    background-color: rgba(42, 185, 57, 0.15);
    color: var(--agricultural-green);
    transform: translateY(-2px);
}

/* ==================== MOBILE MENU ==================== */
#mobileMenu {
    transition: all 0.3s ease;
}

#mobileMenu a {
    transition: color 0.2s ease, background-color 0.2s ease;
}

#mobileMenu a:hover {
    background-color: rgba(42, 185, 57, 0.1);
}

/* ==================== FOOTER STYLES ==================== */
footer a {
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--agricultural-green-light);
}

#footerRecentPosts a {
    padding: 0.25rem 0;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#footerRecentPosts a:last-child {
    border-bottom: none;
}

/* ==================== HEADER SHADOW ON SCROLL ==================== */
header {
    transition: box-shadow 0.3s ease;
}

header.scrolled {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ==================== LOADING SKELETON IMPROVEMENTS ==================== */
.animate-pulse .h-48 {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ==================== ACCESSIBILITY ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--agricultural-green);
    outline-offset: 2px;
}

/* ==================== PRINT STYLES ==================== */
@media print {
    header,
    footer,
    aside,
    #pagination,
    .bg-green-600 {
        display: none;
    }
    
    .blog-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    body {
        background: white;
    }
}

/* ==================== RESPONSIVE IMAGES ==================== */
img {
    max-width: 100%;
    height: auto;
}

/* ==================== SMOOTH SCROLLING ==================== */
html {
    scroll-behavior: smooth;
}

/* ==================== CATEGORY HIERARCHY INDENTATION ==================== */
#categoriesList .ml-6 a {
    font-size: 0.9rem;
}

#categoriesList .ml-6 a:before {
    content: '└─ ';
    color: #9ca3af;
}

/* ==================== MOBILE RESPONSIVE ADJUSTMENTS ==================== */
@media (max-width: 640px) {
    .hero-bg {
        padding: 2rem 1rem;
    }
    
    .blog-card .p-6 {
        padding: 1rem;
    }
    
    aside {
        order: 2;
    }
    
    main > div {
        display: flex;
        flex-direction: column;
    }
    
    .lg\\:col-span-3 {
        order: 1;
    }
    
    .lg\\:col-span-1 {
        order: 2;
    }
    
    #pagination {
        flex-wrap: wrap;
    }
    
    #pageNumbers {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==================== TABLET ADJUSTMENTS ==================== */
@media (min-width: 768px) and (max-width: 1023px) {
    #postsGrid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    aside {
        grid-column: span 4;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* ==================== DESKTOP ENHANCEMENTS ==================== */
@media (min-width: 1024px) {
    .blog-card:hover {
        transform: translateY(-8px);
    }
    
    aside .bg-white {
        position: sticky;
        top: 80px;
    }
}

/* ==================== DARK MODE SUPPORT (Future) ==================== */
@media (prefers-color-scheme: dark) {
    /* Placeholder for dark mode styles */
    /* Can be implemented in future phases */
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */
.blog-card,
.category-link,
.tag-link,
button {
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
