.home-departments {
  padding: 48px 0;
  background: #fff;
}

.home-departments-title {
  margin: 0;
  color: var(--smd-text);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
}

.home-departments-subtitle {
  max-width: 900px;
  margin-top: 12px;
  margin-bottom: 28px;
  color: var(--smd-muted);
  font-size: 15px;
  line-height: 1.7;
}

.departments-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.department-card {
  display: flex;
  aspect-ratio: 1 / 1;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 48, 74, 0.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.department-card:hover,
.department-card:focus-visible {
  color: var(--smd-text);
  box-shadow: 0 18px 36px rgba(15, 48, 74, 0.16);
  transform: translateY(-4px);
}

.department-thumb {
  display: block;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  background: #eef6fb;
}

.department-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.department-card:hover .department-image,
.department-card:focus-visible .department-image {
  transform: scale(1.06);
}

.department-title {
  display: flex;
  align-items: center;
  min-height: 48px;
  flex-shrink: 0;
  padding: 10px 12px;
  color: var(--smd-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
}

@media (max-width: 1280px) {
  .departments-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .departments-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .home-departments {
    padding: 38px 0;
  }

  .departments-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .home-departments {
    padding: 28px 0;
  }

  .home-departments-title {
    font-size: 22px;
  }

  .home-departments-subtitle {
    margin-top: 10px;
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.45;
  }

  .departments-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .department-card {
    min-height: 112px;
    aspect-ratio: auto;
    border-radius: 10px;
  }

  .department-thumb {
    min-height: 68px;
    border-radius: 10px 10px 0 0;
  }

  .department-title {
    min-height: 38px;
    padding: 5px 6px;
    overflow-wrap: anywhere;
    font-size: 11.5px;
    line-height: 1.15;
  }
}
