
/**
 * Theme Variables - Light and Dark Mode
 */
@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #eeeeee;
        --text-color: #222222;
        --main-bg-color: #f8f8f8;
        --heading-color: #222;
        --vethos-mark-color: #888;
        --h1-border-color: #eee;
        --link-color: #005bc1;
        --code-bg-color: #f8f8f8;
        --code-border-color: #eee;
        --blockquote-border-color: #888;
        --blockquote-text-color: #333333;
        --table-border-color: #ddd;
        --th-bg-color: #f2f2f2;
        --selection-bg-color: #b4ceea;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #444444;
        --text-color: #eeeeee;
        --main-bg-color: #333333;
        --heading-color: #eee;
        --vethos-mark-color: #888;
        --h1-border-color: #444;
        --link-color: #93bdec;
        --code-bg-color: #222;
        --code-border-color: #444;
        --blockquote-border-color: #888;
        --blockquote-text-color: #dddddd;
        --table-border-color: #555;
        --th-bg-color: #333;
        --selection-bg-color: #293645;
    }
}

/**
 * Font Families
 */
:root {
    --font-family-serif: 'Noto Serif', 'Source Han Serif TW', 'Source Han Serif CN', 'Times New Roman', serif;
    --font-family-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    --font-family-sans-serif: 'Noto Sans', 'Source Han Sans TW', 'Source Han Sans CN', 'Helvetica Neue', Arial, sans-serif;
}

/**
 * Global Styles and Transitions
 */
* {
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

body {
    font-family: var(--font-family-serif);
    line-height: 1.8;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

::selection {
    background: var(--selection-bg-color);
}

/**
 * Layout Structure
 */
[role="app"] {
    --panel-padding-x: min(70px, 5vw);
    --panel-padding-y-l: 70px;
    --panel-padding-y-s: 40px;

    max-width: min(96vw, 800px);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(2px 2px 8px #88888811);
}

[role="app"] > * {
    width: 100%;
    padding: var(--panel-padding-y-s) var(--panel-padding-x);
    background-color: var(--main-bg-color);
    border-radius: 1px;
}

[role="app"] > :nth-child(1 of *:not(span)) {
    /* select the first child that is not a span */
    padding-top: var(--panel-padding-y-l);
    min-height: 75vh;
}

[role="app"] > *:not(span):not(:has(~ *:not(span))) {
    /* select the last child that is not a span */
    padding-bottom: var(--panel-padding-y-l);
}

main[role="index"] {
    background-color: transparent;
    width: min(96vw, 800px);
}

main[role="index"] hr {
    margin: 1em 0;
}

main[role="index"] ul li {
    margin: 0.5em 0;
}

main[role="index"] h1 {
    font-size: 2em;
}

main[role="article"] h1 {
    word-break: keep-all;
    line-height: 1.4em;
}

[role="status"] {
    position: absolute;
    right: 0;
    top: auto;
    padding: 1.5em;
    width: auto;
    font-family: var(--font-family-sans-serif);
    font-size: 0.5em;
    font-weight: 700;
    opacity: 0.5;
    color: #888888;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    background: transparent;
}

/**
 * Vethos Mark
 */
body[vethos-mark] {
    --vethos-mark-height: 2rem;
}

body[vethos-mark] [role="app"] {
    min-height: calc(100vh - var(--vethos-mark-height));
}

body[vethos-mark]:after {
    content: attr(vethos-mark);
    height: var(--vethos-mark-height);
    font-family: var(--font-family-mono);
    font-size: 0.8em;
    color: var(--vethos-mark-color);
    display: block;
    width: 100%;
    text-align: center;
    position: relative;
    bottom: 0;
    opacity: 0.5;
}

/**
 * Typography
 */
h1 { font-size: 3em; }
h2 { font-size: 2.2em; }
h3 { font-size: 1.6em; }
h4 { font-size: 1.4em; }
h5 { font-size: 1.2em; }
h6 { font-size: 1em; }

h1, h2, h3 {
    margin: 1.8rem 0 0 0;
}

h4, h5, h6 {
    margin: 0.6rem 0 0 0;
}

h1 {
    border-bottom: 2px solid var(--h1-border-color);
    padding-bottom: 0.3em;
}

p, ul, ol {
    margin: 0.6em 0 0.4em;
}

hr {
    border-color: var(--table-border-color);
}

/**
 * Links
 */
a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/**
 * Code and Preformatted Text
 */
code, pre {
    font-family: var(--font-family-mono);
    background-color: var(--code-bg-color);
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--text-color);
}

code {
    padding: 0.2em 0.4em;
}

pre {
    padding: 1em;
    overflow-x: auto;
    border: 1px solid var(--code-border-color);
}

pre code {
    padding: 0;
    background-color: transparent;
    border: none;
    color: inherit;
}

/**
 * Images
 */
img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/**
 * Blockquotes
 */
blockquote {
    border-left: 4px solid var(--blockquote-border-color);
    padding-left: 2em;
    margin-left: 0;
    color: var(--blockquote-text-color);
    font-style: italic;
}

/**
 * Tables
 */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    border: 1px solid var(--table-border-color);
}

th, td {
    border: 1px solid var(--table-border-color);
    padding: 0.5em;
    text-align: left;
}

th {
    background-color: var(--th-bg-color);
}

/**
 * Anchors
 */

.anchor {
    margin-right: 12px;
    margin-left: -30px;
    opacity: 0;
}

h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, h5:hover .anchor, h6:hover .anchor {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.anchor .octicon {
    color: var(--text-color);
    opacity: 0.5;
    fill: currentColor;
}

/**
 * Content Indentation
 */

span[data-indent] {
    display: block;
}

[data-indent="1"] {
    /* TODO: Use calc(attr(data-indent em) * 2) when better supported */
    margin-left: 2em;
}

/**
 * License Styling
 */

@media (prefers-color-scheme: light) {
    [rel="license"] {
        --license-link-color: #004488;
    }
}

@media (prefers-color-scheme: dark) {
    [rel="license"] {
        --license-link-color: #bbddff;
    }
}

[rel="license"] {
    font-size: 0.8em;
}

[rel="license"] > * {
    opacity: 0.8;
}

[rel="license"] a {
    color: var(--license-link-color);
    text-decoration: none;
    margin: 0 0.5em;
}

[rel="license"] a:first-child {
    margin-left: 0;
}
