/* Base styles and content styles */

:root {
    /* Browser default font-size is 16px, this way 1 rem = 10px */
    font-size: 62.5%;
    color-scheme: var(--color-scheme);
}

html {
    font-family: var(--body-font);
    color: var(--fg);
    background-color: var(--bg);
    text-size-adjust: none;
    -webkit-text-size-adjust: none;
}

body {
    margin: 0;
    font-size: 1.55rem;
    line-height: 1.7;
    overflow-x: hidden;
}

#body-container {
    position: relative;
    background-color: var(--bg);
}

.bg-animation {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse at 20% 20%, var(--bg-effect-primary) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, var(--bg-effect-secondary) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, var(--bg-effect-tertiary) 0%, transparent 70%);
    animation: bg-drift 28s ease-in-out infinite alternate;
}

.grid-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        linear-gradient(var(--grid-overlay-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-overlay-color) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.7;
    animation: grid-float 40s linear infinite;
}

.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--particle-color);
    border-radius: 50%;
    opacity: 0;
    filter: blur(0.2px);
    animation: float-particle 16s infinite;
}

@keyframes bg-drift {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(-2%, 1%, 0) scale(1.04); }
}

@keyframes grid-float {
    0% { background-position: 0 0, 0 0; }
    100% { background-position: 60px 30px, 30px 60px; }
}

@keyframes float-particle {
    0% { transform: translate3d(var(--particle-x), 100vh, 0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translate3d(calc(var(--particle-x) * 1.5), -120vh, 0) rotate(720deg); opacity: 0; }
}

code {
    font-family: var(--mono-font) !important;
    font-size: var(--code-font-size);
    direction: ltr !important;
}

/* make long words/inline code not x overflow */
main {
    overflow-wrap: break-word;
}

/* make wide tables scroll if they overflow */
.table-wrapper {
    overflow-x: auto;
}

/* Don't change font size in headers. */
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
    font-size: unset;
}

.left { float: left; }
.right { float: right; }
.boring { opacity: 0.6; }
.hide-boring .boring { display: none; }
.hidden { display: none !important; }

h2, h3 { margin-block-start: 2.5em; }
h4, h5 { margin-block-start: 2em; }

.header + .header h3,
.header + .header h4,
.header + .header h5 {
    margin-block-start: 1em;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--heading-font);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

h1 { font-size: clamp(2.6rem, 2.2rem + 1.5vw, 3.6rem); }
h2 { font-size: clamp(2.1rem, 1.8rem + 1vw, 2.8rem); }
h3 { font-size: clamp(1.8rem, 1.6rem + 0.6vw, 2.2rem); }
h4 { font-size: 1.7rem; }
h5 { font-size: 1.5rem; }

h1:target::before,
h2:target::before,
h3:target::before,
h4:target::before,
h5:target::before,
h6:target::before {
    display: inline-block;
    content: "»";
    margin-inline-start: -30px;
    width: 30px;
}

/* This is broken on Safari as of version 14, but is fixed
   in Safari Technology Preview 117 which I think will be Safari 14.2.
   https://bugs.webkit.org/show_bug.cgi?id=218076
*/
:target {
    /* Safari does not support logical properties */
    scroll-margin-top: calc(var(--menu-bar-height) + 0.5em);
}

.page {
    outline: 0;
    padding: 0 var(--page-padding);
    margin-block-start: calc(0px - var(--menu-bar-height)); /* Compensate for the #menu-bar-hover-placeholder */
}
.page-wrapper {
    box-sizing: border-box;
    background-color: transparent;
    position: relative;
    z-index: 5;
}
.no-js .page-wrapper,
.js:not(.sidebar-resizing) .page-wrapper {
    transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}
[dir=rtl] .js:not(.sidebar-resizing) .page-wrapper {
    transition: margin-right 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}

.content {
    overflow-y: auto;
    padding: 10px 10px 60px 10px;
}
.content main {
    margin-inline-start: auto;
    margin-inline-end: auto;
    max-width: var(--content-max-width);
}
.content nav {
    margin-inline-start: auto;
    margin-inline-end: auto;
    max-width: var(--content-max-width);
    margin-top: 24px;
}
.content p,
.content ol,
.content ul {
    line-height: 1.7;
}
.content p {
    margin: 0 0 1.2em 0;
}
.content a { text-decoration: none; }
.content a:hover { text-decoration: underline; }
.content img, .content video { max-width: 100%; }
.content .header:link,
.content .header:visited {
    color: var(--fg);
}
.content .header:link,
.content .header:visited:hover {
    text-decoration: none;
}

table {
    margin: 0 auto;
    border-collapse: collapse;
    font-size: 0.95em;
}
table td {
    padding: 6px 18px;
    border: 1px var(--table-border-color) solid;
}
table thead {
    background: var(--table-header-bg);
}
table thead td {
    font-weight: 700;
    border: none;
}
table thead th {
    padding: 3px 20px;
}
table thead tr {
    border: 1px var(--table-header-bg) solid;
}
/* Alternate background colors for rows */
table tbody tr:nth-child(2n) {
    background: var(--table-alternate-bg);
}


blockquote {
    margin: 20px 0;
    padding: 0 20px;
    color: var(--fg);
    background-color: var(--quote-bg);
    border-block-start: .1em solid var(--quote-border);
    border-block-end: .1em solid var(--quote-border);
}

.admonition,
blockquote.admonition,
.blockquote-tag,
.note,
.tip,
.warning,
.caution,
.important,
.info,
.success,
.danger,
blockquote.note,
blockquote.tip,
blockquote.warning,
blockquote.caution,
blockquote.important,
blockquote.info,
blockquote.success,
blockquote.danger {
    --admonition-bg: var(--admonition-default-bg);
    --admonition-border: var(--admonition-default-border);
    --admonition-accent: var(--admonition-default-accent);
    --admonition-icon: var(--admonition-icon-default);
    position: relative;
    margin: 20px 0;
    padding: 14px 18px 14px 54px;
    color: var(--fg);
    background: var(--admonition-bg);
    border: 1px solid var(--admonition-border);
    border-block-start: none;
    border-block-end: none;
    border-radius: 12px;
    box-shadow: 0 12px 28px var(--admonition-shadow), inset 4px 0 0 var(--admonition-accent);
}

.blockquote-tag {
    padding: 14px 18px;
}

.admonition.note,
.note,
blockquote.note {
    --admonition-bg: var(--admonition-note-bg);
    --admonition-border: var(--admonition-note-border);
    --admonition-accent: var(--admonition-note-accent);
    --admonition-icon: var(--admonition-icon-note);
}

.admonition.info,
.info,
blockquote.info {
    --admonition-bg: var(--admonition-note-bg);
    --admonition-border: var(--admonition-note-border);
    --admonition-accent: var(--admonition-note-accent);
    --admonition-icon: var(--admonition-icon-note);
}

.blockquote-tag-note,
.blockquote-tag-info {
    --admonition-bg: var(--admonition-note-bg);
    --admonition-border: var(--admonition-note-border);
    --admonition-accent: var(--admonition-note-accent);
}

.admonition.tip,
.tip,
blockquote.tip,
.blockquote-tag-tip,
.admonition.success,
.success,
blockquote.success {
    --admonition-bg: var(--admonition-tip-bg);
    --admonition-border: var(--admonition-tip-border);
    --admonition-accent: var(--admonition-tip-accent);
    --admonition-icon: var(--admonition-icon-tip);
}

.admonition.warning,
.warning,
blockquote.warning,
.blockquote-tag-warning,
.admonition.important,
.important,
blockquote.important {
    --admonition-bg: var(--admonition-warning-bg);
    --admonition-border: var(--admonition-warning-border);
    --admonition-accent: var(--admonition-warning-accent);
    --admonition-icon: var(--admonition-icon-warning);
}

.admonition.caution,
.caution,
blockquote.caution,
.blockquote-tag-caution,
.admonition.danger,
.danger,
blockquote.danger {
    --admonition-bg: var(--admonition-caution-bg);
    --admonition-border: var(--admonition-caution-border);
    --admonition-accent: var(--admonition-caution-accent);
    --admonition-icon: var(--admonition-icon-caution);
}

.admonition::before,
blockquote.admonition::before,
.note::before,
.tip::before,
.warning::before,
.caution::before,
.important::before,
.info::before,
.success::before,
.danger::before,
blockquote.note::before,
blockquote.tip::before,
blockquote.warning::before,
blockquote.caution::before,
blockquote.important::before,
blockquote.info::before,
blockquote.success::before,
blockquote.danger::before {
    content: "";
    position: absolute;
    top: 14px;
    left: 18px;
    width: 20px;
    height: 20px;
    background-color: var(--admonition-accent);
    mask: var(--admonition-icon) no-repeat center / contain;
    -webkit-mask: var(--admonition-icon) no-repeat center / contain;
}

.admonition-title {
    margin: 0 0 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8em;
    color: var(--admonition-accent);
}

.blockquote-tag-title {
    margin: 0 0 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8em;
    color: var(--admonition-accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.blockquote-tag-title svg {
    flex: 0 0 auto;
    fill: currentColor;
}

.admonition > :last-child,
blockquote.admonition > :last-child,
.blockquote-tag > :last-child,
.note > :last-child,
.tip > :last-child,
.warning > :last-child,
.caution > :last-child,
.important > :last-child,
.info > :last-child,
.success > :last-child,
.danger > :last-child,
blockquote.note > :last-child,
blockquote.tip > :last-child,
blockquote.warning > :last-child,
blockquote.caution > :last-child,
blockquote.important > :last-child,
blockquote.info > :last-child,
blockquote.success > :last-child,
blockquote.danger > :last-child {
    margin-bottom: 0;
}

kbd {
    background-color: var(--table-border-color);
    border-radius: 4px;
    border: solid 1px var(--theme-popup-border);
    box-shadow: inset 0 -1px 0 var(--theme-hover);
    display: inline-block;
    font-size: var(--code-font-size);
    font-family: var(--mono-font);
    line-height: 10px;
    padding: 4px 5px;
    vertical-align: middle;
}

sup {
    /* Set the line-height for superscript and footnote references so that there
       isn't an awkward space appearing above lines that contain the footnote.

       See https://github.com/rust-lang/mdBook/pull/2443#discussion_r1813773583
       for an explanation.
    */
    line-height: 0;
}

:not(.footnote-definition) + .footnote-definition,
.footnote-definition + :not(.footnote-definition) {
    margin-block-start: 2em;
}
.footnote-definition {
    font-size: 0.9em;
    margin: 0.5em 0;
}
.footnote-definition p {
    display: inline;
}

.tooltiptext {
    position: absolute;
    visibility: hidden;
    color: #fff;
    background-color: #333;
    transform: translateX(-50%); /* Center by moving tooltip 50% of its width left */
    left:35%; /* Half of the width of the icon */
    top: -35px;
    font-size: 12px;
    text-align: center;
    border-radius: 6px;
    padding: 5px 8px;
    margin: 5px;
    z-index: 1000;
}
.tooltipped .tooltiptext {
    visibility: visible;
}

.result-no-output {
    font-style: italic;
}
