/* ===================================
   OBSIDIAN-LEVEL MARKDOWN FEATURES
   Advanced Markdown Styling
   =================================== */

/* ===================================
   CALLOUTS / ADMONITIONS
   =================================== */
.callout {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md, 12px);
    border-left: 4px solid;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.callout-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.callout-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.callout-content {
    color: var(--text-secondary, #a8a8a8);
    line-height: 1.6;
}

.callout-content p:last-child {
    margin-bottom: 0;
}

/* Callout Types */
.callout-note {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.callout-note .callout-title {
    color: #60a5fa;
}

.callout-tip {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}

.callout-tip .callout-title {
    color: #34d399;
}

.callout-important {
    border-left-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.08);
}

.callout-important .callout-title {
    color: #a78bfa;
}

.callout-warning {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.callout-warning .callout-title {
    color: #fbbf24;
}

.callout-caution {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.callout-caution .callout-title {
    color: #f87171;
}

/* ===================================
   TASK LISTS
   =================================== */
.post-body ul {
    list-style: none;
    padding-left: 0;
}

.post-body ul li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.5rem;
}

/* Task list checkboxes */
.post-body input[type="checkbox"] {
    position: absolute;
    left: 0;
    top: 0.25rem;
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    transition: all 0.2s ease;
}

.post-body input[type="checkbox"]:checked {
    background: #10b981;
    border-color: #10b981;
}

.post-body input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.875rem;
    font-weight: bold;
}

.post-body input[type="checkbox"]:checked + * {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Regular bullet points (when not task lists) */
.post-body ul li::before {
    content: '•';
    position: absolute;
    left: 0.5rem;
    color: var(--text-muted, #666666);
}

.post-body ul li:has(input[type="checkbox"])::before {
    content: none;
}

/* ===================================
   MATH EQUATIONS (KaTeX)
   =================================== */
.math-block {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 12px);
    overflow-x: auto;
    text-align: center;
}

.math-inline {
    padding: 0.125rem 0.25rem;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border-radius: 4px;
}

.math-error {
    color: #ef4444;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.875rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 4px;
}

/* KaTeX overrides for dark theme */
.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 0;
}

/* ===================================
   MERMAID DIAGRAMS
   =================================== */
.mermaid-container {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-lg, 16px);
    overflow-x: auto;
}

.mermaid {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}

/* ===================================
   FOOTNOTES
   =================================== */
.footnotes {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

.footnotes ol {
    padding-left: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary, #a8a8a8);
}

.footnotes li {
    margin-bottom: 0.75rem;
}

.footnote-ref {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875em;
    vertical-align: super;
    padding: 0 0.25rem;
}

.footnote-ref:hover {
    color: #60a5fa;
    text-decoration: underline;
}

.footnote-backref {
    color: var(--text-muted, #666666);
    text-decoration: none;
    margin-left: 0.5rem;
}

.footnote-backref:hover {
    color: var(--text-secondary, #a8a8a8);
}

/* ===================================
   TABLES
   =================================== */
.post-body table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

.post-body thead {
    background: rgba(255, 255, 255, 0.05);
}

.post-body th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    border-bottom: 2px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

.post-body td {
    padding: 0.75rem 1rem;
    color: var(--text-secondary, #a8a8a8);
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

.post-body tr:last-child td {
    border-bottom: none;
}

.post-body tbody tr {
    transition: background-color 0.2s ease;
}

.post-body tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ===================================
   CODE BLOCKS (Enhanced)
   =================================== */
.post-body pre {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 12px);
    overflow-x: auto;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.9rem;
    line-height: 1.6;
}

.post-body code {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.875em;
}

.post-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.post-body :not(pre) > code {
    padding: 0.2rem 0.4rem;
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
    color: #f472b6;
}

/* ===================================
   BLOCKQUOTES (Enhanced)
   =================================== */
.post-body blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--accent-muted, #a0a0a0);
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border-radius: 0 var(--radius-md, 12px) var(--radius-md, 12px) 0;
    font-style: italic;
    color: var(--text-secondary, #a8a8a8);
}

.post-body blockquote p {
    margin: 0;
}

.post-body blockquote cite {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted, #666666);
}

/* ===================================
   HEADINGS (Enhanced with Anchors)
   =================================== */
.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4,
.post-body h5,
.post-body h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary, #ffffff);
    scroll-margin-top: 100px;
}

.post-body h1 { font-size: 2.25rem; }
.post-body h2 { font-size: 1.875rem; }
.post-body h3 { font-size: 1.5rem; }
.post-body h4 { font-size: 1.25rem; }
.post-body h5 { font-size: 1.125rem; }
.post-body h6 { font-size: 1rem; }

.post-body h2 {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

/* Heading anchor links */
.post-body h1[id],
.post-body h2[id],
.post-body h3[id],
.post-body h4[id],
.post-body h5[id],
.post-body h6[id] {
    position: relative;
}

.post-body h1[id]:hover::before,
.post-body h2[id]:hover::before,
.post-body h3[id]:hover::before,
.post-body h4[id]:hover::before,
.post-body h5[id]:hover::before,
.post-body h6[id]:hover::before {
    content: '#';
    position: absolute;
    left: -1.5rem;
    color: var(--text-muted, #666666);
    font-weight: 400;
}

/* ===================================
   HORIZONTAL RULES
   =================================== */
.post-body hr {
    margin: 2rem 0;
    border: none;
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        var(--glass-border, rgba(255, 255, 255, 0.08)) 50%,
        transparent
    );
}

/* ===================================
   PARAGRAPHS & TEXT
   =================================== */
.post-body p {
    margin-bottom: 1.25rem;
    line-height: 1.75;
    color: var(--text-secondary, #a8a8a8);
}

.post-body strong {
    font-weight: 600;
    color: var(--text-primary, #ffffff);
}

.post-body em {
    font-style: italic;
}

.post-body del {
    text-decoration: line-through;
    opacity: 0.7;
}

.post-body mark {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
}

/* ===================================
   LINKS
   =================================== */
.post-body a {
    color: #3b82f6;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.post-body a:hover {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

/* ===================================
   IMAGES
   =================================== */
.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md, 12px);
    margin: 1.5rem 0;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

/* ===================================
   DEFINITION LISTS
   =================================== */
.post-body dl {
    margin: 1.5rem 0;
}

.post-body dt {
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    margin-top: 1rem;
}

.post-body dd {
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary, #a8a8a8);
}

/* ===================================
   SUBSCRIPT & SUPERSCRIPT
   =================================== */
.post-body sub,
.post-body sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

.post-body sup {
    top: -0.5em;
}

.post-body sub {
    bottom: -0.25em;
}

/* ===================================
   RESPONSIVE ADJUSTMENTS
   =================================== */
@media (max-width: 768px) {
    .callout {
        padding: 0.875rem 1rem;
    }
    
    .math-block {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .mermaid-container {
        padding: 1rem;
    }
    
    .post-body table {
        font-size: 0.875rem;
    }
    
    .post-body th,
    .post-body td {
        padding: 0.625rem 0.75rem;
    }
    
    .post-body h1 { font-size: 1.875rem; }
    .post-body h2 { font-size: 1.5rem; }
    .post-body h3 { font-size: 1.25rem; }
}
