/* -------------------------------- 

File#: _1_cross-table
Title: Cross Table
Descr: Two-way data tables used to display correlation between row and column variables
Usage: codyhouse.co/license

-------------------------------- */


table {
  border-collapse: collapse;
  border-spacing: 0;
}


/* -------------------------------- 

Buttons 

-------------------------------- */

.cd-btn {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375em;
  font-size: 1em;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
  transition: 0.2s;
  will-change: transform;
  font-weight: 400;
}

.cd-btn:focus-visible {
  outline: none;
}

.cd-btn:active {
  transform: translateY(2px);
}

.cd-btn--primary {
  background: #8E56DC;
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.15), 
              0 1px 3px hsla(250, 84%, 38%, 0.25), 
              0 2px 6px hsla(250, 84%, 38%, 0.1), 
              0 6px 10px -2px hsla(250, 84%, 38%, 0.25);
  color: hsl(0, 0%, 100%);
}

.cd-btn--primary:hover {
  background: #8E56DC;
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.15), 
              0 1px 2px hsla(250, 84%, 38%, 0.25), 
              0 1px 4px hsla(250, 84%, 38%, 0.1), 
              0 3px 6px -2px hsla(250, 84%, 38%, 0.25);
}

.cd-btn--primary:focus-visible {
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.15), 
              0 1px 2px hsla(250, 84%, 38%, 0.25), 
              0 1px 4px hsla(250, 84%, 38%, 0.1), 
              0 3px 6px -2px hsla(250, 84%, 38%, 0.25), 
              0 0 0 2px hsl(0, 0%, 100%), 
              0 0 0 4px #8E56DC;
}

/* -------------------------------- 

Icons 

-------------------------------- */

.cd-icon {
  --size: 1em;
  font-size: var(--size);
  height: 1em;
  width: 1em;
  display: inline-block;
  color: inherit;
  fill: currentColor;
  line-height: 1;
  flex-shrink: 0;
  max-width: initial;
}

.cd-icon use { /* SVG symbols - enable icon color corrections */
  color: inherit;
  fill: currentColor;
}

/* -------------------------------- 

Component 

-------------------------------- */

.cross-table {
  position: relative;
  z-index: 1;
  width: 100%;
}

.cross-table .cd-btn {
  width: 100%;
}

.cross-table__icon { /* e.g., checkbox icon */
  --size: 20px;
}

.cross-table__icon--red {
  color: hsl(342, 89%, 48%);
}

.cross-table__icon--green {
  color: hsl(170, 78%, 36%);
}

/* mobile only 👇 */
@media not all and (min-width: 42.5rem) {
  .cross-table {
    display: block;
    overflow: hidden;
  }

  .cross-table .cd-btn {
    font-size: 0.9375rem;
  }

  .cross-table__header { /* visually hidden - still accessible to SR */
    position: absolute;
    -webkit-clip-path: inset(50%);
            clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
    padding: 0;
    border: 0;
    white-space: nowrap;
  }

  .cross-table__body {
    position: relative;
    display: flex;
    max-width: 100%;
    overflow: auto;
    padding: 32px 0 1rem; /* padding-top must be equal to .cross-table__cell height */
    margin-left: 10px;
    margin-bottom: 80px;
  }

  .cross-table__body::-webkit-scrollbar { /* custom scrollbar style */
    height: 10px;
  }

  .cross-table__body::-webkit-scrollbar-track { /* progress bar */
    background-color: hsl(240, 4%, 95%);
    border-radius: 50em;
  }

  .cross-table__body::-webkit-scrollbar-thumb { /* handle */
    background-color: hsla(230, 13%, 9%, 0.2);
    border: 2px solid transparent;
    background-clip: content-box;
    border-radius: 50em;
  }

  .cross-table__body::-webkit-scrollbar-thumb:hover {
    background-color: hsla(230, 13%, 9%, 0.3);
  }

  .cross-table__body::after { /* right margin at end of scrolling area */
    content: '';
    display: block;
    height: 1px;
    padding-left: 1px;
  }

  .cross-table__row { /* card */
    display: flex;
    flex-direction: column;
    width: 260px; /* card width */
    flex-shrink: 0;
    margin-right: 1rem;
  }

  .cross-table__cell {
    --cell-border-width: 1px;
    display: flex;
    padding: 0.5rem 0.75rem;
    justify-content: space-between;
    align-items: center;
    min-height: 54px;

    text-align: left;
    line-height: 1;
    font-size: 1rem;

    background-color: hsl(0, 0%, 100%);
    border-top-width: var(--cell-border-width);
    border-left-width: var(--cell-border-width);
    border-right-width: var(--cell-border-width);
    border-style: solid;
    border-color: hsla(230, 13%, 9%, 0.1);
  }

  .cross-table__cell:first-child { /* card title */
    border-left-width: var(--cell-border-width);
    border-top-width: var(--cell-border-width);
    border-radius: 0.375em 0.375em 0 0;
    background-color: #E7DDF5;
    font-weight: 500;
    color: hsl(265.07deg 65.69% 60%);
  }

  .cross-table__cell:last-child {
    border-right-width: var(--cell-border-width);
    border-bottom-width: var(--cell-border-width);
    border-radius: 0 0 0.375em 0.375em;
  }

  .cross-table__label {
    display: inline;
    margin-right: 0.75rem;
  }

  .cross-table__row--w-full {
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
  }

  .cross-table__row--w-full .cross-table__cell { /* labels on top of the table */
    border: none; /* reset */
    background-color: transparent;
    font-weight: normal;
    min-height: 0;
    height: 32px; /* must be equal to .cross-table__body padding-top */
    padding: 0 0.75rem;
    font-size: 0.9375rem;
    color: hsl(225, 4%, 47%);
    min-width: 300px;
  }
}

/* desktop only */
@media (min-width: 42.5rem) {
  .cross-table {
    font-size: 0.9375rem;
  }

  .cross-table__row .cross-table__cell:first-child {
    border-left-width: 0;
    font-weight: 400;
  }
  
  .cross-table__row  .cross-table__cell:last-child {
    border-right-width: 0;
  }
  
  .cross-table__header .cross-table__cell {
    border-top-width: 0;
  }

  .cross-table__row--w-full { /* row with cell spanning full width */
    background-color: hsl(240, 4%, 95%);
  }

  .cross-table__row--w-full .cross-table__cell {
    font-weight: 500;
  }

  .cross-table__description {
    font-weight: 400 !important;
  }

  .cross-table__cell {
    border: 1px solid hsl(240, 4%, 90%); /* border style */
    border-bottom-width: 0;
    padding: 0.75rem;
    width: 25%;
    text-align: center;
  }

  .cross-table__cell:first-child {
    text-align: left;
  }

  .cross-table__label { /* inline copy of column headers (js-cross-table__label) */
    display: none; /* visible only in the card layout 👇 */
  }

  .cross-table__description {
    color: hsl(225, 4%, 47%);
  }
}

/* -------------------------------- 

Utilities 

-------------------------------- */

.cd-link {
  color: #8E56DC;
  text-decoration: none;
  background-image: linear-gradient(to right, #8E56DC 50%, hsla(250, 84%, 54%, 0.2) 50%);
  background-size: 200% 1px;
  background-repeat: no-repeat;
  background-position: 100% 100%;
  transition: background-position 0.2s;
  font-weight: 400;
}

.cd-link:hover {
  background-position: 0% 100%;
}

.cd-margin-bottom-2xs {
  margin-bottom: 0.75rem;
}