/* Code blocks keep their shared frame while Prism themes supply syntax colors. */
.code-block {
    position: relative;
    margin: 0 0 1rem;
    border: 1px solid var(--code-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--code-surface);
}

/* The header sits inside the clipped frame and separates its label from code. */
.code-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.75rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--code-border);
    font-size: 0.85rem;
}

.code-chip {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 0.5rem;
    border-radius: 999px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--lang-hue, var(--text-muted));
    background: var(--lang-tint, var(--surface-3));
    border: 1px solid var(--lang-hue, var(--border));
}

/* Canonical language ids give aliases the same steady chip hue. */
.code-chip[data-lang="html"] {
    --lang-hue: #E34C26;
    --lang-tint: rgba(227,76,38,.12);
}

.code-chip[data-lang="javascript"] {
    --lang-hue: #B58900;
    --lang-tint: rgba(181,137,0,.14);
}

.code-chip[data-lang="typescript"] {
    --lang-hue: #3178C6;
    --lang-tint: rgba(49,120,198,.12);
}

.code-chip[data-lang="php"] {
    --lang-hue: #777BB4;
    --lang-tint: rgba(119,123,180,.14);
}

.code-chip[data-lang="python"] {
    --lang-hue: #3776AB;
    --lang-tint: rgba(55,118,171,.12);
}

.code-chip[data-lang="shell"] {
    --lang-hue: #2E7D32;
    --lang-tint: rgba(46,125,50,.12);
}

.code-chip[data-lang="yaml"] {
    --lang-hue: #CB171E;
    --lang-tint: rgba(203,23,30,.10);
}

.code-chip[data-lang="json"] {
    --lang-hue: #8A6D00;
    --lang-tint: rgba(138,109,0,.14);
}

.code-chip[data-lang="css"] {
    --lang-hue: #563D7C;
    --lang-tint: rgba(86,61,124,.12);
}

.code-chip[data-lang="sql"] {
    --lang-hue: #B25E00;
    --lang-tint: rgba(178,94,0,.12);
}

.code-chip[data-lang="java"] {
    --lang-hue: #B07219;
    --lang-tint: rgba(176,114,25,.14);
}

.code-chip[data-lang="go"] {
    --lang-hue: #007D9C;
    --lang-tint: rgba(0,125,156,.12);
}

.code-chip[data-lang="rust"] {
    --lang-hue: #9A5B33;
    --lang-tint: rgba(154,91,51,.12);
}

.code-chip[data-lang="markdown"] {
    --lang-hue: #083FA1;
    --lang-tint: rgba(8,63,161,.10);
}

.code-chip[data-lang="toml"] {
    --lang-hue: #9C4121;
    --lang-tint: rgba(156,65,33,.12);
}

.code-chip[data-lang="diff"] {
    --lang-hue: #57606A;
    --lang-tint: rgba(87,96,106,.12);
}

.code-chip[data-lang="text"] {
    --lang-hue: #57606A;
    --lang-tint: rgba(87,96,106,.12);
}

/* Dark surfaces need stronger tints while preserving each language hue. */
[data-theme="dark"] .code-chip[data-lang="html"] {
    --lang-tint: rgba(227,76,38,.18);
}

[data-theme="dark"] .code-chip[data-lang="javascript"] {
    --lang-tint: rgba(181,137,0,.20);
}

[data-theme="dark"] .code-chip[data-lang="typescript"] {
    --lang-tint: rgba(49,120,198,.18);
}

[data-theme="dark"] .code-chip[data-lang="php"] {
    --lang-tint: rgba(119,123,180,.20);
}

[data-theme="dark"] .code-chip[data-lang="python"] {
    --lang-tint: rgba(55,118,171,.18);
}

[data-theme="dark"] .code-chip[data-lang="shell"] {
    --lang-tint: rgba(46,125,50,.18);
}

[data-theme="dark"] .code-chip[data-lang="yaml"] {
    --lang-tint: rgba(203,23,30,.16);
}

[data-theme="dark"] .code-chip[data-lang="json"] {
    --lang-tint: rgba(138,109,0,.20);
}

[data-theme="dark"] .code-chip[data-lang="css"] {
    --lang-tint: rgba(86,61,124,.18);
}

[data-theme="dark"] .code-chip[data-lang="sql"] {
    --lang-tint: rgba(178,94,0,.18);
}

[data-theme="dark"] .code-chip[data-lang="java"] {
    --lang-tint: rgba(176,114,25,.20);
}

[data-theme="dark"] .code-chip[data-lang="go"] {
    --lang-tint: rgba(0,125,156,.18);
}

[data-theme="dark"] .code-chip[data-lang="rust"] {
    --lang-tint: rgba(154,91,51,.18);
}

[data-theme="dark"] .code-chip[data-lang="markdown"] {
    --lang-tint: rgba(8,63,161,.16);
}

[data-theme="dark"] .code-chip[data-lang="toml"] {
    --lang-tint: rgba(156,65,33,.18);
}

[data-theme="dark"] .code-chip[data-lang="diff"],
[data-theme="dark"] .code-chip[data-lang="text"] {
    --lang-tint: rgba(87,96,106,.18);
}

.code-block .code-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    padding: 0.4rem 0.75rem;
    background: var(--bg-subtle);
    border: 1px solid var(--code-border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.code-block pre {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    margin: 0;
}

/* Copy controls use the same surface and accent tokens in both themes. */
.copy-btn {
    border: 1px solid var(--border);
    background: var(--surface-1);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.15em 0.6em;
    cursor: pointer;
    font-size: 0.8rem;
}

.copy-btn:hover {
    background: var(--accent);
    color: var(--surface-1);
    border-color: var(--accent);
}

/* Tag chips sit under the title as a quiet, wrap-safe row of pills. */
.doc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 1.25rem;
}

/* Chips use the quiet surface token so they read as metadata below the prose. */
.doc-tag {
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
}

/* Click-to-zoom lightbox: a full-screen viewer for the images in the page
   body. It sits above the whole app, so the backdrop is its own dark surface
   rather than a themed one. */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    background: rgba(12, 16, 22, .88);
}

.lightbox[hidden] {
    display: none;
}

/* The original file, scaled down to the viewport when it is larger than it. */
.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    cursor: pointer;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, .2);
}

.lightbox-close svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Provider actions stay compact beneath the title and inherit themed colors. */
.ai-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1.25rem;
}

/* The label identifies the action without competing with the page heading. */
.ai-panel-label {
    margin-right: 0.2rem;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

/* Each button pairs the provider's brand mark with its name, so the action
   reads correctly even when the mark is small or monochrome. */
.ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 30px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.ai-btn:hover,
.ai-btn:focus-visible {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.ai-btn-icon,
.ai-btn-icon svg {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Keep external links available in the mobile drawer without duplicating desktop header links. */
.drawer-footer {
    display: none;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
    padding-top: 1rem;
}

.drawer-footer-label {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

.drawer-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.drawer-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
}

/* Diff */
.diff-row {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 13px;
    padding: 0.1rem 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-add {
    background: var(--diff-add);
    color: var(--diff-add-text);
}

.diff-del {
    background: var(--diff-del);
    color: var(--diff-del-text);
}

.diff-summary {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 1rem;
}

/* Wide tables scroll inside their wrapper instead of overflowing the column. */
.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    margin: 0 0 1rem;
}

/* Callouts use a quiet shared surface with the leading border carrying the cue. */
.callout {
    border: 1px solid var(--border);
    border-left: 3px solid var(--callout-hue);
    border-radius: var(--radius-md);
    padding: 0.9rem 1rem;
    background: var(--surface-2);
    margin: 0 0 1rem;
}

/* Each callout type keeps a distinct hue for its border and inline icon. */
.callout--note {
    --callout-hue: #0969DA;
    border-left-color: var(--callout-hue);
}

.callout--tip {
    --callout-hue: #1A7F37;
    border-left-color: var(--callout-hue);
}

.callout--info {
    --callout-hue: #57606A;
    border-left-color: var(--callout-hue);
}

.callout--warning {
    --callout-hue: #9A6700;
    border-left-color: var(--callout-hue);
}

.callout--danger {
    --callout-hue: #CF222E;
    border-left-color: var(--callout-hue);
}

.callout--success {
    --callout-hue: #1A7F37;
    border-left-color: var(--callout-hue);
}

.callout--example {
    --callout-hue: #8250DF;
    border-left-color: var(--callout-hue);
}

.callout--quote {
    --callout-hue: #57606A;
    border-left-color: var(--callout-hue);
}

/* The heading aligns its icon and label without overpowering the body text. */
.callout-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
}

.callout-title {
    font-weight: 600;
    color: var(--text-strong);
}

.callout-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
    color: var(--callout-hue);
}

.callout-icon svg {
    width: 16px;
    height: 16px;
}

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

/* Disclosure panels keep the summary compact and reveal content beneath it. */
.details {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 0 0 1rem;
    background: var(--surface-2);
}

.details-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-weight: 600;
    padding: 0.75rem 1rem;
    list-style: none;
}

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

.details-summary::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}

.details[open] > .details-summary::after {
    transform: rotate(225deg);
}

.details-body {
    padding: 0 1rem 0.75rem;
}

/* Release notes use compact version rows and a quiet rhythm between entries. */
.changelog {
    margin: 0 0 1rem;
}

/* A `type: changelog` page carries the same version rows as a changelog
   container, so a front-matter-only page is not styled as plain prose. */
.changelog h2,
.doc-body--changelog h2 {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0 0 0.75rem;
}

.changelog-version {
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 0.9rem;
    font-weight: 600;
}

.changelog-date {
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 400;
}

.changelog ul,
.doc-body--changelog ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Tag hues identify release impact while unknown tags stay neutral. */
.changelog-tag {
    --tag-hue: #57606A;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--tag-hue);
    border-radius: 999px;
    padding: 0 0.45rem;
    color: var(--tag-hue);
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 18px;
    text-transform: uppercase;
}

.changelog-tag--new,
.changelog-tag--added {
    --tag-hue: #1A7F37;
}

.changelog-tag--fixed {
    --tag-hue: #0F766E;
}

.changelog-tag--improved {
    --tag-hue: #0969DA;
}

.changelog-tag--updated {
    --tag-hue: #9A6700;
}

.changelog-tag--deprecated {
    --tag-hue: #BC4C00;
}

.changelog-tag--removed,
.changelog-tag--breaking {
    --tag-hue: #CF222E;
}

.changelog-tag--security {
    --tag-hue: #8250DF;
}

/* Entry rows keep their tag aligned with copy and constrain embedded media.
   The row wraps, so a block sibling (media, code, a table) drops onto its own
   full-width line beneath the text instead of squeezing the text column. */
.changelog-entry {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0 0 0.5rem;
}

.changelog-text {
    flex: 1;
    min-width: 0;
}

.changelog-text > :first-child {
    margin-top: 0;
}

.changelog-text > :last-child {
    margin-bottom: 0;
}

.changelog-entry img,
.changelog-entry video,
.changelog-entry iframe {
    max-width: 100%;
}

/* Block-level siblings of the entry text (media, code, tables) span the
   full width of the entry instead of the narrow text column. */
.changelog-entry > :not(.changelog-tag):not(.changelog-text) {
    flex-basis: 100%;
}

/* Dark surfaces brighten only callout hues for legible icons and accents. */
[data-theme="dark"] .callout--note {
    --callout-hue: #58A6FF;
}

[data-theme="dark"] .callout--tip {
    --callout-hue: #3FB950;
}

[data-theme="dark"] .callout--info {
    --callout-hue: #8B949E;
}

[data-theme="dark"] .callout--warning {
    --callout-hue: #D29922;
}

[data-theme="dark"] .callout--danger {
    --callout-hue: #F85149;
}

[data-theme="dark"] .callout--success {
    --callout-hue: #3FB950;
}

[data-theme="dark"] .callout--example {
    --callout-hue: #A371F7;
}

[data-theme="dark"] .callout--quote {
    --callout-hue: #8B949E;
}

/* Article links share the quiet panel treatment and follow the reading order. */
.doc-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.doc-pager-link {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    text-decoration: none;
}

.doc-pager-link--next {
    grid-column: 2;
    text-align: right;
}

/* The label and the section line share the same quiet uppercase treatment. */
.doc-pager-label,
.doc-pager-section {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

.doc-pager-title {
    font-weight: 600;
}

/* Keep compact article controls usable when the reading column narrows. */
@media (max-width: 860px) {
    /* The footer belongs to the fixed mobile drawer, not the desktop tree sidebar. */
    .drawer-footer {
        display: block;
    }

    .code-head {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
    }

    .code-block .code-title {
        min-width: 0;
    }

    .copy-btn {
        grid-column: 1 / -1;
        justify-self: end;
    }

    .doc-pager {
        grid-template-columns: 1fr;
    }

    .doc-pager-link--next {
        grid-column: 1;
    }

    /* Callouts and details run to the edges of the content column: the
       negative margins cancel the column's 1rem gutter, and the radius is
       dropped so the panel reads as a true edge-to-edge band. */
    .callout,
    .details {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
    }

    /* Give the content a consistent phone gutter without shrinking its components. */
    .doc-column {
        padding: 0 1rem;
    }
}
