@import "./variables.css";

/**
 * UNITS form components
 *
 * ==================================
 * @base:   [.uc-form]
 * ==================================
 * @parts:  [.uc-***]
 *          [.uc-***]
 * ==================================
 * @option: [._***]
 *          [._***]
 * ==================================
 */

.uc-form {

  &._set {
    max-width: 800px;
    margin: 0 auto;
  }

  .uc-grid {
    @media (--small-viewport) {
      flex-direction: column;
    }

    &._gutter {
      margin: calc(-var(--grid-gutter) * .6) 0 0 calc(-var(--grid-gutter) * .6);

      @media (--small-viewport) {
        margin: calc(-var(--grid-gutter) * .6) 0 0 calc(-var(--grid-gutter) * .6);
      }

      .uc-grid-cell {
        padding: calc(var(--grid-gutter) * .6) 0 0 calc(var(--grid-gutter) * .6);

        @media (--small-viewport) {
          padding: calc(var(--grid-gutter) * .6) 0 0 calc(var(--grid-gutter) * .6);
        }
      }
    }
  }
}

.uc-form-group {
  display: flex;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
  overflow: hidden;

  .uc-btn {
    margin: 0;

    @media (--small-viewport) {
      max-width: 120px;
    }
  }
}

.uc-form-parts {
  width: 100%;
  padding: 16px;
  border: none;
  outline: transparent;
  background-color: white;
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);

  &[type="text"],
  &._text {
    line-height: 1;
  }

  &[type="checkbox"],
  &._checkbox,
  &[type="radio"],
  &._radio {
    width: auto;
    margin-right: 8px;
  }

  .uc-form-group & {
    border-radius: 0;
    border: none;
  }

  .uc-form-group & + .uc-btn {
    box-shadow: none;
    border: none;
    border-radius: 0;
    border-left: 1px solid var(--color-border);
  }
}

textarea.uc-form-parts,
.uc-form-parts._textarea {
  height: 10em;

  @media (--small-viewport) {
    height: 8em;
  }
}

select.uc-form-parts,
.uc-form-parts._select {
  -webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
}

.uc-form-parts-unit {
  text-align: left;

  & + .uc-form-parts-unit {
    margin-top: 32px;
  }

  & + .uc-form-parts-unit.uc-grid {
    margin-top: 8px;
  }

  &._center {
    text-align: center;
  }

  label {
    display: inline-block;
    color: color(black a(.7));
    font-weight: bold;
    font-size: .875rem;
    line-height: 1;
    text-align: left;
    cursor: pointer;

    & + label {
      margin-left: 32px;
    }

    & + .uc-form-group,
    & + .uc-form-parts {
      margin-top: 16px;
    }

    ._black &,
    ._dark & {
      color: white;
    }

    > span {
      display: inline-block;
      background-color: var(--color-bg);
      border-radius: calc(var(--border-radius) / 2);
      font-size: .75rem;
      padding: 2px 8px;
      margin: 0 4px;
      color: var(--color-code);
    }
  }

  .uc-btn {
    margin: 0;

    @media (--small-viewport) {
      max-width: 160px;
    }
  }
}
