@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Libertinus+Serif:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Alegreya:ital,wght@0,400..900;1,400..900&display=swap');
@import url('fonts/domitian/Domitian.css');
@import url('fonts/drafting/DraftingMono.css');

:root {
    --bold-weight: 500;
    --fg-color: #2c2c2c;
    --fg-color-rgb: 44, 44, 44;
    --text-fg-color: #000000;
    --text-fg-color-rgb: 0, 0, 0;
    --bg-color: #ffffff;
    --bg-color-rgb: 255, 255, 255;
    --text-font: "Domitian", serif;
    --code-font: "Drafting* Mono", monospace;
    --title-font: "Libertinus Serif", serif;
    --heading-font: "Libertinus Serif", serif;
    --prompt-font: "Space Mono", monospace;
    --paragraph-indent:    1.4em;
    --paragraph-gap:       0em;
    --universal-gap:       0.4em;
    --quoted-vert-gap:     1.4em;
    --quoted-hori-gap:     0.4em;
    --heading-top-gap:     0.8em;
    --heading-bottom-gap:  0;
    --context-line-height: 1.6;
    --dim-alpha: 0.75;
    --sec-alpha: 0.5;
    --third-alpha: 0.25;
    --fourth-alpha: 0.1;
    --textarea-alpha: 0.1;
    --hr-alpha:  0.4;
    color-scheme: light dark;
}

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

*::selection { background-color: rgba(153, 193, 241, 0.3); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

textarea {
    border: none;
    background-color: rgba(0, 0, 0, var(--textarea-alpha));
    width: 100%;
    padding: 0.5em 0.7em;
    color: var(--text-fg-color);
    font-family: var(--code-font);
    font-size: inherit;
    resize: vertical;
    min-height: 10em;
    border-radius: 0;
}

button {
    border: none;
    background-color: #C0C0C0;
    color :var(--text-fg-color);
    font-family: var(--code-font);
    border-radius: 0;
}

button:hover {
    background-color: #A0A0A0;
}

button:active {
    background-color: #909090;
}

q { quotes: "“" "”" "‘" "’"; }
.context q.block {
    display: block;
    margin: var(--quoted-hori-gap) var(--quoted-vert-gap);
    margin-right: 0;
    text-indent: var(--paragraph-indent);
}
h1 + q, h2 + q, h3 + q, h4 + q, h5 + q, h6 + q { margin-top: 0 !important; }
.context q:last-child  { margin-bottom: 0 !important; }

p { margin-bottom: var(--paragraph-gap); }
.context li p { margin-bottom: 0.75em; }

.title {
    position: relative;
    text-align: right;
    font-family: var(--title-font);
    font-weight: 600;
    margin-bottom: 0.3em;
    margin-top: 0.5em;
    font-size: 3.5em;
    line-height: 1.1;
}

.prompt {
    margin: 0;
    font-size: 14em;
    font-family: var(--prompt-font);
    font-weight: 700;
    letter-spacing: -0.1em;
    line-height: 0.8em;
    margin-left: -0.05em;
    margin-bottom: 0.2em;
    cursor: default;
    user-select: none;
}
body:not(.index) .prompt {
    margin-bottom: 0.5em;
}
.cursor {
    display: inline-block;
    width: 0.5em;
    margin-left: 0.1em;
    border-bottom: 0.7em solid var(--fg-color);
    animation: blink 1s steps(1, end) infinite;
}

.posts li a { text-decoration: none; }
a, a:visited {
    color: var(--fg-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}
a:hover {
    position: relative;
    color: var(--bg-color);
    text-decoration: none;
    background: var(--fg-color);
}
a:focus-visible {
    color: var(--bg-color);
    background: var(--fg-color);
    outline: none;
}
a:has(sup):hover { text-decoration: none; }

.home-link {
    position: relative;
    display: inline-block;
    text-decoration: none;
    color: inherit;
    isolation: isolate;
}
.home-link::before {
    content: "";
    position: absolute;
    top: -.05em;
    bottom: -.1em;
    left: -.05em;
    right: -.15em;
    
    background: var(--fg-color, currentColor);
    opacity: 0;
    z-index: -1;
    pointer-events: none;
}
.home-link:hover {
    color: var(--bg-color, #fff);
}
.home-link:hover::before {
    opacity: 1;
}
.blink {
    display: inline-block;
    animation: blink 1s steps(1, end) infinite;
    height: 0.8em;
    margin-left: 0.1em;
}

.footnotes { font-size: 0.9em; }
.footnotes ol { padding-left: 1.3em; }
.footnote-back {
    position: relative;
    left: 0.6em;
    font-size: 0.8em;
    text-decoration: none;
}

ol, ul {
    padding-left: var(--paragraph-indent);
    margin-top: var(--universal-gap);
    margin-bottom: var(--universal-gap);
}
h1 + ol, h2 + ol, h3 + ol, h4 + ol, h5 + ol, h6 + ol { margin-top: 0; }
h1 + ul, h2 + ul, h3 + ul, h4 + ul, h5 + ul, h6 + ul { margin-top: 0; }

li::marker {
  color: rgba(var(--fg-color-rgb), var(--dim-alpha));
  font-family: "Alegreya", var(--text-font), serif;
  font-size: 1.1em;
}
.footnote-ref { text-decoration: none; }
.footnotes li { padding: 0; }
.index ul.posts { padding-left: 0.2em; }
.posts li {
    position: relative;
    list-style: none;
    margin-left: 6em;
}
.posts li:before {
    content: attr(date);
    position: absolute;
    margin-left: -6em;
    color: rgba(var(--fg-color-rgb), var(--dim-alpha));
}

body {
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
}

.context {
    width: 45em;
    margin: 100px 0;
    font-family: var(--text-font);
    color: var(--fg-color);
    hyphens: auto;
    text-align: justify;
    font-variant-ligatures: common-ligatures contextual;
    font-kerning: normal;
    orphans: 3;
    widows: 3;
    line-break: auto;
    word-break: break-word;
    text-justify: inter-word;
    word-spacing: -0.05em;
    letter-spacing: 0.01em;
    font-variant-east-asian: proportional-width;
    line-height: var(--context-line-height);
    font-size: 14px;
}
:lang(zh), :lang(ja), :lang(ko) {
    letter-spacing: normal;
}
.context p { margin: 0 0 var(--paragraph-gap) 0; }
.context p:last-child { margin-bottom: 0; }
p + p { text-indent: var(--paragraph-indent); }
.context > p:not(.no-drop):first-of-type::first-letter {
    font-size: 3.4em;
    line-height: 0.8;
    padding-top: 0.13em;
    padding-right: 0.1em;
    float: left;
    font-weight: normal;
    font-style: normal;
}

code {
    font-family: var(--code-font);
}
pre {
    padding: var(--quoted-hori-gap) var(--quoted-vert-gap);
    font-size: 0.9em;
    line-height: 1.5;
}
pre code {
    display: block;
    hyphens: none;
    word-break: normal;
    white-space: pre;
}

table {
    text-align: start;
    margin-top: var(--universal-gap);
    margin-bottom: var(--universal-gap);
    border-collapse: collapse;
    border-spacing: 0;
    color: var(--fg-color);
    font-size: inherit;
}
thead { text-align: left; }
td, th {
    padding-top: 0.3em;
    padding-bottom: 0.35em;
    padding-left: 0.4em;
    padding-right: 0.4em;
    border: 1px solid rgba(var(--fg-color-rgb), var(--fourth-alpha));
}
th { font-weight: var(--bold-weight); }

h1, h2, h3, h4, h5, h6 {
    margin-top: var(--heading-top-gap);
    margin-bottom: var(--heading-bottom-gap);
    font-family: var(--heading-font);
    font-weight: normal;
}

h1 { font-size: 2em; }
h2 { font-size: 1.75em; }
h3 { font-size: 1.65em; }
h4 { font-size: 1.55em; }
h5 { font-size: 1.45em; }
h6 { font-size: 1.35em; }

strong { font-weight: var(--bold-weight); }

em {
    font-style: italic;
    font-variation-settings: "slnt" -10;
}

hr {
    border: none;
    height: 1px;
    background-color: #00000030;
    margin-bottom: 1.5em;
    margin-top: 1.5em;
}

.textarea {
    position: relative;
}

.textarea .btns {
    position: absolute;
    right: 0.3em;
    top: 0.1em;
}

@media print {
    .prompt { display: none; }
    .cursor, .blink { animation: none; }
    a[href]:not([href^="mailto"]):not([href^="https://creativecommons.org"])::after { content: " (" attr(href) ")"; }
    .index a::after { content: ''; }
    a:has(sup)::after { content: ''; }
    .prompt a::after { content: ''; }
    a:has(sup) { text-decoration: none; }
}

@media (prefers-color-scheme: dark) {
    :root {
        --fg-color: #f2f4f2;
        --fg-color-rgb: 242, 244, 242;
        --text-fg-color: #fcfcfc;
        --text-fg-color-rgb: 252, 252, 252;
        --bg-color: #1f1f1f;
        --bg-color-rgb: 31, 31, 31;
        --textarea-alpha: 0.3;
    }
    button { background-color: #303030; }
    button:active { background-color: #505050; }
    button:hover { background-color: #404040; }
    *::selection { background-color: #ffffff1a; }
    thead { background-color: #ffffff0a; }
    hr { background-color: rgba(var(--text-fg-color-rgb), var(--hr-alpha)); }
}

@media (prefers-reduced-motion: reduce) {
  .cursor, .blink { animation: none; }
}
