:root {
  --gray: #999;
  --blue: #0074d9;
  --color: #333;
  --background-color: #fff;
  --border: 1px solid #eee;
}

.picker {
  background-color: rgba(0, 0, 0, 0.5);
  color: var(--color);
  direction: ltr;
  display: none;
  font-size: 1rem;
  line-height: 1.5;
  overflow: hidden;
  touch-action: none;
  transition: opacity 0.15s;
  user-select: none;
}

.picker-fixed {
  bottom: 0;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1986;

  & > .picker-dialog {
    bottom: -100%;
    left: 0;
    max-height: 100%;
    position: absolute;
    right: 0;
    transition: bottom 0.3s;
  }

  & .picker-header {
    display: block;
  }

  & .picker-footer {
    display: table;
  }
}

.picker-open {
  display: block;
  opacity: 0;
}

.picker-opened {
  opacity: 1;

  & > .picker-dialog {
    bottom: 0;
  }
}

.picker-dialog {
  background-color: var(--background-color);
  border: var(--border);
}

.picker-header {
  border-bottom: var(--border);
  display: none;
  padding: 0.875rem 1.25rem;
  position: relative;
}

.picker-title {
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.25rem;
  margin: 0;
}

.picker-close {
  background-color: transparent;
  border-width: 0;
  color: var(--gray);
  cursor: pointer;
  font-size: 1.75rem;
  height: 3rem;
  opacity: 0.75;
  padding: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 3rem;

  &:focus,
  &:hover {
    opacity: 1;
    outline: none;
  }
}

.picker-body {
  overflow: hidden;
}

.picker-grid {
  display: table;
  table-layout: fixed;
  width: 100%;
}

.picker-cell {
  display: table-cell;
  position: relative;

  &::before,
  &::after {
    content: '';
    display: block;
    left: 0;
    position: absolute;
    right: 0;
    z-index: 3;
  }

  &::before {
    background-image: linear-gradient(to top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.05));
    bottom: 50%;
    margin-bottom: 1rem;
    top: 0;
  }

  &::after {
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.05));
    bottom: 0;
    margin-top: 1rem;
    top: 50%;
  }

  & + .picker-cell {
    border-left: var(--border);
  }

  @nest .picker-headers & {
    &::before {
      margin-bottom: 0;
    }

    &::after {
      margin-top: 2rem;
    }
  }

  @nest .picker-single:not(.picker-controls):not(.picker-headers) & {
    &::before,
    &::after {
      display: none;
    }
  }
}

.picker-cell__header {
  color: var(--gray);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5rem;
  margin: 0;
  overflow: hidden;
  padding: 0.25rem 0.5rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-cell__control {
  cursor: pointer;
  height: 2rem;
  padding: 0.25rem 0.5rem;
  position: relative;
  z-index: 4;

  &::before {
    border: 0 solid #ccc;
    content: '';
    display: block;
    height: 0.5rem;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 0.5rem;
  }

  &:hover::before {
    border-color: var(--primary);
  }
}

.picker-cell__control--prev {
  &::before {
    border-right-width: 1px;
    border-top-width: 1px;
    margin-top: 2px;
  }
}

.picker-cell__control--next {
  &::before {
    border-bottom-width: 1px;
    border-left-width: 1px;
    margin-bottom: 2px;
  }
}

.picker-cell__body {
  overflow: hidden;
  position: relative;

  &::before,
  &::after {
    content: '';
    height: 2rem;
    left: 0;
    position: absolute;
    right: 0;
    z-index: 1;
  }

  &::before {
    background-image: linear-gradient(to top, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
    top: 0;
  }

  &::after {
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
    bottom: 0;
  }

  @nest .picker-single & {
    &::before,
    &::after {
      display: none;
    }
  }
}

.picker-list {
  list-style: none;
  margin: -2rem 0;
  padding: 0;
  position: relative;
}

.picker-item {
  color: var(--gray);
  padding: 0.25rem 0.5rem;
  text-align: center;
  white-space: nowrap;
}

.picker-picked {
  color: var(--blue);
  font-size: 1.125em;
  line-height: 1.5rem;
}

.picker-footer {
  border-top: var(--border);
  display: none;
  width: 100%;
}

.picker-cancel,
.picker-confirm {
  background-color: transparent;
  border-width: 0;
  cursor: pointer;
  display: table-cell;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  width: 50%;

  &:focus,
  &:hover {
    background-color: #fcfcfc;
    outline: none;
  }
}

.picker-confirm {
  color: var(--blue);
}
