/* Highlighted text - macOS style */
mark {
    background: rgba(255, 214, 10, 0.3);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

/* Dark theme support for highlighted text */
:root[data-theme="dark"] mark {
    background: rgba(255, 214, 10, 0.25);
    color: #ffd60a;
}

/* Collapsible sections - macOS Card */
.markdown-details {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 0;
    margin: 1em 0;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur-subtle);
    -webkit-backdrop-filter: var(--glass-blur-subtle);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.markdown-details summary {
    font-weight: 600;
    cursor: pointer;
    padding: 12px 16px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    font-size: 14px;
}

.markdown-details summary:hover {
    background: var(--hover-bg);
}

.markdown-details summary::-webkit-details-marker {
    display: none;
}

.markdown-details summary::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg);
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.markdown-details[open] summary::before {
    transform: rotate(45deg);
}

.details-content {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

/* Video embeds - macOS Card */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 1.5em 0;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
}

/* 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 - macOS Card */
.wiki-toc {
    margin: 1.5rem 0;
    padding: 0;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur-subtle);
    -webkit-backdrop-filter: var(--glass-blur-subtle);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.toc-title {
    font-size: 12px;
    font-weight: 600;
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.toc-list {
    margin: 0;
    padding: 8px 12px;
    list-style-type: none;
}

.toc-list ul {
    list-style-type: none;
    padding-left: 16px;
    margin: 4px 0;
}

.toc-list li {
    margin-bottom: 2px;
    line-height: 1.4;
}

.toc-list a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    transition: var(--transition-smooth);
    padding: 6px 8px;
    border-radius: var(--border-radius-xs);
    font-size: 14px;
}

.toc-list a:hover {
    background: var(--hover-bg);
}

.toc-empty {
    font-style: italic;
    color: var(--text-muted);
    margin: 0;
    padding: 12px 16px;
    font-size: 14px;
}

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

/* Mermaid diagrams - macOS Card */
.mermaid {
    margin: 1.5em 0;
    overflow: auto;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur-subtle);
    -webkit-backdrop-filter: var(--glass-blur-subtle);
    border-radius: var(--border-radius);
    padding: 1.5em;
    transition: var(--transition-smooth);
    color: transparent;
    font-size: 0;
    line-height: 0;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
}

/* Show the SVG once rendered */
.mermaid svg {
    transition: opacity 0.2s 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: var(--transition-smooth);
}

.mermaid-rerendering::after {
    content: "Switching theme...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur-subtle);
    -webkit-backdrop-filter: var(--glass-blur-subtle);
    color: var(--text-color);
    padding: 8px 14px;
    border-radius: var(--border-radius-xs);
    font-size: 13px;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    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 - macOS Card Style */
.markdown-alert {
    padding: 12px 16px;
    margin: 1em 0;
    border-left: 3px solid;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur-subtle);
    -webkit-backdrop-filter: var(--glass-blur-subtle);
    box-shadow: var(--card-shadow);
    border-top: 1px solid var(--card-border);
    border-right: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
}

.markdown-alert-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

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

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

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

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

/* Alert Colors - Light Theme (Apple colors) */
.markdown-alert-note { border-left-color: #007aff; }
.markdown-alert-note .markdown-alert-title { color: #007aff; }

.markdown-alert-tip { border-left-color: #34c759; }
.markdown-alert-tip .markdown-alert-title { color: #34c759; }

.markdown-alert-important { border-left-color: #af52de; }
.markdown-alert-important .markdown-alert-title { color: #af52de; }

.markdown-alert-warning { border-left-color: #ff9500; }
.markdown-alert-warning .markdown-alert-title { color: #ff9500; }

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

/* Alert Colors - Dark Theme (Apple dark colors) */
:root[data-theme="dark"] .markdown-alert-note { border-left-color: #0a84ff; }
:root[data-theme="dark"] .markdown-alert-note .markdown-alert-title { color: #0a84ff; }

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

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

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

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

/* 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;
    }
}