@import "contrast";
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "variables";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/root";
@import "bootstrap/scss/reboot";
@import "bootstrap/scss/code";
@import "bootstrap/scss/type";
@import "bootstrap/scss/grid";
@import "bootstrap/scss/tables";
@import "bootstrap/scss/forms";
@import "bootstrap/scss/buttons";
@import "bootstrap/scss/transitions";
@import "bootstrap/scss/dropdown";
@import "bootstrap/scss/progress";
@import "bootstrap/scss/button-group";
@import "bootstrap/scss/input-group";
@import "bootstrap/scss/custom-forms";
@import "bootstrap/scss/nav";
@import "bootstrap/scss/navbar";
@import "bootstrap/scss/alert";
@import "bootstrap/scss/utilities";
@import "bootstrap/scss/print";

@import "icons";
@import "nav";
@import "events";
@import "highlight";

body {
  font-family: sans-serif;
  font-size: $base-font-size;
  padding-bottom: 1rem;
  text-align: initial;
}

@include media-breakpoint-down(md) {
  .container {
    width: 100%;
    max-width: 100%;
  }
}

a {
  text-decoration: underline;

  &:hover {
    text-decoration: none;
  }
}

a.nav-link, a.navbar-brand, a.btn {
  text-decoration: none;
}

h1 a, h2 a, h3 a, h4 a, h5 a {
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

label {
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea.form-control {
  border-radius: 0;
  border-color: #888;
  color: $gray-800;
  padding: 0.25rem 0.375rem;

  &:active, &:focus {
    color: $gray-800;
  }
}

input[type="checkbox"] {
  position: relative;
  top: 2px;
}

select:not([multiple]).form-control {
  border-radius: 0;
  border-color: #888;
  color: $gray-800;
  padding: 0 0.75rem;
  height: 2.2rem !important;
}

form {
  margin-bottom: 1rem;
}

legend {
  font-size: $base-font-size;
  margin-bottom: 0;
}

h1, h2 {
  margin-top: 0;

  small {
    font-size: $base-font-size;
  }
}

h3 {
  font-size: 1.3rem;
  border-bottom: 1px solid $gray-200;
  padding-bottom: 0.25rem;

  small {
    font-size: 1rem;
    margin-left: 1rem;
  }
}

h4 {
  font-size: 1.1rem;
  border-bottom: 1px solid $gray-200;
  padding-bottom: 0.25rem;

  small {
    font-size: 0.8rem;
    margin-left: 1rem;
  }
}

h5 {
  font-size: 1rem;
  font-weight: bold;
}

.table {
  thead {
    th {
      padding: 0.1rem 0.75rem;
      border: none;
    }
  }

  tbody {
    td {
      position: relative;
      /*
      `position: relative` requires `background-clip: padding-box` to avoid the
      background being drawn on top of the borders on some OSes. Also,
      subsequently setting `background` will override `background-clip`, so make
      sure to use `background-color`.
      */
      background-clip: padding-box;
      vertical-align: middle;
      padding: 0.1rem 0.75rem;
      border: 1px solid $gray-400;
      background-color: $white;

      label {
        margin-bottom: 0;
      }
    }
  }

  tr.danger {
    background: lighten($danger, 20);
  }

  .btn-danger.btn-fill {
    &:hover {
      background: $danger;
    }
  }
}

section {
  padding-bottom: 0.5rem;
}

@mixin btn_type($background, $foreground, $border, $hover) {
  /* FINDME */
  background: $background;
  border: $border 1px solid;
  color: $foreground;

  @at-root a#{&} {
    color: $foreground;

    &:hover {
      color: color_adjust_contrast_AERT($foreground, $hover);
    }
  }

  &:hover {
    background: $hover;
  }
}

.btn {
  border-radius: 0;
  padding: 0.1rem 0.75rem;
  font-size: 0.9rem;
  transition: background 0.1s linear;
}

.btn-default {
  @include btn_type($gray-300, $black, $gray-800, $gray-200);
}

.btn-primary {
  @include btn_type(darken($primary, 10), $white,
    darken($primary, 40), $primary);
}

.btn-success {
  @include btn_type(darken($success, 12),
    color_adjust_contrast_AERT($white, darken($success, 5)),
    darken($success, 20), darken($success, 10));
}

.btn-info {
  @include btn_type(darken($info, 10), $white, darken($info, 40), $info);
}

.btn-danger {
  @include btn_type(darken($danger, 5), $white, darken($danger, 40), $danger);
}

a.btn.btn-link {
  padding: 0;
  font-size: $base-font-size;
  margin-top: -0.1rem;
  text-decoration: underline;
}

a.btn.btn-link:hover {
  text-decoration: none;
}

.btn-fill {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  border: none;
  padding: 0;
  line-height: 1.6;
}

.btn-sm {
  font-size: 0.95rem;
  padding: 0 0.75rem;
}

.alert {
  padding: 0.5rem;
  border-radius: 0;

  .form-group & {
    margin-top: 1rem;
  }
}

.text-centered {
  text-align: center;
}

.text-right {
  text-align: right;
}

.pull-left {
  float: left;
}

.pull-right {
  float: right;
}

blockquote {
  padding-left: 0.5rem;
  border-left: 3px solid #aaa;
}

pre {
  background: $pre-background;
  padding: 0.25rem;
}

code {
  margin: 0;
  background: transparent;
  color: black;
}

.markdown {
  table {
    @extend .table;
  }

  h1, h2, h3, h4, h5, h6 {
    position: relative;
    margin-top: 1em;

    &:first-child {
      margin-top: 0;
    }

    & > a:first-child {
      transition: opacity 0.15s linear;
      opacity: 0;
      position: absolute;
      font-size: inherit;
      left: -.7em;
    }

    @media(prefers-reduced-motion) {
      & > a:first-child {
        transition: none;
      }
    }
    
    &:hover > a:first-child {
      opacity: 1;
    }

    img {
      margin: 0 .2rem;
      max-width: 100%;
    }
  }
}

@media(prefers-color-scheme: dark) {
  @import "dark";
}

.profile .avatar {
  display: block;
  border-radius: 5px;
  max-width: 100%;
  margin: 0 auto;
  margin-bottom: 1rem;

  @include media-breakpoint-down(sm) {
    max-width: 50%;
  }

  @include media-breakpoint-down(xs) {
    max-width: 70%;
  }
}
