/* Base styles - shared across all stylesheets
   Import this and override variables/styles as needed */

:root {
    --font-size-body: 1.0625rem;
    --font-size-mono: 0.9375rem;

    --color-base: #fafafa;
    --color-background: #f6f6f6;
    --color-offset: #eee;
    --color-faded: #ccc;
    --color-gray-lighter: #808080;
    --color-gray: #767676;
    --color-text: #414141;
    --color-accent: #4d83f7;
    --color-link: #4d83f7;
    --color-menu: rgba(211, 211, 211, 0.8);

    --font-family-body:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, Roboto,
        sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --font-family-mono:
        ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;

    --radius: 15px;
    --radius-small: 0.5rem;
    --radius-mini: 0.3rem;

    --width: 700px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-base: #0f0f0f;
        --color-background: #202020;
        --color-offset: #363636;
        --color-faded: #555;
        --color-gray-lighter: #808080;
        --color-gray: #767676;
        --color-text: #fffefa;
        --color-menu: rgba(54, 54, 54, 0.8);
    }
    img.svg-icon {
        filter: invert(1);
    }
}

/* Reset -------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
    text-rendering: optimizeLegibility;
}

* {
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

html {
    font-family: var(--font-family-body);
    font-size: var(--font-size-body);
    background: var(--color-background);
    color: var(--color-text);
}

body {
    max-width: var(--width);
    margin: 0 auto;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
    -moz-osx-font-smoothing: grayscale;
    -ms-font-feature-settings: "kern" 1;
    -o-font-feature-settings: "kern" 1;
    font-feature-settings: "kern" 1;
    -webkit-font-kerning: normal;
    font-kerning: normal;
}

main {
    padding: 0 1rem 3rem;
    margin: 10vh 0;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    object-fit: cover;
    -o-object-fit: cover;
    object-position: center;
}

img {
    border-radius: var(--radius);
    margin: 2rem 0;
}

input,
button,
textarea,
select {
    font: inherit;
    border: 0;
    line-height: 1;
    background: none;
    color: var(--color-text);
}

input,
textarea,
select {
    display: block;
    width: 100%;
}

button {
    cursor: pointer;
    background: var(--color-faded);
}

footer {
    text-align: center;
    padding: 1rem 0;
    font-size: 0.6rem;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

/* Typography --------------------------------------------------------------- */

h1,
h2 {
    font-size: var(--font-size-body);
    color: var(--color-text);
    font-weight: 400;
    margin-bottom: 1rem;
}

h3,
h4,
h5,
h6 {
    font-size: var(--font-size-body);
    color: var(--color-text);
    font-weight: 400;
}

h1 {
    margin-top: 3rem;
}

h2 {
    margin-top: 2rem;
}

h3 {
    margin-top: 1rem;
}

p,
ol,
ul,
pre {
    margin: 0 0 1rem 0;
}

blockquote {
    margin: 1rem 0;
}

ul {
    list-style-type: none;
    margin-left: 2rem;
}

ul li:before,
ol ul li:before {
    position: absolute;
    margin-left: -2rem;
    content: "—";
    color: var(--color-faded);
    font-weight: 500;
    margin-right: 0.5rem;
}

ol {
    list-style-type: none;
    margin-left: 2rem;
    counter-reset: list;
}

ol li:before {
    position: absolute;
    margin-left: -2rem;
    color: var(--color-faded);
    font-weight: 500;
    margin-right: 0.5rem;
    content: counter(list) ".";
    counter-increment: list;
}

b,
strong {
    font-weight: 700;
}

/* Code --------------------------------------------------------------------- */

pre,
code {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-mono);
}

pre {
    overflow: auto;
    padding: 0.5rem;
    overflow-x: scroll;
    border-radius: var(--radius-mini);
    background-color: var(--color-offset);
    tab-size: 1rem;
    white-space: pre;
}

code {
    padding: 2px 6px 3px 6px;
    border-radius: var(--radius-mini);
    background: var(--color-offset);
    color: var(--color-text);
}

h1 code,
h2 code,
h3 code,
h4 code,
h5 code,
h6 code {
    font-size: inherit !important;
}

pre code {
    background-color: var(--color-offset);
    border-radius: 0;
    padding: 0;
}

/* Misc --------------------------------------------------------------------- */

blockquote {
    border-left: 2px solid var(--color-offset);
    padding-left: 1rem;
    margin: 2rem 0;
    color: var(--color-gray-lighter);
}

hr {
    border: none;
    border-top: 2px solid var(--color-offset);
    color: var(--color-faded);
    margin: 2rem 0;
}

/* Video container ---------------------------------------------------------- */

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    margin: 2rem 0;
}

.video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Tables ------------------------------------------------------------------- */

table {
    display: block;
    max-width: fit-content;
    overflow-x: auto;
    white-space: nowrap;
    border-spacing: 0;
}

table > *:first-child > *:first-child > * {
    border-top-width: 2px;
}

table > *:last-child > *:last-child > * {
    border-bottom-width: 2px;
}

table td:first-child,
table th:first-child {
    border-left-width: 2px;
}

table td:last-child,
table th:last-child {
    border-right-width: 2px;
}

table > *:first-child > *:first-child > *:first-child {
    border-top-left-radius: var(--radius);
}

table > *:first-child > *:first-child > *:last-child {
    border-top-right-radius: var(--radius);
}

table > *:last-child > *:last-child > *:first-child {
    border-bottom-left-radius: var(--radius);
}

table > *:last-child > *:last-child > *:last-child {
    border-bottom-right-radius: var(--radius);
}

th,
td {
    font-family: var(--font-family-body);
    font-size: var(--font-size-body);
    font-weight: normal;
    text-align: left;
    border: 1px solid var(--color-offset);
    padding: 0.75rem;
}

tr:hover {
    background-color: var(--color-base);
}

/* Header anchors ----------------------------------------------------------- */

h1[id],
h2[id],
h3[id],
h4[id],
h5[id],
h6[id] {
    position: relative;
    cursor: pointer;
}

h1[id]:hover,
h2[id]:hover,
h3[id]:hover,
h4[id]:hover,
h5[id]:hover,
h6[id]:hover {
    text-decoration: underline;
}

.header-anchor {
    position: absolute;
    left: -1.2em;
    color: var(--color-faded);
    text-decoration: none !important;
    opacity: 0;
    transition: opacity 0.15s ease;
}

h1:hover .header-anchor,
h2:hover .header-anchor,
h3:hover .header-anchor,
h4:hover .header-anchor,
h5:hover .header-anchor,
h6:hover .header-anchor,
.header-anchor:focus {
    opacity: 1;
}

.header-anchor:hover {
    color: var(--color-link);
}
