.turn-departments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  margin: 1.25rem 0;
  padding: 0;
  list-style: none;
}

.turn-departments a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  height: 100%;
  box-sizing: border-box;
  padding: 1rem .5rem;
  border: 1px solid var(--tsv-border);
  border-radius: .5rem;
  color: var(--tsv-green-dark);
  background: #f4f9f7;
  text-decoration: none;
  text-align: center;
  overflow-wrap: anywhere;
}

.turn-departments a:hover,
.turn-departments a:focus-visible {
  border-color: var(--tsv-accent);
  background: var(--tsv-surface-hover);
  text-decoration: underline;
  text-underline-offset: .2em;
}

.turn-departments a:focus-visible {
  outline: 2px solid var(--tsv-green-dark);
  outline-offset: 2px;
}

.turn-departments-icon {
  position: relative;
  flex: 0 0 auto;
  width: 3rem;
  max-width: 100%;
  height: 3rem;
  background-repeat: no-repeat;
  background-position: center;
}

.turn-departments-number {
  position: absolute;
  top: -.25rem;
  right: -.25rem;
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--tsv-accent);
  font: 700 .85rem/1 system-ui, sans-serif;
}

.turn-departments--compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .1rem;
  margin: 0;
}

.article-body > .turn-departments--compact,
.department-compact-list,
.department-compact-panel > .turn-departments--compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, min(100%, 4rem));
  max-width: calc(32rem + 3.5rem);
  row-gap: .9rem;
  column-gap: .5rem;
  padding: 0;
}

.article-body > .turn-departments--compact {
  margin: 1.25rem 0;
}

.article-body > .turn-departments--compact a.department-navigation-link,
.department-compact-item > .department-navigation-link,
.department-compact-submenu:not([open]) > summary,
.department-compact-panel a.department-navigation-link {
  height: auto;
  aspect-ratio: 1;
  justify-content: center;
}

.turn-departments--compact a.department-navigation-link {
  min-height: 0;
  gap: .1rem;
  padding: .3rem 0 .2rem;
  color: var(--tsv-green-dark);
}

.turn-departments--compact a.department-navigation-link:hover,
.turn-departments--compact a.department-navigation-link:focus-visible {
  color: var(--tsv-green-dark);
  text-decoration: none;
}

.turn-departments--compact a.department-navigation-link small {
  max-width: 100%;
  font-size: clamp(.375rem, 2.15vw, .65rem);
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.turn-departments--compact .turn-departments-icon {
  width: 24px;
  height: 24px;
  background-size: contain;
}

.turn-departments--compact .turn-departments-number {
  right: -.65rem;
  width: 1.1rem;
  height: 1.1rem;
  font-size: .7rem;
}

@media (width < 680px) {
  .article-body > .turn-departments--compact,
  .department-compact-list,
  .department-compact-panel > .turn-departments--compact {
    row-gap: .1rem;
    column-gap: .1rem;
  }
}

@media (min-width: 680px) {
  .article-body > .turn-departments--compact,
  .department-compact-list,
  .department-compact-panel > .turn-departments--compact {
    grid-template-columns: repeat(auto-fill, min(100%, 4.7rem));
    max-width: calc(48rem + 3.5rem);
    row-gap: .5rem;
    column-gap: .5rem;
  }

  .article-body > .turn-departments--compact a.department-navigation-link,
  .department-compact-item > .department-navigation-link,
  .department-compact-submenu:not([open]) > summary,
  .department-compact-panel a.department-navigation-link {
    height: 4.5rem;
    aspect-ratio: auto;
  }

  .article-body > .turn-departments--compact .turn-departments-icon {
    width: 36px;
    height: 36px;
    background-size: auto;
  }

  .article-body > .turn-departments--compact .turn-departments-number {
    width: 1.4rem;
    height: 1.4rem;
    font-size: .85rem;
  }

  .article-body > .turn-departments--compact a.department-navigation-link small {
    font-size: clamp(.75rem, .9vw, .85rem);
  }
}

.department-navigation-link {
  --department-tile-background: #f4f9f7;
  display: flex;
  min-height: 4.5rem;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .5rem 0;
  border: 1px solid var(--tsv-border);
  border-radius: .5rem;
  color: var(--tsv-green-dark);
  background: var(--department-tile-background);
  text-decoration: none;
}

.department-navigation-icon {
  display: grid;
  place-items: center;
  height: 36px;
}

.department-navigation-icon img {
  grid-area: 1 / 1;
  width: auto;
  height: auto;
}

.department-navigation-icon-hover {
  visibility: hidden;
}

.department-navigation-link:hover .department-navigation-icon img:not(.department-navigation-icon-hover),
.department-navigation-link:focus-visible .department-navigation-icon img:not(.department-navigation-icon-hover) {
  visibility: hidden;
}

.department-navigation-link:hover .department-navigation-icon-hover,
.department-navigation-link:focus-visible .department-navigation-icon-hover {
  visibility: visible;
}

.department-navigation-link small {
  max-width: 100%;
  font-size: .72rem;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
}

.department-navigation-link:hover,
.department-navigation-link:focus-visible {
  border-color: #00a77f;
  color: var(--tsv-green-dark);
  background: #e0eee7;
}

.department-navigation-link[aria-current="page"] {
  border-color: #00a77f;
  color: var(--tsv-green-dark);
  background: #e0eee7;
}

.department-compact-list {
  width: 100%;
  max-width: none;
  margin: 0;
  list-style: none;
}

.department-compact-item > .department-navigation-link,
.department-compact-submenu > summary {
  min-height: 0;
  gap: .1rem;
  padding: .3rem 0 .2rem;
}

.department-compact .department-navigation-icon {
  height: 24px;
}

.department-compact .department-navigation-icon img {
  max-width: 24px;
  max-height: 24px;
}

.department-compact .department-navigation-link:is([href^="/ch.html"], [href^="/te.html"], [href^="/bd.html"]) .department-navigation-icon {
  width: 100%;
}

.department-compact .department-navigation-link:is([href^="/ch.html"], [href^="/te.html"], [href^="/bd.html"]) .department-navigation-icon img {
  max-width: min(40px, 100%);
}

.department-compact .department-navigation-link small {
  font-size: clamp(.375rem, 2.15vw, .58rem);
  line-height: 1.15;
  white-space: nowrap;
}

@media (min-width: 680px) {
  .department-compact .department-navigation-link small,
  .department-compact .turn-departments--compact a.department-navigation-link small {
    font-size: .75rem;
  }

  .department-compact .department-navigation-link:is([href^="/ch.html"], [href^="/la.html"]) small {
    font-size: .7rem;
  }
}

.department-compact .department-navigation-link[aria-current],
.department-compact .department-navigation-link.is-current {
  border-color: var(--tsv-accent);
  background: var(--tsv-surface-hover);
}

.department-compact-panel a[aria-current] {
  border-color: var(--tsv-accent);
  background: var(--tsv-surface-hover);
}

.department-compact-submenu .department-compact-expand {
  right: -.65rem;
  width: 1.1rem;
  height: 1.1rem;
  font-size: .7rem;
}
