/**
 * Quick Wins CSS - Back to Top, Reading Progress, Related Posts, etc.
 */

/* Back to Top Button */
.cs-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.cs-back-to-top:hover,
.cs-back-to-top:focus {
    background: #1d4ed8;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.cs-back-to-top:focus {
    outline: 3px solid #60a5fa;
    outline-offset: 2px;
}

/* Reading Progress Bar */
.cs-reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    z-index: 9999;
}

.cs-reading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2563eb 0%, #7c3aed 100%);
    width: 0%;
    transition: width 0.1s ease;
}

/* Reading Time & Post Views */
.cs-reading-time,
.cs-post-views {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    font-size: 0.875rem;
    margin-right: 1rem;
}

.cs-reading-time i,
.cs-post-views i {
    color: #2563eb;
}

/* Related Posts */
.cs-related-posts {
    margin: 3rem 0;
    padding: 2rem;
    background: #f9fafb;
    border-radius: 12px;
}

.cs-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    color: #1a202c;
}

.cs-section-title i {
    color: #2563eb;
}

.cs-related-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.cs-related-post-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.cs-related-post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.cs-related-post-image {
    display: block;
    overflow: hidden;
}

.cs-related-post-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.cs-related-post-card:hover .cs-related-post-image img {
    transform: scale(1.05);
}

.cs-related-post-content {
    padding: 1.25rem;
}

.cs-related-post-title {
    margin: 0 0 0.75rem;
    font-size: 1.125rem;
    line-height: 1.4;
}

.cs-related-post-title a {
    color: #1a202c;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cs-related-post-title a:hover,
.cs-related-post-title a:focus {
    color: #2563eb;
}

.cs-related-post-meta {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Author Box */
.cs-author-box {
    display: flex;
    gap: 1.5rem;
    margin: 3rem 0;
    padding: 2rem;
    background: #f9fafb;
    border-radius: 12px;
    border-left: 4px solid #2563eb;
}

.cs-author-avatar img {
    border-radius: 50%;
    width: 120px;
    height: 120px;
    object-fit: cover;
}

.cs-author-info {
    flex: 1;
}

.cs-author-name {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.cs-author-name a {
    color: #1a202c;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cs-author-name a:hover,
.cs-author-name a:focus {
    color: #2563eb;
}

.cs-author-bio {
    margin: 0 0 1rem;
    color: #4a5568;
    line-height: 1.6;
}

.cs-author-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cs-author-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

.cs-author-link:hover,
.cs-author-link:focus {
    color: #2563eb;
}

/* Breadcrumbs */
.cs-breadcrumbs {
    margin: 1rem 0;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.cs-breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.cs-breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cs-breadcrumb-item a {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cs-breadcrumb-item a:hover,
.cs-breadcrumb-item a:focus {
    color: #2563eb;
}

.cs-breadcrumb-item[aria-current="page"] {
    color: #1a202c;
    font-weight: 600;
}

.cs-breadcrumb-separator {
    color: #d1d5db;
}

/* Table of Contents */
.cs-table-of-contents {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f0f9ff;
    border: 2px solid #bfdbfe;
    border-radius: 8px;
}

.cs-toc-title {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    color: #1e40af;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cs-toc-title::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.875rem;
    margin-left: auto;
    transition: transform 0.3s ease;
}

.cs-toc-title.collapsed::after {
    transform: rotate(-90deg);
}

.cs-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: toc-counter;
}

.cs-toc-item {
    counter-increment: toc-counter;
    margin: 0.5rem 0;
}

.cs-toc-item::before {
    content: counter(toc-counter) ". ";
    color: #2563eb;
    font-weight: 600;
}

.cs-toc-item a {
    color: #1e40af;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cs-toc-item a:hover,
.cs-toc-item a:focus {
    color: #1d4ed8;
    text-decoration: underline;
}

.cs-toc-item a.active {
    color: #1d4ed8;
    font-weight: 600;
}

.cs-toc-level-3 {
    margin-left: 1.5rem;
    font-size: 0.95rem;
}

.cs-toc-level-4 {
    margin-left: 3rem;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .cs-back-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 20px;
        font-size: 1.125rem;
    }

    .cs-author-box {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }

    .cs-author-avatar img {
        width: 100px;
        height: 100px;
        margin: 0 auto;
    }

    .cs-author-meta {
        justify-content: center;
    }

    .cs-related-posts-grid {
        grid-template-columns: 1fr;
    }

    .cs-breadcrumb-list {
        font-size: 0.8125rem;
    }
}

/* High Contrast */
@media (prefers-contrast: high) {
    .cs-back-to-top {
        border: 3px solid #fff;
    }

    .cs-related-post-card,
    .cs-author-box,
    .cs-table-of-contents {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .cs-back-to-top,
    .cs-related-post-card,
    .cs-related-post-image img,
    .cs-reading-progress-bar,
    .cs-toc-title::after {
        transition: none;
    }

    .cs-related-post-card:hover,
    .cs-back-to-top:hover {
        transform: none;
    }
}

/* Print */
@media print {
    .cs-back-to-top,
    .cs-reading-progress,
    .cs-related-posts,
    .cs-table-of-contents {
        display: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .cs-related-posts,
    .cs-author-box {
        background: #1a202c;
    }

    .cs-related-post-card {
        background: #2d3748;
    }

    .cs-section-title,
    .cs-related-post-title a,
    .cs-author-name a {
        color: #f7fafc;
    }

    .cs-table-of-contents {
        background: #1e3a8a;
        border-color: #3b82f6;
    }
}
