/**
 * Course Article Template Styles
 * Reusable two-column layout with sticky TOC sidebar for educational articles
 * Color scheme: Blue only (#2563eb, #1e40af) — NO purple
 */

/* === CSS Custom Properties === */
.course-article-content {
    --article-primary: #2563eb;
    --article-primary-dark: #1e40af;
    --article-primary-light: #3b82f6;
    --article-gray-50: #f9fafb;
    --article-gray-100: #f3f4f6;
    --article-gray-200: #e5e7eb;
    --article-gray-600: #4b5563;
    --article-gray-800: #1f2937;
    --article-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    --article-shadow-hover: 0 8px 25px rgba(37, 99, 235, 0.15);
    background: #ffffff;
}

/* === Reading Progress Bar === */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #2563eb 0%, #1e40af 100%);
    z-index: 9999;
    transition: width 0.1s linear;
}

/* === Main Layout Structure === */
.article-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.main-content {
    flex: 1;
    min-width: 65%;
    max-width: 100%;
}

.sidebar {
    flex-basis: 300px;
    flex-grow: 0;
    flex-shrink: 0;
    position: -webkit-sticky;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    height: fit-content;
}

/* === Breadcrumbs === */
.course-article-breadcrumbs {
    font-size: 0.9rem;
    color: var(--article-gray-600);
    margin-bottom: 1.5rem;
    padding: 0;
}

.course-article-breadcrumbs ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
}

.course-article-breadcrumbs li {
    display: flex;
    align-items: center;
    margin: 0;
}

.course-article-breadcrumbs li + li::before {
    content: "›";
    margin: 0 0.5rem;
    color: #9ca3af;
    font-size: 1.1rem;
}

.course-article-breadcrumbs a {
    color: var(--article-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.course-article-breadcrumbs a:hover {
    color: var(--article-primary-dark);
    text-decoration: underline;
}

.course-article-breadcrumbs .active {
    color: var(--article-gray-600);
}

/* === Post Header === */
.course-article-content .article-title {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
    margin-bottom: 1rem;
}

.course-article-content .post-meta {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* === Author Badge === */
.author-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 10px;
    margin-bottom: 2rem;
    border: 1px solid #bfdbfe;
}

.author-badge img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--article-primary);
}

.author-badge .author-info {
    display: flex;
    flex-direction: column;
}

.author-badge .author-label {
    font-size: 0.8rem;
    color: var(--article-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.author-badge .author-name {
    color: var(--article-primary-dark);
    font-weight: 600;
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.author-badge .author-name:hover {
    color: var(--article-primary);
    text-decoration: underline;
}

/* === Table of Contents === */
.table-of-contents {
    background: var(--article-gray-50);
    border: 1px solid var(--article-gray-200);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--article-shadow);
    max-height: 70vh;
    overflow-y: auto;
}

.table-of-contents h3 {
    margin-top: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
    border-bottom: 2px solid var(--article-primary);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.table-of-contents ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.table-of-contents li {
    margin-bottom: 10px;
    position: relative;
    padding-left: 20px;
}

.table-of-contents li::before {
    content: "▶";
    position: absolute;
    left: 0;
    color: var(--article-primary);
    font-size: 0.7rem;
    top: 4px;
    transition: transform 0.2s ease;
}

.table-of-contents li:hover::before {
    transform: translateX(3px);
}

.table-of-contents a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 0.93rem;
    line-height: 1.4;
    transition: color 0.2s ease;
    display: block;
}

.table-of-contents a:hover {
    color: var(--article-primary);
    text-decoration: none;
}

.table-of-contents .toc-h3 {
    margin-left: 15px;
}

.table-of-contents .toc-h3 a {
    font-size: 0.88rem;
    color: #666;
    font-weight: 400;
}

.table-of-contents .toc-h3::before {
    content: "◦";
    font-size: 1rem;
    top: 2px;
}

.toc-link.active {
    color: var(--article-primary) !important;
    font-weight: 600 !important;
    background: rgba(37, 99, 235, 0.1);
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 4px;
}

/* === Typography === */
.main-content h2,
.main-content h3,
.main-content h4 {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1a1a1a;
    line-height: 1.4;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.main-content h2 {
    font-size: 1.8rem;
    font-weight: 600;
    border-bottom: 2px solid var(--article-primary);
    padding-bottom: 0.5rem;
    scroll-margin-top: 80px;
}

.main-content h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #2c3e50;
    scroll-margin-top: 80px;
}

.main-content h4 {
    font-size: 1.15rem;
    font-weight: 600;
    scroll-margin-top: 80px;
}

.main-content p {
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.8;
    font-size: 17px;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.main-content ul,
.main-content ol {
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.7;
    font-size: 17px;
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

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

.main-content a {
    color: var(--article-primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease;
}

.main-content a:hover {
    color: var(--article-primary-dark);
    border-bottom-color: var(--article-primary-dark);
}

/* === Tables === */
.main-content .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5rem 0;
    border-radius: 8px;
}

.main-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    overflow: hidden;
    margin: 0;
}

.main-content table th {
    background: linear-gradient(135deg, var(--article-primary) 0%, var(--article-primary-dark) 100%);
    color: white;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    font-size: 0.9rem;
    white-space: nowrap;
}

.main-content table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--article-gray-200);
    font-family: 'Georgia', serif;
    font-size: 0.95rem;
}

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

.main-content table tr:hover {
    background: #eff6ff;
}

/* === Educational Components === */

/* Key Concept Callout Box */
.key-concept {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-left: 4px solid var(--article-primary);
    border-radius: 0 10px 10px 0;
    padding: 1.25rem 1.5rem;
    margin: 1.75rem 0;
    position: relative;
}

.key-concept::before {
    content: "\f0eb";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    top: -12px;
    left: 12px;
    background: var(--article-primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.key-concept-title {
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    font-weight: 700;
    color: var(--article-primary-dark);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
}

.key-concept p {
    font-size: 16px !important;
    margin-bottom: 0 !important;
    color: #1e3a5f;
    line-height: 1.6 !important;
}

/* Formula Display Block */
.formula-display {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 1.75rem 2rem;
    margin: 2rem 0;
    text-align: center;
}

.formula-label {
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--article-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.formula-main {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 1.5rem;
    color: var(--article-primary-dark);
    font-weight: 400;
    letter-spacing: 1px;
    line-height: 1.6;
}

.formula-main sub,
.formula-main sup {
    font-size: 0.7em;
}

.formula-description {
    font-family: 'Georgia', serif;
    font-size: 0.9rem;
    color: var(--article-gray-600);
    margin-top: 0.75rem;
    font-style: italic;
}

/* Pro Tip Box */
.pro-tip {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-left: 4px solid #22c55e;
    border-radius: 0 10px 10px 0;
    padding: 1.25rem 1.5rem;
    margin: 1.75rem 0;
    position: relative;
}

.pro-tip::before {
    content: "\f005";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    top: -12px;
    left: 12px;
    background: #22c55e;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.pro-tip-title {
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    font-weight: 700;
    color: #166534;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
}

.pro-tip p {
    font-size: 16px !important;
    margin-bottom: 0 !important;
    color: #14532d;
    line-height: 1.6 !important;
}

/* Example Box */
.example-box {
    background: var(--article-gray-50);
    border: 1px solid var(--article-gray-200);
    border-radius: 10px;
    padding: 1.5rem;
    margin: 1.75rem 0;
}

.example-box-title {
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    font-weight: 700;
    color: var(--article-gray-800);
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.example-box-title i {
    color: var(--article-primary);
}

.example-box p:last-child {
    margin-bottom: 0 !important;
}

/* Warning Box */
.warning-box {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-left: 4px solid #f59e0b;
    border-radius: 0 10px 10px 0;
    padding: 1.25rem 1.5rem;
    margin: 1.75rem 0;
    position: relative;
}

.warning-box::before {
    content: "\f071";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    top: -12px;
    left: 12px;
    background: #f59e0b;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.warning-box-title {
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    font-weight: 700;
    color: #92400e;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
}

.warning-box p {
    font-size: 16px !important;
    margin-bottom: 0 !important;
    color: #78350f;
    line-height: 1.6 !important;
}

/* Comparison Table Cards */
.comparison-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 1.75rem 0;
}

.comparison-card {
    background: white;
    border: 1px solid var(--article-gray-200);
    border-radius: 10px;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.comparison-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--article-shadow-hover);
}

.comparison-card h4 {
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    color: var(--article-primary-dark);
    font-size: 1.1rem;
    margin-top: 0 !important;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comparison-card ul {
    padding-left: 1.25rem !important;
    margin-bottom: 0 !important;
}

.comparison-card li {
    font-size: 15px;
}

/* CTA Link Box */
.cta-box {
    background: linear-gradient(135deg, var(--article-primary) 0%, var(--article-primary-dark) 100%);
    border-radius: 10px;
    margin: 1.75rem 0;
    text-align: center;
    overflow: hidden;
}

.cta-box a {
    color: white !important;
    font-weight: 600;
    font-size: 1.05rem;
    border-bottom: none !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 1.25rem 1.5rem;
    transition: opacity 0.2s ease;
}

.cta-box a:hover {
    opacity: 0.9;
    color: white !important;
}

/* === FAQ Accordion === */
.faq-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--article-gray-200);
}

.faq-section > h2 {
    text-align: center;
    border-bottom: none !important;
    margin-bottom: 1.5rem !important;
}

.faq-accordion .accordion-item {
    border: 1px solid var(--article-gray-200);
    border-radius: 8px !important;
    margin-bottom: 0.5rem;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.faq-accordion .accordion-header {
    margin: 0 !important;
    padding: 0;
}

.faq-accordion .accordion-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.faq-accordion .accordion-button {
    background: var(--article-gray-50);
    color: var(--article-gray-800);
    font-weight: 600;
    font-size: 1rem;
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    padding: 0.85rem 1.25rem;
    border: none;
    box-shadow: none !important;
    line-height: 1.4;
}

.faq-accordion .accordion-button:not(.collapsed) {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--article-primary-dark);
}

.faq-accordion .accordion-button::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%232563eb'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.faq-accordion .accordion-body {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 16px;
    line-height: 1.7;
    color: #2c3e50;
    padding: 1rem 1.25rem;
}

.faq-accordion .accordion-body a {
    color: var(--article-primary);
    border-bottom: 1px solid rgba(37, 99, 235, 0.3);
    text-decoration: none;
}

/* === Disclaimer === */
.course-article-disclaimer {
    background: var(--article-gray-50);
    border-left: 4px solid #f59e0b;
    border-radius: 0 8px 8px 0;
    padding: 1rem 1.25rem;
    margin-top: 3rem;
}

.course-article-disclaimer h5 {
    font-family: 'Source Sans Pro', -apple-system, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 0.5rem;
}

.course-article-disclaimer p {
    font-size: 0.85rem !important;
    color: var(--article-gray-600) !important;
    line-height: 1.5 !important;
    margin-bottom: 0 !important;
}

/* === Mobile Responsiveness === */
@media (max-width: 768px) {
    .article-container {
        flex-direction: column;
        gap: 20px;
    }

    .main-content {
        min-width: 100%;
        order: 1;
    }

    .sidebar {
        position: static;
        width: 100%;
        order: 2;
        margin-top: 20px;
    }

    .course-article-content .article-title {
        font-size: 2rem;
    }

    .table-of-contents {
        padding: 20px;
        max-height: none;
    }

    .main-content h2 {
        font-size: 1.5rem;
    }

    .main-content h3 {
        font-size: 1.25rem;
    }

    .main-content p,
    .main-content ul,
    .main-content ol {
        font-size: 16px;
    }

    .comparison-cards {
        grid-template-columns: 1fr;
    }

    .formula-main {
        font-size: 1.2rem;
    }

    .author-badge {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 576px) {
    .course-article-content {
        padding: 2rem 0;
    }

    .course-article-content .article-title {
        font-size: 1.75rem;
    }

    .table-of-contents {
        padding: 15px;
    }

    .key-concept,
    .pro-tip,
    .warning-box {
        padding: 1rem 1.25rem;
    }

    .formula-display {
        padding: 1.25rem 1rem;
    }

    .formula-main {
        font-size: 1.1rem;
    }

    .comparison-card {
        padding: 1.25rem;
    }
}

/* === Video Embeds === */
.course-article-content .video-embed {
    background: var(--article-gray-50);
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--article-gray-200);
}

.course-article-content .video-embed h3 {
    color: var(--article-gray-700);
    font-weight: 600;
    font-size: 1.1rem;
}

.course-article-content .video-embed h3 i {
    color: var(--article-primary);
}

/* Video embeds
   Bootstrap (enqueued site-wide) already provides the responsive `.ratio` sizing.
   Only apply presentation styles here to avoid fighting Bootstrap's ratio utilities. */
.course-article-content .video-embed .ratio {
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--article-shadow);
    background: #000;
}

.course-article-content .video-embed .ratio iframe {
    /* Override theme-wide calculators YouTube sizing constraints (in `style.css`) */
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border: 0;
}

/* If WP Rocket swaps YouTube iframes for a preview container, make it fill the ratio box too */
.course-article-content .video-embed .ratio .rll-youtube-player {
    /* WP Rocket uses its own aspect-ratio wrapper; inside Bootstrap `.ratio` we need it to behave like a fill element. */
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    padding-bottom: 0 !important;
    margin: 0 !important;
}

.course-article-content .video-embed .ratio .rll-youtube-player > div {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.course-article-content .video-embed .ratio .rll-youtube-player img {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.course-article-content .video-embed .ratio .rll-youtube-player button.play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}
