@use "../../wc";

:host {
  display: block;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  column-gap: var(--zn-spacing-large);

  font-size: var(--zn-text-table-content-font-size);
  line-height: var(--zn-text-table-content-line-height);
  font-weight: var(--zn-text-table-content-font-weight);
  color: var(--zn-text-table-content-color);

  &--has-image,
  &--has-caption,
  &--has-description,
  &--has-properties,
  &--has-actions {
    padding-inline: var(--zn-base-gap);
  }

  &--has-image {
    padding: var(--zn-base-gap);
  }

  &--has-href {
    cursor: pointer;

    &:hover {
      background-color: var(--zn-color-neutral-100);
    }
  }

  &--flush {
    padding: 0;
  }

  &--flush-x {
    padding-inline: 0;
  }

  &--flush-y {
    padding-block: 0;
  }
}

a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

::slotted(zn-icon) {
  display: flex;
  justify-content: center;
  align-items: center;
}

.tile__link {
  display: flex;
  align-items: center;
  column-gap: var(--zn-spacing-small);
  min-width: 0;
}

.tile__left {
  display: flex;
  align-items: center;
  column-gap: var(--zn-spacing-small);
  min-width: 0;
}

.tile__image {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.tile__content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.tile--inline .tile__content {
  flex-direction: row;
  align-items: center;
  column-gap: var(--zn-spacing-x-small);
}

.tile__caption {
  margin: 0;
  font-weight: 600;
  color: rgb(var(--zn-text-heading));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile--plain .tile__caption {
  font-weight: var(--zn-text-table-content-font-weight);
  color: var(--zn-text-table-content-color);
}

.tile__description {
  margin: var(--zn-spacing-3x-small) 0 0;
  font-weight: var(--zn-text-table-content-font-weight);
  color: var(--zn-text-table-content-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile--inline .tile__description {
  margin: 0;
}

.tile__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  column-gap: var(--zn-spacing-large);
  min-width: 0;
}

.tile__properties {
  display: flex;
  flex-direction: row;
  align-items: center;
  column-gap: var(--zn-spacing-large);
  min-width: 0;
  overflow: hidden;

  ::slotted(*) {
    white-space: nowrap;
  }

  @include wc.container-query(null, sm) {
    display: none;
  }
}

.tile__actions {
  display: flex;
  align-items: center;
  column-gap: var(--zn-spacing-small);
  flex-shrink: 0;
}

:host([grouped]) {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
}

:host([grouped]) .tile {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  justify-items: end;
  min-height: 48px;
}

:host([grouped]) .tile__link,
:host([grouped]) .tile__right,
:host([grouped]) .tile__properties,
:host([grouped]) .tile__actions {
  display: contents;
}

:host([grouped]) .tile__left {
  grid-column: 1;
  justify-self: stretch;
  min-width: 0;
  overflow: hidden;
}
