/* Custom styles for ContentLift - Mobile First Responsive Design */

/* Base responsive settings */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px; /* Base font size for mobile */
}

body {
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Mobile-first responsive typography */
@media (min-width: 640px) {
    html { font-size: 16px; }
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

@media (min-width: 1024px) {
    html { font-size: 16px; }
}

@media (min-width: 1280px) {
    html { font-size: 18px; }
}

/* SEO Links Styling - Clean and Professional */
.internal-link {
    @apply text-blue-600 hover:text-blue-800 transition-colors duration-150;
    text-decoration: none;
    border-bottom: 1px dotted rgba(37, 99, 235, 0.4);
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.internal-link:hover {
    border-bottom-style: solid;
    border-bottom-color: rgba(37, 99, 235, 0.7);
}

.external-link {
    @apply text-blue-600 hover:text-blue-800 transition-colors duration-150;
    text-decoration: none;
    border-bottom: 1px dotted rgba(37, 99, 235, 0.4);
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.external-link:hover {
    border-bottom-style: solid;
    border-bottom-color: rgba(37, 99, 235, 0.7);
}

.external-link::after {
    content: " ↗";
    font-size: 0.75em;
    opacity: 0.6;
    font-weight: normal;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Loading animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Custom button hover effects */
.btn-primary {
    @apply bg-blue-600 text-white px-4 py-2 sm:px-6 sm:py-3 rounded-lg font-medium transition-all duration-200 hover:bg-blue-700 hover:shadow-lg transform hover:-translate-y-0.5;
    width: 100%;
}

@media (min-width: 640px) {
    .btn-primary {
        width: auto;
    }
}

.btn-secondary {
    @apply bg-gray-200 text-gray-800 px-4 py-2 sm:px-6 sm:py-3 rounded-lg font-medium transition-all duration-200 hover:bg-gray-300 hover:shadow-md;
    width: 100%;
}

@media (min-width: 640px) {
    .btn-secondary {
        width: auto;
    }
}

/* Card hover effects */
.card-hover {
    @apply transition-all duration-300 hover:shadow-xl hover:-translate-y-1;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Custom focus styles */
.focus-ring {
    @apply focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2;
}

/* Article content styling */
.article-content {
    @apply prose prose-lg max-w-none;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    @apply text-gray-900 font-semibold;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content p {
    @apply text-gray-700 leading-relaxed;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content a {
    @apply text-blue-600 hover:text-blue-800 transition-colors;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content ul,
.article-content ol {
    @apply text-gray-700;
}

.article-content blockquote {
    @apply border-l-4 border-blue-500 bg-blue-50 p-4 italic text-gray-800;
}

.article-content code {
    @apply bg-gray-100 text-gray-800 px-2 py-1 rounded text-sm font-mono;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content pre {
    @apply bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto;
}

/* Loading spinner */
.spinner {
    border: 2px solid #f3f4f6;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile-first responsive utilities */
.mobile-hide {
    display: none;
}

.mobile-full {
    width: 100%;
}

@media (min-width: 640px) {
    .mobile-hide {
        display: block;
    }
    
    .mobile-full {
        width: auto;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-full-width {
        width: 100% !important;
        max-width: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .dark-mode-support {
        @apply bg-gray-900 text-gray-100;
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to main content link */
.skip-link {
    @apply absolute left-4 top-4 z-50 bg-blue-600 text-white px-4 py-2 rounded-md;
    transform: translateY(-100%);
    transition: transform 0.3s;
}

.skip-link:focus {
    transform: translateY(0);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .high-contrast {
        @apply border-2 border-black;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== MOBILE RESPONSIVE FIXES ===== */

/* Fix text wrapping issues */
.no-wrap {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-responsive {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Article metadata responsive layout */
.article-meta {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
}

@media (min-width: 640px) {
    .article-meta {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 1rem;
    }
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

.meta-item svg {
    flex-shrink: 0;
}

.meta-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* Ensure metadata stays on one line on mobile */
@media (max-width: 639px) {
    .article-meta .flex-wrap {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
        padding-bottom: 0.5rem;
    }
    
    .article-meta .flex-wrap::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }
    
    .meta-item {
        flex-shrink: 0;
        min-width: max-content;
    }
    
    .share-buttons {
        flex-shrink: 0;
        margin-left: 0;
    }
    
    /* Force horizontal layout on mobile */
    .article-meta > div:first-child {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .article-meta > div:first-child::-webkit-scrollbar {
        display: none;
    }
}

/* Share buttons alignment with metadata */
.share-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.share-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.share-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Enhanced share buttons styling */
.share-button[onclick*="shareArticle"],
.share-button[onclick*="copyToClipboard"] {
    position: relative;
    overflow: hidden;
    border: none;
    font-weight: 500;
    letter-spacing: 0.025em;
    cursor: pointer;
    user-select: none;
}

.share-button[onclick*="shareArticle"]:active,
.share-button[onclick*="copyToClipboard"]:active {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

/* Responsive share buttons */
@media (max-width: 640px) {
    .share-button[onclick*="shareArticle"],
    .share-button[onclick*="copyToClipboard"] {
        min-width: 120px !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem;
    }
    
    .flex.flex-wrap.justify-center.gap-4 {
        gap: 0.75rem !important;
    }
}

/* Navigation responsive fixes */
.nav-container {
    padding: 0 1rem;
}

/* Fixed navbar styling */
nav.fixed {
    backdrop-filter: blur(8px);
    background-color: rgba(255, 255, 255, 0.95);
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Navbar scroll effect */
nav.fixed.scrolled {
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Ensure content doesn't hide behind fixed navbar */
body.pt-16 {
    padding-top: 4rem; /* 64px - matches navbar height */
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem; /* Account for fixed navbar */
}

@media (min-width: 640px) {
    .nav-container {
        padding: 0 1.5rem;
    }
}

@media (min-width: 1024px) {
    .nav-container {
        padding: 0 2rem;
    }
}

/* Logo responsive sizing */
.logo-text {
    font-size: 1.125rem;
    font-weight: 600;
}

@media (min-width: 640px) {
    .logo-text {
        font-size: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .logo-text {
        font-size: 1.5rem;
    }
}

/* Mobile menu improvements */
.mobile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 50;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-height: 0;
    overflow: hidden;
}

.mobile-menu.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    max-height: 400px;
}

/* Ensure all mobile menu items are visible */
.mobile-menu-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.mobile-menu-item:last-child {
    border-bottom: none;
}

.mobile-menu-item:hover {
    background-color: #f9fafb;
}

/* Ensure mobile menu is properly positioned */
@media (max-width: 767px) {
    .nav-container {
        position: relative;
    }
    
    .mobile-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(8px);
    }
    
    /* Ensure mobile menu content has proper spacing */
    .mobile-menu > div {
        padding-bottom: 1rem;
    }
    
    /* Prevent text wrapping in mobile menu items */
    .mobile-menu-item {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }
}

.mobile-menu-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s;
}

.mobile-menu-item:hover {
    background-color: #f9fafb;
}

/* Content responsive layout */
.content-container {
    padding: 0 1rem;
    max-width: 100%;
}

@media (min-width: 640px) {
    .content-container {
        padding: 0 1.5rem;
        max-width: 640px;
        margin: 0 auto;
    }
}

@media (min-width: 768px) {
    .content-container {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .content-container {
        padding: 0 2rem;
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .content-container {
        max-width: 1280px;
    }
}

/* Grid responsive system */
.responsive-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .responsive-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 768px) {
    .responsive-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
}

@media (min-width: 1024px) {
    .responsive-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

/* Sidebar responsive behavior */
.sidebar {
    order: 2;
    margin-top: 2rem;
}

@media (min-width: 1024px) {
    .sidebar {
        order: 1;
        margin-top: 0;
    }
}

/* Article header responsive */
.article-header h1 {
    font-size: 1.875rem;
    line-height: 2.25rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
    .article-header h1 {
        font-size: 2.25rem;
        line-height: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .article-header h1 {
        font-size: 3rem;
        line-height: 1;
    }
}

/* Share buttons responsive */
.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

@media (min-width: 640px) {
    .share-buttons {
        margin-top: 0;
    }
}

.share-button {
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

/* Footer responsive */
.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Enhanced footer styling */
footer {
    position: relative;
    z-index: 10;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Footer grid improvements */
footer .grid {
    align-items: start;
}

/* Footer section spacing */
footer .space-y-4 > * + * {
    margin-top: 1rem;
}

/* Footer links hover effects */
footer a:hover {
    transform: translateX(2px);
    transition: transform 0.2s ease;
}

/* Social media buttons */
footer .w-10.h-10 {
    transition: all 0.3s ease;
}

footer .w-10.h-10:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Category indicators */
footer .w-2.h-2 {
    transition: all 0.2s ease;
}

footer a:hover .w-2.h-2 {
    transform: scale(1.5);
}

/* Footer responsive improvements */
@media (max-width: 768px) {
    footer {
        margin-top: 2rem;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
    
    footer .grid {
        gap: 2rem;
    }
    
    footer .flex-col.md\:flex-row {
        text-align: center;
    }
}

/* Utility classes for responsive design */
.hidden-mobile {
    display: none;
}

@media (min-width: 640px) {
    .hidden-mobile {
        display: block;
    }
}

.visible-mobile {
    display: block;
}

@media (min-width: 640px) {
    .visible-mobile {
        display: none;
    }
}

/* Text size responsive utilities */
.text-xs-mobile {
    font-size: 0.75rem;
}

@media (min-width: 640px) {
    .text-xs-mobile {
        font-size: 0.875rem;
    }
}

.text-sm-mobile {
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .text-sm-mobile {
        font-size: 1rem;
    }
}

/* Spacing responsive utilities */
.space-y-mobile > * + * {
    margin-top: 1rem;
}

@media (min-width: 640px) {
    .space-y-mobile > * + * {
        margin-top: 1.5rem;
    }
}

/* Container responsive padding */
.container-padding {
    padding: 1rem;
}

@media (min-width: 640px) {
    .container-padding {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container-padding {
        padding: 2rem;
    }
}

/* ===== GOOGLE ADSENSE STYLING ===== */

/* AdSense ad containers */
.adsense-ad,
.adsense-top-ad,
.adsense-inline-ad {
    margin: 2rem 0;
    text-align: center;
}

/* Top article ad styling */
.adsense-top-ad {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

/* Inline paragraph ads */
.adsense-inline-ad {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1.5rem 0;
}

/* Standard paragraph ads */
.adsense-ad {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
}

/* Ad labels */
.adsense-ad .text-sm,
.adsense-top-ad .text-sm,
.adsense-inline-ad .text-xs {
    font-weight: 500;
    letter-spacing: 0.025em;
}

/* Responsive ad sizing */
@media (max-width: 640px) {
    .adsense-ad,
    .adsense-top-ad,
    .adsense-inline-ad {
        margin: 1.5rem 0;
        padding: 1rem;
    }
    
    .adsense-top-ad {
        padding: 1rem;
    }
}

/* AdSense responsive behavior */
.adsbygoogle {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Prevent ad overflow on mobile */
@media (max-width: 480px) {
    .adsense-ad,
    .adsense-top-ad,
    .adsense-inline-ad {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-radius: 0;
    }
}
