/* ==========================================================================
   HUB 4 MECH UNIFIED EDITOR & VIEW STYLES (Marginalia Architecture)
   ================ ========================================================== */

.editor-content {
    font-family: var(--reader-font-family, 'Inter', ui-sans-serif, system-ui, sans-serif);
    font-size: var(--reader-font-size, 16px);
    line-height: var(--reader-line-height, 1.6);
    word-wrap: break-word;
    counter-reset: exCounter ntCounter hnCounter wrCounter eqCounter figCounter;
    position: relative;
    width: 100% !important;
}

/* Regular text and blocks use two thirds of the width */
.editor-content h1, 
.editor-content h2, 
.editor-content h3, 
.editor-content h4, 
.editor-content h5, 
.editor-content h6,
.editor-content p, 
.editor-content ul, 
.editor-content ol, 
.editor-content blockquote, 
.editor-content table, 
.editor-content hr, 
.editor-content figure.img-under {
    max-width: calc(66.666% - 1.5rem) !important;
}

/* Shared heading styles */
.editor-content h1, 
.editor-content h2, 
.editor-content h3, 
.editor-content h4, 
.editor-content h5, 
.editor-content h6 {
    color: inherit;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.2;
    font-family: 'Inter', sans-serif !important;
}

/* H1 and H2 use a medium weight (500), matching the details pages */
.editor-content h1, 
.editor-content h2 {
    font-weight: 500 !important;
}

/* H3-H6 keep a heavy weight (800) for emphasis */
.editor-content h3, 
.editor-content h4, 
.editor-content h5, 
.editor-content h6 {
    font-weight: 800 !important;
}

.editor-content h1 { font-size: 2.25em; }
.editor-content h2 { font-size: 1.75em; }
.editor-content h3 { font-size: 1.5em; }
.editor-content h4 { font-size: 1.25em; }
.editor-content h5 { font-size: 1.1em; }
.editor-content h6 { font-size: 1em; }

.editor-content strong, 
.editor-content b {
    font-weight: 800 !important;
    color: inherit;
}

.editor-content i, 
.editor-content em {
    font-style: italic;
}

.editor-content u {
    text-decoration: underline;
}

.editor-content p {
    margin-top: 0;
    margin-bottom: 1rem;
}

.editor-content ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.editor-content ol {
    list-style-type: decimal;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.editor-content a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.editor-content a:hover {
    text-decoration: underline;
}

.editor-content blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 1rem;
    color: #6b7280;
    font-style: italic;
    margin: 1rem 0;
}

html.dark .editor-content blockquote, 
.dark .editor-content blockquote {
    border-left-color: #4b5563;
    color: #9ca3af;
}

.editor-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.editor-content th, 
.editor-content td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
}

html.dark .editor-content th, html.dark .editor-content td,
.dark .editor-content th, .dark .editor-content td {
    border-color: #374151;
}

.editor-content figure.img-figure {
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s;
    counter-increment: figCounter;
}

html.dark .editor-content figure.img-figure,
.dark .editor-content figure.img-figure {
    background: #111827;
    border-color: #374151;
}

.editor-content .img-under {
    display: block;
    margin: 2rem 0;
    box-sizing: border-box;
}

.editor-content .img-right {
    float: right;
    width: 33.333%;
    max-width: 300px;
    margin: 0 0 1.5rem 1.5rem;
    clear: right;
}

.editor-content figcaption {
    text-align: center;
    font-size: 0.85em;
    color: #64748b;
    margin-top: 10px;
    line-height: 1.4;
}

html.dark .editor-content figcaption,
.dark .editor-content figcaption {
    color: #9ca3af;
}

.editor-content figcaption::before {
    content: 'Figure ' counter(figCounter) '. ';
    font-weight: 800;
    color: #3b82f6;
    margin-right: 4px;
}

html.dark .editor-content figcaption::before,
.dark .editor-content figcaption::before {
    color: #60a5fa;
}

/* ==========================================================================
   CALLOUT KUTULARI
   ================ ========================================================== */

.editor-content .callout {
    padding: 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    border-left: 4px solid;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
    max-width: calc(66.666% - 1.5rem) !important;
    width: 100% !important;
    box-sizing: border-box;
}

.editor-content .callout p,
.editor-content .callout ul,
.editor-content .callout ol,
.editor-content .callout div,
.editor-content .callout .callout-p,
.editor-content .callout-title {
    max-width: 100% !important;
    width: 100% !important;
}

.editor-content .callout-title {
    font-weight: 800 !important;
    margin-bottom: 0.75rem;
    display: block;
    font-size: 1.05em;
}

.editor-content .callout-p {
    margin: 0 !important;
}

.editor-content .c-example { counter-increment: exCounter; background: #f5f3ff; border-color: #8b5cf6; color: #5b21b6; }
.editor-content .c-example .callout-title::before { content: 'Example ' counter(exCounter); }
html.dark .editor-content .c-example, .dark .editor-content .c-example { background: #5b21b633; border-color: #8b5cf6; color: #ddd6fe; }

.editor-content .c-note { counter-increment: ntCounter; background: #eff6ff; border-color: #3b82f6; color: #1e3a8a; }
.editor-content .c-note .callout-title::before { content: 'Note ' counter(ntCounter); }
html.dark .editor-content .c-note, .dark .editor-content .c-note { background: #1e3a8a33; border-color: #3b82f6; color: #bfdbfe; }

.editor-content .c-hint { counter-increment: hnCounter; background: #f0fdf4; border-color: #10b981; color: #065f46; }
.editor-content .c-hint .callout-title::before { content: 'Hint ' counter(hnCounter); }
html.dark .editor-content .c-hint, .dark .editor-content .c-hint { background: #065f4633; border-color: #10b981; color: #a7f3d0; }

.editor-content .c-warning { counter-increment: wrCounter; background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.editor-content .c-warning .callout-title::before { content: 'Warning ' counter(wrCounter); }
html.dark .editor-content .c-warning, .dark .editor-content .c-warning { background: #991b1b33; border-color: #ef4444; color: #fecaca; }

.editor-content .c-formula { counter-increment: eqCounter; background: #f3f4f6; border-color: #6366f1; color: #3730a3; }
.editor-content .c-formula .callout-title::before { content: 'Equation ' counter(eqCounter); }
/* ==========================================================================
   MATHEMATICAL TYPOGRAPHY & KATEX SYSTEM ENHANCEMENTS
   ========================================================================== */

/* 1. Base KaTeX typography: natural size matching Inter body text */
.editor-content .katex {
    font-size: 1.08em;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* High contrast isolation: Math should not inherit callout tint colors */
.editor-content .katex,
.editor-content .callout .katex {
    color: #0f172a !important; /* Deep Slate 900 */
}

html.dark .editor-content .katex,
.dark .editor-content .katex,
html.dark .editor-content .callout .katex,
.dark .editor-content .callout .katex {
    color: #f8fafc !important; /* Pure Slate 50 */
}

/* 2. Fraction bar clarity without breaking KaTeX's pixel-perfect vlist math axis alignment */
.editor-content .katex .mfrac .frac-line {
    border-bottom-width: 1.25px !important;
    min-height: 1.25px !important;
    border-color: currentColor !important;
}

/* 3. Display equation container styling */
.editor-content .katex-display {
    margin: 1.25em 0 !important;
    padding: 0.35em 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100% !important;
    scrollbar-width: thin;
    text-align: center;
}

.editor-content .katex-display > .katex {
    font-size: 1.25em;
    text-align: center;
    white-space: nowrap;
}

/* 4. Full-width containers override marginalia constraint (Problems, full solutions, full-width) */
.editor-content.full-width h1, .editor-content.full-width h2, .editor-content.full-width h3, 
.editor-content.full-width h4, .editor-content.full-width h5, .editor-content.full-width h6,
.editor-content.full-width p, .editor-content.full-width ul, .editor-content.full-width ol, 
.editor-content.full-width blockquote, .editor-content.full-width table, .editor-content.full-width hr,
.editor-content.full-width .callout,
#problem-content-body p, #problem-content-body h1, #problem-content-body h2, #problem-content-body h3,
#problem-hero-statement-content p, #problem-hero-statement-content h1, #problem-hero-statement-content h2,
#problem-solution-body p, #solution-details-drawer p,
#problem-view-statement-outer p, #problem-hero-statement-outer p {
    max-width: 100% !important;
}

#problem-view-statement-outer {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
#problem-content-body-outer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}
#problem-content-body.article-content {
    min-height: 0 !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 4. Centered calculation blocks in academic notes */
.editor-content [style*="text-align: center"] .katex,
.editor-content [style*="text-align:center"] .katex,
.editor-content div[align="center"] .katex,
.editor-content p[align="center"] .katex {
    font-size: 1.2em;
    padding: 0.25em 0;
    display: inline-block;
}

@media (max-width: 1024px) {
    .editor-content h1, .editor-content h2, .editor-content h3, .editor-content h4, .editor-content h5, .editor-content h6, 
    .editor-content p, .editor-content ul, .editor-content ol, .editor-content blockquote, .editor-content table, 
    .editor-content hr, .editor-content .callout, .editor-content figure.img-under { 
        max-width: 100% !important; 
    }
    .editor-content .img-right { float: none; width: 100%; max-width: 100%; margin: 1.5rem 0; clear: both; }
}