// File styles
//
// There are two styles of displaying files. One style is showing files
// as attachments with articles. The other style is when files are in forms (edit mode).
//
// Weight: 6
//
// Style guide: molecules.files

// File in node
//
// The display of files in nodes is done with small cards (emphasis layer).
// The cards must be placed in a grid `.card-files__grid`. The element consists of the file name (max 3 lines truncated), the file type and file size.
//
// markup: file-node.twig
//
// Weight: 1
//
// Style guide: molecules.files.node

// File in form
//
// Files in forms need to be able to changed easily. For example for images their is
// a preview shown when editing content. For file attachments the file molecule is part of
// the multiple file upload widget where multiple rows can be added.
//
// markup: file-form.twig
//
// Weight: 2
//
// Style guide: molecules.files.form

@import 'settings';

// Drupal default display

.file {
  display: flex;
  font-size: 0.75rem;
  margin: 10px 0;
  width: 100%;
  background: #fff;
  border: 1px solid $gray-lighter;
  padding: 0.5em 0;

  @include for-tablet-portrait-up {
    margin-top: 5px;
  }

  > span {
    padding-left:0.5em;
    padding-right: 0.5em;
  }

  > .tabledrag-changed {
    display: table-cell;
    padding: 0 1em;
    top: 0;
    vertical-align: middle;
    border-left: 1px solid inherit;
  }
}

.form-managed-file .file {
  margin-bottom: 0;
}

.file-icon {
  user-select: none;
  flex: 0 0 32px;

  .node-file__icon {
    display: block;
  }
}

.file-link {
  flex: 1;
  white-space: normal;
  word-break: break-word;

  a, a:hover, a:focus, a:active {
    text-decoration: none;
    color: inherit;
    font-weight: 400;
  }

}

.file-size {
  text-align: right;
  white-space: pre;
  vertical-align: middle;
}

// Display of attachments as cards

.card-files {
  margin-top: 40px;
}

.card-files__grid {
  @include list-unstyled;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  @include for-tablet-landscape-up {
    justify-content: flex-start;
  }

}

.card-files__title {
  margin-bottom: 20px;
}

.card-file {
  @include z-depth-1;
  flex: 0 0 47.5%;
  margin-bottom: 13px;
  font-size: 0.75rem;
  background: $gray-lightest;

  @include for-tablet-landscape-up {
    flex-basis: 23%;
    margin-right: 2%;

    &:nth-child(4n+4) {
      margin-right: 0;
    }
  }

  &:hover {
    @include z-depth-2;

    &:after {

    }

  }
}

.card-file__link {
  display: block;
  position: relative;
  height: 100px;
  padding: $padding-base-horizontal;
  color: inherit;
  text-decoration: none;
}

.card-file__title {
  @include multiLineEllipsis(1.35em, 2, $gray-lightest);
  display: block;
  word-break: break-word;
  word-wrap: normal;
}

.card-file__type {
  display: flex;
  flex-wrap: wrap;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
  position: absolute;
  bottom: $padding-base-horizontal;
  width: calc(100% - (2 * #{$padding-base-horizontal}) );
}

.card-file__icon {
  margin-right: 8px;
  user-select: none;
  width: 16px;
  height: 16px;
}

.card-file__size,
.card-file__count {
  text-overflow: ellipsis;
  overflow: hidden;
  line-height: 1rem;
}

.card-file__count {
  flex: 1 0 100%;
  white-space: nowrap;
  margin: 5px 0 0 24px;
}

