/* 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: "Share Tech Mono", monospace;
    color: var(--fg);
    background-color: var(--bg);
    text-size-adjust: none;
    -webkit-text-size-adjust: none;
}

body {
    margin: 0;
    font-size: 1.6rem;
    overflow-x: hidden;
}

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:target::before,
h2:target::before,
h3:target::before,
h4:target::before,
h5:target::before,
h6:target::before,
dt: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 #mdbook-menu-bar-hover-placeholder */
}
.page-wrapper {
    box-sizing: border-box;
    background-color: var(--bg);
}
html:not(.js) .page-wrapper,
.js:not(.sidebar-resizing) .page-wrapper {
    transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
}
[dir=rtl]:not(.js) .page-wrapper,
[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: 0 5px 50px 5px;
}
.content main {
    margin-inline-start: auto;
    margin-inline-end: auto;
    max-width: var(--content-max-width);
}
.content p { line-height: 1.75em; }
.content ol { line-height: 1.75em; }
.content ul { line-height: 1.75em; }
.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;
}

/* ── Bold/strong: subtle color lift over body text ── */

.enamel strong,
.enamel b {
    color: #1A2028;
}

.blueprint strong,
.blueprint b {
    color: #B0DAD6;
}

/* ── Rustpunk Typography ── */

/* Headings: Rajdhani on enamel, Share Tech Mono on blueprint */
h1, h2, h3, h4, h5, h6 {
    font-family: "Rajdhani", sans-serif;
    font-weight: 700;
}

.enamel h1, .enamel h2, .enamel h3 {
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #28323A;
}
.enamel h1 {
    font-size: 2.4rem;
    letter-spacing: 0.10em;
    border-bottom: 2px solid #B7410E;
    padding-bottom: 0.3em;
}
.enamel h2 {
    font-size: 1.8rem;
    letter-spacing: 0.08em;
}
.enamel h3 {
    font-size: 1.5rem;
    font-weight: 600;
}
.enamel h4, .enamel h5, .enamel h6 {
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #48525C;
}

.blueprint h1, .blueprint h2, .blueprint h3,
.blueprint h4, .blueprint h5, .blueprint h6 {
    font-family: "Share Tech Mono", monospace;
    font-weight: 400;
}
.blueprint h1, .blueprint h2, .blueprint h3 {
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #5A8A83;
}
.blueprint h1 {
    font-size: 2.2rem;
    letter-spacing: 0.20em;
    border-bottom: 1px dashed #1A2E2A;
    padding-bottom: 0.3em;
}
.blueprint h2 {
    font-size: 1.7rem;
}
.blueprint h3 {
    font-size: 1.4rem;
}
.blueprint h4, .blueprint h5, .blueprint h6 {
    color: #5A7D78;
    letter-spacing: 0.10em;
    text-transform: uppercase;
}

/* ── Background Textures ── */

/* Enamel: horizontal ruling — subliminal surface texture */
.enamel .page-wrapper::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 28px,
        rgba(100, 110, 120, 0.035) 28px,
        rgba(100, 110, 120, 0.035) 29px
    );
}

/* Enamel: left-edge hazard stripe — zone marking */
.enamel .page-wrapper::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    z-index: 10;
    pointer-events: none;
    background: repeating-linear-gradient(
        45deg,
        #B7410E,
        #B7410E 3px,
        #262C34 3px,
        #262C34 6px
    );
    opacity: 0.55;
}

/* Blueprint: SVG grid paper via embedded data URI */
.blueprint .page-wrapper::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.08;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cdefs%3E%3Cpattern id='s' width='20' height='20' patternUnits='userSpaceOnUse'%3E%3Cpath d='M 20 0 L 0 0 0 20' fill='none' stroke='%2343B3AE' stroke-width='0.3'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='100' height='100' fill='url(%23s)'/%3E%3Cpath d='M 100 0 L 0 0 0 100' fill='none' stroke='%2343B3AE' stroke-width='0.8'/%3E%3C/svg%3E");
}

/* ── Tables ── */

table {
    margin: 0 auto;
    border-collapse: collapse;
}
table td {
    padding: 3px 20px;
    border: 1px var(--table-border-color) solid;
}
table thead {
    background: var(--table-header-bg);
}
table thead td,
table thead th {
    font-family: "Rajdhani", sans-serif;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.85em;
}

.enamel table thead td,
.enamel table thead th {
    color: #8A9298;
}

.blueprint table thead td,
.blueprint table thead th {
    font-family: "Share Tech Mono", monospace;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: #5A8A83;
}

table thead td {
    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);
}

/* Blueprint blockquotes: dashed borders */
.blueprint blockquote {
    border-block-start-style: dashed;
    border-block-end-style: dashed;
}

/* TODO: Remove .warning in a future version of mdbook, it is replaced by
blockquote tags. */
.warning {
    margin: 20px;
    padding: 0 20px;
    border-inline-start: 2px solid var(--warning-border);
}

.warning:before {
    position: absolute;
    width: 3rem;
    height: 3rem;
    margin-inline-start: calc(-1.5rem - 21px);
    content: "ⓘ";
    text-align: center;
    background-color: var(--bg);
    color: var(--warning-border);
    font-weight: bold;
    font-size: 2rem;
}

blockquote .warning:before {
    background-color: var(--quote-bg);
}

kbd {
    background-color: var(--table-border-color);
    border-radius: 2px;
    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 {
    line-height: 0;
}

.footnote-definition {
    font-size: 0.9em;
}
/* The default spacing for a list is a little too large. */
.footnote-definition ul,
.footnote-definition ol {
    padding-left: 20px;
}
.footnote-definition > li {
    /* Required to position the ::before target */
    position: relative;
}
.footnote-definition > li:target {
    scroll-margin-top: 50vh;
}
.footnote-reference:target {
    scroll-margin-top: 50vh;
}
.footnote-definition > li:target::before {
    border: 2px solid var(--footnote-highlight);
    border-radius: 2px;
    position: absolute;
    top: -8px;
    right: -8px;
    bottom: -8px;
    left: -32px;
    pointer-events: none;
    content: "";
}
@media not (prefers-reduced-motion) {
    .footnote-reference:target  {
        animation: fn-highlight 0.8s;
        border-radius: 2px;
    }

    @keyframes fn-highlight {
        from {
            background-color: var(--footnote-highlight);
        }
    }
}

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

.chapter li.part-title {
    color: var(--sidebar-fg);
    margin: 5px 0px;
    font-weight: bold;
}

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

.fa-svg svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
    margin-bottom: -0.1em;
}

dt {
    font-weight: bold;
    margin-top: 0.5em;
    margin-bottom: 0.1em;
}

dl, dt {
    counter-reset: dd-counter;
}

dd:has(+ dd), dd + dd {
    counter-increment: dd-counter;
    display: flex;
    align-items: flex-start;
}

dd:has(+ dd)::before, dd + dd::before  {
    content: counter(dd-counter) ". ";
    font-weight: 600;
    display: inline-block;
    margin-right: 0.5em;
}

dd > p {
    margin-top: 0;
}

/* Remove some excess space from the bottom. */
.blockquote-tag p:last-child {
    margin-bottom: 2px;
}

.blockquote-tag {
    padding: 2px 0px 2px 20px;
    border-inline-start-style: solid;
    border-inline-start-width: 4px;
    background-color: inherit;
    border-block-start: none;
    border-block-end: none;
}

/* Blueprint: dashed callout borders */
.blueprint .blockquote-tag {
    border-inline-start-style: dashed;
}

.blockquote-tag-title svg {
    fill: currentColor;
    margin-right: 8px;
}

.blockquote-tag-note {
    border-inline-start-color: var(--blockquote-note-color);
}

.blockquote-tag-tip {
    border-inline-start-color: var(--blockquote-tip-color);
}

.blockquote-tag-important {
    border-inline-start-color: var(--blockquote-important-color);
}

.blockquote-tag-warning {
    border-inline-start-color: var(--blockquote-warning-color);
}

.blockquote-tag-caution {
    border-inline-start-color: var(--blockquote-caution-color);
}

.blockquote-tag-note .blockquote-tag-title {
    color: var(--blockquote-note-color);
}

.blockquote-tag-tip .blockquote-tag-title {
    color: var(--blockquote-tip-color);
}

.blockquote-tag-important .blockquote-tag-title {
    color: var(--blockquote-important-color);
}

.blockquote-tag-warning .blockquote-tag-title {
    color: var(--blockquote-warning-color);
}

.blockquote-tag-caution .blockquote-tag-title {
    color: var(--blockquote-caution-color);
}

.blockquote-tag-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    margin: 2px 0 8px 0;
}

.blockquote-tag-title .fa-svg {
    fill: currentColor;
    margin-right: 8px;
}

/* ── Inline code ── */

:not(pre) > .hljs {
    padding: 0.15em 0.4em;
}

.enamel :not(pre) > .hljs {
    background: #D8DCE0;
    border: 1px solid #B4BCC4;
}

.blueprint :not(pre) > .hljs {
    background: #0A1412;
    border: 1px solid #1A2E2A;
}

/* ── Code blocks ── */

.enamel pre > code {
    background: #E6E9EC;
    border: 1px solid #B4BCC4;
}

.blueprint pre > code {
    background: #080F0E;
    border: 1px solid #1A2E2A;
}
