/**
 * Academic Content Blocks Styles
 * Styles for code blocks, math equations, scientific figures, references, and callouts
 */

/* =============================================================================
   Code Blocks
   ============================================================================= */

.code-block {
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #1d1f21;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.code-filename {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #282a2e;
    color: #969896;
    font-size: 0.875rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    border-bottom: 1px solid #373b41;
}

.code-filename .icon {
    opacity: 0.7;
}

.code-block pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
}

.code-block pre[class*="language-"] {
    margin: 0;
    border-radius: 0;
}

.code-caption {
    padding: 0.75rem 1rem;
    background: #282a2e;
    color: #969896;
    font-size: 0.875rem;
    border-top: 1px solid #373b41;
    font-style: italic;
}

/* =============================================================================
   Math Blocks
   ============================================================================= */

.math-block {
    margin: 1.5rem 0;
}

.math-block.math-block {
    overflow-x: auto;
    padding: 0.5rem 0;
}

.math-block .katex-display {
    margin: 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.math-block .katex-inline {
    padding: 0.125rem 0.25rem;
    background: #f1f5f9;
    border-radius: 0.25rem;
}

.math-caption {
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* =============================================================================
   Scientific Figures
   ============================================================================= */

.scientific-figure {
    margin: 2rem 0;
    text-align: center;
}

.scientific-figure img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scientific-figure img:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.scientific-figure figcaption {
    margin-top: 1rem;
    text-align: left;
    padding: 0 1rem;
}

.scientific-figure .figure-number {
    color: #0f172a;
    font-weight: 600;
}

.scientific-figure .figure-caption {
    color: #475569;
    line-height: 1.6;
}

.scientific-figure .figure-attribution {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #64748b;
}

.scientific-figure .figure-attribution a {
    color: #3b82f6;
    text-decoration: none;
}

.scientific-figure .figure-attribution a:hover {
    text-decoration: underline;
}

.scientific-figure .figure-license {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #94a3b8;
}

/* =============================================================================
   References
   ============================================================================= */

.reference-block {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
    background: #f8fafc;
    border-left: 4px solid #3b82f6;
    border-radius: 0 0.5rem 0.5rem 0;
}

.reference-number {
    font-weight: 700;
    color: #3b82f6;
    font-size: 0.875rem;
}

.reference-citation {
    flex: 1;
    font-style: normal;
    color: #334155;
    line-height: 1.6;
}

.reference-links {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
}

.reference-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #3b82f6;
    background: #eff6ff;
    border-radius: 0.25rem;
    text-decoration: none;
    transition: background 0.2s ease;
}

.reference-links a:hover {
    background: #dbeafe;
}

/* =============================================================================
   Callouts
   ============================================================================= */

.callout {
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
}

.callout-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 600;
}

.callout-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.callout-title {
    flex: 1;
}

.callout-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.callout-toggle:hover {
    opacity: 1;
}

.callout[data-collapsed="true"] .callout-toggle {
    transform: rotate(-90deg);
}

.callout[data-collapsed="true"] .callout-content {
    display: none;
}

.callout-content {
    padding: 1rem;
}

/* Callout type variants */
.callout-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}
.callout-info .callout-header {
    background: #dbeafe;
    color: #1e40af;
}

.callout-tip {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}
.callout-tip .callout-header {
    background: #dcfce7;
    color: #166534;
}

.callout-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
}
.callout-warning .callout-header {
    background: #fef3c7;
    color: #92400e;
}

.callout-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
}
.callout-danger .callout-header {
    background: #fee2e2;
    color: #991b1b;
}

.callout-note {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.callout-note .callout-header {
    background: #f1f5f9;
    color: #334155;
}

.callout-example {
    background: #faf5ff;
    border: 1px solid #e9d5ff;
}
.callout-example .callout-header {
    background: #f3e8ff;
    color: #6b21a8;
}

.callout-question {
    background: #fefce8;
    border: 1px solid #fef08a;
}
.callout-question .callout-header {
    background: #fef9c3;
    color: #854d0e;
}

.callout-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
}
.callout-success .callout-header {
    background: #bbf7d0;
    color: #166534;
}

/* =============================================================================
   Tables
   ============================================================================= */

.table-figure {
    margin: 2rem 0;
    overflow-x: auto;
}

.table-caption {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #334155;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #0f172a;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.table-source {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
    font-style: italic;
}

/* =============================================================================
   Responsive adjustments
   ============================================================================= */

@media (max-width: 640px) {
    .reference-block {
        flex-direction: column;
        align-items: flex-start;
    }

    .reference-links {
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .scientific-figure figcaption {
        padding: 0;
    }

    .code-block pre {
        font-size: 0.8rem;
    }
}
