.question {
  margin-bottom: 2.5rem;
  @media (width < 600px) {
    margin-bottom: 2.25rem;
  }
  @media (width < 450px) {
    margin-bottom: 2rem;
  }
  @media print {
    margin-bottom: 1.5rem !important;
    break-inside: avoid;
  }

  &:last-child {
    margin-bottom: 0.75rem;
  }

  &.unsure .question-title {
    @media not print {
      background-color: yellow;
    }
  }

  .question-header {
    display: flex;
    justify-content: space-between;

    .question-title {
      margin-left: -2.5px;
      padding: 2.5px;
      border-radius: 5px;
    }

    .learned-tag {
      font-size: 0.9em;
      color: hsl(120, 100%, 20%);

      margin-left: 0.3rem;
      @media (width >= 600px) {
        margin-left: 0.6rem;
      }
    }

    .unsure-label {
      color: gray;
      font-size: 0.9em;

      input {
        height: 0.9rem;
        width: 0.9rem;
      }

      .show-explanation {
        display: none;
      }
    }
  }

  .question-body,
  .question-body :is(ul, ol, p) {
    margin: 0.55rem 0;
    @media (width < 600px) {
      margin: 0.5rem 0;
    }
    @media (width < 450px) {
      margin: 0.45rem 0;
    }
    @media print {
      margin: 0.4rem 0;
    }
  }

  .question-body li {
    margin: 0.4rem 0;
  }

  .question-choices {
    margin: 0.8rem 0;
    @media (width < 600px) {
      margin: 0.75rem 0;
    }
    @media (width < 450px) {
      margin: 0.7rem 0;
    }
    @media print {
      margin: 0.6rem 0;
    }
  }

  figure {
    margin: auto;
    margin-bottom: -0.2rem;
  }

  img {
    max-width: 100%;
    max-height: 50vh;

    &.choice-image {
      max-width: calc(100% - 2rem);
      max-height: 20vh;
    }
  }

  .question-choices {
    @media (width >= 750px) {
      padding-inline-start: 2rem;
    }
    @media (width >= 900px) {
      padding-inline-start: 2.25rem;
    }

    &:has(li img) {
      @media (width < 900px) {
        padding-inline-start: 0.75rem;
      }
      @media (width < 750px) {
        padding-inline-start: 0.5rem;
      }
      @media (width < 600px) {
        padding-inline-start: 0.25rem;
      }
      @media (width < 450px) {
        padding-inline-start: 0;
      }
    }

    li:has(img) {
      margin: 1rem 0;
    }
  }

  .explanation-container {
    display: none;

    padding-top: 3px;
    margin-left: 2.25rem;
    width: calc(100% - 2.25rem);
    @media (width < 900px) {
      margin-left: 2rem;
      width: calc(100% - 2rem);
    }
    @media (width < 750px) {
      margin-left: 0;
      width: 100%;
    }

    textarea.explanation {
      font-family: sans-serif;
      font-size: 1rem !important;
    }

    div.explanation {
      color: blue;
      width: 100%;

      &:has(~ .bx) {
        width: calc(100% - 3rem);

        @media (width < 750px) {
          div.explanation {
            width: calc(100% - 2.5rem);
          }
        }
        @media (width < 600px) {
          div.explanation {
            width: calc(100% - 2rem);
            ~ .bx {
              font-size: 1.5rem;
            }
          }
        }
        @media (width < 475px) {
          #placeholder-expansion {
            display: none;
          }
        }
        @media (width < 450px) {
          div.explanation {
            width: calc(100% - 1.5rem);
            ~ .bx {
              font-size: 1.4rem;
            }
          }
        }
      }

      > * {
        margin: 0.8rem 0;
        &:has(+ :is(ul, ol)) {
          margin-bottom: 0.4rem;
        }
      }
      > *:first-child {
        margin-top: 0;
      }
      > *:last-child {
        margin-bottom: 0;
      }

      > :is(ul, ol) {
        &:first-child {
          padding-inline-start: 1rem;
        }
        margin-top: 0.4rem;
        li {
          margin: 0.4rem 0;
        }
      }

      ~ .bx {
        display: block;
        margin: auto;
        margin-right: 0;
        font-size: 1.6rem;
        color: blue;
      }

      ~ .bx-loader {
        display: none;
      }

      &.empty {
        &:not(:has(~ .bx)) {
          display: none;
        }

        color: gray;
        ~ .bx {
          color: gray;
        }
      }

      &.editing {
        &.empty {
          visibility: hidden;
        }
        &:not(.empty) {
          color: gray !important;
        }

        ~ .bx-edit {
          display: none;
        }
        ~ .bx-loader {
          display: block;
        }
      }
    }
  }

  form {
    position: relative;

    .explanation {
      width: 100%;
      font-size: 1rem;
    }

    button {
      bottom: 0;
      position: absolute;
      font-weight: bold;
      font-size: 1rem;
    }
    button[type="reset"] {
      right: 5rem;
      background-color: hsla(0, 80%, 80%);
    }
    button[type="submit"] {
      right: 0;
      background-color: hsla(120, 80%, 75%);
    }

    @media (width < 600px) {
      .explanation,
      button {
        font-size: 0.92rem;
      }
      button[type="reset"] {
        right: 4.6rem;
      }
    }

    @media (width < 450px) {
      .explanation,
      button {
        font-size: 0.83rem;
      }
      button[type="reset"] {
        right: 4.2rem;
      }
    }
  }
}

#quiz:not(.submitted) {
  li label {
    display: flex;
    &:has(img) {
      align-items: center;
    }
  }
}

#quiz.submitted {
  .question {
    @media not print {
      &.incorrect .question-title {
        background-color: hsla(0, 85%, 75%, 75%);
      }
    }

    &.incorrect .unsure-label {
      display: none;
    }

    li {
      label {
        display: inline-flex;
      }

      &.correct {
        margin-left: -2.5px;

        label {
          padding: 2.5px;
          border-radius: 5px;
          background-color: hsl(120, 80%, 80%);
        }
      }
    }

    li + li.correct,
    li.correct + li {
      margin-top: calc(0.65rem - 2.5px);

      @media (width < 600px) {
        margin-top: calc(0.6rem - 2.5px);
      }

      @media (width < 450px) {
        margin-top: calc(0.55rem - 2.5px);
      }

      @media print {
        margin-top: calc(0.5rem - 2.5px);
      }
    }

    li.correct:has(+ li),
    li:has(+ li.correct) {
      margin-bottom: calc(0.65rem - 2.5px);

      @media (width < 600px) {
        margin-bottom: calc(0.6rem - 2.5px);
      }

      @media (width < 450px) {
        margin-bottom: calc(0.55rem - 2.5px);
      }

      @media print {
        margin-bottom: calc(0.5rem - 2.5px);
      }
    }
  }

  &.explained .question {
    &.incorrect,
    &.unsure {
      .explanation-container {
        display: flex;
      }
    }
    .im-not-sure {
      display: none;
    }
    .show-explanation {
      display: initial;
    }
  }

  &:not(.explained) .unsure-label {
    display: none;
  }
}

@media print {
  .question {
    margin: 1.5rem;
    &:last-child {
      margin-bottom: 1rem;
    }

    &.joke {
      display: none;
    }

    .learned-tag {
      display: none;
    }
  }

  .unsure-label {
    display: none !important;
  }

  #quiz.submitted.explained {
    .explanation-container {
      display: flex;
    }
    .explanation-container:has(.explanation.empty) {
      display: none;
    }
    .explanation ~ .bx {
      display: none;
    }
  }
}
