.tq-card {
  /* background: var(--tq-surface, #ffffff); */
  border: 1px solid var(--tq-border, #e3e2e6);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--tq-elev-card, 0 1px 3px rgba(0, 0, 0, 0.15), 0 4px 8px 3px rgba(0, 0, 0, 0.06));
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Only compositor-friendly properties animate. */
  transition:
    transform var(--tq-dur-base, 260ms) var(--tq-ease-out, cubic-bezier(0.2, 0.7, 0.3, 1)),
    box-shadow var(--tq-dur-base, 260ms) var(--tq-ease-out, cubic-bezier(0.2, 0.7, 0.3, 1)),
    border-color var(--tq-dur-base, 260ms) ease;
}

/* Lift + deepen on hover, and on keyboard focus inside the card so the
   same affordance is available without a pointer. */
.tq-card:hover,
.tq-card:focus-within {
  transform: translateY(-6px);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: var(--tq-elev-card-hover, 0 12px 28px rgba(0, 0, 0, 0.18), 0 6px 12px rgba(0, 0, 0, 0.1));
}

.tq-card:active {
  transform: translateY(-2px);
}

.tq-card__media-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.tq-card__body {
  padding: clamp(12px, 1.2vw, 20px) clamp(14px, 1.4vw, 20px) clamp(12px, 1.2vw, 20px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.1vw, 16px);
  flex: 1;
}

.tq-card__title {
  font-size: var(--font-size-t6);
  font-weight: 500;
  line-height: clamp(20px, 1.6vw, 24px);
  letter-spacing: 0.3px;
  color: var(--tq-text, #1b1b1f);
  text-wrap: pretty;
  flex: 1;
}

.tq-image-slot {
  width: min(100%, 220px);
  aspect-ratio: 3 / 2;
  margin: clamp(12px, 1.1vw, 16px) auto 0;
  position: relative;
  overflow: hidden;
  perspective: 900px;
}

.tq-image-slot img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border: 1px solid var(--tq-border, #e3e2e6);
  box-sizing: border-box;
}

.tq-image-slot--postcard {
  aspect-ratio: 3 / 2;
}

.tq-image-slot--letter {
  aspect-ratio: 3 / 4;
}

.tq-image-slot--envelope {
  aspect-ratio: 2.313 / 1;
  /* border: 1px solid #e2e2e2; */
}

/* .tq-card:hover .tq-image-slot,
.tq-card:focus-within .tq-image-slot {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
} */

.tq-image-slot__flipper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 2.5s var(--tq-ease-out, cubic-bezier(0.2, 0.7, 0.3, 1));
}

.tq-card:hover .tq-image-slot__flipper,
.tq-card:focus-within .tq-image-slot__flipper {
  transform: rotateX(-180deg);
}

.tq-image-slot__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tq-image-slot__face--back {
  transform: rotateX(-180deg);
}

.tq-image-slot__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border: 1px solid var(--tq-border, #e3e2e6);
  box-sizing: border-box;
}

.tq-image-slot__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 0.9vw, 8px);
  padding: clamp(var(--space-sl), 1vw, var(--space-md));
  text-align: center;
  color: var(--tq-text-tertiary, #75757f);
}

.tq-image-slot__icon {
  opacity: 0.55;
  transition: opacity var(--tq-dur-base, 260ms) ease;
}

.tq-card:hover .tq-image-slot__icon {
  opacity: 0.75;
}

.tq-image-slot__label {
  font-size: var(--font-size-small);
  line-height: clamp(14px, 1vw, 16px);
  letter-spacing: 0.4px;
}

/* Older Safari has no aspect-ratio support — fall back to a padding box. */
@supports not (aspect-ratio: 1 / 1) {
  .tq-image-slot {
    height: 0;
    padding-bottom: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tq-card,
  .tq-image-slot,
  .tq-image-slot__flipper,
  .tq-image-slot__icon {
    transition: none;
  }

  .tq-card:hover,
  .tq-card:focus-within,
  .tq-card:active {
    transform: none;
  }
}
