/* partials/hub_cards.html — hub grid cards: card box, layout, and the hover swap from
   title to description. Typography: partials/hub-common.css. */

.topic {
  display: flex;
  flex-direction: column;
  height: 12.5rem;
  padding: 1.35rem 1.4rem 1.25rem;
  border-radius: var(--radius-lg);
}

.topic-flip {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.topic-top {
  position: relative;
  flex: 1;
}

.topic-cefr {
  position: absolute;
  right: 0;
  bottom: 0;
}

.topic-desc {
  max-width: 24rem;
  margin-top: auto;
  padding-top: 1.35rem;
}

/* Without hover, the description sits under the title and the arrow is not shown. */
.topic-desc .topic-title,
.topic-desc .topic-arrow {
  display: none;
}

@media (hover: hover) {
  .topic-flip {
    position: relative;
    height: 100%;
  }

  .topic-top,
  .topic-desc {
    position: absolute;
    inset: 0;
    margin: 0;
    padding-top: 0;
    transition: opacity 0.2s ease;
  }

  .topic-desc {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.5rem;
    max-width: none;
    opacity: 0;
  }

  .topic-desc .topic-title {
    display: block;
  }

  .topic-desc:has(.topic-arrow) .topic-desc-text {
    max-width: 24rem;
    padding-right: calc(var(--nav-icon-size) + 1rem);
  }

  .topic-desc .topic-arrow {
    position: absolute;
    top: 0;
    right: 0;
    display: block;
    margin-top: 0.05rem;
  }

  .topic:has(.topic-desc):hover .topic-top,
  .topic:has(.topic-desc):focus-visible .topic-top {
    opacity: 0;
  }

  .topic:hover .topic-desc,
  .topic:focus-visible .topic-desc {
    opacity: 1;
  }
}
