/* ========================================
   Global doc-article styles
   Applied to any page rendered inside DocsLayout.
   Not scoped so we don't duplicate markup styling per page.
   ======================================== */

.doc-article {
    font-size: 15.5px;
    line-height: 1.7;
    color: #111827;
}

/* Eyebrow + hero */
.doc-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--brand-600);
    background: var(--brand-50);
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 12px;
}

.doc-article h1.doc-hero-title {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.15;
    margin: 0 0 16px 0;
    color: #111827;
}

.doc-article p.doc-lede {
    font-size: 18px;
    color: #4b5563;
    line-height: 1.6;
    margin: 0 0 32px 0;
    max-width: 720px;
}

/* Section headings */
.doc-article h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.6px;
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.doc-article h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 48px 0 12px 0;
    padding-top: 8px;
    scroll-margin-top: 80px;
}

.doc-article h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 28px 0 8px 0;
    scroll-margin-top: 80px;
}

.doc-article p { margin: 0 0 16px 0; }

.doc-article p.doc-fineprint {
    font-size: 12.5px;
    color: #6b7280;
    margin-top: -8px;
}

.doc-article ul,
.doc-article ol {
    margin: 0 0 16px 0;
    padding-left: 24px;
}

.doc-article li { margin-bottom: 6px; }

.doc-article a {
    color: var(--brand-600);
    text-decoration: none;
    font-weight: 500;
}

.doc-article a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.doc-article hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 40px 0;
}

.doc-article strong {
    color: #111827;
    font-weight: 600;
}

/* Inline code */
.doc-article code {
    background: #f3f4f6;
    color: var(--brand-700);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.doc-article pre {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 18px 22px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    margin: 16px 0 24px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.doc-article pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* Tables */
.doc-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 24px 0;
    font-size: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.doc-article table th,
.doc-article table td {
    padding: 10px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #f3f4f6;
}

.doc-article table th {
    background: #fafbfc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #6b7280;
}

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

/* Callouts */
.callout {
    margin: 24px 0;
    padding: 16px 18px;
    border-radius: 10px;
    border-left: 3px solid;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 14.5px;
}

.callout i { font-size: 20px; flex-shrink: 0; margin-top: 1px; }

.callout-body { flex: 1; }

.callout-body > *:last-child { margin-bottom: 0; }

.callout-info    { background: #eff6ff; border-color: #3b82f6; color: #1e3a8a; }
.callout-info i  { color: #3b82f6; }
.callout-warn    { background: #fffbeb; border-color: #f59e0b; color: #78350f; }
.callout-warn i  { color: #f59e0b; }
.callout-success { background: #f0fdf4; border-color: #22c55e; color: #14532d; }
.callout-success i { color: #22c55e; }
.callout-danger  { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.callout-danger i { color: #ef4444; }

.callout-body strong { color: inherit; }

/* Cards grid */
.doc-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin: 24px 0 32px;
}

.doc-card {
    display: block;
    padding: 22px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: #111827;
    transition: all 0.18s ease;
    position: relative;
}

.doc-card:hover {
    border-color: var(--brand-200);
    box-shadow: 0 6px 18px rgba(0, 73, 128, 0.1);
    text-decoration: none;
}

.doc-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--brand-50);
    color: var(--brand-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--brand-100);
}

.doc-card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.doc-card-desc {
    font-size: 13.5px;
    color: #6b7280;
    line-height: 1.5;
}

.doc-card-arrow {
    position: absolute;
    top: 20px;
    right: 22px;
    color: #9ca3af;
    font-size: 14px;
    transition: transform 0.18s ease;
}

.doc-card:hover .doc-card-arrow {
    color: var(--brand-600);
    transform: translateX(3px);
}

/* ─── Mermaid ─── */
/* Outer block — hides raw source while mermaid is loading */
.doc-article .mermaid {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin: 28px 0;
    padding: 0;
    overflow: hidden;
    text-align: left;
    white-space: pre;
    font-size: 0; /* hide raw source pre-render */
    color: transparent;
    position: relative;
    min-height: 60px;
}

.doc-article .mermaid[data-rendered="1"] {
    font-size: inherit;
    color: inherit;
    white-space: normal;
    background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}

/* Viewer wrapper placed inside .mermaid by docs-mermaid.js */
.mermaid-viewer {
    position: relative;
    padding: 24px 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
}

.mermaid-surface svg {
    max-width: 100%;
    height: auto;
    min-width: 520px; /* bump baseline rendering size for readability */
}

.mermaid-expand-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    opacity: 0;
}

.mermaid-viewer:hover .mermaid-expand-btn { opacity: 1; }

.mermaid-expand-btn:hover {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
}

/* ─── Lightbox (full-screen diagram viewer) ─── */
body.mermaid-lightbox-open { overflow: hidden; }

.mermaid-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(17, 24, 39, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    animation: mmlb-fade-in 0.18s ease-out;
}

@keyframes mmlb-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.mermaid-lightbox-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mmlb-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    border-radius: 7px;
    color: #4b5563;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.12s ease;
}

.mmlb-btn:hover {
    background: var(--brand-50);
    border-color: var(--brand-300);
    color: var(--brand-700);
}

.mmlb-btn.mmlb-close:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.mmlb-divider {
    width: 1px;
    height: 22px;
    background: #e5e7eb;
    margin: 0 6px;
}

.mermaid-lightbox-stage {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    position: relative;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
}

.mermaid-lightbox-surface {
    transform-origin: center center;
    transition: transform 0.08s ease-out;
    cursor: grab;
    padding: 24px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.mermaid-lightbox-surface svg {
    display: block;
    max-width: none;
    max-height: none;
    /* Render at 1.25× baseline inside the lightbox for better legibility */
    width: calc(100vw - 120px);
    max-width: 1400px;
    height: auto;
}

/* Error fallback */
.mermaid-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 12px 16px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 13px;
    margin: 0;
}

/* HTTP method pill inside docs */
.http-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    margin-right: 6px;
}

.http-pill.get    { background: #dbeafe; color: #1e40af; }
.http-pill.post   { background: #dcfce7; color: #166534; }
.http-pill.patch  { background: #fef3c7; color: #92400e; }
.http-pill.delete { background: #fee2e2; color: #991b1b; }

/* On-this-page (TOC inside article) */
.doc-toc-inline {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    margin: 0 0 32px 0;
    font-size: 13.5px;
}

.doc-toc-inline-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #6b7280;
    font-weight: 700;
    margin-bottom: 8px;
}

.doc-toc-inline ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }

@media (max-width: 700px) { .doc-toc-inline ul { columns: 1; } }

.doc-toc-inline li { margin: 0 0 4px 0; break-inside: avoid; }

.doc-toc-inline a {
    color: #4b5563;
    font-weight: 500;
    display: inline-block;
    padding: 3px 0;
}

.doc-toc-inline a:hover { color: var(--brand-600); text-decoration: none; }

/* Hero metrics (home page) */
.doc-hero-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin: 32px 0 0;
}

.doc-hero-metric {
    padding: 16px 18px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.doc-hero-metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.4px;
}

.doc-hero-metric-label {
    font-size: 12.5px;
    color: #6b7280;
    margin-top: 2px;
}

/* Step list (numbered) */
.doc-steps {
    list-style: none;
    padding: 0;
    margin: 24px 0;
    counter-reset: step;
}

.doc-steps > li {
    position: relative;
    padding: 18px 20px 18px 64px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 12px;
    counter-increment: step;
}

.doc-steps > li::before {
    content: counter(step);
    position: absolute;
    top: 20px;
    left: 20px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--brand-600);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.doc-steps > li h3 {
    margin: 0 0 4px 0 !important;
    font-size: 15.5px !important;
}

.doc-steps > li > *:last-child { margin-bottom: 0; }

/* Side-by-side comparison */
.doc-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 24px 0;
}

@media (max-width: 700px) { .doc-compare { grid-template-columns: 1fr; } }

.doc-compare-col {
    padding: 18px 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.doc-compare-col h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-compare-col h4 i { font-size: 16px; }

.doc-compare-col.recommended {
    border-color: #a7f3d0;
    background: #f0fdf4;
}

.doc-compare-col.recommended h4 i { color: #22c55e; }
