/* SD Markdown Export - in-page trigger button that opens a modal showing the
   page Markdown in a code block, with a stateful copy-to-clipboard button. */

.sd-mdx {
    --sd-mdx-accent: var(--sd-mdx-primary, #7c5cff);
    --sd-mdx-accent-deep: var(--sd-mdx-primary-hover, #6446d6);
    --sd-mdx-success: #16a34a;
    --sd-mdx-success-deep: #15803d;
    --sd-mdx-error: #dc2626;
    display: inline-block;
    margin: 14px 0;
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- In-page trigger button ---- */
.sd-mdx__open {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 152px;
    height: 37px;
    padding: 0 14px;
    border: none;
    border-radius: 9px;
    background: var(--sd-mdx-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
}
.sd-mdx__open::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: 0 0 0 0 var(--sd-mdx-accent);
    animation: sd-mdx-breathe 2.6s ease-in-out infinite;
}
.sd-mdx__open:hover::after, .sd-mdx__open:focus-visible::after { animation: none; box-shadow: none; }
.sd-mdx__open:hover { background: var(--sd-mdx-accent-deep); }
.sd-mdx__open:focus-visible { outline: 3px solid var(--sd-mdx-accent-deep); outline-offset: 3px; }
.sd-mdx__open:active { transform: translateY(1px) scale(0.985); }
.sd-mdx__open svg { width: 16px; height: 16px; display: block; flex: 0 0 auto; }

@keyframes sd-mdx-breathe {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sd-mdx-accent) 55%, transparent); }
    70%  { box-shadow: 0 0 0 7px color-mix(in srgb, var(--sd-mdx-accent) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sd-mdx-accent) 0%, transparent); }
}

/* ---- Modal ---- */
.sd-mdx-overlay {
    position: fixed;
    inset: 0;
    z-index: 99991;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 18, 25, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}
.sd-mdx-overlay.is-open { opacity: 1; visibility: visible; }

.sd-mdx-modal {
    display: flex;
    flex-direction: column;
    width: min(820px, 100%);
    max-height: min(85vh, 900px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    transform: translateY(8px);
    transition: transform 0.18s ease;
}
.sd-mdx-overlay.is-open .sd-mdx-modal { transform: translateY(0); }

.sd-mdx-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e6e8eb;
}
.sd-mdx-modal__title { margin: 0; font: 600 15px/1.3 inherit; color: #1a1d21; }
.sd-mdx-modal__close {
    flex: 0 0 auto;
    width: 32px; height: 32px;
    border: none; border-radius: 8px;
    background: transparent; color: #5b6169;
    font-size: 22px; line-height: 1; cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.sd-mdx-modal__close:hover, .sd-mdx-modal__close:focus-visible { background: #f0f2f4; color: #1a1d21; outline: none; }

.sd-mdx-modal__body { margin: 0; padding: 0; overflow: auto; background: #f6f8fa; flex: 1 1 auto; }
.sd-mdx-modal__body.is-state {
    display: flex; align-items: center; justify-content: center;
    padding: 40px 18px; color: #5b6169; font-size: 14px;
}
.sd-mdx-modal__code {
    display: block; margin: 0; padding: 16px 18px;
    background: transparent; color: #1f2328;
    font: 13px/1.55 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    white-space: pre-wrap; word-break: break-word; tab-size: 2;
}

.sd-mdx-modal__foot {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px; border-top: 1px solid #e6e8eb; background: #fff;
}
.sd-mdx__raw { margin-left: auto; color: #5b6169; font-size: 13px; text-decoration: none; }
.sd-mdx__raw:hover, .sd-mdx__raw:focus-visible { color: var(--sd-mdx-accent); text-decoration: underline; }

body.sd-mdx-lock { overflow: hidden; }

/* ---- Stateful copy button (inside the modal footer) ---- */
.sd-mdx__btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 168px;
    height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: 9px;
    background: var(--sd-mdx-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.45s ease, transform 0.12s ease;
}
.sd-mdx__btn:hover { background: var(--sd-mdx-accent-deep); }
.sd-mdx__btn:focus-visible { outline: 3px solid var(--sd-mdx-accent-deep); outline-offset: 3px; }
.sd-mdx__btn:active { transform: translateY(1px) scale(0.985); }
.sd-mdx__btn[data-state="loading"] { background: var(--sd-mdx-accent-deep); cursor: progress; }
.sd-mdx__btn[data-state="success"] { background: var(--sd-mdx-success); }
.sd-mdx__btn[data-state="error"]   { background: var(--sd-mdx-error); }
.sd-mdx__label { min-width: 96px; text-align: left; white-space: nowrap; }

.sd-mdx__icon { position: relative; width: 16px; height: 16px; flex: 0 0 auto; }
.sd-mdx__icon > * { position: absolute; inset: 0; display: none; color: #fff; }
.sd-mdx__btn[data-state="idle"]    .sd-mdx__g-idle,
.sd-mdx__btn[data-state="loading"] .sd-mdx__g-spin,
.sd-mdx__btn[data-state="success"] .sd-mdx__g-check,
.sd-mdx__btn[data-state="error"]   .sd-mdx__g-error { display: block; }
.sd-mdx__g-idle svg, .sd-mdx__g-check svg, .sd-mdx__g-error svg { width: 16px; height: 16px; display: block; }

.sd-mdx__spin {
    width: 14px; height: 14px; margin: 1px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: sd-mdx-spin 0.6s linear infinite;
}
@keyframes sd-mdx-spin { to { transform: rotate(360deg); } }

.sd-mdx__check-path {
    stroke: #fff; stroke-width: 2.4; fill: none;
    stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 18; stroke-dashoffset: 18;
}
.sd-mdx__btn[data-state="success"] .sd-mdx__check-path { animation: sd-mdx-draw 0.42s ease forwards; }
@keyframes sd-mdx-draw { to { stroke-dashoffset: 0; } }

@media (prefers-color-scheme: dark) { .sd-mdx { --sd-mdx-success: #22c55e; } }

@media (prefers-reduced-motion: reduce) {
    .sd-mdx__open::after, .sd-mdx__spin, .sd-mdx__check-path, .sd-mdx__btn, .sd-mdx-overlay, .sd-mdx-modal {
        animation: none !important; transition: none !important;
    }
    .sd-mdx__check-path { stroke-dashoffset: 0; }
}

@media (max-width: 600px) {
    .sd-mdx { display: block; }
    .sd-mdx__open { width: 100%; }
    .sd-mdx-overlay { padding: 0; }
    .sd-mdx-modal { width: 100%; max-height: 100vh; height: 100%; border-radius: 0; }
}
