/*
 * Adapted from archmanweb, https://gitlab.archlinux.org/archlinux/archmanweb
 * SPDX-License-Identifier: GPL-3.0-only
 */

/*
 * Basic style
 */

.man-page-content {
    font-family: monospace, monospace;
}

.man-page-content div.manual-text {
    margin-left: 5ex;
}

/* don't align nested elements */
.man-page-content div.manual-text table table,
.man-page-content div.manual-text table dl,
.man-page-content div.manual-text dl table,
.man-page-content div.manual-text dl dl {
    text-align: initial;
}

/* fix top margin */
.man-page-content > :first-child {
    margin-top: 0;
}
.man-page-content table.head,
.man-page-content table.foot {
    border-spacing: 0px;  /* chromium sets it to 2px by default */
}
.man-page-content table.head td,
.man-page-content table.foot td {
    padding: 0px;
}

/* Override top margin for paragraphs (needs to be the same as bottom margin,
 * because mandoc creates elements with text of the first paragraph outside <p>.
 * The value 0.6em is consistent with the margins assigned to markup elements
 * such as ".Bl-tag > dd".
 */
.man-page-content p {
    margin-top: 0.6em;
    margin-bottom: 0.6em;
}
/* Override top margin of first children in elements for which mandoc sets zero
 * margin (cannot be done everywhere because of the note above).
 */
.Bl-tag > dt > :first-child,
.Bl-tag > dd > :first-child
{
    margin-top: 0em;
}
/* Override bottom margin of all last children except headers.
 * (mandoc creates some sections where <h1> or <h2> is the only element and
 * the text is not inside <p>
 */
.man-page-content :last-child:not(h1.Sh):not(h2.Ss) {
    margin-bottom: 0em;
}


/*
 * Custom styles for mandoc elements.
 * (upstream styles are overridden with the .man-page-content selector)
 */

/* font sizes */
.man-page-content h1.Sh {
    font-size: 1.25em;
    margin-left: -4ex;
    border-bottom: none;
}
.man-page-content h2.Ss {
    font-size: 1.1em;
    margin-left: -2ex;
    border-bottom: none;
}

/* fancy anchor links */
.man-page-content a.permalink {
    color: inherit;
    text-decoration: inherit;
    border-bottom: thin dotted;
}
.man-page-content a.permalink:only-child:hover:after {
    /* :only-child is necessary, otherwise the following text would be shifted */
    /* (alternatively we could match only links inside <h1> etc. */
    content: " ¶";
}

/* Arch-styled tables
 * - "th" style applied also to "td" in the first row
 * - top and bottom margins set to 0.6em for consistency with other markup elements
 *   (they have to be the same because mandoc creates elements with text of the
 *   first paragraph outside <p>)
 */
.man-page-content table.tbl {
    background: var(--table-bg-color) none repeat scroll 0 0;
    border: 1px solid var(--table-border-color);
    margin-top: 0.6em;
    margin-bottom: 0.6em;
    padding: 0.65em;
    font-size: 1.00em;
    border-collapse: collapse;
}

.man-page-content table.tbl tr td,
.man-page-content table.tbl th {
    padding: 0.35em 0.90em;
    text-align: left;
}

.man-page-content table.tbl th,
.man-page-content table.tbl tr:first-child td:not(:only-child) {
    background: var(--table-th-bg-color) none repeat scroll 0 0;
    border-bottom: 1px solid var(--table-border-color);
    font-weight: bold;
    word-break: initial;
}

.man-page-content table.tbl tr:hover {
    background-color: var(--table-focus-bg-color);
}

.man-page-content table.tbl tr td {
    border-top: 1px dotted var(--table-border-color);
    border-bottom: 1px dotted var(--table-border-color);
}

/*
 * these were copied from mandoc.css and limited only to the children of our
 * man-page-content wrapper
 */
.man-page-content * { clear: both }
.man-page-content td { vertical-align: top; }
.man-page-content ul,
.man-page-content table,
.man-page-content dl {
    margin-top: 1ex;
    margin-bottom: 1ex;
}
/* unlike upstream, only nested dl's have zero margins */
.man-page-content table table,
.man-page-content table dl,
.man-page-content dl table,
.man-page-content dl dl {
    margin-top: 0ex;
    margin-bottom: 0ex;
}
.man-page-content li,
.man-page-content dt {
    margin-top: 1em;
}


/*
 * The following rules were copied from the upstream mandoc.css file and modified:
 * - Margins of ".Bl-tag" and ".Bl-tag > dt" were changed from 5.5em to 3.8em to
 *   match ".Bd-indent".
 * - added ".Bd-indent > pre:only-child" to cancel useless indentation of pre tags
 * Only classes that mandoc emits for man(7) input (what scdoc produces) are kept.
 */

/* Header and footer lines. */

table.head {    width: 100%;
                border-bottom: 1px dotted #808080;
                margin-bottom: 1em;
                font-size: smaller; }
td.head-vol {   text-align: center; }
td.head-rtitle {
                text-align: right; }

table.foot {    width: 100%;
                /* equal columns, so the date is centered regardless of the side cells */
                table-layout: fixed;
                border-top: 1px dotted #808080;
                /* Match the gap below the header, which comes from h1.Sh's
                   1.2em margin at 125% size: 1.5em of body text = 1.8em at "smaller". */
                margin-top: 1.8em;
                font-size: smaller; }
td.foot-date {  text-align: center; }
td.foot-title { text-align: right; }

/* Sections and paragraphs. */

.manual-text {
                margin-left: 3.8em; }
h1.Sh {         margin-top: 1.2em;
                margin-bottom: 0.6em;
                margin-left: -3.2em;
                font-size: 110%; }
h2.Ss {         margin-top: 1.2em;
                margin-bottom: 0.6em;
                margin-left: -1.2em;
                font-size: 105%; }
.Pp {           margin: 0.6em 0em; }

/* Displays and lists. */

.Bd-indent {    margin-left: 3.8em; }
/* cancel useless indentation of pre tags (leave visual left margin of 1em) */
.Bd-indent > pre:only-child {
                margin-left: -2.8em;
                margin-top: 0em; }
/* cancel useless double-indent */
.Bd-indent > .Bd-indent:only-child {
                margin-left: 0em; }

.Bl-bullet {    list-style-type: disc;
                padding-left: 1em; }

.Bl-tag {       margin-top: 0.6em;
                margin-left: 3.8em; }
.Bl-tag > dt {
                float: left;
                width: 100%;
                margin-top: 0em;
                margin-left: -3.8em;
                padding-right: 0.5em;
                vertical-align: top; }
.Bl-tag > dd {
                clear: right;
                width: 100%;
                margin-top: 0em;
                margin-left: 0em;
                margin-bottom: 0.6em;
                vertical-align: top;
                overflow: auto; }

.tbl td {       vertical-align: middle; }

/* Responsive overrides to avoid excessive margins on small devices. */

@media (max-width: 33em) {
.man-page-content div.manual-text {
    margin-left: 0em;
}
.man-page-content h1.Sh,
.man-page-content h2.Ss {
    margin-left: 0em;
}
/* the following rules are copied from mandoc.css */
.Bd-indent {    margin-left: 2em; }
.Bl-tag {       margin-left: 2em; }
.Bl-tag > dt {
                margin-left: -2em; }
}
