/*** variables ***/

/* TODO:
 * Fix header sizes.
 * Figure out how to handle body > footer/header/main layout
 * Combine README to make index in doc.
 * Most common stuff at the top of the reference and "full HTML reference" below.
 * Re-order HTML.
 * add additional style for inputs defaults
 * add "shade" to use instead of dotted lines (maybe?)
 * fix broken image in preview page.
 * */

:root {
  --fg: #191817;
  --bg: #F2F0EB;
  --highlight: #F2F0EB;
  /* --highlight: #00666D; */
  /* --highlight: #BBB645; */
  --font: Arial, Inter, Helvetica, sans-serif;
  --font-h: Arial, Inter, Helvetica, sans-serif;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #F2F0EB;
    --bg: #191817;
  }
}

/*** Page defaults ***/

html {
  font-size: 1.25rem;
  box-sizing: border-box;
}

*, ::after, ::before {
  box-sizing: inherit;
  text-decoration-thickness: .1rem;
}

body {
  margin: 0;
  padding: 1em;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
}

/**************
 * Typography *
 **************/

a {
  color: var(--fg);
}

figure {
  margin: 0;
}

figcaption {
  text-align: right;
  font-size: 0.8em;
  border-bottom: .2rem solid var(--fg);
  padding-bottom: .2rem;
}

img {
  max-width: 100%;
  height: auto;
}

main section + section {
  padding: 2rem 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-h);
}

h1 { font-size: 2em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.17em; }
h4 { font-size: 1.00em; }
h5 { font-size: 0.83em; }
h6 { font-size: 0.67em; }

ul {
  list-style: square;
}

nav {
  margin: 2rem 0;
}

nav ul {
  padding: 0;
  list-style: none;
}

nav ul li {
  margin: 0 .2rem;
  display: inline-block;
}

table {
  width: 100%;
  border-spacing: 0;
}

td, th {
  padding: .4rem;
}

td:first-child, th:first-child {
  padding-left: 0;
}

td:last-child, th:last-child {
  padding-right: 0;
}

th {
  border-bottom: .1rem solid var(--fg);
  text-align: left;
}

td {
  border-bottom: .05rem solid var(--fg);
}

blockquote, pre {
  margin-left: 0;
  margin-right: 0;
  padding: .5rem .8rem;
  border-left: .1rem solid var(--fg);
  overflow-y: hidden;
}

pre {
  border: .05rem dotted var(--fg);
  border-left: .1rem solid var(--fg);
}

pre > code {
  white-space: pre;
  display: block;
  font-size: .8rem;
}

hr {
  border: .05rem solid var(--fg);
}

ul {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

/********************
 * HTML form inputs *
 ********************/

button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .2rem .5rem;
  font-size: 1rem;
  font-weight: normal;
  background: var(--bg);
  color: var(--bg);
  border: .1rem solid var(--fg);
  background-color: var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
}

button:disabled,
input[type="button"]:disabled,
input[type="reset"]:disabled,
input[type="submit"]:disabled{
  border-style: dashed;
  cursor: not-allowed;
}

input[type="checkbox"] {
  appearance: none;
  cursor: pointer;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5em;
  height: 1.5em;
  border: .1rem solid var(--fg);
  border-radius: var(--radius);
  margin: 0px 0.25em;
}

input[type="checkbox"]:checked {
  /* appearance: none;
  accent-color: var(--fg); */
  color: var(--bg);
  background-color: var(--fg);
  font-weight: bold;
}

input[type="checkbox"]:after {
  display: inline-flex;
  content: " ";
  justify-content: center;
  align-items: center;
  width: 1.25em;
  height: 1.25em;
}

input[type="checkbox"]:checked:after {
  content: "x";
}

fieldset {
  border: .1rem solid var(--fg);
}

label, legend {
  display: block;
  font-weight: bold;
  margin-bottom: .4rem;
}

input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="url"],
input,
textarea,
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-shadow: none;
  box-sizing: inherit;
  padding: .2rem .5rem;
  font-size: 1rem;
  color: var(--fg);
  background-color: var(--bg);
  border: .1rem solid var(--fg);
  border-radius: var(--radius);
  font-family: var(--font);
}

fieldset, input, select, textarea {
  margin: 0 0 0 0;
}

select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' preserveAspectRatio='none' viewBox='0 0 40 40'%3E%3Cpath d='M9.4,12.3l10.4,10.4l10.4-10.4c0.2-0.2,0.5-0.4,0.9-0.4c0.3,0,0.6,0.1,0.9,0.4l3.3,3.3c0.2,0.2,0.4,0.5,0.4,0.9 c0,0.4-0.1,0.6-0.4,0.9L20.7,31.9c-0.2,0.2-0.5,0.4-0.9,0.4c-0.3,0-0.6-0.1-0.9-0.4L4.3,17.3c-0.2-0.2-0.4-0.5-0.4-0.9 c0-0.4,0.1-0.6,0.4-0.9l3.3-3.3c0.2-0.2,0.5-0.4,0.9-0.4S9.1,12.1,9.4,12.3z' fill='%237f7f7f' /%3E%3C/svg%3E");
  background-size: 1.25rem;
  background-repeat: no-repeat;
  background-position: calc(100% - 0.25rem) center;
  padding-right: 1.75rem;
  cursor: pointer;
}

input::placeholder,
textarea::placeholder {
  color: var(--fg);
  font-style: italic;
  opacity: 1;
}

progress {
  -moz-appearance: none;
  -webkit-appearance: none;
  display: block;
  height: .5rem;
  overflow: hidden;
  padding: 0;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: .1rem solid var(--fg);
  border-radius: var(--radius);
}

progress::-webkit-progress-bar {
  background-color: var(--bg);
}

progress::-webkit-progress-value {
  background-color: var(--fg);
}

progress::-moz-progress-bar {
  background-color: var(--fg);
}

fieldset {
  border-radius: var(--radius);
}

/**********
 * Layout *
 **********/

/*
body > header,
body > main,
body > footer {
  margin: auto;
  max-width: 660px;
  width: 100%;
}

body > header {
  padding-top: 8rem;
  padding-bottom: 8rem;
  font-size: 1.2em;
}

footer {
  text-align: center;
}
*/

/*** Utilities ***/

.page {
  width: 800px;
  max-width: 100%;
  margin: auto;
}

.spread {
  display: flex;
  justify-content: space-between;
  gap: 0.25em;
}

.loader {
  display: flex;
  justify-content: center;
  align-items: center;
}

.loader div {
  animation: spin 0.33s linear infinite;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  border: 3px solid transparent;
  border-left: 3px solid silver;
  border-right: 3px solid silver;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
