// ------
// Tables
// ------

//- Mixin: Table
///
/// Ported directly from Twitter Bootstrap (by way of [Axis](axis.netlify.com)), as they did an
/// excellent job with the tables.
///
/// @param {variable} $border [true] - Makes table bordered
/// @param {variable} $striped [true] - Adds zebra striping
/// @param {variable} $condensed [false] - Makes the table condensed
/// @group table
/// @example
///   table {
///     @include table();
///   }
/// @todo - make hover effect optional

@mixin table($border : true, $striped : true, $condensed : false) {
  border-collapse: collapse;
  border-spacing: 0;
  margin-bottom: 18px;
  max-width: 100%;
  width: 100%;

  th,
  td {
    border-top: 1px solid lighten($base-gray, 30%);
    line-height: 18px;
    padding: 8px;
    text-align: left;
    vertical-align: top;
  }

  th {
    font-weight: bold;
  }

  thead th {
    vertical-align: bottom;
  }

  thead:first-child tr th,
  thead:first-child tr td {
    border-top: 0;
  }

  tbody + tbody {
    border-top: 2px solid lighten($base-gray, 30%);
  }

  @if $condensed {
    th,
    td {
      padding: 4px 5px;
    }
  }

  @if $border {
    border: 1px solid lighten($base-gray, 30%);
    border-collapse: separate;
    border-radius: 4px;

    th + th,
    td + td,
    th + td,
    td + th {
      border-left: 1px solid lighten($base-gray, 30%);
    }

    thead:first-child tr:first-child th,
    tbody:first-child tr:first-child th,
    tbody:first-child tr:first-child td {
      border-top: 0;
    }

    thead:first-child tr:first-child th:first-child,
    tbody:first-child tr:first-child td:first-child {
      border-radius: 4px 0 0;
    }

    thead:first-child tr:first-child th:last-child,
    tbody:first-child tr:first-child td:last-child {
      border-radius: 0 4px;
    }

    thead:last-child tr:last-child th:first-child,
    tbody:last-child tr:last-child td:first-child {
      border-radius: 0 0 0 4px;
    }

    thead:last-child tr:last-child th:last-child,
    tbody:last-child tr:last-child td:last-child {
      border-radius: 0 0 4px;
    }
  }

  @if $striped {
    tbody tr:nth-child(odd) td,
    tbody tr:nth-child(odd) th {
      background-color: lighten($base-gray, 47%);
    }
  }

  tbody tr:hover td,
  tbody tr:hover th {
    background-color: lighten($base-gray, 47%);
  }
}
