/* Variables */
:root {
  --max-width: 530px;
  --body-background-color: #F5F5F5;
  --button-color: #FFF;
  --error-color: #EA4848;
  --button-background-color: #5F9EA0;
  --button-hover-background-color: #7EB1B3;
  --disabled-button-color: #BBB;
  --link-color: #000;
  --link-hover-color: #666;
  --code-background-color: #DDD;
  --transition-duration: 0.2s;
}

/* Fonts */
@font-face {
  font-family: 'Damion';
  font-style: normal;
  font-weight: 400;
  src: local(''), url('assets/damion-v10.woff2') format('woff2'), url('assets/damion-v10.woff') format('woff');
}

/* Layout */
html {
  box-sizing: border-box;
  * {
    box-sizing: inherit;
  }
}
body {
  font-family: Courier New;
  font-size: 16px;
  padding: 0;
  margin: 0;
  min-height: 100vh;
  text-align: center;
  background-color: var(--body-background-color);
}
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  & > * {
    width: 100%;
    max-width: var(--max-width);
  }
}
p {
  text-align: justify;
  margin: 0 0 10px 0;
  &:last-of-type {
    margin-bottom: 0;
  }
}
.contents {
  display: contents;
}
.row {
  margin-bottom: 10px;
  &:last-of-type {
    margin-bottom: 0;
  }
}
.space-top {
  padding-top: 10px;
}

/* Buttons, links */
.button-title {
  font-size: 1.5em;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
a.button { /* Anchors styled as buttons (required for bookmarklet) */
  transition: background-color var(--transition-duration) ease;
  background-color: var(--button-background-color);
  border-radius: 10px;
  color: var(--button-color);
  padding: 20px;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  &:hover {
    @media (any-hover: hover) {
      background-color: var(--button-hover-background-color);
    }
  }
  &:not([href]) {
    background-color: var(--disabled-button-color);
    &:hover {
      cursor: not-allowed;
    }
  }
}
a:not(.button) { /* Typical anchors */
  transition: color var(--transition-duration) ease;
  color: var(--link-color);
  text-decoration: underline;
  &:hover {
    color: var(--link-hover-color);
  }
}
button { /* Buttons styled as anchors (toggle code editor) */
  background: none !important;
  border: none;
  padding: 0 !important;
  font-family: inherit;
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
  color: inherit;
  &:hover {
    color: var(--link-hover-color);
  }
}

/* Input */
input {
  font-family: sans-serif;
  text-align: center;
  font-size: 1em;
  border-radius: 10px;
  border: 0;
  width: 100%;
  padding: 10px;
}
label:has(input[type='checkbox']) {
  font-family: sans-serif;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  display: inline-flex;
  justify-content: space-evenly;
  width: 100%;
  font-size: 1em;
  border-radius: 10px;
  border: 0;
  width: 100%;
  &:focus-within {
    outline: -webkit-focus-ring-color auto 1px;
  }
  input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    &:checked + div {
      left: 50%;
    }
  }
  div {
    position: absolute;
    z-index: -1;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px) !important; /* Forces autoprefixer to include both */
    left: 0;
    width: 50%;
    height: 100%;
    background-color: #0001;
  }
  &::before, &::after {
    position: relative;
    content: 'true';
    flex: 1;
    z-index: -2;
    background-color: white;
    padding: 10px;
    text-align: center;
  }
  &::after {
    content: 'false';
  }
  &:has(input:checked)::after, &:has(input:not(:checked))::before {
    color: #bbb;
  }
}

/* Header, footer */
header {
  margin-bottom: 30px;
  h1 {
    @media only screen and (max-width: 420px) {
      font-size: 3em;
    }
    font-family: 'Damion', cursive;
    font-size: 4em;
    line-height: 0.8;
    font-weight: bold;
    margin: 0;
  }
  h2 {
    font-weight: normal;
    font-size: 1.5em;
    margin: 0;
    line-height: 1em;
  }
  a {
    text-decoration: none !important;
  }
}
footer {
  margin-top: 30px;
}

/* Bookmarklet */
#div-bookmarklet-subtitle:after { /* Use pseudo-elements to avoid anchor title including subtitle */
  content: 'drag to bookmarks to save'
}
h3 {
  font-size: 1em;
  margin-block-start: 0;
  margin-block-end: 0;
}
table {
  width: 100%;
  tr {
    td {
      padding: 0 0 10px 0;
      vertical-align: top;
      text-align: right;
      &:nth-child(1) {
        max-width: 10em;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      &:nth-child(2) {
        text-align: justify;
        word-break: break-word;
        padding-left: 10px;
        width: 100%;
      }
    }
    &:last-of-type {
      td {
        padding-bottom: 0;
      }
    }
  }
}

/* Errors */
pre {
  text-align: justify;
  margin: 0;
  font-family: inherit;
  font-size: 0.9em;
  background-color: #ffaeae;
  padding: 1em;
  border-radius: 10px;
  overflow-x: scroll;
}
.error{
  margin: 3em 0;
  .error-code {
    font-size: 10em;
    margin-bottom: 0;
    line-height: 0.8em;
  }
}

/* Text styles */
.code {
  background-color: var(--code-background-color);
}
.v-center {
  vertical-align: middle;
}
