/* Highlighted text */
mark {
    background-color: #ffff66;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* Dark theme support for highlighted text */
:root[data-theme="dark"] mark {
    background-color: #665500;
    color: #ffffff;
}

/* Collapsible sections */
.markdown-details {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.5em;
    margin: 1em 0;
}

.markdown-details summary {
    font-weight: bold;
    cursor: pointer;
    padding: 0.5em;
    user-select: none;
}

.markdown-details summary:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.details-content {
    padding: 0.5em;
    border-top: 1px solid #eee;
    margin-top: 0.5em;
}

/* Video embeds */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 1.5em 0;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Text direction classes */
.rtl, .rtl * {
    direction: rtl;
    unicode-bidi: isolate;
    text-align: right;
    margin: 0.2em 0 1em 0;
}

.ltr, .ltr * {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
    margin: 0.2em 0 1em 0;
}

/* Table of Contents styles */
.wiki-toc {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.toc-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.toc-list {
    margin: 0;
    padding-left: 1rem;
    list-style-type: none;
}

.toc-list ul {
    list-style-type: none;
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.toc-list li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.toc-list a {
    color: var(--primary-color);
    text-decoration: none;
    /* color: var(--text-color); */
    display: inline-block;
    transition: color 0.2s;
}

.toc-list a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.toc-empty {
    font-style: italic;
    color: var(--text-secondary);
    margin: 0;
}

/* Dark theme adjustments */
:root[data-theme="dark"] .wiki-toc {
    background-color: var(--code-bg);
}

/* Mermaid diagrams */
.mermaid {
    margin: 20px 0;
    overflow: auto;
    text-align: center;
    background-color: transparent;
    border-radius: 4px;
    padding: 10px 0;
    transition: opacity 0.2s ease;
    color: transparent; /* Hide raw text content */
    font-size: 0; /* Hide text completely */
    line-height: 0;
}

/* Show the SVG once rendered */
.mermaid svg {
    transition: opacity 0.15s ease;
    color: initial;
    font-size: initial;
    line-height: initial;
}

/* Override text hiding when SVG is present */
.mermaid:has(svg) {
    color: initial;
    font-size: initial;
    line-height: initial;
}

/* Fallback for browsers that don't support :has() */
.mermaid.mermaid-rendered {
    color: initial;
    font-size: initial;
    line-height: initial;
}

/* Mermaid diagram loading states for theme switching */
.mermaid-rerendering {
    position: relative;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.mermaid-rerendering::after {
    content: "Switching theme...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--background-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid var(--border-color);
    z-index: 10;
    pointer-events: none;
}

/* Screen-specific styles */
@media screen {
    .video-print-placeholder {
        display: none;
    }
}

/* -------------------------------------------------- */
/* Heading anchors (¶ links)                          */
/* Hide by default, reveal on hover/focus/touch       */
/* -------------------------------------------------- */
.markdown-content .heading-anchor,
.editor-preview .heading-anchor,
.version-content .heading-anchor {
    opacity: 0;
    margin-left: 0.25em;
    text-decoration: none;
    color: var(--text-color);
    transition: opacity 0.15s ease;
}

.markdown-content .heading-anchor:hover,
.editor-preview .heading-anchor:hover,
.version-content .heading-anchor:hover {
    text-decoration: none;
}

/* Show when heading (parent) is hovered */
.markdown-content h1:hover  .heading-anchor,
.markdown-content h2:hover  .heading-anchor,
.markdown-content h3:hover  .heading-anchor,
.markdown-content h4:hover  .heading-anchor,
.markdown-content h5:hover  .heading-anchor,
.markdown-content h6:hover  .heading-anchor,
.editor-preview h1:hover  .heading-anchor,
.editor-preview h2:hover  .heading-anchor,
.editor-preview h3:hover  .heading-anchor,
.editor-preview h4:hover  .heading-anchor,
.editor-preview h5:hover  .heading-anchor,
.editor-preview h6:hover  .heading-anchor,
.version-content  h1:hover  .heading-anchor,
.version-content  h2:hover  .heading-anchor,
.version-content  h3:hover  .heading-anchor,
.version-content  h4:hover  .heading-anchor,
.version-content  h5:hover  .heading-anchor,
.version-content  h6:hover  .heading-anchor,
.heading-anchor:focus, .heading-anchor:active {
    opacity: 1;
}

/* GitHub-flavored Alerts */
.markdown-alert {
    padding: 8px 16px;
    margin-bottom: 16px;
    border-left: 4px solid;
    border-radius: 0 4px 4px 0;
    /* background-color: var(--blockquote-bg); */ /* Optional: background color */
}

.markdown-alert-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 4px;
    font-size: 14px;
}

.markdown-alert-title svg,
.markdown-alert-title i {
    margin-right: 8px;
    fill: currentColor;
}

.markdown-alert-content {
    font-size: 14px;
}

.markdown-alert-content > :first-child {
    margin-top: 0;
}

.markdown-alert-content > :last-child {
    margin-bottom: 0;
}

/* Alert Colors - Light Theme */
.markdown-alert-note { border-color: #0969da; }
.markdown-alert-note .markdown-alert-title { color: #0969da; }

.markdown-alert-tip { border-color: #1a7f37; }
.markdown-alert-tip .markdown-alert-title { color: #1a7f37; }

.markdown-alert-important { border-color: #8250df; }
.markdown-alert-important .markdown-alert-title { color: #8250df; }

.markdown-alert-warning { border-color: #9a6700; }
.markdown-alert-warning .markdown-alert-title { color: #9a6700; }

.markdown-alert-caution { border-color: #cf222e; }
.markdown-alert-caution .markdown-alert-title { color: #cf222e; }

/* Alert Colors - Dark Theme */
:root[data-theme="dark"] .markdown-alert-note { border-color: #2f81f7; }
:root[data-theme="dark"] .markdown-alert-note .markdown-alert-title { color: #2f81f7; }

:root[data-theme="dark"] .markdown-alert-tip { border-color: #3fb950; }
:root[data-theme="dark"] .markdown-alert-tip .markdown-alert-title { color: #3fb950; }

:root[data-theme="dark"] .markdown-alert-important { border-color: #a371f7; }
:root[data-theme="dark"] .markdown-alert-important .markdown-alert-title { color: #a371f7; }

:root[data-theme="dark"] .markdown-alert-warning { border-color: #d29922; }
:root[data-theme="dark"] .markdown-alert-warning .markdown-alert-title { color: #d29922; }

:root[data-theme="dark"] .markdown-alert-caution { border-color: #f85149; }
:root[data-theme="dark"] .markdown-alert-caution .markdown-alert-title { color: #f85149; }

/* Print styles */
@media print {
    /* Collapsible sections */
    .markdown-details {
        display: block !important;
        border: 1px solid #ddd !important;
    }

    .markdown-details summary {
        display: none !important;
    }

    .markdown-details .details-content {
        display: block !important;
        border-top: none !important;
        padding-top: 0 !important;
    }

    details.markdown-details {
        height: auto !important;
        overflow: visible !important;
    }

    details.markdown-details > * {
        display: block !important;
    }

    /* Video embeds */
    .video-container,
    .local-video-player {
        display: none !important;
    }

    .video-print-placeholder {
        display: block !important;
        border: 1px solid #ddd;
        padding: 1em;
        margin: 1em 0;
        background-color: #f9f9f9;
    }

    /* TOC print styles */
    .wiki-toc {
        background-color: #f8f8f8 !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    .toc-title {
        color: black !important;
        border-bottom-color: #ddd !important;
    }

    .toc-list a {
        color: black !important;
    }
}