/* Prefer common installed fonts; other systems may use their normal family fallbacks. */
:root {
    --guide-accent: #245a86;
    --guide-code-background: #f3f4f5;
    --guide-border: #c8cdd2;
    --body-family: "DejaVu Serif", serif;
    --title-family: "DejaVu Sans", sans-serif;
    --mono-family: "DejaVu Sans Mono", monospace;
}

/* User Guide additions to DocBook xslTNG's screen and print styles. */
.command, .prompt {
    font-weight: bold;
}

.prompt {
    color: green;
    /* Allow copying commands without selecting the prompt. */
    -webkit-user-select: none;
    user-select: none;
}

pre.verbatim {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    padding: 0.75em;
}

pre.screen, p .userinput, .computeroutput {
    background-color: #F0F0F0;
}

pre.programlisting {
    background-color: #f3f4f5;
    border: 1px solid #c8cdd2;
    border-radius: 0.2rem;
    padding: 0.75em 1em;
}

.example {
    border: 0.15em solid #4040CC;
}

/* Token colors only: leave code-panel layout and unhighlighted text unchanged. */
:is(pre.programlisting, code.language-bali-phy-model) :is(.c, .c1, .cm) {
    color: #387c7c;
}

:is(pre.programlisting, code.language-bali-phy-model) :is(.s, .s1, .s2, .se) {
    color: #b52b2b;
}

:is(pre.programlisting, code.language-bali-phy-model) :is(.m, .mi, .mf, .mh, .mo, .mb, .il) {
    color: #8444b8;
}

:is(pre.programlisting, code.language-bali-phy-model) .p {
    color: #2468c0;
    font-weight: bold;
}

:is(pre.programlisting, code.language-bali-phy-model) .o {
    color: #287c42;
    font-weight: bold;
}

.table table, .informaltable table {
    border-collapse: collapse;
}

.table tbody > tr:nth-child(odd), .informaltable tbody > tr:nth-child(odd) {
    background-color: #E0E0E0;
}

td, th {
    vertical-align: top;
    overflow-wrap: break-word;
}

.term {
    font-weight: bold;
}

/* Titles identify each notice without a decorative icon column, including in print. */
.admonition {
    --guide-notice-background: #edf4fa;
    --guide-notice-accent: var(--guide-accent);
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-height: 0;
    margin: 1em 0;
    padding: 0.75em 1em;
    border: 1px solid var(--guide-notice-accent);
    border-left-width: 3px;
    border-radius: 0.2rem;
    background: var(--guide-notice-background);
    color: #24292f;
}

.admonition:is(.caution, .important) {
    --guide-notice-background: #fff5df;
    --guide-notice-accent: #805500;
}

.admonition.warning {
    --guide-notice-background: #fff0f0;
    --guide-notice-accent: #a12622;
}

.admonition > div, .admonition .body {
    display: block;
    padding: 0;
}

.admonition .icon {
    display: none;
}

.admonition header {
    padding: 0;
    margin: 0 0 0.4em;
    break-after: avoid;
}

.admonition .title {
    font-family: var(--title-family);
    font-size: 1em;
    font-weight: bold;
    color: var(--guide-notice-accent);
    background: transparent;
}

.admonition .body > div > :first-child {
    margin-top: 0;
}

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

/* Override upstream notice colors on inline code; block code retains its panel background. */
.admonition code {
    background-color: var(--guide-code-background);
    border-color: var(--guide-border);
}

.admonition pre code {
    background-color: inherit;
    border-color: inherit;
}

/* Expressions may be alternatives or comparisons, rather than a complete file or script. */
pre.expression {
    border: 1px solid var(--guide-border);
    border-radius: 0.2rem;
    padding: 0.75em 1em;
}

/* A caption identifies file contents in HTML and print; the listing shares its enclosure. */
figure.example.file-content {
    margin: 1em 0;
    border: 1px solid var(--guide-border);
    border-radius: 0.2rem;
    background: white;
}

figure.file-content > figcaption {
    padding: 0.4em 1em;
    border-bottom: 1px solid var(--guide-border);
    font-family: var(--title-family);
    font-size: 0.9em;
    break-after: avoid;
}

figure.file-content pre.programlisting {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

figure.file-content > .pre-wrap {
    margin: 0;
}

figure.file-content pre code, pre.screen .computeroutput {
    background: transparent;
}

pre.screen .computeroutput {
    font-weight: normal;
}

pre.literallayout.monospaced {
    margin-left: 1em;
    padding: 0;
    border: 0;
    background: transparent;
}

/* Monospace identifies filenames; reserve inline backgrounds for expressions and input. */
code.filename, .admonition code.filename {
    background: transparent;
    border: 0;
    padding: 0;
}

/* There is no interactive panel until the upstream script populates it. */
nav.toc:empty, nav.tocopen:empty {
    display: none;
}

@media screen {
    .section-toc {
        display: none;
    }

    pre.programlisting.expression, pre.synopsis.expression {
        background-color: #edf2f6;
    }

    /* Content links share the shell selectors' accent, without changing navigation controls. */
    main article a[href], main article a[href]:visited {
        color: var(--guide-accent);
        text-decoration: underline;
    }

    main article a.xref {
        font-style: normal;
    }

    main article a[href]:focus-visible {
        outline: 2px solid var(--guide-accent);
        outline-offset: 2px;
    }

    pre.screen :is(.userinput, .command) {
        font-weight: normal;
    }

    pre.screen, pre.programlisting {
        background-color: var(--guide-code-background);
        border: 1px solid var(--guide-border);
        border-radius: 0.2rem;
        padding: 0.75em 1em;
    }

    :is(.table, .informaltable) tbody > tr:nth-child(odd) {
        background-color: var(--guide-code-background);
    }

    :is(.table, .informaltable) :is(td, th) {
        padding: 0.35em 0.6em;
    }

    :is(.table, .informaltable) thead {
        border-bottom: 1px solid var(--guide-border);
    }

    /* xslTNG hides these native controls inline. Keep them focusable until upstream
       supplies keyboard access; the associated labels remain the visible selectors. */
    .variablelist.panelset input[type=radio] {
        display: block !important;
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
    }

    .variablelist.panelset input[type=radio]:focus-visible + label {
        outline: 2px solid var(--guide-accent);
        outline-offset: 2px;
    }

    /* Reserve the underline in every state so borders do not change the label dimensions.
       Each label keeps its own underline when the selectors wrap onto another row. */
    .variablelist.panelset label {
        padding: 0.3em 0.55em;
        margin: 0;
        border: 0;
        border-bottom: 3px solid transparent;
        border-radius: 0;
        color: #3d4650;
        background: transparent;
        font-family: var(--title-family);
        font-size: 0.9em;
        transition: none;
    }

    .variablelist.panelset input[type=radio]:checked + label {
        border: 0;
        border-bottom: 3px solid var(--guide-accent);
        color: var(--guide-accent);
        background: transparent;
        font-weight: bold;
    }

    .variablelist.panelset label:hover {
        background: #edf2f6;
    }

    .variablelist.panelset, .variablelist.panelset .panelset,
    .variablelist.panelset .paneltab {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .variablelist.panelset > .panelset {
        width: 100%;
        gap: 0.25em;
    }

    .variablelist.panelset .paneltab {
        padding: 0.5em 0 0;
        border: 0;
        background: transparent;
    }

    .variablelist.panelset .paneltab > :first-child {
        margin-top: 0;
    }

    .variablelist.panelset .paneltab > :last-child {
        margin-bottom: 0;
    }

    /* Keep two levels in the opening list, while retaining the full panel and print contents. */
    main > article > .list-of-titles ul.toc ul.toc ul.toc {
        display: none;
    }

    nav.toc {
        box-sizing: border-box;
        max-width: 100vw;
    }

    nav.tocopen {
        background: var(--focused-color);
        padding: 0.25em;
    }

    nav.tocopen:focus-visible, nav.toc .close:focus-visible {
        outline: 2px solid currentColor;
        outline-offset: 2px;
    }

    /* Wide model tables can scroll without widening the surrounding document. */
    .table, .informaltable {
        overflow-x: auto;
    }
}

@media print {
    /* Use ordinary pages rather than the upstream book layout's named page families. */
    @page {
        size: Letter;
        margin: 18mm 12.7mm;
        @top-center {
            content: string(GuideSection);
            font-family: var(--title-family);
            font-size: 9pt;
        }
        @bottom-center {
            content: counter(page);
            font-family: var(--title-family);
            font-size: 9pt;
        }
    }

    @page :first {
        @top-center { content: none; }
    }

    main > article > section {
        break-before: page;
    }

    main > article > section > header {
        margin-top: 0;
        break-after: avoid;
    }

    main > article > section.section > header > h2 {
        margin-top: 0;
        string-set: GuideSection content();
    }

    /* Keep sections and immediate subsections in the opening print contents. */
    main > article > .list-of-titles ul.toc ul.toc ul.toc {
        display: none;
    }

    :is(.section-toc, main > article > .list-of-titles) .toc li {
        hyphens: none;
    }

    :is(.section-toc, main > article > .list-of-titles) .toc a::after {
        color: #555;
    }

    .section-toc {
        margin: 0 0 1.25em;
        font-size: 0.9em;
        line-height: 1.3;
    }

    .section-toc > .title {
        margin: 0 0 0.35em;
        font-family: var(--title-family);
        font-weight: bold;
        break-after: avoid;
    }

    .section-toc > ul.toc {
        margin: 0;
        padding: 0;
    }

    /* FAQ topics are indexed by the section contents; print questions directly above answers. */
    #FAQ .qandaset > ul.toc,
    #FAQ .qandaentry :is(.question, .answer) > .label {
        display: none;
    }

    #FAQ .qandaentry :is(.qanda, .question, .answer, .body) {
        display: block;
    }

    #FAQ .qandaentry {
        margin: 1em 0;
    }

    #FAQ .question {
        font-weight: bold;
        break-after: avoid;
    }

    #FAQ .question .body > :last-child {
        margin-bottom: 0.35em;
        break-after: avoid;
    }

    figure.example.file-content {
        break-inside: auto;
    }

    figure.file-content pre {
        break-inside: auto;
        hyphens: none;
    }

    pre.programlisting.expression, pre.synopsis.expression {
        background-color: white;
    }

    .admonition {
        --guide-notice-accent: #24292f;
        background: white;
        color: #24292f;
        border-color: #24292f;
        break-inside: auto;
    }

    .admonition .title {
        color: #24292f;
    }

    /* The short stop-all warning must stay with its command; longer notices may split. */
    .admonition.warning {
        break-inside: avoid;
    }

    .admonition :is(code, .filename, .command, .computeroutput, .userinput) {
        hyphens: none;
    }

    /* The PDF uses the same HTML as the browser. Print every alternative in source
       order, even if a different upstream stylesheet hides unselected panels. */
    .variablelist.panelset, .variablelist.panelset .panelset,
    .variablelist.panelset .paneltab {
        display: block;
        border: 0;
        padding: 0;
        background: transparent;
    }

    .variablelist.panelset {
        margin: 0.5em 0 1em;
    }

    .variablelist.panelset input[type=radio] {
        display: none !important;
    }

    .variablelist.panelset label {
        display: block;
        font-family: var(--title-family);
        font-size: 0.85em;
        font-weight: bold;
        margin: 0 0 0.2em;
        break-after: avoid;
    }

    .variablelist.panelset .paneltab + input + label {
        margin-top: 0.65em;
    }

    .variablelist.panelset .paneltab > :first-child {
        margin-top: 0;
    }

    .variablelist.panelset .paneltab > :last-child {
        margin-bottom: 0;
    }

    /* Keep short commands intact, but allow long alternatives and groups to span pages. */
    .variablelist.panelset pre {
        break-inside: avoid;
    }

    /* Technical text must not acquire automatic hyphens when typeset for print. */
    pre, code, .filename, .command, .computeroutput, .userinput, .literal {
        hyphens: none;
    }

    .command, .userinput {
        font-weight: normal;
    }

    :is(.table, .informaltable) tbody > tr:nth-child(odd) {
        background-color: #f3f3f3;
    }

    :is(.table, .informaltable) :is(th, td) {
        padding: 0.3em 0.5em;
    }

    :is(.table, .informaltable) th {
        border-bottom: 1px solid #aaa;
    }

    :is(.table, .informaltable) :is(th, td) > p {
        margin: 0.35em 0;
    }

    :is(.table, .informaltable) :is(th, td) > :first-child {
        margin-top: 0;
    }

    :is(.table, .informaltable) :is(th, td) > :last-child {
        margin-bottom: 0;
    }

    /* Shell alternatives have their own spacing; tighten ordinary term/description lists. */
    .variablelist:not(.panelset) dt {
        margin-bottom: 0.2em;
    }

    .variablelist:not(.panelset) dd > p {
        margin: 0.35em 0;
    }

    .variablelist:not(.panelset) dd {
        margin-bottom: 0.65em;
    }

    /* Keep rows together when they fit, but let long tables continue across pages. */
    :is(.table, .informaltable) tr {
        break-inside: avoid;
    }

    /* Column headings are short labels; wrap between words rather than hyphenating them. */
    :is(.table, .informaltable) th {
        hyphens: none;
    }

    /* Code may wrap at spaces and punctuation, but must not acquire hyphens or split words. */
    :is(.table, .informaltable) :is(code, .filename, .command, .computeroutput, .userinput) {
        hyphens: none;
        overflow-wrap: normal;
        word-break: normal;
    }

    nav.toc, nav.tocopen {
        display: none;
    }

    :root {
        --margin-inner: 0.5in;
        --margin-outer: 0.5in;
        --margin-above: 0.5in;
        --margin-below: 0.5in;
        --default-line-height: 1.4;
    }
}
