// Global variables
$input-padding: 0.3rem;

.noselect {
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none;   /* Chrome/Safari/Opera */
  -khtml-user-select: none;    /* Konqueror */
  -moz-user-select: none;      /* Firefox */
  -ms-user-select: none;       /* IE/Edge */
  user-select: none;           /* non-prefixed version, currently */
}

* {
  box-sizing: border-box;
}

br {
  border-style: none; // why, IE...
}

body {
  @include usevar(background-color, main-background-color);
  @include usevar(color, main-color);

  font-family: "Fira Sans", sans-serif;
  background-size: cover;
  min-height: 100vh;
  box-sizing: border-box;
  font-size: px2rem(14px);
  line-height: 1.5;
  font-weight: 400;
}

a, .link {
  @include usevar(color, link-color);
  @include usevar(border-bottom-color, link-border-color);

  border-bottom: none;
  text-decoration: none;

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

  &.external::after {
    font-family: "icons";
    content:" 1";
    vertical-align:middle;
  }
}

ol {
  list-style-type: decimal;
}

ul {
  list-style-type: circle;
  padding: 0;
  margin: 0;
}

.list-none {
  list-style-type: none;
}

li {
  padding: 0;
  margin: 0;
  padding-left: 5px;
  margin-left: 15px;
}

h1, h2, h3, h4, h5 {
  font-weight: 500;
  margin: 0;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  line-height: 1.25em;
}

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

p {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.p-spaced p {
  $spacing: 0.6em;

  &:not(:first-child) {
    margin-top: $spacing;
  }
  
  &:not(:last-child) {
    margin-bottom: $spacing;
  }
}

table {
  border-collapse: collapse;
  table-layout: fixed;
}

th, td {
  @include usevar(color, fg-font-color);
}

td {
  vertical-align:baseline;
}

hr {
  @include usevar(border-top-color, hr-color);
  @extend .mv3;

  border-width: 1px 0 0;
  border-top-style: solid;
}

$monospace-fonts: "Fira Mono", monospace;

.mono {
  font-family: $monospace-fonts;
}

article code {
  font-family: $monospace-fonts;
}

.big { font-size:120%; }

.title {
  font-weight: bold;
}

.clear {
  width: 0;
}

.full {
  width: 100%;
}

.hidden {
  display: none;
}

.empty {
  padding-left: 20px;
}

.column h2 {
  text-align: center;
  margin-bottom: 20px;
}

.margin-center {
  margin-left: auto;
  margin-right: auto;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

.flex-grow-1 {
  flex-grow: 1;
}

.flex-fair {
  flex-basis: 1px;
  flex-grow: 1;
  flex-shrink: 1;
}

@media #{$breakpoint-not-small} {
  .flex-fair-ns {
    flex-basis: 1px;
    flex-grow: 1;
    flex-shrink: 1;
  }
}

@media #{$breakpoint-large} {
  .flex-fair-l {
    flex-basis: 1px;
    flex-grow: 1;
    flex-shrink: 1;
  }
}

.b--theme {
  @include usevar(border-color, theme-color);
}

.c--dim {
  @include usevar(color, dim-color);
}

.c--theme-dim {
  @include usevar(color, theme-color-dim);
}

.b--dim {
  @include usevar(border-color, dim-color);
}

.b--theme-dim {
  @include usevar(border-color, theme-color-dim);
}

.c--dimmer {
  @include usevar(color, dimmer-color);
}

.c--theme-dimmer {
  @include usevar(color, theme-color-dimmer);
}

.b--dimmer {
  @include usevar(border-color, dimmer-color);
}

.b--theme-dimmer {
  @include usevar(border-color, theme-color-dimmer);
}

.c--dimmest {
  @include usevar(color, dimmest-color);
}

.c--theme-dimmest {
  @include usevar(color, theme-color-dimmest);
}

.b--dimmest {
  @include usevar(border-color, dimmest-color);
}

.b--theme-dimmest {
  @include usevar(border-color, theme-color-dimmest);
}

.bg--dim {
  @include usevar(background-color, dim-background);
}

.bg--content {
  @include usevar(background-color, content-background);
}

.bg--card {
  @include usevar(background-color, card-background);
}

.f8 {
  font-size: 0.65rem;
}

.mw-site {
  max-width: 80rem;
}

.mh-3 {
  max-height: $height-3;
}

.mh-4 {
  max-height: $height-4;
}

.mh-5 {
  max-height: $height-5;
}

.mh-6 {
  max-height: $height-6;
}

.mh-100 {
  max-height: 100%;
}

.mh-50vh {
  max-height: 50vh;
}

.mh-60vh {
  max-height: 60vh;
}

.mh-70vh {
  max-height: 70vh;
}

.mh-80vh {
  max-height: 80vh;
}

.minw-100 {
  min-width: 100%;
}

.minh-1 {
  min-height: $height-1;
}

.minh-2 {
  min-height: $height-2;
}

.minh-3 {
  min-height: $height-3;
}

.minh-4 {
  min-height: $height-4;
}

.minh-5 {
  min-height: $height-5;
}

.minh-6 {
  min-height: $height-6;
}

.fira {
  font-family: "Fira Sans", sans-serif;
}

.bi-avoid { break-inside: avoid; }
.cc-auto { column-count: auto; }
.cc1 { column-count: 1; }
.cc2 { column-count: 2; }
.cc3 { column-count: 3; }
.cg0 { column-gap: $spacing-none; }
.cg1 { column-gap: $spacing-extra-small; }
.cg2 { column-gap: $spacing-small; }
.cg3 { column-gap: $spacing-medium; }
.cg4 { column-gap: $spacing-large; }
.cg5 { column-gap: $spacing-extra-large; }

@media #{$breakpoint-not-small} {
  .bi-avoid-ns { break-inside: avoid; }
  .cc-auto-ns { column-count: auto; }
  .cc1-ns { column-count: 1; }
  .cc2-ns { column-count: 2; }
  .cc3-ns { column-count: 3; }
  .cg0-ns { column-gap: $spacing-none; }
  .cg1-ns { column-gap: $spacing-extra-small; }
  .cg2-ns { column-gap: $spacing-small; }
  .cg3-ns { column-gap: $spacing-medium; }
  .cg4-ns { column-gap: $spacing-large; }
  .cg5-ns { column-gap: $spacing-extra-large; }

  .bg--dim-ns {
    @include usevar(background-color, dim-background);
  }
}

@media #{$breakpoint-medium} {
  .bi-avoid-m { break-inside: avoid; }
  .cc-auto-m { column-count: auto; }
  .cc1-m { column-count: 1; }
  .cc2-m { column-count: 2; }
  .cc3-m { column-count: 3; }
  .cg1-m { column-gap: $spacing-extra-small; }
  .cg2-m { column-gap: $spacing-small; }
  .cg3-m { column-gap: $spacing-medium; }
  .cg4-m { column-gap: $spacing-large; }
  .cg5-m { column-gap: $spacing-extra-large; }

  .bg--dim-m {
    @include usevar(background-color, dim-background);
  }
}

@media #{$breakpoint-large} {
  .bi-avoid-l { break-inside: avoid; }
  .cc-auto-l { column-count: auto; }
  .cc1-l { column-count: 1; }
  .cc2-l { column-count: 2; }
  .cc3-l { column-count: 3; }
  .cg1-l { column-gap: $spacing-extra-small; }
  .cg2-l { column-gap: $spacing-small; }
  .cg3-l { column-gap: $spacing-medium; }
  .cg4-l { column-gap: $spacing-large; }
  .cg5-l { column-gap: $spacing-extra-large; }

  .bg--dim-l {
    @include usevar(background-color, dim-background);
  }
}

.not-first:first-child {
  display: none;
}

.not-first-of-type:first-of-type {
  display: none;
}

.not-last:last-child {
  display: none;
}

.not-last-of-type:last-of-type {
  display: none;
}

.svgicon {
  svg {
    fill: currentColor;
    stroke: currentColor;
    width: 1em;
    height: 1em;
  }

  &:not(.svgicon-nofix) svg {
    transform: translate(0px,0.1em);
  }
}

// Tachyons' `center` is unfortunately overloaded by a .center
// class we have in our own CSS.
.center-layout {
  margin-right: auto;
  margin-left: auto;
}

footer {
  .list li:not(:last-child)::after {
    @extend .c--dimmer;

    @media #{$breakpoint-not-small} {
      & {
        content: ' / ';
      }
    }
  }
}

.content {
  @include usevar(background-color, content-background);

  margin: auto;

  p {
    -moz-text-size-adjust:auto;
    -webkit-text-size-adjust:auto;
    text-size-adjust:auto;

    margin: 0.6rem 0;
  }

  .description {
    line-height: 1.42em;
    text-align: left;
    margin: auto;

    p {
      margin-bottom: $spacing-small;
      text-align: left;
    }
  }

  > .top-bar {
      text-align: left;
  }
}

.content-block {
  // TODO: What the heck are these styles
  /* Background color given by theme */
  background-repeat:repeat-x;
  border-radius:2px;
  text-align:left;
  width:100%;
  /* box-shadow: 0px 4px 7px rgba(0,0,0,0.5); /* Not themed */
  position:relative;
  box-sizing:border-box;

  &.top-bar {
    background-image:none;
  }

  &.language-desc {
    padding: 10px;

    h3 {
      margin-left: 10px;
    }
  }

  .no-bg {
    background-image:none;
    background-color:transparent;
    box-shadow:none;
  }
}

.sidebar {
  .content-block {
    &.single {
      padding:0px; /* for project list, TODO */
      margin-top:20px;
    }

    &.top-bar {
      /* box-shadow: 0px 2px 4px rgba(0,0,0,0.2); /* Not themed */
      width:80%;
      display:block;
      margin:10px auto;
    }
  }

  br.sidebar-filler {
    line-height:20px;
  }

  .projectlist {
    background-color:transparent;
  }
}

.content-block .bottom-padding, .sidebar .bottom-padding {
  margin-top: $spacing-medium;
}

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

  &.current {
    text-overflow: clip ellipsis;
  }
}

.breadcrumb-before:nth-of-type(n+2)::before {
  content: '≫';
}

.optionbar {
  @extend .b--dimmest;

  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  align-items: center;
  border-style: dashed;
  border-width: 0px;
  border-bottom-width: 1px;
  padding-bottom: $spacing-small;

  @media #{$breakpoint-not-small} {
    flex-direction: row;
    text-align: left;
    padding-bottom: 0;
  }

  &.bottom {
    border-bottom-width: 0px;
    border-top-width: 1px;
    padding-bottom: 0;
    padding-top: $spacing-small;

    @media #{$breakpoint-not-small} {
      padding-top: 0;
    }
  }

  &.center {
    text-align: center; // TODO: find this and kill it
  }

  .options {
    display: flex;
    flex-direction: column;

    @media #{$breakpoint-not-small} {
      flex-direction: row;
    }

    & {
      #{$buttons} {
        @include lite-button;
        @extend .ph2;
        @extend .pv1;
        @extend .pv2-ns;
      }
    }
  }

  .group {
    display: inline-block;
    height: 100%;
    margin: auto;
  }
}

.tab {
  @include usevar(background-color, tab-background);
  @extend .pa2;
}

.tab-bar {
  @include usevar(border-color, tab-border-color);
  @extend .flex, .flex-row;

  width: 100%;

  .tab-button {
    @include usevar(background-color, tab-button-background);
    @include usevar(border-color, tab-border-color);
    @extend .ph3, .pv2;

    cursor: pointer; // TODO: Should this be a link?

    &:hover {
      @include usevar(background-color, tab-button-background-hover);
    }

    &.current {
      @include usevar(background-color, tab-button-background-current);
      font-weight: 500;
    }
  }
}

.pagination {
  .page.current {
    cursor: default;
    font-weight: 600;

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

  .button {
    @extend .pv0, .ph2;
  }
}

.user-link {
  position:relative;
}

// TODO(ben): It appears that this code is inactive because the JS that would
// create the popups is commented out.
.user-popup {
  opacity:0;
  max-height:0px;
  width:340px;

  text-align:center;

  transition:max-height 0.2s, opacity 0.1s;
  box-shadow:0px 2px 5px rgba(0,0,0,0.3);

  overflow:hidden;
  position:absolute;
  bottom:0px;

  &.expanded {
    visibility:visible;
    max-height:250px;
    opacity:1;
  }

  table {
    /* Background color given by theme */
    width:100%;
    position:relative;
    border-radius:3px;
    z-index:10;
  }

  td {
    vertical-align:top;
    padding:15px 9px;
  }

  #avatar {
    width:100px;
    height:100px;
    background-size:contain;
    background-position:center center;
    background-repeat:no-repeat;
    border-radius:3px;
    margin:0px auto;
  }

  .username {
    font-weight:bold;
  }

  .bottom {
    /* Border color given by theme */
    border-top: 1px solid transparent;
    padding: 15px;

    .bio {
      vertical-align:top;
      width:90%;
    }
  }
}

.site-search {
  &[type=text].lite {
    // wow CSS selector priority sucks

    // First transition copied from input .lite
    transition: border-bottom-color 60ms ease-in-out, width 300ms ease;
  }
}

#search_button_homepage {
  margin:0px;
  height:100%;
  height:calc(100% - 2px);
  border-radius:0px;
  display:inline-block;
  display:none;
}

.background-even:nth-of-type(even) {
  // this is the default, and should be overridden by dynamic colors.
  @include usevar(background-color, background-even-background);
  @include usevar(--fade-color, background-even-background);
}
