/* Custom styles to complement Tailwind CSS */

/* Ensure consistent image sizing for thumbnails */
.post-thumbnail {
    width: 100%;
    height: 240px;
    object-fit: cover;
}

/* Mobile menu animation improvements */
@media (max-width: 1023px) {
    #mobile-menu {
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    }
}

/* Smooth transitions for all interactive elements */
a, button, input {
    transition: all 0.3s ease;
}

/* Custom scrollbar for mobile menu */
#mobile-menu::-webkit-scrollbar {
    width: 4px;
}

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

#mobile-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

#mobile-menu::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Ensure proper spacing for grid items */
.post-grid-item {
    break-inside: avoid;
    margin-bottom: 2rem;
}

/* Responsive typography adjustments */
@media (max-width: 768px) {
    .post-title {
        font-size: 1.125rem;
        line-height: 1.4;
    }
}

/* Focus states for accessibility */
a:focus, button:focus, input:focus {
    outline: 2px solid #000;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .text-gray-medium {
        color: #000 !important;
    }
    
    .border-gray-border {
        border-color: #000 !important;
    }
}

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

/* Pagination styles */
.pagination-links a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #F6F9FC;
    color: #222;
    text-decoration: none;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    border: 1px solid #EBF1F8;
}

.pagination-links a:hover {
    background-color: #000;
    color: #fff;
    border-color: #000;
}

/* Search form improvements */
.search-form input[type="text"], 
input[type="search"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.search-form input[type="text"]:focus,
input[type="search"]:focus {
    box-shadow: none;
}

/* Header navigation alignment */
header nav {
    height: 40px;
}

header nav a {
    height: 40px;
    display: flex;
    align-items: center;
    line-height: 1;
}

/* Header search form specific styles */
header form {
    height: 40px;
}

header form input[type="text"] {
    font-size: 14px;
    line-height: 1;
    height: 40px;
    box-sizing: border-box;
    padding-top: 0;
    padding-bottom: 0;
    vertical-align: middle;
}

header form button[type="submit"] {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 10;
    box-sizing: border-box;
    height: 32px;
    line-height: 1;
}

/* Mobile search form */
@media (max-width: 1023px) {
    #mobile-menu form input[type="text"] {
        height: 48px;
        font-size: 16px;
    }
    
    #mobile-menu form button[type="submit"] {
        height: 32px;
        font-size: 12px;
    }
}

/* Remove focus animations and transitions */
header form input[type="text"]:focus {
    z-index: 1;
    width: inherit !important;
    transition: border-color 0.3s ease;
}

header form button[type="submit"]:hover {
    z-index: 11;
}

/* Ensure perfect vertical alignment */
header .flex.items-center {
    align-items: center;
}

/* Fixed width for all search inputs - no width changes on focus */
header nav form input[type="text"] {
    width: 12rem !important; /* 192px - equivalent to w-48 */
    transition: border-color 0.3s ease;
}

header nav form input[type="text"]:focus {
    width: 12rem !important; /* Keep same width on focus */
}

/* Mobile search input - always full width */
#mobile-menu form input[type="text"] {
    width: 100% !important;
}

#mobile-menu form input[type="text"]:focus {
    width: 100% !important;
}

/* Mobile menu hamburger improvements */
#mobile-menu-btn span {
    transform-origin: center;
}

/* Ensure proper spacing in navigation */
header nav a {
    display: inline-block;
    padding: 0.5rem 0;
}

/* Desktop search form container */
@media (min-width: 1024px) {
    header form {
        min-width: 280px;
    }
    
    /* Ensure proper button positioning on desktop */
    header form button[type="submit"] {
        min-width: 44px;
        height: 32px;
    }
}

/* Footer search form styles */
footer form {
    height: 56px;
}

footer form input[type="text"] {
    height: 56px;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 1;
    font-size: 16px;
    width: 100% !important;
}

footer form input[type="text"]:focus {
    width: 100% !important;
}

footer form button[type="submit"] {
    height: 40px;
    min-width: 80px;
    font-size: 11px;
    line-height: 1;
}

/* Prevent button text wrapping */
form button[type="submit"] {
    flex-shrink: 0;
}

/* Ensure consistent vertical alignment */
form input[type="text"], 
form button[type="submit"] {
    box-sizing: border-box;
}

/* Perfect vertical centering for all form elements */
form.relative.flex {
    align-items: center;
}

/* Remove any default margins that might affect alignment */
header nav a,
header form input,
header form button {
    margin: 0;
    vertical-align: middle;
}

/* Ensure line-height doesn't interfere with centering */
header nav *,
form * {
    line-height: 1;
}

/* Global rule: prevent all search inputs from changing width */
input[type="text"][name="s"],
input[type="search"][name="s"] {
    transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
}

input[type="text"][name="s"]:focus,
input[type="search"][name="s"]:focus {
    transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Override any Tailwind focus width utilities */
.focus\:w-48:focus,
.focus\:w-40:focus,
.focus\:w-52:focus {
    width: inherit !important;
}

/* Posts grid responsive optimizations */
@media (min-width: 640px) and (max-width: 767px) {
    /* Small screens: 2 columns */
    .grid.grid-cols-1.sm\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    /* Medium screens: 3 columns */
    .grid.md\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    /* Large screens: 3 columns */
    .grid.lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    /* Extra large screens: 4 columns */
    .grid.xl\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Ensure consistent card heights in grid */
.grid article {
    display: flex;
    flex-direction: column;
    height: fit-content;
}

/* Optimize gap spacing for different screen sizes */
@media (max-width: 1023px) {
    .gap-6 {
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .lg\:gap-8 {
        gap: 2rem;
    }
}

/* Responsive typography for different grid layouts */
@media (min-width: 1280px) {
    /* 4-column layout: slightly smaller text */
    .xl\:grid-cols-4 article h2 {
        font-size: 1.125rem; /* text-lg */
        line-height: 1.4;
    }
    
    .xl\:grid-cols-4 article .text-xs {
        font-size: 0.75rem;
    }
}

/* Ensure images maintain aspect ratio in all layouts */
.grid article img,
.grid article > div:first-child {
    aspect-ratio: 4/3;
    object-fit: cover;
}

/* Consistent spacing for article content */
.grid article .space-y-3 > * + * {
    margin-top: 0.75rem;
}

/* Responsive padding adjustments */
@media (min-width: 1280px) {
    .xl\:grid-cols-4 article {
        padding-bottom: 2rem;
        margin-bottom: 2rem;
    }
}

/* Tags page specific styles */
.tags-page .hot-tags a {
    transition: all 0.3s ease;
    transform: translateY(0);
}

.tags-page .hot-tags a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Tag grid cards */
.tag-card {
    transition: all 0.3s ease;
    transform: translateY(0);
}

.tag-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Random posts grid for tags page */
.random-posts-grid article {
    transition: transform 0.3s ease;
}

.random-posts-grid article:hover {
    transform: translateY(-4px);
}

/* Responsive adjustments for tags page */
@media (max-width: 640px) {
    .tags-page .hot-tags {
        justify-content: center;
    }
    
    .tags-page .hot-tags a {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
}

/* Tags grid responsive */
@media (min-width: 1280px) {
    .xl\:grid-cols-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

/* Pagination for tags page */
.tags-pagination a {
    transition: all 0.3s ease;
}

.tags-pagination a:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Comments styling */
.comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.comment-list li {
    border-bottom: 1px solid #EBF1F8;
    padding: 1.5rem 0;
    margin-bottom: 0;
}

.comment-list li:last-child {
    border-bottom: none;
}

.comment-list img.avatar {
    float: left;
    margin-right: 1.5rem;
    border-radius: 50%;
    width: 48px;
    height: 48px;
}

.comment-list .comment-meta {
    font-size: 0.875rem;
    color: #5D738D;
    margin-bottom: 1rem;
}

.comment-list .comment-meta a {
    color: #222;
    font-weight: 600;
    text-decoration: none;
}

.comment-list .comment-meta a:hover {
    color: #000;
}

.comment-list .comment-content {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.comment-reply, .cancel-comment-reply {
    text-align: right;
    margin-top: 0.5rem;
}

.comment-reply a, .cancel-comment-reply a {
    font-size: 0.875rem;
    color: #5D738D;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border: 1px solid #EBF1F8;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.comment-reply a:hover, .cancel-comment-reply a:hover {
    color: #000;
    border-color: #000;
}

.comment-list .comment-list li {
    margin-left: 4rem;
    border-bottom: none;
    padding-bottom: 0;
    padding-top: 1rem;
}

.comment-list cite.fn {
    font-style: normal;
    font-weight: 600;
}

/* Pagination for comments */
.pagination-nav a {
    display: inline-block;
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    background-color: #F6F9FC;
    color: #222;
    text-decoration: none;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: 1px solid #EBF1F8;
}

.pagination-nav a:hover {
    background-color: #000;
    color: #fff;
    border-color: #000;
}

/* Mobile responsive improvements */
@media (max-width: 640px) {
    .post-grid {
        grid-template-columns: 1fr;
    }
    
    .header-nav {
        padding: 1rem;
    }
    
    .comment-list img.avatar {
        width: 40px;
        height: 40px;
        margin-right: 1rem;
    }
    
    .comment-list .comment-list li {
        margin-left: 2.5rem;
    }
    
    /* Mobile menu adjustments */
    #mobile-menu {
        width: min(320px, 85vw);
    }
    
    /* Header adjustments for small screens */
    header .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Logo text size on mobile */
    header h1 a {
        font-size: 1.5rem;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here */
}