/**
 * Knowledge Base Styles
 *
 * Styles for KB archive and single article templates
 *
 * @package Remko_Theme
 * @since 1.0.0
 */

/* ==========================================================================
   KB Archive Page
   ========================================================================== */

/* Hero Section */
.kb-hero {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.kb-search-container .form-input {
    border: none;
    outline: none;
}

.kb-search-container .form-input:focus {
    box-shadow: none;
}

/* Category Navigation */
.kb-category-nav {
    transition: box-shadow 0.3s ease;
}

.kb-category-nav.is-sticky {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kb-nav-link {
    position: relative;
    font-weight: 500;
    transition: color 0.2s ease;
    border-bottom: 2px solid transparent;
}

.kb-nav-link:hover,
.kb-nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Topic Section */
.kb-topic-section {
    scroll-margin-top: 80px; /* Account for sticky nav */
}

/* Article Cards */
.kb-article-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kb-article-card:hover {
    transform: translateY(-4px);
}

.kb-article-card h3 a:hover {
    color: var(--accent);
}

/* ==========================================================================
   KB Single Article Page
   ========================================================================== */

/* Article Header */
.kb-article-header {
    background: #fff;
}

/* TOC Sidebar */
.kb-toc-sidebar {
    position: relative;
}

.kb-toc-sidebar > div {
    position: sticky;
    top: 100px;
}

.toc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-nav li {
    margin-bottom: 0.5rem;
}

.toc-nav a {
    display: block;
    padding: 0.5rem 0;
    padding-left: 1rem;
    font-size: 0.9375rem;
    color: var(--gray-700);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
}

.toc-nav a:hover {
    color: var(--accent);
    border-left-color: var(--accent);
}

.toc-nav a.active {
    color: var(--dark);
    font-weight: 600;
    border-left-color: var(--accent);
    background: rgba(255, 207, 0, 0.1);
}

.toc-loading {
    font-style: italic;
}

/* Article Content Styling */
.kb-article-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--gray-800);
}

.kb-article-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-200);
    scroll-margin-top: 120px;
}

.kb-article-content h2:first-child {
    margin-top: 0;
}

.kb-article-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.kb-article-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--dark);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.kb-article-content p {
    margin-bottom: 1.25rem;
}

.kb-article-content ul,
.kb-article-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.kb-article-content li {
    margin-bottom: 0.5rem;
}

.kb-article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
}

.kb-article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9375rem;
}

.kb-article-content th,
.kb-article-content td {
    padding: 0.75rem 1rem;
    text-align: left;
    border: 1px solid var(--gray-200);
}

.kb-article-content th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--dark);
}

.kb-article-content tr:nth-child(even) td {
    background: var(--gray-50);
}

/* ==========================================================================
   Callout Boxes
   ========================================================================== */

/* Info Callout (Blue) */
.kb-callout-info,
.wp-block-paragraph.kb-callout-info {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid #3B82F6;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}

.kb-callout-info::before {
    content: "\f05a";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: #3B82F6;
    margin-right: 0.5rem;
}

/* Warning Callout (Red) */
.kb-callout-warning,
.wp-block-paragraph.kb-callout-warning {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #EF4444;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}

/* Success/Key Takeaway Callout (Green) */
.kb-callout-success,
.wp-block-paragraph.kb-callout-success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid #10B981;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}

/* Note Callout (Gray) */
.kb-callout-note,
.wp-block-paragraph.kb-callout-note {
    background: var(--gray-100);
    border-left: 4px solid var(--gray-400);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}

/* Callout with Icon (Phosphor Icons) */
.kb-callout-info .ph,
.kb-callout-warning .ph,
.kb-callout-success .ph,
.kb-callout-note .ph {
    margin-right: 0.5rem;
    font-size: 1.25rem;
    vertical-align: middle;
}

/* ==========================================================================
   Related Articles
   ========================================================================== */

.kb-related-articles {
    background: var(--gray-50);
}

.kb-related-card .card-blog {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kb-related-card .card-blog:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Placeholder Image */
.kb-placeholder-image {
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
}

.kb-placeholder-image svg {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.kb-related-card:hover .kb-placeholder-image svg {
    opacity: 0.7;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 1024px) {
    .kb-toc-sidebar {
        display: none;
    }

    .kb-article-main {
        grid-column: span 4;
    }
}

@media (max-width: 768px) {
    .kb-category-nav {
        position: relative;
        overflow-x: auto;
    }

    .kb-category-nav .d-flex {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .kb-nav-link {
        white-space: nowrap;
    }

    .kb-article-header h1 {
        font-size: 1.75rem !important;
    }

    .kb-article-content h2 {
        font-size: 1.25rem;
    }

    .kb-article-content h3 {
        font-size: 1.125rem;
    }
}

/* ==========================================================================
   Search Results Highlighting
   ========================================================================== */

.kb-search-highlight {
    background: rgba(255, 207, 0, 0.4);
    padding: 0.1em 0.2em;
    border-radius: 0.2em;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.kb-nav-link:focus,
.kb-article-card a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* TOC links - no visible focus outline (styled via active state instead) */
.toc-nav a:focus {
    outline: none;
}

.toc-nav a:focus-visible {
    outline: 2px solid var(--gray-400);
    outline-offset: 2px;
}

/* Skip to main content */
.kb-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--dark);
    color: var(--accent);
    padding: 0.5rem 1rem;
    z-index: 1000;
    transition: top 0.3s ease;
}

.kb-skip-link:focus {
    top: 0;
}
