/* ==========================================================================
   category-modal: full-screen window with one privilege category, opened by
   "Learn more" on a Privileges card (js/modules/category-modal.js).
   Photo, name, description, partner cards (css/blocks/privilege-card.css),
   and a link to the next category at the end. Scrolls inside itself.
   ========================================================================== */

.category-modal {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border: 0;
  background-color: var(--bg-page);
  color: var(--text-body);
}

.category-modal::backdrop {
  background-color: rgba(0, 28, 30, 0.6);
}

.category-modal[open] {
  animation: category-modal-in 600ms var(--ease-out);
}

@keyframes category-modal-in {
  from { opacity: 0; transform: translateY(2rem); }
  to { opacity: 1; transform: none; }
}

/* close: always in the top right corner of the screen, above the content */
.category-modal__close {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  right: calc(var(--gutter) + env(safe-area-inset-right));
  z-index: 2;
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  /* light with a shadow: visible over the page and over the dark logo bands */
  background-color: var(--color-ivory);
  color: var(--color-teal);
  box-shadow: 0 10px 30px -10px rgba(0, 28, 30, 0.55);
  transition: background-color 300ms var(--ease-out), color 300ms var(--ease-out);
}

.category-modal__close-line {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.1rem;
  height: 1.5px;
  background-color: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.category-modal__close-line + .category-modal__close-line {
  transform: translate(-50%, -50%) rotate(-45deg);
}

@media (hover: hover) {
  .category-modal__close:hover {
    background-color: var(--color-copper);
    color: var(--color-ivory);
  }
}

.category-modal__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.category-modal__inner {
  padding-block: calc(4.5rem + var(--space-md)) var(--space-xl);
}

.category-modal__head {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.category-modal__index {
  color: var(--accent);
}

.category-modal__title {
  max-width: 18ch;
}

.category-modal__desc {
  max-width: 30rem;
}

.category-modal__media {
  aspect-ratio: 4 / 3;
  margin-bottom: var(--space-lg);
  overflow: hidden;
  border-radius: var(--radius-md);
  background-color: var(--bg-darker);
}

.category-modal__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-modal__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* end: the next category */
.category-modal__next {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--line);
}

.category-modal__next-name {
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  text-transform: uppercase;
  color: var(--text-heading);
}

@media (min-width: 600px) {
  .category-modal__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-modal__media {
    aspect-ratio: 16 / 9;
  }
}

@media (min-width: 1000px) {
  .category-modal__head {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    align-items: end;
    column-gap: var(--space-xl);
  }

  .category-modal__index {
    grid-column: 1 / -1;
  }

  .category-modal__desc {
    justify-self: end;
  }

  .category-modal__media {
    aspect-ratio: 21 / 8;
  }

  .category-modal__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .category-modal[open] {
    animation: none;
  }
}
