/* Custom CSS for the Rust Specification. */

/*
.parenthetical class used to keep e.g. "less-than symbol (<)" from wrapping
the end parenthesis onto its own line. Use in a span between the last word and
the parenthetical. So for this example, you'd use
```less-than <span class="parenthetical">symbol (`<`)</span>```
*/
.parenthetical {
    white-space: nowrap;
}

/*
Warnings are defined using admonitions in blockquotes:

> [!WARNING]
> This is bad!

*/
main .warning blockquote {
    padding: 0px;
}

main .warning blockquote p {
    padding: 0px 20px;
    margin: 10px 0;
}

main .warning blockquote p:first-child::before {
    content: "⚠️ ";
}

.light main .warning blockquote,
.rust main .warning blockquote {
    border: 2px solid red;
    background: #ffcece;
}

.rust main .warning blockquote {
    /* overrides previous declaration */
    border-color: #961717;
}

.coal main .warning blockquote,
.navy main .warning blockquote,
.ayu main .warning blockquote {
    background: #542626;
}

/* Make the links higher contrast on dark themes */
.coal main .warning blockquote p a,
.navy main .warning blockquote p a,
.ayu main .warning blockquote p a {
    color: #80d0d0;
}

/* <kbd> tags can be used to highlight specific character elements. */
kbd {
    border: 1px solid #999;
    display: inline-block;
    border-radius: 3px;
    padding: 0 0.6ex;
    background: #eee;
    box-shadow: inset -1px -1px 0 #999;
    vertical-align: baseline;
    color: #000;
    height: 1.55em;
    font-style: normal;
    font-weight: bold;
    font-family: inherit;
    font-size: revert;
    line-height: revert;
}
kbd.optional {
    border-style: dashed;
    background: #fff;
}
var.optional {
    border-style: dashed;
}

/* <var> tags can be used for non-terminals. */
var {
    border: 1px solid #9c9;
    box-shadow: inset -1px -1px 0 #9c9;
    font-style: normal;
    display: inline-block;
    vertical-align: baseline;
    border-radius: 7px;
    padding: 0 4px;
    background: #dfd;
    margin: 2px;
}
var.type {
    box-shadow: inset -1px -1px 0 #c99;
    border-color: #c99;
    background: #fdd;
}

/* <span class="repeat"> can be used for a grammar production that repeats zero or more times. */
span.repeat {
    position: relative;
    border: 1px dashed #393;
    border-radius: 10px;
    display: inline-block;
    padding: 6px;
    margin-left: 0.5ex;
    margin-top: 1em;
    margin-bottom: 0.5ex;
    min-width: 3.8em;
    text-align: center;
}
span.repeat::before {
    content: "zero or more";
    white-space: nowrap;
    display: block;
    text-align: center;
    font-size: 0.75em;
    position: absolute;
    left: 0;
    right: 0;
    top: -1.4em;
    color: #393;
}
var > span {
    display: inline-block;
    border-right: 1px dotted green;
    padding-right: 0.5ex;
    margin-right: 0.5ex;
    font-style: italic;
}

/* <span class="version"> can be used to highlight a specific version of Rust. */
span.version {
    float: right;
    margin-left: 1em;
    margin-bottom: 1em;
    background: #f7c0eb;
    padding: 0.2ex 0.5ex;
    border-radius: 5px;
    display: block;
    box-shadow: inset -1px -1px 0 #a06894;
    font-size: 0.9em;
}

/* <dfn> tags are used to indicate a specific word or phrase is being defined. */
dfn {
    font-style: italic;
    text-decoration: underline;
}

.content main {
    /* Provides space on the left for the rule call-outs. */
    padding-left: 4em;
}

/* Rules are generated via r[foo.bar] syntax, processed by mdbook-spec. */
.rule {
    /* Allows the rule to be positioned. */
    position: relative;
    /* Position slightly to the left. */
    left: -4em;
    color: #999;
    font-size: 0.8em;
}
/* mdbook will wrap the rule content in a <p> tag, with a margin. However, we
   don't need the extra space
*/
.rule ~ p {
    margin-top: 0px;
}

/* When the sidebar is visible, reduce the spacing of rules so that the
   content doesn't get shifted too far, and make the text too narrow.
*/
.sidebar-visible .rule {
    left: -1em;
}
.sidebar-visible .content main {
    padding-left: 1em;
}

/* Remove the blue coloring of links on rules that mdbook normally sets. */
.rule-link {
    color: #999 !important;
}

/* When clicking a rule, it is added as a URL fragment and the browser will
   navigate to it. This adds an indicator that the linked rule is the one that
   is "current", just like normal headers are in mdbook.
*/
.rule:target::before {
    display: inline-block;
    content: "»";
    margin-inline-start: -20px;
    width: 20px;
}

/* Sets the color for [!HISTORY] blockquote admonitions. */
.history > blockquote {
    background: #f7c0eb;
}

/* Provides a anchor container for positioning popups. */
.popup-container {
    position: relative;
}
/* In the test summary page, a convenience class for toggling visibility. */
.popup-hidden {
    display: none;
}
/* In the test summary page, the styling for the uncovered rule popup. */
.uncovered-rules-popup {
    position: absolute;
    left: -250px;
    width: 400px;
    background: var(--bg);
    border-radius: 4px;
    border: 1px solid;
    z-index: 1000;
    padding: 1rem;
}

/* The popup that shows when viewing tests for a specific rule. */
.tests-popup {
    color: var(--fg);
    background: var(--bg);
    border-radius: 4px;
    border: 1px solid;
    z-index: 1000;
    padding: 1rem;
}
