.drawer {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 10px 5px;
  width: 300px;
  flex: none;
  contain: strict;

  &:first-child {
    padding-left: 10px;
  }

  &:last-child {
    padding-right: 10px;
  }

  @include single-column('screen and (max-width: 630px)') { flex: auto }

  @include limited-single-column('screen and (max-width: 630px)') {
    &, &:first-child, &:last-child { padding: 0 }
  }

  .wide & {
    min-width: 300px;
    max-width: 400px;
    flex: 1 1 200px;
  }

  @include single-column('screen and (max-width: 630px)') {
    :root & {  //  Overrides `.wide` for single-column view
      flex: auto;
      width: 100%;
      min-width: 0;
      max-width: none;
      padding: 0;
    }
  }

  .react-swipeable-view-container & { height: 100% }

  & > .contents {
    display: flex;
    position: relative;
    flex-direction: column;
    padding: 0;
    width: 100%;
    height: 100%;
    background: lighten($ui-base-color, 13%);
    overflow-x: hidden;
    overflow-y: auto;
    contain: strict;

    & > .mastodon {
      flex: 1;
      border: none;
      cursor: inherit;
    }
  }

  @for $i from 0 through 3 {
    &.mbstobon-#{$i} > .contents {
      @if $i == 3 {
        background: url('~flavours/glitch/images/wave-drawer.png') no-repeat bottom / 100% auto, lighten($ui-base-color, 13%);
      } @else {
        background: url('~flavours/glitch/images/wave-drawer-glitched.png') no-repeat bottom / 100% auto, lighten($ui-base-color, 13%);
      }

      & > .mastodon {
        background: url("~flavours/glitch/images/mbstobon-ui-#{$i}.png") no-repeat left bottom / contain;

        @if $i != 3 {
          filter: contrast(50%) brightness(50%);
        }
      }
    }
  }
}

.drawer--header {
  display: flex;
  flex-direction: row;
  margin-bottom: 10px;
  flex: none;
  background: lighten($ui-base-color, 8%);
  font-size: 16px;

  & > * {
    display: block;
    box-sizing: border-box;
    border-bottom: 2px solid transparent;
    padding: 15px 5px 13px;
    height: 48px;
    flex: 1 1 auto;
    color: $darker-text-color;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
  }

  a {
    transition: background 100ms ease-in;

    &:focus,
    &:hover {
      outline: none;
      background: lighten($ui-base-color, 3%);
      transition: background 200ms ease-out;
    }
  }
}

.drawer--search {
  position: relative;
  margin-bottom: 10px;
  flex: none;

  @include limited-single-column('screen and (max-width: 360px)') { margin-bottom: 0 }
  @include single-column('screen and (max-width: 630px)') { font-size: 16px }

  input {
    display: block;
    box-sizing: border-box;
    margin: 0;
    border: none;
    padding: 10px 30px 10px 10px;
    width: 100%;
    height: 36px;
    outline: 0;
    color: $darker-text-color;
    background: $ui-base-color;
    font-size: 14px;
    font-family: inherit;
    line-height: 16px;

    &:focus {
      outline: 0;
      background: lighten($ui-base-color, 4%);
    }
  }

  & > .icon {
    display: block;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 18px;
    height: 18px;
    color: $secondary-text-color;
    font-size: 18px;
    line-height: 18px;
    z-index: 2;

    .fa {
      display: inline-block;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      opacity: 0;
      cursor: default;
      pointer-events: none;
      transition: all 100ms linear;
    }

    .fa-search {
      opacity: 0.3;
      transform: rotate(0deg);
    }

    .fa-times-circle {
      transform: rotate(-90deg);
      cursor: pointer;

      &:hover { color: $primary-text-color }
    }
  }

  &.active {
    & > .icon {
      .fa-search {
        opacity: 0;
        transform: rotate(90deg);
      }

      .fa-times-circle {
        opacity: 0.3;
        pointer-events: auto;
        transform: rotate(0deg);
      }
    }
  }
}

.drawer--search--popout {
  box-sizing: border-box;
  margin-top: 10px;
  border-radius: 4px;
  padding: 10px 14px 14px 14px;
  box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4);
  color: $light-text-color;
  background: $simple-background-color;

  h4 {
    margin-bottom: 10px;
    color: $light-text-color;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
  }

  ul { margin-bottom: 10px }
  li { padding: 4px 0 }

  em {
    color: $inverted-text-color;
    font-weight: 500;
  }
}

.drawer--account {
  padding: 10px;
  color: $darker-text-color;

  & > a {
    color: inherit;
    text-decoration: none;
  }

  & > .avatar {
    float: left;
    margin-right: 10px;
  }

  & > .acct {
    display: block;
    color: $secondary-text-color;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.drawer--results {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0;
  background: $ui-base-color;
  overflow-x: hidden;
  overflow-y: auto;
  contain: strict;

  & > header {
    border-bottom: 1px solid darken($ui-base-color, 4%);
    padding: 15px 10px;
    color: $dark-text-color;
    background: lighten($ui-base-color, 2%);
    font-size: 14px;
    font-weight: 500;
  }

  & > section {
    background: $ui-base-color;

    & > .hashtag {
      display: block;
      padding: 10px;
      color: $secondary-text-color;
      text-decoration: none;

      &:hover,
      &:active,
      &:focus {
        color: lighten($secondary-text-color, 4%);
        text-decoration: underline;
      }
    }
  }
}

.drawer__pager {
  box-sizing: border-box;
  padding: 0;
  flex-grow: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.drawer__inner {
  position: absolute;
  top: 0;
  left: 0;
  background: lighten($ui-base-color, 13%) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 234.80078 31.757813" width="234.80078" height="31.757812"><path d="M19.599609 0c-1.05 0-2.10039.375-2.90039 1.125L0 16.925781v14.832031h234.80078V17.025391l-16.5-15.900391c-1.6-1.5-4.20078-1.5-5.80078 0l-13.80078 13.099609c-1.6 1.5-4.19883 1.5-5.79883 0L179.09961 1.125c-1.6-1.5-4.19883-1.5-5.79883 0L159.5 14.224609c-1.6 1.5-4.20078 1.5-5.80078 0L139.90039 1.125c-1.6-1.5-4.20078-1.5-5.80078 0l-13.79883 13.099609c-1.6 1.5-4.20078 1.5-5.80078 0L100.69922 1.125c-1.600001-1.5-4.198829-1.5-5.798829 0l-13.59961 13.099609c-1.6 1.5-4.200781 1.5-5.800781 0L61.699219 1.125c-1.6-1.5-4.198828-1.5-5.798828 0L42.099609 14.224609c-1.6 1.5-4.198828 1.5-5.798828 0L22.5 1.125C21.7.375 20.649609 0 19.599609 0z" fill="#{hex-color($ui-base-color)}"/></svg>') no-repeat bottom / 100% auto;
  box-sizing: border-box;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-y: auto;
  width: 100%;
  height: 100%;

  &.darker {
    background: $ui-base-color;
  }

  > .mastodon {
    background: url('~images/elephant_ui_plane.svg') no-repeat left bottom / contain;
    flex: 1;
  }
}

.pseudo-drawer {
  background: lighten($ui-base-color, 13%);
  font-size: 13px;
  text-align: left;
}

.drawer__backdrop {
  cursor: pointer;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba($base-overlay-background, 0.5);
}