@font-face {
    font-family: "Editorial New";
    font-style: normal;
    src: url("https://aaaa.sh/fonts/editorialnew-regular.woff2") format("woff2");
}

@font-face {
    font-family: "Commit Mono";
    font-style: normal;
    src: url("https://aaaa.sh/fonts/commitmono-regular.woff2") format("woff2");
}

@font-face {
    font-family: "Commit Mono";
    font-style: italic;
    src: url("https://aaaa.sh/fonts/commitmono-italic.woff2") format("woff2");
}

:root {
    --base-color: #faf4ed;
    --surface-color: #fffaf3;
    --overlay-color: #f2e9e1;
    --text-color: #575279;
    --muted-color: #9893a5;
    --love-color: #b4637a;
    --gold-color: #ea9d34;
    --rose-color: #d7827e;
    --pine-color: #286983;
    --foam-color: #56949f;
    --iris-color: #907aa9;
}

@media (prefers-color-scheme: dark) {
    :root {
        --base-color: #232136;
        --surface-color: #2a273f;
        --overlay-color: #393552;
        --muted-color: #6e6a86;
        --subtle-color: #908caa;
        --text-color: #e0def4;
        --love-color: #eb6f92;
        --gold-color: #f6c177;
        --rose-color: #ea9a97;
        --pine-color: #3e8fb0;
        --foam-color: #9ccfd8;
        --iris-color: #c4a7e7;
    }
}

header {
    width: 100%;
    font-size: 20px;
    display: flex;
    justify-content: space-between;
    color: var(--text-color);
    font-family: 'Times New Roman', Times, serif;
}

header a {
    color: var(--iris-color);
}

body {
    background-color: var(--base-color);
}

article > * {
    margin: 40px auto !important;
}

article > p, article > h1, article > ul, article > span.katex-display, article > small {
    max-width: 620px;
}

article > div.editor {
    max-width: 620px;
}

a { color: var(--foam-color) }
a:visited { color: var(--iris-color) }
span.katex-display { color: var(--text-color) }

div.editor > textarea {
    height: 100%;
}

.side-by-side-code-example {
    flex-direction: row;
    max-width: 1200px;
}

.vertical-code-example {
    flex-direction: column;
    max-width: 620px;
}

.side-by-side-code-example, .vertical-code-example {
    display: flex;
    gap: 10px;
    background-color: var(--overlay-color);
    border: none;
    border-radius: 4px;
    padding: 20px;
}

article h1 {
    font-family: "Editorial New";
    font-size: 50px;
    color: var(--text-color);
}

article p, label, ul, small {
    font-family: "Commit Mono";
    line-height: 1.5em;
    font-size: 16px;
    font-weight: 300;
    color: var(--text-color);
}

button {
    font-family: "Commit Mono";
    font-size: 16px;
    font-weight: 300;
    color: var(--text-color);
    background-color: var(--overlay-color);
    border-radius: 4px;
    border-width: 2px 0px 2px 0px;
    border-top-color:    hsl(from var(--overlay-color) h s calc(l + 4));
    border-bottom-color: hsl(from var(--overlay-color) h s calc(l + 4));
}

button:active {
    border-width: 0px;
    transform: translateY(2px);
}

article img {
    width: 100%;
    padding: 40px;
    box-sizing: border-box;
}

@media (min-width: 600px) {
    .side-by-side-code-example > .inputs > .editor {
        flex-grow: 2;
        margin-top: 20px;
    }

    .side-by-side-code-example > .inputs { min-width: 420px; }

    .side-by-side-code-example {
        height: 800px;
    }

    body { padding: 0px 10px; }
}

@media (max-width:600px) {
    .inputs > .row { flex-direction: column }
    .side-by-side-code-example { flex-direction: column }
    .editor { max-height: 200px }
    .view-all-button { display: none }
}

.inputs {
    display: flex;
    flex-direction: column;
}

.editor {
    position: relative;
    margin-top: 20px;
    border-radius: 4px;
    background-color: var(--overlay-color);
    transition-duration: 0.2s;

    overflow-y: scroll;
}

.editor:hover {
    background-color: var(--surface-color);
}

.editor code {
    position: absolute;
    left: 0px;
    top: 0px;
}

.editor > textarea, .editor code {
    width: 100%;
    resize: none;
    padding: 10px;
    box-sizing: border-box;
    margin: 0px;
    border: none;
    text-wrap: auto;
    font-size: 14px;
    font-family: "Commit Mono";
    background-color: transparent;
    overflow-y: hidden;
}

.editor > textarea {
    color: black;
    caret-color: var(--text-color);
}

textarea {
    border: none;
    overflow: hidden;
    outline: none;

    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;

    resize: none;
}

.editor > pre {
    pointer-events: none;
    margin: 0px;
}

.inputs > .row {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

.inputs > .row > div {
    flex-grow: 1;

    display: flex;
    flex-direction: column;
}

.side-by-side-code-example > .code-example, .vertical-code-example > .code-example {
    flex-grow: 1;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

.code-example > canvas {
    width: 100%;
    min-height: 300px;
    height: 100%;
}

.code-example > .error {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    background-color: var(--rose-color);
    color: white;
    font-family: "Commit Mono";
}

.code-example > .view-all-button {
    position: absolute;
    left: 0px;
    bottom: 0px;
    margin: 10px;
    filter: drop-shadow(0px 0px 8px var(--overlay-color));
    z-index: 3;
}

dialog#all-code-dialog {
    overflow-y: scroll;
    z-index: 2;
    box-sizing: border-box;
    background-color: transparent;
    border: none;
}

dialog#all-code-dialog pre {
    background-color: var(--overlay-color);
    width: 620px;
    padding: 20px;
    box-sizing: border-box;
    margin: 20px auto;
    display: block;
    border-radius: 4px;
    cursor: pointer;
    transition-duration: 0.2s;
}

dialog#all-code-dialog pre:hover {
    background-color: var(--surface-color);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  background-color: var(--muted-color);
  border-radius: 0.5rem;
  height: 0.5rem;
}

input[type="range"]::-moz-range-track {
  background-color: var(--muted-color);
  border-radius: 0.5rem;
  height: 0.5rem;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; /* Override default look */
  appearance: none;
  margin-top: -4px; /* Centers thumb on the track */
  background-color: var(--text-color);
  border-radius: 0.5rem;
  height: 1rem;
  width: 1rem;
}

input[type="range"]::-moz-range-thumb {
  background-color: var(--text-color);
  border: none; /*Removes extra border that FF applies*/
  border-radius: 0.5rem;
  height: 1rem;
  width: 1rem;
}

input[type="range"]:focus::-webkit-slider-thumb, input[type="range"]:focus::-moz-range-thumb {
  outline: 3px solid var(--text-color);
  outline-offset: 0.125rem;
}

/* Text style & opacity */
.token.entity {
	cursor: help;
}

.token.important,
.token.bold {
	font-weight: bold;
}

.token.italic,
.token.selector,
.token.doctype,
.token.attr-name,
.token.inserted,
.token.deleted,
.token.comment,
.token.prolog,
.token.cdata,
.token.constant,
.token.parameter,
.token.url {
	font-style: italic;
}

.token.url {
	text-decoration: underline;
}

.namespace {
	opacity: 0.7;
}


/* Syntax highlighting */
.token.constant, code {
	color: var(--text-color);
}

.token.comment, .token.prolog, .token.cdata, .token.punctuation {
	color: var(--muted-color);
}

.token.delimiter, .token.important, .token.atrule, .token.operator, 
.token.keyword {
	color: var(--pine-color);
}

.token.tag, .token.tag .punctuation, .token.doctype, .token.variable, 
.token.regex, .token.class-name, .token.selector, .token.inserted {
	color: var(--foam-color);
}

.token.boolean, .token.entity, .token.number, .token.symbol, .token.function {
	color: var(--rose-color);
}

.token.string, .token.char, .token.property, .token.attr-value, 
.token.attr-value .punctuation {
	color: var(--gold-color);
}

.token.parameter, .token.url, .token.name, .token.attr-name, .token.builtin {
	color: var(--iris-color);
}
