/* Feed row: one deal in the list. */

@layer components {
  .deal-row {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0.75rem var(--inline-space);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);

    /* Pill styling/sizing is shared in votes.css; the row only lifts the control
       above its stretched title link. */
    .vote {
      position: relative;
      z-index: 1;
    }

    &.deal-row--expired {
      opacity: 0.72;

      .deal-row__price {
        color: var(--color-text-muted);
      }
    }
  }

  .deal-row__top {
    display: flex;
    gap: var(--inline-space);
  }

  .deal-row__thumb {
    inline-size: 4rem;
    block-size: 4rem;
    flex: none;
    object-fit: contain;
    padding: 0.25rem 0.4ch;
    border-radius: var(--radius-sm);
    background: var(--color-canvas);
    border: 1px solid var(--color-border-subtle);
  }

  .deal-row__body {
    flex: 1;
    min-inline-size: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .deal-row__price {
    font-size: var(--text-medium);
    color: var(--color-ink);
  }

  .deal-row__was {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--text-x-small);
    text-decoration: line-through;
    color: var(--color-text-muted);
  }

  .deal-row__disc {
    font-family: var(--font-mono);
    font-size: var(--text-x-small);
    font-weight: 700;
    color: var(--color-up);
  }

  .deal-row__title {
    margin-block: 0.125rem;

    a {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      overflow: hidden;
      font-size: var(--text-normal);
      font-weight: 600;
      line-height: var(--leading-snug);
      color: var(--color-ink);

      @media (any-hover: hover) {
        &:hover {
          color: var(--color-primary-press);
          text-decoration: none;
        }
      }
    }
  }

  /* Stretch the title link over the whole row so the entire card opens the deal.
     Interactive controls in the action row sit above it via z-index. */
  .deal-row__link::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .deal-row__meta {
    display: flex;
    align-items: center;
    gap: var(--inline-space-half);
    flex-wrap: wrap;
    font-size: var(--text-x-small);
    color: var(--color-text-muted);
  }

  .deal-row__retailer {
    font-weight: 600;
    color: var(--color-text-subtle);
  }

  .deal-row__category {
    font-weight: 600;
    color: var(--color-text-subtle);
  }

  .deal-row__expiry {
    font-weight: 600;
    color: var(--color-primary-press);
  }

  /* Bottom action row (modern Reddit): the vote pill anchors the left; comments,
     share, and reaction flair group together and push to the right so the row
     stays balanced whether or not a deal has reactions. Each interactive control
     rises above the stretched title link. */
  .deal-row__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75ch;
  }

  .deal-row__engage {
    display: inline-flex;
    align-items: center;
    gap: 0.75ch;
    margin-inline-start: auto;
  }

  .deal-row__action {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.4ch;
    padding: 0.375rem var(--inline-space);
    border-radius: var(--radius-pill);
    background: var(--tint-ink-5);
    font-size: var(--text-x-small);
    font-weight: 600;
    color: var(--color-text-subtle);

    @media (any-hover: hover) {
      &:hover {
        background: var(--tint-ink-10);
        color: var(--color-ink);
        text-decoration: none;
      }
    }

    .icon {
      font-size: var(--text-small);
    }
  }

  /* Fallback when a deal has no image (deals_helper): a centered maple-red
     price-tag mark on the tile's own surface. Rendered in the row, hero, and
     deal-page thumbnail slots, which set their own size; the icon scales to a
     share of whatever tile it lands in. */
  .thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    --icon-size: 55%;
  }
}
