/* Custom styles for collapsible sections */
details {
    margin: 1em 0;
    padding: 0.5em;
    border-left: 3px solid #6366f1;
    background-color: rgba(99, 102, 241, 0.05);
}

details summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.5em;
    margin: -0.5em;
    user-select: none;
}

details summary:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

details[open] summary {
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    margin-bottom: 0.5em;
    padding-bottom: 0.5em;
}

/* Ensure images are responsive and don't exceed container */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em auto;
}

/* Nested details styling */
details details {
    margin-left: 1em;
    border-left-color: #818cf8;
    background-color: rgba(129, 140, 248, 0.03);
}

details details details {
    border-left-color: #a5b4fc;
    background-color: rgba(165, 180, 252, 0.02);
}

/* Text justification */
.md-typeset p,
.md-typeset li,
.md-typeset blockquote,
article p,
article li,
article blockquote {
    text-align: justify;
}

/* Don't justify captions or headings */
.figure-caption,
h1, h2, h3, h4, h5, h6,
summary {
    text-align: left;
}

/* Subtitle styling - bring closer to title */
h1 + p {
    margin-top: -0.8em;
    margin-bottom: 0.8em;
}

h1 + p strong {
    font-size: 0.9em;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.7);
}

/* Darker blockquote for better readability */
blockquote {
    background-color: rgba(0, 0, 0, 0.08) !important;
    border-left: 4px solid rgba(0, 0, 0, 0.3);
    padding: 0.8em 1em;
    margin: 1em 0;
    color: #000 !important;
}

blockquote p {
    color: #000 !important;
}

/* Image captions - style differently from body text */
.figure-caption {
    font-style: italic;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.7);
    text-align: center;
    margin-top: 0.5em;
    margin-bottom: 1.5em;
    font-size: 0.95em;
}

/* Fallback: paragraphs that immediately follow paragraphs containing images */
p:has(img) + p {
    font-style: italic;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.7);
    text-align: center;
    margin-top: 0.5em;
    margin-bottom: 1.5em;
    font-size: 0.95em;
}

/* Footnotes styling */
.footnote {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    font-size: 0.9em;
    color: rgba(0, 0, 0, 0.75);
}

.footnote hr {
    display: none; /* Hide the default hr, we use border-top instead */
}

.footnote ol {
    margin: 0;
    padding-left: 1.5em;
}

.footnote li {
    margin: 0.8em 0;
    text-align: left;
}

.footnote p {
    margin: 0.5em 0;
    text-align: left;
}

.footnote-ref {
    text-decoration: none;
    font-weight: 600;
    color: #6366f1;
    padding: 0 0.2em;
}

.footnote-ref:hover {
    text-decoration: underline;
}

.footnote-backref {
    text-decoration: none;
    margin-left: 0.3em;
    color: #6366f1;
    font-weight: 600;
}

.footnote-backref:hover {
    text-decoration: underline;
}

/* Inline footnotes */
.footnote-inline {
    position: relative;
    display: inline-block;
}

.footnote-trigger {
    text-decoration: none;
    font-weight: 600;
    color: #6366f1;
    padding: 0 0.2em;
    cursor: pointer;
    border-bottom: 1px dotted #6366f1;
}

.footnote-trigger:hover {
    text-decoration: none;
    background-color: #e0e7ff;
}

.footnote-content {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.5em 0.8em;
    margin-bottom: 0.5em;
    width: 300px;
    max-width: 90vw;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 0.9em;
    line-height: 1.4;
    z-index: 1000;
    text-align: left;
    white-space: normal;
}

.footnote-trigger:hover + .footnote-content,
.footnote-content:hover {
    display: block;
}

/* Make footnote content visible on click for mobile */
.footnote-trigger:focus + .footnote-content {
    display: block;
}

sup .footnote-ref {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
}

/* Collapse/Expand all buttons */
#collapse-controls {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#collapse-controls button {
    padding: 10px 15px;
    background-color: #6366f1;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: background-color 0.2s;
    white-space: nowrap;
}

#collapse-controls button:hover {
    background-color: #4f46e5;
}

#collapse-controls button:active {
    transform: scale(0.95);
}

/* Hide buttons on small screens */
@media (max-width: 768px) {
    #collapse-controls {
        display: none;
    }
}

/* Hide edit icon (pen) in collapsible headings */
details summary .md-icon,
details summary .md-icon--edit,
summary .md-icon,
summary .md-icon--edit,
details summary a[title*="edit" i],
summary a[title*="edit" i],
details summary .md-content__icon,
summary .md-content__icon {
    display: none !important;
}

/* Hide any anchor/edit links in summary */
details summary a.md-icon,
summary a.md-icon {
    display: none !important;
}

/* Hide edit icons added by MkDocs Material */
.md-header__source,
.md-content__button {
    display: none !important;
}

/* Hide any icons in summary that might be added by JavaScript */
details summary::after,
summary::after {
    display: none !important;
}

