/* Based on Simple.css: https://github.com/kevquirk/simple.css */

:root {
  --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
    "Nimbus Sans L", Roboto, Noto, "Segoe UI", Arial, Helvetica,
    "Helvetica Neue", sans-serif;
  --mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;

  --base-fontsize: 1.15rem;
  --header-scale: 1.2;
  --line-height: 1.2;
  --small-fontsize: 1rem;

  --row-padding: 15px;
  --column-padding: 20px;
  --paragraph-padding: 10px;
  --footer-height: 70px;

  --max-page-width: 55rem;
  --max-copy-width: 40rem;

  /* Default (light) theme */
  --body-color:  #353f48;
  /* --page-color:  #607181; */
	--page-color: #c3c3ba;
  --accent-bg: #f5f7ff;
  /* --text: #FDF4C7; */
	--text: #353f48;
  --text-light: #454545;
  --border: #d8dae1;
  --accent: #fddf17;
  --accent-light: #90caf9;
  --code: #d81b60;
  --preformatted: #444;
  --marked: #ffdd33;
  --disabled: #efefef;
}

/* Dark theme 
@media (prefers-color-scheme: dark) {
  :root {
    --body-color: #212121;
    --page-color: #313131;
    --accent-bg: #2b2b2b;
    --text: #dcdcdc;
    --text-light: #ababab;
    --border: #666;
    --accent: #9b9363;
    --accent-light: #ffecb3;
    --code: #f06292;
    --preformatted: #ccc;
    --disabled: #111;
  }

  img,
  video {
    opacity: 0.6;
  }
}
*/

html, body, header, footer, main,
div, section, a, p, dfn, article,
input[type=submit], button,
h1, h2, h3, h4,
ul, ol, li {
  margin: 0;
  padding: 0;
  font-weight: 300;
  letter-spacing: 0.035em;
}

li { list-style: none; }

html {
  font-family: var(--sans-font);
  min-height: 100vh;
  width: 100vw;
}

body {
  background: var(--body-color);
  color: var(--text);
  font-size: var(--base-fontsize);
  line-height: var(--line-height);
  min-height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

#page {
  margin: 0;
  position: relative;
  min-height: 100vh;
  background-color: var(--page-color);
	background-image: url('./page-background.jpg');
	background-size: 100%;
	background-repeat: no-repeat;
}
@media (min-width: 900px) {
  #page {
    margin: 0 auto;
    max-width: var(--max-page-width);
  }
}
#bottom-buffer {
  height:  var(--footer-height);
}

header {
  padding: var(--row-padding);
  display: grid;
  grid-template-columns: 1fr;
}
header > h1 {
  white-space: nowrap;
  margin-top:  5px;
}
header > h1 > a {
  text-decoration: none;
}
header > form {
  white-space: nowrap;
}
header > nav > ul > li {
  display:  inline-block;
}
@media (min-width: 900px) {
  header {
    grid-template-columns: auto auto;
  }
  header > form {
    display:  inline-block;
  }
  header > nav > ul {
    margin-top: 4px;
    display: grid;
    grid-template-columns: auto;
    grid-column-gap: var(--column-padding);
  }
  header > nav > ul > li {
      text-align: right;
  }
}

/* Fix line height when title wraps */
h1,
h2,
h3 {
  line-height: 1.1;
}

footer {
  color: var(--text-light);
  font-size: var(--small-fontsize);
  padding: 3px var(--row-padding);
  width: calc(100% - 2 * var(--row-padding));
  position:  absolute;
  bottom: 0;
  left:  0;
  border-top: solid 1px var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-column-gap: var(--column-padding);
  background-color: var(--page-color);
}
footer > nav > ul {
  display: grid;
  grid-template-columns: auto auto;
  grid-column-gap: var(--column-padding);
}
footer > nav > ul > li {
  text-align: right;
  display:  inline-block;
}
@media (min-width: 900px) {
  footer {
    margin: 0 auto;
    max-width: var(--max-page-width);
  }
}

strong, strong a {
  font-weight: 400;
}

/* Format headers */
h1 {
  font-size: calc(
    var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale) * var(--header-scale) * var(--header-scale)
  );
}

h2 {
  font-size: calc(
    var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale)
  );
}

h3 {
  font-size: calc(
    var(--base-fontsize) * var(--header-scale) * var(--header-scale)
  );
}

h4 {
  font-size: calc(var(--base-fontsize) * var(--header-scale));
}

h5 {
  font-size: var(--base-fontsize);
}

h6 {
  font-size: calc(var(--base-fontsize) / var(--header-scale));
}

a, a:visited {
  color:  var(--text);
}
a:hover {
  text-decoration: none;
}

a button,
button,
[role="button"],
input[type="submit"],
input[type="reset"],
input[type="button"] {
  border: none;
  border-radius: 5px;
  background: var(--accent);
  font-size: 1rem;
  color: var(--text);
  padding: 0.4rem 0.4rem;
  transition: 0.4s;
}

a button[disabled],
button[disabled],
[role="button"][aria-disabled="true"],
input[type="submit"][disabled],
input[type="reset"][disabled],
input[type="button"][disabled],
input[type="checkbox"][disabled],
input[type="radio"][disabled],
select[disabled] {
  cursor: default;
  opacity: 0.5;
  cursor: not-allowed;
}

input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  background-color: var(--disabled);
}

input[type="range"] {
  padding: 0;
}

/* Set the cursor to '?' while hovering over an abbreviation */
abbr {
  cursor: help;
}

button:focus,
button:enabled:hover,
[role="button"]:focus,
[role="button"]:not([aria-disabled="true"]):hover,
input[type="submit"]:focus,
input[type="submit"]:enabled:hover,
input[type="reset"]:focus,
input[type="reset"]:enabled:hover,
input[type="button"]:focus,
input[type="button"]:enabled:hover,
input[type="checkbox"]:focus,
input[type="checkbox"]:enabled:hover,
input[type="radio"]:focus,
input[type="radio"]:enabled:hover {
  opacity: 0.8;
  cursor: pointer;
}

/* Format the expanding box */
details {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 1rem;
}

summary {
  cursor: pointer;
  font-weight: bold;
  padding: 0.6rem 1rem;
}

details[open] {
  padding: 0.6rem 1rem 0.75rem 1rem;
}

details[open] summary {
  margin-bottom: 0.5rem;
  padding: 0;
}

details[open] > *:last-child {
  margin-bottom: 0;
}

/* Format tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
}

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

th {
  background: var(--accent-bg);
  font-weight: bold;
}

tr:nth-child(even) {
  /* Set every other cell slightly darker. Improves readability. */
  background: var(--accent-bg);
}

table caption {
  font-weight: bold;
  margin-bottom: 0.5rem;
}

/* Format forms */
textarea,
select,
input {
  font-size: inherit;
  font-family: inherit;
  padding: 0.4rem;
  color: var(--text);
  background: var(--page-color);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: none;
  box-sizing: border-box;
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
}

/* Add arrow to  */
select {
  background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
    linear-gradient(135deg, var(--text) 51%, transparent 49%);
  background-position: calc(100% - 20px), calc(100% - 15px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select[multiple] {
  background-image: none;
}

/* checkbox and radio button style */
input[type="checkbox"],
input[type="radio"] {
  vertical-align: bottom;
  position: relative;
}

input[type="radio"] {
  border-radius: 100%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--accent);
}

input[type="checkbox"]:checked::after {
  /* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */
  content: " ";
  width: 0.1em;
  height: 0.25em;
  border-radius: 0;
  position: absolute;
  top: 0.05em;
  left: 0.18em;
  background: transparent;
  border-right: solid var(--page-color) 0.08em;
  border-bottom: solid var(--page-color) 0.08em;
  font-size: 1.8em;
  transform: rotate(45deg);
}
input[type="radio"]:checked::after {
  /* creates a colored circle for the checked radio button  */
  content: " ";
  width: 0.25em;
  height: 0.25em;
  border-radius: 100%;
  position: absolute;
  top: 0.125em;
  background: var(--page-color);
  left: 0.125em;
  font-size: 32px;
}

/* Make the textarea wider than other inputs */
textarea {
  width: 80%;
}

/* Ensures the checkbox and radio inputs do not have a set width like other input fields */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
}

/* do not show border around file selector button */
input[type="file"] {
  border: 0;
}

/* Without this any HTML using <fieldset> shows ugly borders and has additional padding/margin. (Issue #3) */
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

/* Misc body elements */

hr {
  color: var(--border);
  border-top: 1px;
  margin: 1rem auto;
}

mark {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--marked);
}

main img,
main video {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
}

figure {
  margin: 0;
}

figcaption {
  font-size: 0.9rem;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 1rem;
}

blockquote {
  margin: 2rem 0 2rem 2rem;
  padding: 0.4rem 0.8rem;
  border-left: 0.35rem solid var(--accent);
  opacity: 0.8;
  font-style: italic;
}

cite {
  font-size: 0.9rem;
  color: var(--text-light);
  font-style: normal;
}

/* Use mono font for code like elements */
code,
pre,
pre span,
kbd,
samp {
  font-size: 1.075rem;
  font-family: var(--mono-font);
  color: var(--code);
}

kbd {
  color: var(--preformatted);
  border: 1px solid var(--preformatted);
  border-bottom: 3px solid var(--preformatted);
  border-radius: 5px;
  padding: 0.1rem;
}

pre {
  padding: 1rem 1.4rem;
  max-width: 100%;
  overflow: auto;
  overflow-x: auto;
  color: var(--preformatted);
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}

/* Fix embedded code within pre */
pre code {
  color: var(--preformatted);
  background: none;
  margin: 0;
  padding: 0;
}

.row { padding: 0 var(--row-padding); }

.list-main, .single-main {
  padding: 0 var(--row-padding);
}
.list-main > p, .single-main > p {
  margin-bottom:  var(--paragraph-padding);
}
.list-main > h1:first-child, .single-main > h1:first-child {
  margin-bottom: 0.25em;
}
.list-main > ul > li {
  margin-bottom: 16px;
}

.single-main .byline {
  margin:  0;
}
.single-main .formatted-date {
  font-size:  0.75em;
}

.single-content {
  max-width: var(--max-copy-width);
}
.single-content > h2 {
  margin: 15px 0 10px 0;
}
.single-content > h2 > a:hover {
  text-decoration: underline;
}
.single-content > h3 {
  margin-top:  15px;
  margin-bottom: 5px;
}
.single-content > h3 > a {
  text-decoration: none;
}
.single-content > h3 > a:hover {
  text-decoration: underline;
}
.single-content p {
  padding-bottom: var(--paragraph-padding);
}
.single-content ul {
  margin: 0 0 15px 15px;
}
.single-content li {
  list-style: disc;
}

