@use "../settings" as *;
@use "../tools" as *;

////
/// Tables
///
/// 1. Force `<table>`s to be full-width by default.
/// 2. Allow word breaks anywhere to prevent table fit-to-content.
/// 3. Allow word breaks when necessary (deprecated but works, unlike overflow-wrap).
///
/// @group elements
////

table {
  width: 100%; // [1]
  border-spacing: 0;
  vertical-align: top;

  @include nhsuk-responsive-margin(7, "bottom");

  .nhsuk-u-text-break-word {
    word-break: break-all; // [2]
    word-break: break-word; // [3]
  }

  @include nhsuk-media-query($media-type: print) {
    page-break-inside: avoid;
  }
}

thead {
  th {
    border-bottom-width: $nhsuk-border-table-header-width;
  }
}

th,
td {
  padding-left: 0;
  border: solid $nhsuk-border-colour;
  border-width: 0 0 $nhsuk-border-table-cell-width;
  text-align: left;
  vertical-align: top;

  @include nhsuk-font-size(19);
  @include nhsuk-responsive-padding(3, "bottom");
  @include nhsuk-responsive-padding(4, "right");
  @include nhsuk-responsive-padding(3, "top");

  &:last-child {
    padding-right: 0;
  }
}

th {
  @include nhsuk-font-weight-bold;
}

caption {
  text-align: left;
  @include nhsuk-font($size: 22, $weight: bold);
}
