/* Shared compact category cards. This file owns card, grid and disclosure states. */
.ap-category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ap-category-card {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  min-height: 104px;
  gap: 16px;
  padding: 16px;
  border: 1px solid #dfe9ec;
  border-radius: 12px;
  background: #fff;
  color: #0e3446;
  text-decoration: none;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.ap-category-card-image {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  min-width: 0;
}

.ap-category-card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ap-category-card-initial {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #f2fafc;
  color: #007b88;
  font-size: 24px;
  font-weight: 500;
}

.ap-category-card-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.2px;
  overflow-wrap: anywhere;
}

.ap-category-card:focus-visible {
  border-color: #007b88;
  background: #f6fbfc;
  color: #0e3446;
  text-decoration: none;
}

.ap-category-disclosure { margin-top: 20px; }
.ap-category-disclosure[hidden] { display: none; }
.ap-category-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: fit-content;
  min-height: 44px;
  margin: 0 auto;
  padding: 10px 20px;
  border: 1px solid #dfe9ec;
  border-radius: 8px;
  color: #007b88;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  list-style: none;
}
.ap-category-disclosure > summary::-webkit-details-marker { display: none; }
.ap-category-disclosure > summary svg { width: 16px; height: 16px; }
.ap-category-disclosure [data-ap-categories-less] { display: none; }
.ap-category-disclosure[open] { display: flex; flex-direction: column; gap: 20px; margin-top: 12px; }
.ap-category-disclosure[open] > summary { order: 1; }
.ap-category-disclosure[open] > summary svg { transform: rotate(180deg); }
.ap-category-disclosure[open] [data-ap-categories-more] { display: none; }
.ap-category-disclosure[open] [data-ap-categories-less] { display: inline; }

@media (hover: hover) and (pointer: fine) {
  .ap-category-card:hover {
    border-color: #007b88;
    background: #f6fbfc;
    color: #0e3446;
    text-decoration: none;
  }
  .ap-category-disclosure > summary:hover { border-color: #007b88; background: #f6fbfc; }
}

@media (min-width: 1800px) {
  .ap-category-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1199px) {
  .ap-category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
  .ap-category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .ap-category-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 10px; }
  /* The home navigation keeps its horizontal mobile rail. Category pages keep their grid. */
  .ap-category-grid--home {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    margin-right: -16px;
    padding: 4px 16px 12px 4px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }
  .ap-category-grid--home .ap-category-card {
    display: flex;
    flex: 0 0 128px;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 0;
    padding: 12px 0;
    border-color: transparent;
    text-align: center;
    scroll-snap-align: start;
  }
  .ap-category-grid--home .ap-category-card-image { width: 88px; height: 88px; }
  .ap-category-grid--home .ap-category-card-name { font-size: 14px; font-weight: 700; }
  .ap-category-disclosure, .ap-category-disclosure[open] { display: block; margin-top: 16px; }
  .ap-category-disclosure[hidden] { display: none; }
  .ap-category-disclosure > summary { justify-content: flex-start; margin: 0; padding: 0 4px; border: 0; border-radius: 0; }
  .ap-category-disclosure .ap-category-grid { margin-top: 16px; }
  .ap-category-disclosure-count { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ap-category-card { transition: none; }
  .ap-category-grid--home { scroll-behavior: auto; }
}
