/* Basics */

*, *:before, *:after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

:root {
  --main-font: merriweather_sans, sans-serif;
  --monospace-font: monospace;
  --mouse-x: 0.5;

  box-sizing: border-box;
  font-family: var(--main-font);
  font-size: calc(5vw);
  cursor: default;
  line-height: 1.1;
  box-sizing: border-box;
}

::selection {
  text-shadow: none;
  background: #FF0;
  color: black;
}

a {
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  background-image: linear-gradient(to right, currentcolor, currentcolor);
  background-position: 0 1.9ex;
  background-repeat: repeat-x;
  background-size: 8px 0.08ex;
}

li {
  list-style: none;
}

code {
  font-family: monospace;
  font-family: var(--monospace-font, monospace);
}

kbd {
  font-size: 0.7em;
  border-radius: 0.2em;
  padding: 0.1em;
  font-family: inherit;
  text-transform: uppercase;
  display: inline-block;
  border: 0.1em solid;
}

textarea {
  font-family: monospace;
  font-family: var(--monospace-font, monospace);
  font-size: 0.5em;
}

h1 {
  font-size: 1.5em;
  font-weight: 400;
}
h2 {
  font-size: 1em;
  font-weight: 900;
}

sup {
  display: inline-block;
  margin-top: -0.5em;
}

sub {
  display: inline-block;
  margin-bottom: -0.5em;
}

img.thumbnail {
  height: 1em;
  width: 1em;
  object-fit: cover;
  object-position: center;
}

iframe {
  background-color: white;
}

blockquote {
  quotes: "\201C""\201D""\2018""\2019";
  text-align: left;
  margin: 0 2em;
}

blockquote > p::before, blockquote > p::after {
  display: inline-block;
  position: absolute;
  margin: -0.2em;
  font-size: 4em;
  opacity: 0.25;
  pointer-events: none;
}
blockquote > p::before {
  content: open-quote;
}
blockquote > p::after {
  content: close-quote;
}

blockquote > cite {
  font-style: normal;
  font-size: 0.8em;
  text-align: right;
}

blockquote > cite::before {
  content: '- ';
}

/* Layout */
body {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  background-color: black;
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body.is-loading:after {
  content: 'Loading...';
  font-size: 0.5em;
  line-height: 100vh;
  color: white;
  background-image: linear-gradient(45deg, #030, #000, #003);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  text-align: center;
  z-index: 100;
}

body.simulate-projection {
  filter: contrast(0.8);
}

main {
  margin-top: 0;
  perspective: 100vmin;
  transform-style: preserve-3d;
  height: 100vh;
}

.row, .col {
  position: relative;
  display: flex;
  flex-grow: 1;
  flex-basis: 0;
  align-items: stretch;
  justify-content: center;
}

.row--shrink, .col--shrink {
  flex: 0 1 auto;
  align-self: center;
}

.row {
  flex-direction: row;
}

.col {
  flex-direction: column;
  align-items: stretch;
}

/* Components */
nav {
  flex-wrap: wrap;
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.25em 0.25em 6em;
  transition: transform ease 0.5s;
  font-size: 0.5rem;
  z-index: 2;
  background-image: linear-gradient(to top, hsla(0, 0%, 0%, 0), hsla(0, 0%, 0%, 1));
}

nav > label {
  flex: 0 0 auto;
  padding-right: 1ch;
}

nav > input {
  flex: 1 1 auto;
  padding: 0;
  font-size: inherit;
  border: none;
  background: transparent;
  color: inherit;
  outline: none;
}

nav > input:invalid {
  color: red;
}

ul.help {
  width: 100%;
  flex-shrink: 0;
  font-size: 0.5em;
}

ul.help li {
  display: inline-block;
  background-color: hsla(0, 0%, 40%, 0.6);
  border-radius: 0.5em;
  padding: 0 0.5em;
}

table {
  margin: 0 auto;
}

th, td {
  text-align: center;
}

thead th div {
  white-space: nowrap;
  width: 1.5em;
  height: 1em;
  line-height: 0.9;
  text-align: left;
  transform-origin: left bottom;
  transform: translateX(1.3em) rotate(-60deg);
}

tbody th {
  text-align: right;
  padding-right: 0.5em;
}

tbody tr, tbody td {
  text-align: inherit;
}

hr {
  width: 80%;
  margin: 0.25rem auto;
  border: 1px solid white;
  border-width: 1px 0;
}

section {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  text-align: center;
  background-color: black;
  transition: transform ease 0.5s, opacity ease 0.5s, visibility step-end 0.5s;
  transform-origin: 50% 50%;
  perspective: 100vmax;
}

/* live-coding */

.live-coding {
  display: flex;
  flex: 1 1 100%;
}

.live-coding__code {
  position: relative;
  width: 100%;
}

.live-coding__code textarea, .live-coding__code .highlight {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0.1em;
  font-size: 0.4em;
  resize: none;
  color: white;
  font-family: monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  border: none;
  outline: none;
  text-align: left;
  line-height: 1.1;
}

.live-coding__code textarea {
  background: #333;
}

.live-coding__code .highlight {
  pointer-events: none;
}

.live-coding__code textarea::selection {
  background-color: black;
  color: transparent;
}

.live-coding__component {
  display: flex;
  flex: 1 1 auto;
}

.col > .live-coding__component {
  flex-direction: column;
}

.live-coding__component label {
  line-height: 1;
  color: var(--theme-color, inherit);
}

.hidden,
.live-coding input[type="radio"],
.live-coding input[type="checkbox"],
.live-coding input[type="radio"]:not(:checked) + .live-coding__component > .live-coding__code,
.live-coding input[type="checkbox"]:not(:checked) + .live-coding__component > .live-coding__code {
  position: fixed;
  visibility: hidden;
  right: 110vw;
}

.live-coding input[type="radio"]:not(:checked) + .live-coding__component,
.live-coding input[type="checkbox"]:not(:checked) + .live-coding__component {
  flex: 0 1 auto;
}

.row > .live-coding__component label {
  writing-mode: vertical-rl;
  text-align: right;
  transform: rotate(180deg);
  border-left: 0.1em solid var(--theme-color, currentcolor);
  line-height: 1;
  flex: 0 0 auto;
}

.col > .live-coding__component label {
  text-align: left;
  max-height: 1em;
  border-bottom: 0.1em solid var(--theme-color, currentcolor);
}

/* adapted from Lea Verou's http://dabblet.com/gist/14cf7ecbd12505768478b36510f623c8 */
.browser {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  margin: 0 auto;
  border-radius: 0.5vmin;
  overflow: hidden;
  --chrome-height: 4vmin;
  padding-top: var(--chrome-height);
  background-color: #DDD;
}

.browser::before {
  content: "";
  position: absolute;
  top: 0; right: 0; left: 0;
  border: solid;
  --right: 146; --left: 201;
  border-width: var(--chrome-height) calc(var(--right) / 38 * var(--chrome-height)) 0 calc(var(--left) / 38 * var(--chrome-height));
  border-image: url('browser-bar.png') 100% var(--right) 0 var(--left) repeat;
}

.browser iframe {
  pointer-events: none;
  flex: 1 1 auto;
  height: 100%;
  width: 100%;
}

/* states and transitions */

[janus-timeline='past'] {
  transition: transform ease 0.5s, opacity ease 0.5s, visibility step-end 0.5s;
}
section[janus-timeline='present'] [janus-timeline='past']:not([janus-past]) {
  transition: transform ease 0.5s, opacity ease 0.5s;
}

[janus-timeline='present'] {
  transition: transform ease 0.5s, opacity ease 0.5s, visibility step-start 0.5s;
}

[janus-timeline='future'] {
  transition: transform ease 0.5s, opacity ease 0.5s, visibility step-end 0.5s;
  opacity: 0;
  visibility: hidden;
}

body.show-notes section [janus-timeline='future'], body.show-notes section [janus-timeline='past'][janus-past] {
  visibility: visible;
  opacity: 0.4;
}

body.show-notes section[janus-timeline='future'] [janus-timeline='future'] {
  opacity: 1;
}

body:not(.show-notes) [janus-timeline='past'][janus-past='up'], body:not(.show-notes) [janus-timeline='future'][janus-future='up'] {
  transform: translate3d(0, -100vh, 0);
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}

body:not(.show-notes) [janus-timeline='past'][janus-past='down'], body:not(.show-notes) [janus-timeline='future'][janus-future='down'] {
  transform: translate3d(0, 100vh, 0);
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}

body:not(.show-notes) [janus-timeline='past'][janus-past='left'], body:not(.show-notes) [janus-timeline='future'][janus-future='left'] {
  transform: translate3d(-100vw, 0, 0);
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}

body:not(.show-notes) [janus-timeline='past'][janus-past='right'], body:not(.show-notes) [janus-timeline='future'][janus-future='right'] {
  transform: translate3d(100vw, 0, 0);
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}

body:not(.show-notes) [janus-timeline='past'][janus-past='flip-h'], body:not(.show-notes) [janus-timeline='future'][janus-future='flip-h'] {
  transform: translate3d(0, 0, -10vmin) rotateY(-180deg);
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}
body:not(.show-notes) [janus-timeline='future'][janus-future='flip-h'] {
  transform: translate3d(0, 0, -10vmin) rotateY(180deg);
}

section[janus-timeline='past'], /* default past-tense state */
body:not(.show-notes) [janus-timeline='past'][janus-past='big'], body:not(.show-notes) [janus-timeline='future'][janus-future='big'] {
  transform: translate3d(0, 5vmin, 0) scale(1.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}

[janus-timeline='past'][janus-past='hidden'] {
  opacity: 0;
  visibility: hidden;
}

section[janus-timeline='present'] {
  transform: none;
  opacity: 1;
}

section[janus-timeline='future'], /* default future-tense state */
body:not(.show-notes) [janus-timeline='past'][janus-past='small'], body:not(.show-notes) [janus-timeline='future'][janus-future='small'] {
  transform: translate3d(0, -5vmin, 0) scale(0.8);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.cover, .contain {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  z-index: -1;
  transform: none;
}
.cover {
  object-fit: cover;
}
.contain {
  object-fit: contain;
}

body.show-notes {
  background-color: #333;
}

body.show-notes section, body.show-notes section * {
  transition: none;
}

.notes {
  display: none;
  background-color: #333;
  box-sizing: border-box;
  white-space: pre-line;
  position: absolute;
  top: 0;
  left: -300%;
  width: 300%;
  height: 400%;
  font-size: 3rem;
  text-align: left;
  padding: 0.2em;
}
body.show-notes section[janus-timeline='present'] > .notes {
  display: block;
}

body.show-notes section[janus-timeline='present'] {
  transform: scale(0.25);
  transform-origin: top right;
  top: 0;
  right: 0;
  bottom: auto;
  left: auto;
  overflow: visible;
}

body.show-notes section[janus-timeline='present'] + section[janus-timeline='future'] {
  transform: scale(0.25);
  transform-origin: bottom right;
  top: auto;
  left: auto;
  bottom: 0;
  right: 0;
  opacity: 1;
  visibility: visible;
  z-index: 3;
}
