/**
 * CMA member directory ([cma_member_directory]).
 *
 * Ships as its own filemtime-versioned file rather than through the compiled
 * style.css, which diverges per install.
 *
 * Palette comes straight from the theme tokens so the section reads as part of
 * the page: navy headings, bright-blue accents, NAM green rule, dark-gray body.
 * The `:not(#nam-x)` guards out-rank the theme's global
 * `.entry-content a { display: inline !important }` rule.
 */

.cma-dir {
  --cd-primary: var(--wdg-color-primary, #0032a0);
  --cd-primary-dark: var(--wdg-color-accent-dark, #002678);
  --cd-secondary: var(--wdg-color-secondary, #00a9e0);
  --cd-secondary-xlight: var(--wdg-color-secondary-xlight, #cceef9);
  --cd-green: var(--wdg-color-nam-green, #43b02a);
  --cd-text: var(--wdg-color-dark-gray, #414042);
  --cd-band: var(--wdg-color-white-gray, #efefef);
  --cd-line: #e3e6ee;

  scroll-margin-top: 150px;
  padding: 3.5rem 0 4.5rem;
  font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
  color: var(--cd-text);
}

.cma-dir *,
.cma-dir *::before,
.cma-dir *::after {
  box-sizing: border-box;
}

/* The theme injects margin-block-start on headings and blocks inside
   .entry-content; this section owns its own rhythm. */
.cma-dir h2,
.cma-dir h3,
.cma-dir p,
.cma-dir ul,
.cma-dir li,
.cma-dir nav,
.cma-dir div {
  margin-block-start: 0;
}

.cma-dir__wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

/* -- Header ----------------------------------------------------------- */

.cma-dir__head {
  max-width: 68ch;
  margin-bottom: 2rem;
}

.cma-dir__eyebrow {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cd-secondary);
}

.cma-dir__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.7rem;
  position: relative;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--cd-primary);
}

.cma-dir__title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 72px;
  height: 5px;
  border-radius: 3px;
  background: var(--cd-green);
}

.cma-dir__count {
  display: inline-flex;
  align-items: center;
  padding: 0.3em 0.8em;
  border-radius: 999px;
  background: var(--cd-secondary-xlight);
  color: var(--cd-primary);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.cma-dir__intro {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--cd-text);
}

/* -- Search + A-Z ----------------------------------------------------- */

.cma-dir__tools {
  position: sticky;
  top: var(--cd-stick-top, 0px);
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.5rem;
  padding: 0.9rem 0;
  background: #fff;
  border-bottom: 1px solid var(--cd-line);
}

.cma-dir__search {
  position: relative;
  flex: 0 1 320px;
  display: flex;
  align-items: center;
}

.cma-dir__search-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--cd-primary);
  pointer-events: none;
}

/* Out-ranks the theme's input[type="search"] block (0,1,1). */
.cma-dir .cma-dir__input {
  width: 100%;
  height: auto;
  padding: 0.7rem 2.4rem 0.7rem 2.6rem;
  border: 2px solid var(--cd-line);
  border-radius: 999px;
  background: #fff;
  color: var(--cd-text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.2;
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
  -webkit-appearance: none;
}

.cma-dir__input::-webkit-search-cancel-button {
  display: none;
}

.cma-dir__input::placeholder {
  color: #8a8a8a;
}

.cma-dir .cma-dir__input:focus {
  outline: none;
  border-color: var(--cd-secondary);
  box-shadow: 0 0 0 3px rgba(0, 169, 224, 0.18);
}

.cma-dir__clear {
  position: absolute;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--cd-band);
  color: var(--cd-primary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.cma-dir__clear:hover {
  background: var(--cd-secondary-xlight);
}

.cma-dir__az {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-left: auto;
}

.cma-dir .cma-dir__chip:not(#nam-x) {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 0.5rem;
  border-radius: 6px;
  background: var(--cd-band);
  color: var(--cd-primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.cma-dir .cma-dir__chip:not(#nam-x):hover,
.cma-dir .cma-dir__chip:not(#nam-x):focus-visible {
  background: var(--cd-secondary);
  color: #fff;
}

.cma-dir .cma-dir__chip.is-empty:not(#nam-x) {
  opacity: 0.3;
  pointer-events: none;
}

.cma-dir__status {
  margin: 0.9rem 0 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--cd-primary);
}

.cma-dir__status:empty {
  margin: 0;
  min-height: 0;
}

/* -- Groups ----------------------------------------------------------- */

.cma-dir__groups {
  margin-top: 1.6rem;
}

.cma-dir__group {
  margin: 0 0 2rem;
  scroll-margin-top: 200px;
}

.cma-dir__group[hidden] {
  display: none;
}

/* Out-ranks both the theme h3 color and the page block's .nam-cma h3 rule. */
.cma-dir .cma-dir__letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  margin: 0 0 0.9rem;
  padding: 0 0.6rem;
  border-radius: 8px;
  background: var(--cd-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cma-dir__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.1rem 1.6rem;
}

.cma-dir__item {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--cd-line);
}

.cma-dir__item[hidden] {
  display: none;
}

.cma-dir .cma-dir__link:not(#nam-x) {
  display: block !important;
  padding: 0.6rem 0.2rem 0.6rem 0;
  color: var(--cd-text);
  font-size: 0.92rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.15s, padding-left 0.15s;
}

.cma-dir .cma-dir__link:not(#nam-x):hover,
.cma-dir .cma-dir__link:not(#nam-x):focus-visible {
  color: var(--cd-primary);
  padding-left: 0.35rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cma-dir .cma-dir__link--plain:not(#nam-x) {
  cursor: default;
}

.cma-dir .cma-dir__link--plain:not(#nam-x):hover {
  color: var(--cd-text);
  padding-left: 0;
  text-decoration: none;
}

.cma-dir__link mark {
  background: var(--cd-secondary-xlight);
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}

/* -- Empty state + note ----------------------------------------------- */

.cma-dir__empty {
  margin: 2rem 0;
  padding: 2rem;
  border: 1px dashed var(--cd-line);
  border-radius: 12px;
  text-align: center;
  color: var(--cd-text);
}

.cma-dir__empty[hidden] {
  display: none;
}

.cma-dir__note {
  margin: 1.6rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--cd-line);
  font-size: 0.82rem;
  line-height: 1.55;
  color: #6f6f74;
}

.cma-dir .cma-dir__note a:not(#nam-x) {
  color: var(--cd-primary);
  font-weight: 700;
}

/* -- Responsive ------------------------------------------------------- */

@media (max-width: 1100px) {
  .cma-dir__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .cma-dir__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cma-dir__az {
    margin-left: 0;
    width: 100%;
  }

  .cma-dir__search {
    flex: 1 1 100%;
  }
}

@media (max-width: 560px) {
  .cma-dir {
    padding: 2.5rem 0 3rem;
  }

  .cma-dir__list {
    grid-template-columns: minmax(0, 1fr);
  }

  .cma-dir__tools {
    position: static;
  }

  .cma-dir__az {
    gap: 0.25rem;
  }

  .cma-dir .cma-dir__chip:not(#nam-x) {
    min-width: 27px;
    height: 27px;
    font-size: 0.74rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cma-dir * {
    transition: none !important;
  }
}
