/* Typography for docs article pages — tuned for long-form reading (Twilio-style scale) */

.docs-article__title {
    font-size: 1.75rem;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

@media (min-width: 768px) {
    .docs-article__title {
        font-size: 2.25rem;
    }
}

.docs-article__meta {
    font-size: 0.8125rem;
}

.docs-article__body {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: #334155;
}

.docs-article__body > * {
    margin-top: 0;
    margin-bottom: 0;
}

.docs-article__body > * + * {
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .docs-article__body {
        font-size: 1.125rem;
        line-height: 1.7;
    }

    .docs-article__body > * + * {
        margin-top: 1.625rem;
    }
}

.docs-article__body p {
    margin-bottom: 0;
}

.docs-article__body p.text-base {
    font-size: inherit;
}

.docs-article__body h2 {
    font-size: 1.375rem;
    font-weight: 900;
    color: #0f172a;
    margin-top: 0;
    margin-bottom: 0;
    line-height: 1.45;
    position: relative;
    scroll-margin-top: calc(var(--site-header-h, 7rem) + 1rem);
    border-radius: 0.5rem;
    transition: color 0.2s ease;
}

.docs-article__body > h2:not(:first-child) {
    margin-top: 2.75rem;
    padding-top: 0.75rem;
}

.docs-article__body .docs-section-divider + h2 {
    margin-top: 1.25rem;
    padding-top: 0;
}

@media (min-width: 768px) {
    .docs-article__body > h2:not(:first-child) {
        margin-top: 3.5rem;
        padding-top: 1rem;
    }

    .docs-article__body .docs-section-divider + h2 {
        margin-top: 1.25rem;
        padding-top: 0;
    }

    .docs-article__body h2 {
        font-size: 1.625rem;
    }
}

.docs-article__body h3 {
    font-size: 1.125rem;
    font-weight: 800;
    color: #0f172a;
    margin-top: 0;
    margin-bottom: 0;
    line-height: 1.5;
    scroll-margin-top: calc(var(--site-header-h, 7rem) + 1rem);
}

@media (min-width: 768px) {
    .docs-article__body h3 {
        font-size: 1.25rem;
    }
}

.docs-article__body ul,
.docs-article__body ol {
    margin-bottom: 0;
}

.docs-article__body li {
    line-height: 1.75;
}

.docs-article__body a {
    font-weight: 700;
}

.docs-article__body > * + h3 {
    margin-top: 2rem;
}

.docs-article__body > h2 + h3 {
    margin-top: 1.5rem;
}

.docs-article__body > * + blockquote {
    margin-top: 2rem;
}

.docs-article__body > p + blockquote.docs-reading-tip {
    margin-top: 2.75rem;
    padding-top: 2rem;
    border-top: 1px solid #e2e8f0;
}

@media (min-width: 768px) {
    .docs-article__body > p + blockquote.docs-reading-tip {
        margin-top: 3rem;
        padding-top: 2.25rem;
    }
}

.docs-article__body > * + .overflow-x-auto {
    margin-top: 1.75rem;
}

.docs-figure {
    margin: 0 0 1.5rem;
}

.docs-article__body > * + .docs-figure {
    margin-top: 2.5rem;
}

@media (min-width: 768px) {
    .docs-article__body > * + .docs-figure {
        margin-top: 3rem;
    }
}

.docs-figure img {
    display: block;
    width: 100%;
    height: auto;
}

.docs-figure figcaption {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 1rem auto 0;
    padding: 0;
    text-align: center !important;
    direction: rtl;
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.6;
}

.docs-article__body > .docs-figure + .docs-section-divider {
    padding-top: 3rem;
}

@media (min-width: 768px) {
    .docs-article__body > .docs-figure + .docs-section-divider {
        padding-top: 3.5rem;
    }
}

.docs-section-divider {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 0;
    padding-top: 2.75rem;
}

@media (min-width: 768px) {
    .docs-section-divider {
        padding-top: 3rem;
    }
}

/* Docs layout: sticky TOC sidebar (RTL — TOC on the right of article text) */
.docs-article-layout {
    direction: rtl;
}

.docs-article-layout > main,
.docs-article-layout > .docs-toc-aside {
    direction: rtl;
}

.docs-toc-aside {
    position: sticky;
    top: calc(var(--site-header-h, 7rem) + 1rem);
    align-self: start;
    max-height: calc(100vh - var(--site-header-h, 7rem) - 2rem);
    max-width: 17rem;
}

.docs-toc-sidebar {
    max-height: inherit;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.25rem 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.docs-toc-sidebar::-webkit-scrollbar {
    width: 4px;
}

.docs-toc-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}

.docs-toc-sidebar__title {
    font-size: 0.9375rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.45;
    margin-bottom: 1rem;
}

.docs-article__toc-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: #94a3b8;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.docs-article__toc {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.docs-toc__section {
    list-style: none;
}

.docs-toc__section--has-children .docs-toc__link--h2 {
    padding-left: 0.15rem;
}

.docs-toc__children {
    list-style: none;
    margin: 0;
    margin-right: 0.75rem;
    padding: 0.15rem 0.85rem 0.35rem 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    border-right: 1px solid #e2e8f0;
    transition: max-height 0.28s ease, opacity 0.2s ease, padding 0.2s ease;
}

.docs-toc__section--open .docs-toc__children {
    max-height: 24rem;
    opacity: 1;
    padding-bottom: 0.5rem;
}

.docs-toc__item--h3 {
    padding-right: 0.25rem;
}

.docs-toc__link {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.45rem 0.35rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #64748b;
    text-decoration: none;
    border-radius: 0.5rem;
    text-align: start;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.docs-toc__label {
    flex: 1;
    min-width: 0;
    text-align: start;
    text-wrap: pretty;
}

.docs-toc__link--h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
}

.docs-toc__link--h2 .docs-toc__label {
    font-size: inherit;
}

.docs-toc__link--h3 {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #94a3b8;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    padding-right: 0.5rem;
}

.docs-toc__chevron {
    flex-shrink: 0;
    width: 0.45rem;
    height: 0.45rem;
    margin-top: 0.5rem;
    border-top: 2px solid #94a3b8;
    border-left: 2px solid #94a3b8;
    transform: rotate(45deg);
    transition: transform 0.2s ease, border-color 0.15s ease;
}

.docs-toc__section--open .docs-toc__chevron {
    transform: rotate(225deg);
    border-color: #1d5ed2;
}

.docs-toc__dot {
    flex-shrink: 0;
    width: 0.55rem;
    height: 0.55rem;
    margin-top: 0.42rem;
    border-radius: 9999px;
    border: 2px solid #cbd5e1;
    background: transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.docs-toc__dot--child {
    width: 0.35rem;
    height: 0.35rem;
    margin-top: 0.55rem;
    border-width: 1.5px;
}

.docs-toc__link:hover {
    color: #1d5ed2;
    background-color: rgba(29, 94, 210, 0.04);
}

.docs-toc__link--h2:hover {
    color: #1d5ed2;
}

.docs-toc__link--active {
    color: #1d5ed2;
    background-color: rgba(29, 94, 210, 0.06);
}

.docs-toc__link--h2.docs-toc__link--active {
    color: #1d5ed2;
    font-weight: 600;
}

.docs-toc__link--active .docs-toc__dot {
    background: #1d5ed2;
    border-color: #1d5ed2;
}

.docs-toc__link--h3.docs-toc__link--active {
    color: #1d5ed2;
    font-weight: 500;
}

.docs-toc__section--open .docs-toc__link--h2 {
    color: #1d5ed2;
}

.docs-article__body h2.docs-heading--active {
    color: #1d5ed2 !important;
}

.docs-article__body h3.docs-heading--active {
    color: #1d5ed2 !important;
}

.docs-article__body h2.docs-heading--active::before {
    content: '';
    position: absolute;
    left: -0.95rem;
    top: 50%;
    width: 0.45rem;
    height: 0.45rem;
    border-top: 2px solid #1d5ed2;
    border-right: 2px solid #1d5ed2;
    transform: translateY(-50%) rotate(-135deg);
    pointer-events: none;
}

.docs-article__body {
    overflow: visible;
}

@keyframes docs-heading-focus {
    0% { background-color: rgba(29, 94, 210, 0.12); }
    100% { background-color: transparent; }
}

.docs-article__body h2.docs-heading--flash,
.docs-article__body h3.docs-heading--flash {
    animation: docs-heading-focus 0.9s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .docs-article__body h2.docs-heading--flash,
    .docs-article__body h3.docs-heading--flash {
        animation: none;
        background-color: rgba(29, 94, 210, 0.08);
    }

    .docs-toc__children {
        transition: none;
    }
}

.docs-article__body blockquote {
    border-right: 4px solid #1d5ed2;
    padding-right: 1rem;
    margin-bottom: 0;
    color: #475569;
    font-size: 0.9375rem;
    line-height: 1.7;
}

/* Related articles (end of article) */
.site-header--docs ~ #content-wrapper .docs-article__body h2,
.site-header--docs ~ #content-wrapper .docs-article__body h3 {
    scroll-margin-top: calc(var(--site-header-h, 7rem) + 0.75rem);
}

.docs-related {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #e2e8f0;
}

.docs-related__title {
    font-size: 1.125rem;
    font-weight: 900;
    color: #0f172a;
}

@media (min-width: 768px) {
    .docs-related__title {
        font-size: 1.25rem;
    }
}

.docs-related__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .docs-related__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
